babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999
  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. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1094. import { Nullable } from "babylonjs/types";
  1095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1096. /**
  1097. * This represents the required contract to create a new type of texture loader.
  1098. */
  1099. export interface IInternalTextureLoader {
  1100. /**
  1101. * Defines wether the loader supports cascade loading the different faces.
  1102. */
  1103. supportCascades: boolean;
  1104. /**
  1105. * This returns if the loader support the current file information.
  1106. * @param extension defines the file extension of the file being loaded
  1107. * @param mimeType defines the optional mime type of the file being loaded
  1108. * @returns true if the loader can load the specified file
  1109. */
  1110. canLoad(extension: string, mimeType?: string): boolean;
  1111. /**
  1112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1113. * @param data contains the texture data
  1114. * @param texture defines the BabylonJS internal texture
  1115. * @param createPolynomials will be true if polynomials have been requested
  1116. * @param onLoad defines the callback to trigger once the texture is ready
  1117. * @param onError defines the callback to trigger in case of error
  1118. */
  1119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1120. /**
  1121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1122. * @param data contains the texture data
  1123. * @param texture defines the BabylonJS internal texture
  1124. * @param callback defines the method to call once ready to upload
  1125. */
  1126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/IPipelineContext" {
  1130. /**
  1131. * Class used to store and describe the pipeline context associated with an effect
  1132. */
  1133. export interface IPipelineContext {
  1134. /**
  1135. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1136. */
  1137. isAsync: boolean;
  1138. /**
  1139. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1140. */
  1141. isReady: boolean;
  1142. /** @hidden */
  1143. _getVertexShaderCode(): string | null;
  1144. /** @hidden */
  1145. _getFragmentShaderCode(): string | null;
  1146. /** @hidden */
  1147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Meshes/dataBuffer" {
  1151. /**
  1152. * Class used to store gfx data (like WebGLBuffer)
  1153. */
  1154. export class DataBuffer {
  1155. /**
  1156. * Gets or sets the number of objects referencing this buffer
  1157. */
  1158. references: number;
  1159. /** Gets or sets the size of the underlying buffer */
  1160. capacity: number;
  1161. /**
  1162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1163. */
  1164. is32Bits: boolean;
  1165. /**
  1166. * Gets the underlying buffer
  1167. */
  1168. get underlyingResource(): any;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1172. /** @hidden */
  1173. export interface IShaderProcessor {
  1174. attributeProcessor?: (attribute: string) => string;
  1175. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1176. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1177. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1178. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1179. lineProcessor?: (line: string, isFragment: boolean) => string;
  1180. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1181. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1186. /** @hidden */
  1187. export interface ProcessingOptions {
  1188. defines: string[];
  1189. indexParameters: any;
  1190. isFragment: boolean;
  1191. shouldUseHighPrecisionShader: boolean;
  1192. supportsUniformBuffers: boolean;
  1193. shadersRepository: string;
  1194. includesShadersStore: {
  1195. [key: string]: string;
  1196. };
  1197. processor?: IShaderProcessor;
  1198. version: string;
  1199. platformName: string;
  1200. lookForClosingBracketForUniformBuffer?: boolean;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1204. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1205. /** @hidden */
  1206. export class ShaderCodeNode {
  1207. line: string;
  1208. children: ShaderCodeNode[];
  1209. additionalDefineKey?: string;
  1210. additionalDefineValue?: string;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. process(preprocessors: {
  1215. [key: string]: string;
  1216. }, options: ProcessingOptions): string;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1220. /** @hidden */
  1221. export class ShaderCodeCursor {
  1222. private _lines;
  1223. lineIndex: number;
  1224. get currentLine(): string;
  1225. get canRead(): boolean;
  1226. set lines(value: string[]);
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1230. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1231. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1252. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. not: boolean;
  1268. constructor(define: string, not?: boolean);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1286. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1287. /** @hidden */
  1288. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1289. leftOperand: ShaderDefineExpression;
  1290. rightOperand: ShaderDefineExpression;
  1291. isTrue(preprocessors: {
  1292. [key: string]: string;
  1293. }): boolean;
  1294. }
  1295. }
  1296. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1297. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1298. /** @hidden */
  1299. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1300. define: string;
  1301. operand: string;
  1302. testValue: string;
  1303. constructor(define: string, operand: string, testValue: string);
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Offline/IOfflineProvider" {
  1310. /**
  1311. * Class used to enable access to offline support
  1312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1313. */
  1314. export interface IOfflineProvider {
  1315. /**
  1316. * Gets a boolean indicating if scene must be saved in the database
  1317. */
  1318. enableSceneOffline: boolean;
  1319. /**
  1320. * Gets a boolean indicating if textures must be saved in the database
  1321. */
  1322. enableTexturesOffline: boolean;
  1323. /**
  1324. * Open the offline support and make it available
  1325. * @param successCallback defines the callback to call on success
  1326. * @param errorCallback defines the callback to call on error
  1327. */
  1328. open(successCallback: () => void, errorCallback: () => void): void;
  1329. /**
  1330. * Loads an image from the offline support
  1331. * @param url defines the url to load from
  1332. * @param image defines the target DOM image
  1333. */
  1334. loadImage(url: string, image: HTMLImageElement): void;
  1335. /**
  1336. * Loads a file from offline support
  1337. * @param url defines the URL to load from
  1338. * @param sceneLoaded defines a callback to call on success
  1339. * @param progressCallBack defines a callback to call when progress changed
  1340. * @param errorCallback defines a callback to call on error
  1341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1342. */
  1343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1344. }
  1345. }
  1346. declare module "babylonjs/Misc/filesInputStore" {
  1347. /**
  1348. * Class used to help managing file picking and drag'n'drop
  1349. * File Storage
  1350. */
  1351. export class FilesInputStore {
  1352. /**
  1353. * List of files ready to be loaded
  1354. */
  1355. static FilesToLoad: {
  1356. [key: string]: File;
  1357. };
  1358. }
  1359. }
  1360. declare module "babylonjs/Misc/retryStrategy" {
  1361. import { WebRequest } from "babylonjs/Misc/webRequest";
  1362. /**
  1363. * Class used to define a retry strategy when error happens while loading assets
  1364. */
  1365. export class RetryStrategy {
  1366. /**
  1367. * Function used to defines an exponential back off strategy
  1368. * @param maxRetries defines the maximum number of retries (3 by default)
  1369. * @param baseInterval defines the interval between retries
  1370. * @returns the strategy function to use
  1371. */
  1372. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1373. }
  1374. }
  1375. declare module "babylonjs/Misc/baseError" {
  1376. /**
  1377. * @ignore
  1378. * Application error to support additional information when loading a file
  1379. */
  1380. export abstract class BaseError extends Error {
  1381. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1382. }
  1383. }
  1384. declare module "babylonjs/Misc/fileTools" {
  1385. import { WebRequest } from "babylonjs/Misc/webRequest";
  1386. import { Nullable } from "babylonjs/types";
  1387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1389. import { BaseError } from "babylonjs/Misc/baseError";
  1390. /** @ignore */
  1391. export class LoadFileError extends BaseError {
  1392. request?: WebRequest;
  1393. file?: File;
  1394. /**
  1395. * Creates a new LoadFileError
  1396. * @param message defines the message of the error
  1397. * @param request defines the optional web request
  1398. * @param file defines the optional file
  1399. */
  1400. constructor(message: string, object?: WebRequest | File);
  1401. }
  1402. /** @ignore */
  1403. export class RequestFileError extends BaseError {
  1404. request: WebRequest;
  1405. /**
  1406. * Creates a new LoadFileError
  1407. * @param message defines the message of the error
  1408. * @param request defines the optional web request
  1409. */
  1410. constructor(message: string, request: WebRequest);
  1411. }
  1412. /** @ignore */
  1413. export class ReadFileError extends BaseError {
  1414. file: File;
  1415. /**
  1416. * Creates a new ReadFileError
  1417. * @param message defines the message of the error
  1418. * @param file defines the optional file
  1419. */
  1420. constructor(message: string, file: File);
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export class FileTools {
  1426. /**
  1427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1428. */
  1429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1430. /**
  1431. * Gets or sets the base URL to use to load assets
  1432. */
  1433. static BaseUrl: string;
  1434. /**
  1435. * Default behaviour for cors in the application.
  1436. * It can be a string if the expected behavior is identical in the entire app.
  1437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1438. */
  1439. static CorsBehavior: string | ((url: string | string[]) => string);
  1440. /**
  1441. * Gets or sets a function used to pre-process url before using them to load assets
  1442. */
  1443. static PreprocessUrl: (url: string) => string;
  1444. /**
  1445. * Removes unwanted characters from an url
  1446. * @param url defines the url to clean
  1447. * @returns the cleaned url
  1448. */
  1449. private static _CleanUrl;
  1450. /**
  1451. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1452. * @param url define the url we are trying
  1453. * @param element define the dom element where to configure the cors policy
  1454. */
  1455. static SetCorsBehavior(url: string | string[], element: {
  1456. crossOrigin: string | null;
  1457. }): void;
  1458. /**
  1459. * Loads an image as an HTMLImageElement.
  1460. * @param input url string, ArrayBuffer, or Blob to load
  1461. * @param onLoad callback called when the image successfully loads
  1462. * @param onError callback called when the image fails to load
  1463. * @param offlineProvider offline provider for caching
  1464. * @param mimeType optional mime type
  1465. * @returns the HTMLImageElement of the loaded image
  1466. */
  1467. 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>;
  1468. /**
  1469. * Reads a file from a File object
  1470. * @param file defines the file to load
  1471. * @param onSuccess defines the callback to call when data is loaded
  1472. * @param onProgress defines the callback to call during loading process
  1473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1474. * @param onError defines the callback to call when an error occurs
  1475. * @returns a file request object
  1476. */
  1477. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1478. /**
  1479. * Loads a file from a url
  1480. * @param url url to load
  1481. * @param onSuccess callback called when the file successfully loads
  1482. * @param onProgress callback called while file is loading (if the server supports this mode)
  1483. * @param offlineProvider defines the offline provider for caching
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @returns a file request object
  1487. */
  1488. 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;
  1489. /**
  1490. * Loads a file
  1491. * @param url url to load
  1492. * @param onSuccess callback called when the file successfully loads
  1493. * @param onProgress callback called while file is loading (if the server supports this mode)
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @param onOpened callback called when the web request is opened
  1497. * @returns a file request object
  1498. */
  1499. 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;
  1500. /**
  1501. * Checks if the loaded document was accessed via `file:`-Protocol.
  1502. * @returns boolean
  1503. */
  1504. static IsFileURL(): boolean;
  1505. }
  1506. }
  1507. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1508. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1509. import { WebRequest } from "babylonjs/Misc/webRequest";
  1510. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1511. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1512. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1513. /** @hidden */
  1514. export class ShaderProcessor {
  1515. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1516. private static _ProcessPrecision;
  1517. private static _ExtractOperation;
  1518. private static _BuildSubExpression;
  1519. private static _BuildExpression;
  1520. private static _MoveCursorWithinIf;
  1521. private static _MoveCursor;
  1522. private static _EvaluatePreProcessors;
  1523. private static _PreparePreProcessors;
  1524. private static _ProcessShaderConversion;
  1525. private static _ProcessIncludes;
  1526. /**
  1527. * Loads a file from a url
  1528. * @param url url to load
  1529. * @param onSuccess callback called when the file successfully loads
  1530. * @param onProgress callback called while file is loading (if the server supports this mode)
  1531. * @param offlineProvider defines the offline provider for caching
  1532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1533. * @param onError callback called when the file fails to load
  1534. * @returns a file request object
  1535. * @hidden
  1536. */
  1537. 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;
  1538. }
  1539. }
  1540. declare module "babylonjs/Maths/math.like" {
  1541. import { float, int, DeepImmutable } from "babylonjs/types";
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IColor4Like {
  1546. r: float;
  1547. g: float;
  1548. b: float;
  1549. a: float;
  1550. }
  1551. /**
  1552. * @hidden
  1553. */
  1554. export interface IColor3Like {
  1555. r: float;
  1556. g: float;
  1557. b: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IVector4Like {
  1563. x: float;
  1564. y: float;
  1565. z: float;
  1566. w: float;
  1567. }
  1568. /**
  1569. * @hidden
  1570. */
  1571. export interface IVector3Like {
  1572. x: float;
  1573. y: float;
  1574. z: float;
  1575. }
  1576. /**
  1577. * @hidden
  1578. */
  1579. export interface IVector2Like {
  1580. x: float;
  1581. y: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IMatrixLike {
  1587. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1588. updateFlag: int;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IViewportLike {
  1594. x: float;
  1595. y: float;
  1596. width: float;
  1597. height: float;
  1598. }
  1599. /**
  1600. * @hidden
  1601. */
  1602. export interface IPlaneLike {
  1603. normal: IVector3Like;
  1604. d: float;
  1605. normalize(): void;
  1606. }
  1607. }
  1608. declare module "babylonjs/Materials/iEffectFallbacks" {
  1609. import { Effect } from "babylonjs/Materials/effect";
  1610. /**
  1611. * Interface used to define common properties for effect fallbacks
  1612. */
  1613. export interface IEffectFallbacks {
  1614. /**
  1615. * Removes the defines that should be removed when falling back.
  1616. * @param currentDefines defines the current define statements for the shader.
  1617. * @param effect defines the current effect we try to compile
  1618. * @returns The resulting defines with defines of the current rank removed.
  1619. */
  1620. reduce(currentDefines: string, effect: Effect): string;
  1621. /**
  1622. * Removes the fallback from the bound mesh.
  1623. */
  1624. unBindMesh(): void;
  1625. /**
  1626. * Checks to see if more fallbacks are still availible.
  1627. */
  1628. hasMoreFallbacks: boolean;
  1629. }
  1630. }
  1631. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1632. /**
  1633. * Class used to evalaute queries containing `and` and `or` operators
  1634. */
  1635. export class AndOrNotEvaluator {
  1636. /**
  1637. * Evaluate a query
  1638. * @param query defines the query to evaluate
  1639. * @param evaluateCallback defines the callback used to filter result
  1640. * @returns true if the query matches
  1641. */
  1642. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1643. private static _HandleParenthesisContent;
  1644. private static _SimplifyNegation;
  1645. }
  1646. }
  1647. declare module "babylonjs/Misc/tags" {
  1648. /**
  1649. * Class used to store custom tags
  1650. */
  1651. export class Tags {
  1652. /**
  1653. * Adds support for tags on the given object
  1654. * @param obj defines the object to use
  1655. */
  1656. static EnableFor(obj: any): void;
  1657. /**
  1658. * Removes tags support
  1659. * @param obj defines the object to use
  1660. */
  1661. static DisableFor(obj: any): void;
  1662. /**
  1663. * Gets a boolean indicating if the given object has tags
  1664. * @param obj defines the object to use
  1665. * @returns a boolean
  1666. */
  1667. static HasTags(obj: any): boolean;
  1668. /**
  1669. * Gets the tags available on a given object
  1670. * @param obj defines the object to use
  1671. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1672. * @returns the tags
  1673. */
  1674. static GetTags(obj: any, asString?: boolean): any;
  1675. /**
  1676. * Adds tags to an object
  1677. * @param obj defines the object to use
  1678. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1679. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1680. */
  1681. static AddTagsTo(obj: any, tagsString: string): void;
  1682. /**
  1683. * @hidden
  1684. */
  1685. static _AddTagTo(obj: any, tag: string): void;
  1686. /**
  1687. * Removes specific tags from a specific object
  1688. * @param obj defines the object to use
  1689. * @param tagsString defines the tags to remove
  1690. */
  1691. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _RemoveTagFrom(obj: any, tag: string): void;
  1696. /**
  1697. * Defines if tags hosted on an object match a given query
  1698. * @param obj defines the object to use
  1699. * @param tagsQuery defines the tag query
  1700. * @returns a boolean
  1701. */
  1702. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1703. }
  1704. }
  1705. declare module "babylonjs/Maths/math.scalar" {
  1706. /**
  1707. * Scalar computation library
  1708. */
  1709. export class Scalar {
  1710. /**
  1711. * Two pi constants convenient for computation.
  1712. */
  1713. static TwoPi: number;
  1714. /**
  1715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1716. * @param a number
  1717. * @param b number
  1718. * @param epsilon (default = 1.401298E-45)
  1719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. */
  1721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1722. /**
  1723. * Returns a string : the upper case translation of the number i to hexadecimal.
  1724. * @param i number
  1725. * @returns the upper case translation of the number i to hexadecimal.
  1726. */
  1727. static ToHex(i: number): string;
  1728. /**
  1729. * Returns -1 if value is negative and +1 is value is positive.
  1730. * @param value the value
  1731. * @returns the value itself if it's equal to zero.
  1732. */
  1733. static Sign(value: number): number;
  1734. /**
  1735. * Returns the value itself if it's between min and max.
  1736. * Returns min if the value is lower than min.
  1737. * Returns max if the value is greater than max.
  1738. * @param value the value to clmap
  1739. * @param min the min value to clamp to (default: 0)
  1740. * @param max the max value to clamp to (default: 1)
  1741. * @returns the clamped value
  1742. */
  1743. static Clamp(value: number, min?: number, max?: number): number;
  1744. /**
  1745. * the log2 of value.
  1746. * @param value the value to compute log2 of
  1747. * @returns the log2 of value.
  1748. */
  1749. static Log2(value: number): number;
  1750. /**
  1751. * Loops the value, so that it is never larger than length and never smaller than 0.
  1752. *
  1753. * This is similar to the modulo operator but it works with floating point numbers.
  1754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1755. * With t = 5 and length = 2.5, the result would be 0.0.
  1756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1757. * @param value the value
  1758. * @param length the length
  1759. * @returns the looped value
  1760. */
  1761. static Repeat(value: number, length: number): number;
  1762. /**
  1763. * Normalize the value between 0.0 and 1.0 using min and max values
  1764. * @param value value to normalize
  1765. * @param min max to normalize between
  1766. * @param max min to normalize between
  1767. * @returns the normalized value
  1768. */
  1769. static Normalize(value: number, min: number, max: number): number;
  1770. /**
  1771. * Denormalize the value from 0.0 and 1.0 using min and max values
  1772. * @param normalized value to denormalize
  1773. * @param min max to denormalize between
  1774. * @param max min to denormalize between
  1775. * @returns the denormalized value
  1776. */
  1777. static Denormalize(normalized: number, min: number, max: number): number;
  1778. /**
  1779. * Calculates the shortest difference between two given angles given in degrees.
  1780. * @param current current angle in degrees
  1781. * @param target target angle in degrees
  1782. * @returns the delta
  1783. */
  1784. static DeltaAngle(current: number, target: number): number;
  1785. /**
  1786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1787. * @param tx value
  1788. * @param length length
  1789. * @returns The returned value will move back and forth between 0 and length
  1790. */
  1791. static PingPong(tx: number, length: number): number;
  1792. /**
  1793. * Interpolates between min and max with smoothing at the limits.
  1794. *
  1795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1797. * @param from from
  1798. * @param to to
  1799. * @param tx value
  1800. * @returns the smooth stepped value
  1801. */
  1802. static SmoothStep(from: number, to: number, tx: number): number;
  1803. /**
  1804. * Moves a value current towards target.
  1805. *
  1806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1807. * Negative values of maxDelta pushes the value away from target.
  1808. * @param current current value
  1809. * @param target target value
  1810. * @param maxDelta max distance to move
  1811. * @returns resulting value
  1812. */
  1813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1814. /**
  1815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. *
  1817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1819. * @param current current value
  1820. * @param target target value
  1821. * @param maxDelta max distance to move
  1822. * @returns resulting angle
  1823. */
  1824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1825. /**
  1826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1827. * @param start start value
  1828. * @param end target value
  1829. * @param amount amount to lerp between
  1830. * @returns the lerped value
  1831. */
  1832. static Lerp(start: number, end: number, amount: number): number;
  1833. /**
  1834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1836. * @param start start value
  1837. * @param end target value
  1838. * @param amount amount to lerp between
  1839. * @returns the lerped value
  1840. */
  1841. static LerpAngle(start: number, end: number, amount: number): number;
  1842. /**
  1843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1844. * @param a start value
  1845. * @param b target value
  1846. * @param value value between a and b
  1847. * @returns the inverseLerp value
  1848. */
  1849. static InverseLerp(a: number, b: number, value: number): number;
  1850. /**
  1851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1853. * @param value1 spline value
  1854. * @param tangent1 spline value
  1855. * @param value2 spline value
  1856. * @param tangent2 spline value
  1857. * @param amount input value
  1858. * @returns hermite result
  1859. */
  1860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1861. /**
  1862. * Returns a random float number between and min and max values
  1863. * @param min min value of random
  1864. * @param max max value of random
  1865. * @returns random value
  1866. */
  1867. static RandomRange(min: number, max: number): number;
  1868. /**
  1869. * This function returns percentage of a number in a given range.
  1870. *
  1871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1873. * @param number to convert to percentage
  1874. * @param min min range
  1875. * @param max max range
  1876. * @returns the percentage
  1877. */
  1878. static RangeToPercent(number: number, min: number, max: number): number;
  1879. /**
  1880. * This function returns number that corresponds to the percentage in a given range.
  1881. *
  1882. * PercentToRange(0.34,0,100) will return 34.
  1883. * @param percent to convert to number
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the number
  1887. */
  1888. static PercentToRange(percent: number, min: number, max: number): number;
  1889. /**
  1890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1891. * @param angle The angle to normalize in radian.
  1892. * @return The converted angle.
  1893. */
  1894. static NormalizeRadians(angle: number): number;
  1895. }
  1896. }
  1897. declare module "babylonjs/Maths/math.constants" {
  1898. /**
  1899. * Constant used to convert a value to gamma space
  1900. * @ignorenaming
  1901. */
  1902. export const ToGammaSpace: number;
  1903. /**
  1904. * Constant used to convert a value to linear space
  1905. * @ignorenaming
  1906. */
  1907. export const ToLinearSpace = 2.2;
  1908. /**
  1909. * Constant used to define the minimal number value in Babylon.js
  1910. * @ignorenaming
  1911. */
  1912. let Epsilon: number;
  1913. export { Epsilon };
  1914. }
  1915. declare module "babylonjs/Maths/math.viewport" {
  1916. /**
  1917. * Class used to represent a viewport on screen
  1918. */
  1919. export class Viewport {
  1920. /** viewport left coordinate */
  1921. x: number;
  1922. /** viewport top coordinate */
  1923. y: number;
  1924. /**viewport width */
  1925. width: number;
  1926. /** viewport height */
  1927. height: number;
  1928. /**
  1929. * Creates a Viewport object located at (x, y) and sized (width, height)
  1930. * @param x defines viewport left coordinate
  1931. * @param y defines viewport top coordinate
  1932. * @param width defines the viewport width
  1933. * @param height defines the viewport height
  1934. */
  1935. constructor(
  1936. /** viewport left coordinate */
  1937. x: number,
  1938. /** viewport top coordinate */
  1939. y: number,
  1940. /**viewport width */
  1941. width: number,
  1942. /** viewport height */
  1943. height: number);
  1944. /**
  1945. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1946. * @param renderWidth defines the rendering width
  1947. * @param renderHeight defines the rendering height
  1948. * @returns a new Viewport
  1949. */
  1950. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1951. /**
  1952. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1953. * @param renderWidth defines the rendering width
  1954. * @param renderHeight defines the rendering height
  1955. * @param ref defines the target viewport
  1956. * @returns the current viewport
  1957. */
  1958. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1959. /**
  1960. * Returns a new Viewport copied from the current one
  1961. * @returns a new Viewport
  1962. */
  1963. clone(): Viewport;
  1964. }
  1965. }
  1966. declare module "babylonjs/Misc/arrayTools" {
  1967. /**
  1968. * Class containing a set of static utilities functions for arrays.
  1969. */
  1970. export class ArrayTools {
  1971. /**
  1972. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1973. * @param size the number of element to construct and put in the array
  1974. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1975. * @returns a new array filled with new objects
  1976. */
  1977. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1978. }
  1979. }
  1980. declare module "babylonjs/Maths/math.plane" {
  1981. import { DeepImmutable } from "babylonjs/types";
  1982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1983. /**
  1984. * Represents a plane by the equation ax + by + cz + d = 0
  1985. */
  1986. export class Plane {
  1987. private static _TmpMatrix;
  1988. /**
  1989. * Normal of the plane (a,b,c)
  1990. */
  1991. normal: Vector3;
  1992. /**
  1993. * d component of the plane
  1994. */
  1995. d: number;
  1996. /**
  1997. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1998. * @param a a component of the plane
  1999. * @param b b component of the plane
  2000. * @param c c component of the plane
  2001. * @param d d component of the plane
  2002. */
  2003. constructor(a: number, b: number, c: number, d: number);
  2004. /**
  2005. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2006. */
  2007. asArray(): number[];
  2008. /**
  2009. * @returns a new plane copied from the current Plane.
  2010. */
  2011. clone(): Plane;
  2012. /**
  2013. * @returns the string "Plane".
  2014. */
  2015. getClassName(): string;
  2016. /**
  2017. * @returns the Plane hash code.
  2018. */
  2019. getHashCode(): number;
  2020. /**
  2021. * Normalize the current Plane in place.
  2022. * @returns the updated Plane.
  2023. */
  2024. normalize(): Plane;
  2025. /**
  2026. * Applies a transformation the plane and returns the result
  2027. * @param transformation the transformation matrix to be applied to the plane
  2028. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2029. */
  2030. transform(transformation: DeepImmutable<Matrix>): Plane;
  2031. /**
  2032. * Compute the dot product between the point and the plane normal
  2033. * @param point point to calculate the dot product with
  2034. * @returns the dot product (float) of the point coordinates and the plane normal.
  2035. */
  2036. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2037. /**
  2038. * Updates the current Plane from the plane defined by the three given points.
  2039. * @param point1 one of the points used to contruct the plane
  2040. * @param point2 one of the points used to contruct the plane
  2041. * @param point3 one of the points used to contruct the plane
  2042. * @returns the updated Plane.
  2043. */
  2044. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2045. /**
  2046. * Checks if the plane is facing a given direction
  2047. * @param direction the direction to check if the plane is facing
  2048. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2049. * @returns True is the vector "direction" is the same side than the plane normal.
  2050. */
  2051. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2052. /**
  2053. * Calculates the distance to a point
  2054. * @param point point to calculate distance to
  2055. * @returns the signed distance (float) from the given point to the Plane.
  2056. */
  2057. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2058. /**
  2059. * Creates a plane from an array
  2060. * @param array the array to create a plane from
  2061. * @returns a new Plane from the given array.
  2062. */
  2063. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2064. /**
  2065. * Creates a plane from three points
  2066. * @param point1 point used to create the plane
  2067. * @param point2 point used to create the plane
  2068. * @param point3 point used to create the plane
  2069. * @returns a new Plane defined by the three given points.
  2070. */
  2071. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2072. /**
  2073. * Creates a plane from an origin point and a normal
  2074. * @param origin origin of the plane to be constructed
  2075. * @param normal normal of the plane to be constructed
  2076. * @returns a new Plane the normal vector to this plane at the given origin point.
  2077. * Note : the vector "normal" is updated because normalized.
  2078. */
  2079. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2080. /**
  2081. * Calculates the distance from a plane and a point
  2082. * @param origin origin of the plane to be constructed
  2083. * @param normal normal of the plane to be constructed
  2084. * @param point point to calculate distance to
  2085. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2086. */
  2087. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2088. }
  2089. }
  2090. declare module "babylonjs/Engines/performanceConfigurator" {
  2091. /** @hidden */
  2092. export class PerformanceConfigurator {
  2093. /** @hidden */
  2094. static MatrixUse64Bits: boolean;
  2095. /** @hidden */
  2096. static MatrixTrackPrecisionChange: boolean;
  2097. /** @hidden */
  2098. static MatrixCurrentType: any;
  2099. /** @hidden */
  2100. static MatrixTrackedMatrices: Array<any> | null;
  2101. /** @hidden */
  2102. static SetMatrixPrecision(use64bits: boolean): void;
  2103. }
  2104. }
  2105. declare module "babylonjs/Maths/math.vector" {
  2106. import { Viewport } from "babylonjs/Maths/math.viewport";
  2107. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2108. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2109. import { Plane } from "babylonjs/Maths/math.plane";
  2110. /**
  2111. * Class representing a vector containing 2 coordinates
  2112. */
  2113. export class Vector2 {
  2114. /** defines the first coordinate */
  2115. x: number;
  2116. /** defines the second coordinate */
  2117. y: number;
  2118. /**
  2119. * Creates a new Vector2 from the given x and y coordinates
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. */
  2123. constructor(
  2124. /** defines the first coordinate */
  2125. x?: number,
  2126. /** defines the second coordinate */
  2127. y?: number);
  2128. /**
  2129. * Gets a string with the Vector2 coordinates
  2130. * @returns a string with the Vector2 coordinates
  2131. */
  2132. toString(): string;
  2133. /**
  2134. * Gets class name
  2135. * @returns the string "Vector2"
  2136. */
  2137. getClassName(): string;
  2138. /**
  2139. * Gets current vector hash code
  2140. * @returns the Vector2 hash code as a number
  2141. */
  2142. getHashCode(): number;
  2143. /**
  2144. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2145. * @param array defines the source array
  2146. * @param index defines the offset in source array
  2147. * @returns the current Vector2
  2148. */
  2149. toArray(array: FloatArray, index?: number): Vector2;
  2150. /**
  2151. * Update the current vector from an array
  2152. * @param array defines the destination array
  2153. * @param index defines the offset in the destination array
  2154. * @returns the current Vector3
  2155. */
  2156. fromArray(array: FloatArray, index?: number): Vector2;
  2157. /**
  2158. * Copy the current vector to an array
  2159. * @returns a new array with 2 elements: the Vector2 coordinates.
  2160. */
  2161. asArray(): number[];
  2162. /**
  2163. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2164. * @param source defines the source Vector2
  2165. * @returns the current updated Vector2
  2166. */
  2167. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Sets the Vector2 coordinates with the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns the current updated Vector2
  2173. */
  2174. copyFromFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Sets the Vector2 coordinates with the given floats
  2177. * @param x defines the first coordinate
  2178. * @param y defines the second coordinate
  2179. * @returns the current updated Vector2
  2180. */
  2181. set(x: number, y: number): Vector2;
  2182. /**
  2183. * Add another vector with the current one
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2186. */
  2187. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @param result defines the target vector
  2192. * @returns the unmodified current Vector2
  2193. */
  2194. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2195. /**
  2196. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns the current updated Vector2
  2199. */
  2200. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns a new Vector2
  2205. */
  2206. addVector3(otherVector: Vector3): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2209. * @param otherVector defines the other vector
  2210. * @returns a new Vector2
  2211. */
  2212. subtract(otherVector: Vector2): Vector2;
  2213. /**
  2214. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2215. * @param otherVector defines the other vector
  2216. * @param result defines the target vector
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2220. /**
  2221. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns the current updated Vector2
  2224. */
  2225. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Multiplies in place the current Vector2 coordinates by the given ones
  2228. * @param otherVector defines the other vector
  2229. * @returns the current updated Vector2
  2230. */
  2231. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns a new Vector2
  2236. */
  2237. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2240. * @param otherVector defines the other vector
  2241. * @param result defines the target vector
  2242. * @returns the unmodified current Vector2
  2243. */
  2244. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2247. * @param x defines the first coordinate
  2248. * @param y defines the second coordinate
  2249. * @returns a new Vector2
  2250. */
  2251. multiplyByFloats(x: number, y: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @returns a new Vector2
  2256. */
  2257. divide(otherVector: Vector2): Vector2;
  2258. /**
  2259. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2260. * @param otherVector defines the other vector
  2261. * @param result defines the target vector
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2265. /**
  2266. * Divides the current Vector2 coordinates by the given ones
  2267. * @param otherVector defines the other vector
  2268. * @returns the current updated Vector2
  2269. */
  2270. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vector2 with current Vector2 negated coordinates
  2273. * @returns a new Vector2
  2274. */
  2275. negate(): Vector2;
  2276. /**
  2277. * Negate this vector in place
  2278. * @returns this
  2279. */
  2280. negateInPlace(): Vector2;
  2281. /**
  2282. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2283. * @param result defines the Vector3 object where to store the result
  2284. * @returns the current Vector2
  2285. */
  2286. negateToRef(result: Vector2): Vector2;
  2287. /**
  2288. * Multiply the Vector2 coordinates by scale
  2289. * @param scale defines the scaling factor
  2290. * @returns the current updated Vector2
  2291. */
  2292. scaleInPlace(scale: number): Vector2;
  2293. /**
  2294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2295. * @param scale defines the scaling factor
  2296. * @returns a new Vector2
  2297. */
  2298. scale(scale: number): Vector2;
  2299. /**
  2300. * Scale the current Vector2 values by a factor to a given Vector2
  2301. * @param scale defines the scale factor
  2302. * @param result defines the Vector2 object where to store the result
  2303. * @returns the unmodified current Vector2
  2304. */
  2305. scaleToRef(scale: number, result: Vector2): Vector2;
  2306. /**
  2307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2308. * @param scale defines the scale factor
  2309. * @param result defines the Vector2 object where to store the result
  2310. * @returns the unmodified current Vector2
  2311. */
  2312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2313. /**
  2314. * Gets a boolean if two vectors are equals
  2315. * @param otherVector defines the other vector
  2316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2317. */
  2318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2319. /**
  2320. * Gets a boolean if two vectors are equals (using an epsilon value)
  2321. * @param otherVector defines the other vector
  2322. * @param epsilon defines the minimal distance to consider equality
  2323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2324. */
  2325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2326. /**
  2327. * Gets a new Vector2 from current Vector2 floored values
  2328. * @returns a new Vector2
  2329. */
  2330. floor(): Vector2;
  2331. /**
  2332. * Gets a new Vector2 from current Vector2 floored values
  2333. * @returns a new Vector2
  2334. */
  2335. fract(): Vector2;
  2336. /**
  2337. * Gets the length of the vector
  2338. * @returns the vector length (float)
  2339. */
  2340. length(): number;
  2341. /**
  2342. * Gets the vector squared length
  2343. * @returns the vector squared length (float)
  2344. */
  2345. lengthSquared(): number;
  2346. /**
  2347. * Normalize the vector
  2348. * @returns the current updated Vector2
  2349. */
  2350. normalize(): Vector2;
  2351. /**
  2352. * Gets a new Vector2 copied from the Vector2
  2353. * @returns a new Vector2
  2354. */
  2355. clone(): Vector2;
  2356. /**
  2357. * Gets a new Vector2(0, 0)
  2358. * @returns a new Vector2
  2359. */
  2360. static Zero(): Vector2;
  2361. /**
  2362. * Gets a new Vector2(1, 1)
  2363. * @returns a new Vector2
  2364. */
  2365. static One(): Vector2;
  2366. /**
  2367. * Gets a new Vector2 set from the given index element of the given array
  2368. * @param array defines the data source
  2369. * @param offset defines the offset in the data source
  2370. * @returns a new Vector2
  2371. */
  2372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2373. /**
  2374. * Sets "result" from the given index element of the given array
  2375. * @param array defines the data source
  2376. * @param offset defines the offset in the data source
  2377. * @param result defines the target vector
  2378. */
  2379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2380. /**
  2381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2382. * @param value1 defines 1st point of control
  2383. * @param value2 defines 2nd point of control
  2384. * @param value3 defines 3rd point of control
  2385. * @param value4 defines 4th point of control
  2386. * @param amount defines the interpolation factor
  2387. * @returns a new Vector2
  2388. */
  2389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2390. /**
  2391. * 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".
  2392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2394. * @param value defines the value to clamp
  2395. * @param min defines the lower limit
  2396. * @param max defines the upper limit
  2397. * @returns a new Vector2
  2398. */
  2399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2400. /**
  2401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2402. * @param value1 defines the 1st control point
  2403. * @param tangent1 defines the outgoing tangent
  2404. * @param value2 defines the 2nd control point
  2405. * @param tangent2 defines the incoming tangent
  2406. * @param amount defines the interpolation factor
  2407. * @returns a new Vector2
  2408. */
  2409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2412. * @param start defines the start vector
  2413. * @param end defines the end vector
  2414. * @param amount defines the interpolation factor
  2415. * @returns a new Vector2
  2416. */
  2417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2418. /**
  2419. * Gets the dot product of the vector "left" and the vector "right"
  2420. * @param left defines first vector
  2421. * @param right defines second vector
  2422. * @returns the dot product (float)
  2423. */
  2424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Returns a new Vector2 equal to the normalized given vector
  2427. * @param vector defines the vector to normalize
  2428. * @returns a new Vector2
  2429. */
  2430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2433. * @param left defines 1st vector
  2434. * @param right defines 2nd vector
  2435. * @returns a new Vector2
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2438. /**
  2439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2440. * @param left defines 1st vector
  2441. * @param right defines 2nd vector
  2442. * @returns a new Vector2
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2447. * @param vector defines the vector to transform
  2448. * @param transformation defines the matrix to apply
  2449. * @returns a new Vector2
  2450. */
  2451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2452. /**
  2453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2454. * @param vector defines the vector to transform
  2455. * @param transformation defines the matrix to apply
  2456. * @param result defines the target vector
  2457. */
  2458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2459. /**
  2460. * Determines if a given vector is included in a triangle
  2461. * @param p defines the vector to test
  2462. * @param p0 defines 1st triangle point
  2463. * @param p1 defines 2nd triangle point
  2464. * @param p2 defines 3rd triangle point
  2465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2466. */
  2467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2468. /**
  2469. * Gets the distance between the vectors "value1" and "value2"
  2470. * @param value1 defines first vector
  2471. * @param value2 defines second vector
  2472. * @returns the distance between vectors
  2473. */
  2474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2475. /**
  2476. * Returns the squared distance between the vectors "value1" and "value2"
  2477. * @param value1 defines first vector
  2478. * @param value2 defines second vector
  2479. * @returns the squared distance between vectors
  2480. */
  2481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2482. /**
  2483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns a new Vector2
  2487. */
  2488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2489. /**
  2490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2491. * @param p defines the middle point
  2492. * @param segA defines one point of the segment
  2493. * @param segB defines the other point of the segment
  2494. * @returns the shortest distance
  2495. */
  2496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2497. }
  2498. /**
  2499. * Class used to store (x,y,z) vector representation
  2500. * A Vector3 is the main object used in 3D geometry
  2501. * It can represent etiher the coordinates of a point the space, either a direction
  2502. * Reminder: js uses a left handed forward facing system
  2503. */
  2504. export class Vector3 {
  2505. private static _UpReadOnly;
  2506. private static _ZeroReadOnly;
  2507. /** @hidden */
  2508. _x: number;
  2509. /** @hidden */
  2510. _y: number;
  2511. /** @hidden */
  2512. _z: number;
  2513. /** @hidden */
  2514. _isDirty: boolean;
  2515. /** Gets or sets the x coordinate */
  2516. get x(): number;
  2517. set x(value: number);
  2518. /** Gets or sets the y coordinate */
  2519. get y(): number;
  2520. set y(value: number);
  2521. /** Gets or sets the z coordinate */
  2522. get z(): number;
  2523. set z(value: number);
  2524. /**
  2525. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2526. * @param x defines the first coordinates (on X axis)
  2527. * @param y defines the second coordinates (on Y axis)
  2528. * @param z defines the third coordinates (on Z axis)
  2529. */
  2530. constructor(x?: number, y?: number, z?: number);
  2531. /**
  2532. * Creates a string representation of the Vector3
  2533. * @returns a string with the Vector3 coordinates.
  2534. */
  2535. toString(): string;
  2536. /**
  2537. * Gets the class name
  2538. * @returns the string "Vector3"
  2539. */
  2540. getClassName(): string;
  2541. /**
  2542. * Creates the Vector3 hash code
  2543. * @returns a number which tends to be unique between Vector3 instances
  2544. */
  2545. getHashCode(): number;
  2546. /**
  2547. * Creates an array containing three elements : the coordinates of the Vector3
  2548. * @returns a new array of numbers
  2549. */
  2550. asArray(): number[];
  2551. /**
  2552. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2553. * @param array defines the destination array
  2554. * @param index defines the offset in the destination array
  2555. * @returns the current Vector3
  2556. */
  2557. toArray(array: FloatArray, index?: number): Vector3;
  2558. /**
  2559. * Update the current vector from an array
  2560. * @param array defines the destination array
  2561. * @param index defines the offset in the destination array
  2562. * @returns the current Vector3
  2563. */
  2564. fromArray(array: FloatArray, index?: number): Vector3;
  2565. /**
  2566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2568. */
  2569. toQuaternion(): Quaternion;
  2570. /**
  2571. * Adds the given vector to the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Adds the given coordinates to the current Vector3
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Subtract the given vector from the current Vector3
  2599. * @param otherVector defines the second operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2605. * @param otherVector defines the second operand
  2606. * @returns the resulting Vector3
  2607. */
  2608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2609. /**
  2610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2611. * @param otherVector defines the second operand
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2618. * @param x defines the x coordinate of the operand
  2619. * @param y defines the y coordinate of the operand
  2620. * @param z defines the z coordinate of the operand
  2621. * @returns the resulting Vector3
  2622. */
  2623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2624. /**
  2625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2626. * @param x defines the x coordinate of the operand
  2627. * @param y defines the y coordinate of the operand
  2628. * @param z defines the z coordinate of the operand
  2629. * @param result defines the Vector3 object where to store the result
  2630. * @returns the current Vector3
  2631. */
  2632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2633. /**
  2634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2635. * @returns a new Vector3
  2636. */
  2637. negate(): Vector3;
  2638. /**
  2639. * Negate this vector in place
  2640. * @returns this
  2641. */
  2642. negateInPlace(): Vector3;
  2643. /**
  2644. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. negateToRef(result: Vector3): Vector3;
  2649. /**
  2650. * Multiplies the Vector3 coordinates by the float "scale"
  2651. * @param scale defines the multiplier factor
  2652. * @returns the current updated Vector3
  2653. */
  2654. scaleInPlace(scale: number): Vector3;
  2655. /**
  2656. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2657. * @param scale defines the multiplier factor
  2658. * @returns a new Vector3
  2659. */
  2660. scale(scale: number): Vector3;
  2661. /**
  2662. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2663. * @param scale defines the multiplier factor
  2664. * @param result defines the Vector3 object where to store the result
  2665. * @returns the current Vector3
  2666. */
  2667. scaleToRef(scale: number, result: Vector3): Vector3;
  2668. /**
  2669. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2670. * @param scale defines the scale factor
  2671. * @param result defines the Vector3 object where to store the result
  2672. * @returns the unmodified current Vector3
  2673. */
  2674. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2675. /**
  2676. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2677. * @param origin defines the origin of the projection ray
  2678. * @param plane defines the plane to project to
  2679. * @returns the projected vector3
  2680. */
  2681. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2682. /**
  2683. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2684. * @param origin defines the origin of the projection ray
  2685. * @param plane defines the plane to project to
  2686. * @param result defines the Vector3 where to store the result
  2687. */
  2688. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2689. /**
  2690. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2691. * @param otherVector defines the second operand
  2692. * @returns true if both vectors are equals
  2693. */
  2694. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2695. /**
  2696. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2697. * @param otherVector defines the second operand
  2698. * @param epsilon defines the minimal distance to define values as equals
  2699. * @returns true if both vectors are distant less than epsilon
  2700. */
  2701. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2702. /**
  2703. * Returns true if the current Vector3 coordinates equals the given floats
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns true if both vectors are equals
  2708. */
  2709. equalsToFloats(x: number, y: number, z: number): boolean;
  2710. /**
  2711. * Multiplies the current Vector3 coordinates by the given ones
  2712. * @param otherVector defines the second operand
  2713. * @returns the current updated Vector3
  2714. */
  2715. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2716. /**
  2717. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2718. * @param otherVector defines the second operand
  2719. * @returns the new Vector3
  2720. */
  2721. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2722. /**
  2723. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2724. * @param otherVector defines the second operand
  2725. * @param result defines the Vector3 object where to store the result
  2726. * @returns the current Vector3
  2727. */
  2728. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2731. * @param x defines the x coordinate of the operand
  2732. * @param y defines the y coordinate of the operand
  2733. * @param z defines the z coordinate of the operand
  2734. * @returns the new Vector3
  2735. */
  2736. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2739. * @param otherVector defines the second operand
  2740. * @returns the new Vector3
  2741. */
  2742. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2745. * @param otherVector defines the second operand
  2746. * @param result defines the Vector3 object where to store the result
  2747. * @returns the current Vector3
  2748. */
  2749. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2750. /**
  2751. * Divides the current Vector3 coordinates by the given ones.
  2752. * @param otherVector defines the second operand
  2753. * @returns the current updated Vector3
  2754. */
  2755. divideInPlace(otherVector: Vector3): Vector3;
  2756. /**
  2757. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2758. * @param other defines the second operand
  2759. * @returns the current updated Vector3
  2760. */
  2761. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2764. * @param other defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2770. * @param x defines the x coordinate of the operand
  2771. * @param y defines the y coordinate of the operand
  2772. * @param z defines the z coordinate of the operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2786. * Check if is non uniform within a certain amount of decimal places to account for this
  2787. * @param epsilon the amount the values can differ
  2788. * @returns if the the vector is non uniform to a certain number of decimal places
  2789. */
  2790. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2791. /**
  2792. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2793. */
  2794. get isNonUniform(): boolean;
  2795. /**
  2796. * Gets a new Vector3 from current Vector3 floored values
  2797. * @returns a new Vector3
  2798. */
  2799. floor(): Vector3;
  2800. /**
  2801. * Gets a new Vector3 from current Vector3 floored values
  2802. * @returns a new Vector3
  2803. */
  2804. fract(): Vector3;
  2805. /**
  2806. * Gets the length of the Vector3
  2807. * @returns the length of the Vector3
  2808. */
  2809. length(): number;
  2810. /**
  2811. * Gets the squared length of the Vector3
  2812. * @returns squared length of the Vector3
  2813. */
  2814. lengthSquared(): number;
  2815. /**
  2816. * Normalize the current Vector3.
  2817. * Please note that this is an in place operation.
  2818. * @returns the current updated Vector3
  2819. */
  2820. normalize(): Vector3;
  2821. /**
  2822. * Reorders the x y z properties of the vector in place
  2823. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2824. * @returns the current updated vector
  2825. */
  2826. reorderInPlace(order: string): this;
  2827. /**
  2828. * Rotates the vector around 0,0,0 by a quaternion
  2829. * @param quaternion the rotation quaternion
  2830. * @param result vector to store the result
  2831. * @returns the resulting vector
  2832. */
  2833. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2834. /**
  2835. * Rotates a vector around a given point
  2836. * @param quaternion the rotation quaternion
  2837. * @param point the point to rotate around
  2838. * @param result vector to store the result
  2839. * @returns the resulting vector
  2840. */
  2841. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2842. /**
  2843. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2844. * The cross product is then orthogonal to both current and "other"
  2845. * @param other defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. cross(other: Vector3): Vector3;
  2849. /**
  2850. * Normalize the current Vector3 with the given input length.
  2851. * Please note that this is an in place operation.
  2852. * @param len the length of the vector
  2853. * @returns the current updated Vector3
  2854. */
  2855. normalizeFromLength(len: number): Vector3;
  2856. /**
  2857. * Normalize the current Vector3 to a new vector
  2858. * @returns the new Vector3
  2859. */
  2860. normalizeToNew(): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 to the reference
  2863. * @param reference define the Vector3 to update
  2864. * @returns the updated Vector3
  2865. */
  2866. normalizeToRef(reference: Vector3): Vector3;
  2867. /**
  2868. * Creates a new Vector3 copied from the current Vector3
  2869. * @returns the new Vector3
  2870. */
  2871. clone(): Vector3;
  2872. /**
  2873. * Copies the given vector coordinates to the current Vector3 ones
  2874. * @param source defines the source Vector3
  2875. * @returns the current updated Vector3
  2876. */
  2877. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2878. /**
  2879. * Copies the given floats to the current Vector3 coordinates
  2880. * @param x defines the x coordinate of the operand
  2881. * @param y defines the y coordinate of the operand
  2882. * @param z defines the z coordinate of the operand
  2883. * @returns the current updated Vector3
  2884. */
  2885. copyFromFloats(x: number, y: number, z: number): Vector3;
  2886. /**
  2887. * Copies the given floats to the current Vector3 coordinates
  2888. * @param x defines the x coordinate of the operand
  2889. * @param y defines the y coordinate of the operand
  2890. * @param z defines the z coordinate of the operand
  2891. * @returns the current updated Vector3
  2892. */
  2893. set(x: number, y: number, z: number): Vector3;
  2894. /**
  2895. * Copies the given float to the current Vector3 coordinates
  2896. * @param v defines the x, y and z coordinates of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. setAll(v: number): Vector3;
  2900. /**
  2901. * Get the clip factor between two vectors
  2902. * @param vector0 defines the first operand
  2903. * @param vector1 defines the second operand
  2904. * @param axis defines the axis to use
  2905. * @param size defines the size along the axis
  2906. * @returns the clip factor
  2907. */
  2908. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2909. /**
  2910. * Get angle between two vectors
  2911. * @param vector0 angle between vector0 and vector1
  2912. * @param vector1 angle between vector0 and vector1
  2913. * @param normal direction of the normal
  2914. * @return the angle between vector0 and vector1
  2915. */
  2916. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 set from the index "offset" of the given array
  2919. * @param array defines the source array
  2920. * @param offset defines the offset in the source array
  2921. * @returns the new Vector3
  2922. */
  2923. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2926. * @param array defines the source array
  2927. * @param offset defines the offset in the source array
  2928. * @returns the new Vector3
  2929. * @deprecated Please use FromArray instead.
  2930. */
  2931. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2934. * @param array defines the source array
  2935. * @param offset defines the offset in the source array
  2936. * @param result defines the Vector3 where to store the result
  2937. */
  2938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2939. /**
  2940. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2941. * @param array defines the source array
  2942. * @param offset defines the offset in the source array
  2943. * @param result defines the Vector3 where to store the result
  2944. * @deprecated Please use FromArrayToRef instead.
  2945. */
  2946. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the given floats.
  2949. * @param x defines the x coordinate of the source
  2950. * @param y defines the y coordinate of the source
  2951. * @param z defines the z coordinate of the source
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2957. * @returns a new empty Vector3
  2958. */
  2959. static Zero(): Vector3;
  2960. /**
  2961. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2962. * @returns a new unit Vector3
  2963. */
  2964. static One(): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2967. * @returns a new up Vector3
  2968. */
  2969. static Up(): Vector3;
  2970. /**
  2971. * Gets a up Vector3 that must not be updated
  2972. */
  2973. static get UpReadOnly(): DeepImmutable<Vector3>;
  2974. /**
  2975. * Gets a zero Vector3 that must not be updated
  2976. */
  2977. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2980. * @returns a new down Vector3
  2981. */
  2982. static Down(): Vector3;
  2983. /**
  2984. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2985. * @param rightHandedSystem is the scene right-handed (negative z)
  2986. * @returns a new forward Vector3
  2987. */
  2988. static Forward(rightHandedSystem?: boolean): Vector3;
  2989. /**
  2990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2991. * @param rightHandedSystem is the scene right-handed (negative-z)
  2992. * @returns a new forward Vector3
  2993. */
  2994. static Backward(rightHandedSystem?: boolean): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2997. * @returns a new right Vector3
  2998. */
  2999. static Right(): Vector3;
  3000. /**
  3001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3002. * @returns a new left Vector3
  3003. */
  3004. static Left(): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the transformed Vector3
  3011. */
  3012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3023. * This method computes tranformed coordinates only, not transformed direction vectors
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3034. * @param vector defines the Vector3 to transform
  3035. * @param transformation defines the transformation matrix
  3036. * @returns the new Vector3
  3037. */
  3038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3039. /**
  3040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3042. * @param vector defines the Vector3 to transform
  3043. * @param transformation defines the transformation matrix
  3044. * @param result defines the Vector3 where to store the result
  3045. */
  3046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3047. /**
  3048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3050. * @param x define the x coordinate of the source vector
  3051. * @param y define the y coordinate of the source vector
  3052. * @param z define the z coordinate of the source vector
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3059. * @param value1 defines the first control point
  3060. * @param value2 defines the second control point
  3061. * @param value3 defines the third control point
  3062. * @param value4 defines the fourth control point
  3063. * @param amount defines the amount on the spline to use
  3064. * @returns the new Vector3
  3065. */
  3066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3067. /**
  3068. * 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"
  3069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3071. * @param value defines the current value
  3072. * @param min defines the lower range value
  3073. * @param max defines the upper range value
  3074. * @returns the new Vector3
  3075. */
  3076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * 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"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3087. /**
  3088. * Checks if a given vector is inside a specific range
  3089. * @param v defines the vector to test
  3090. * @param min defines the minimum range
  3091. * @param max defines the maximum range
  3092. */
  3093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3094. /**
  3095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3096. * @param value1 defines the first control point
  3097. * @param tangent1 defines the first tangent vector
  3098. * @param value2 defines the second control point
  3099. * @param tangent2 defines the second tangent vector
  3100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3101. * @returns the new Vector3
  3102. */
  3103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3106. * @param start defines the start value
  3107. * @param end defines the end value
  3108. * @param amount max defines amount between both (between 0 and 1)
  3109. * @returns the new Vector3
  3110. */
  3111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3112. /**
  3113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3114. * @param start defines the start value
  3115. * @param end defines the end value
  3116. * @param amount max defines amount between both (between 0 and 1)
  3117. * @param result defines the Vector3 where to store the result
  3118. */
  3119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3120. /**
  3121. * Returns the dot product (float) between the vectors "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3127. /**
  3128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3129. * The cross product is then orthogonal to both "left" and "right"
  3130. * @param left defines the left operand
  3131. * @param right defines the right operand
  3132. * @returns the cross product
  3133. */
  3134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3135. /**
  3136. * Sets the given vector "result" with the cross product of "left" and "right"
  3137. * The cross product is then orthogonal to both "left" and "right"
  3138. * @param left defines the left operand
  3139. * @param right defines the right operand
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3143. /**
  3144. * Returns a new Vector3 as the normalization of the given vector
  3145. * @param vector defines the Vector3 to normalize
  3146. * @returns the new Vector3
  3147. */
  3148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the normalization of the given first vector
  3151. * @param vector defines the Vector3 to normalize
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Project a Vector3 onto screen space
  3157. * @param vector defines the Vector3 to project
  3158. * @param world defines the world matrix to use
  3159. * @param transform defines the transform (view x projection) matrix to use
  3160. * @param viewport defines the screen viewport to use
  3161. * @returns the new Vector3
  3162. */
  3163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3164. /** @hidden */
  3165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param source defines the screen space Vector3 to use
  3169. * @param viewportWidth defines the current width of the viewport
  3170. * @param viewportHeight defines the current height of the viewport
  3171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3172. * @param transform defines the transform (view x projection) matrix to use
  3173. * @returns the new Vector3
  3174. */
  3175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param view defines the view matrix to use
  3183. * @param projection defines the projection matrix to use
  3184. * @returns the new Vector3
  3185. */
  3186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3187. /**
  3188. * Unproject from screen space to object space
  3189. * @param source defines the screen space Vector3 to use
  3190. * @param viewportWidth defines the current width of the viewport
  3191. * @param viewportHeight defines the current height of the viewport
  3192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3193. * @param view defines the view matrix to use
  3194. * @param projection defines the projection matrix to use
  3195. * @param result defines the Vector3 where to store the result
  3196. */
  3197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param sourceX defines the screen space x coordinate to use
  3201. * @param sourceY defines the screen space y coordinate to use
  3202. * @param sourceZ defines the screen space z coordinate to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @param result defines the Vector3 where to store the result
  3209. */
  3210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3211. /**
  3212. * Gets the minimal coordinate values between two Vector3
  3213. * @param left defines the first operand
  3214. * @param right defines the second operand
  3215. * @returns the new Vector3
  3216. */
  3217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3218. /**
  3219. * Gets the maximal coordinate values between two Vector3
  3220. * @param left defines the first operand
  3221. * @param right defines the second operand
  3222. * @returns the new Vector3
  3223. */
  3224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * Returns the distance between the vectors "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the distance
  3230. */
  3231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3232. /**
  3233. * Returns the squared distance between the vectors "value1" and "value2"
  3234. * @param value1 defines the first operand
  3235. * @param value2 defines the second operand
  3236. * @returns the squared distance
  3237. */
  3238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3239. /**
  3240. * Returns a new Vector3 located at the center between "value1" and "value2"
  3241. * @param value1 defines the first operand
  3242. * @param value2 defines the second operand
  3243. * @returns the new Vector3
  3244. */
  3245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3246. /**
  3247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3249. * to something in order to rotate it from its local system to the given target system
  3250. * Note: axis1, axis2 and axis3 are normalized during this operation
  3251. * @param axis1 defines the first axis
  3252. * @param axis2 defines the second axis
  3253. * @param axis3 defines the third axis
  3254. * @returns a new Vector3
  3255. */
  3256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3257. /**
  3258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3259. * @param axis1 defines the first axis
  3260. * @param axis2 defines the second axis
  3261. * @param axis3 defines the third axis
  3262. * @param ref defines the Vector3 where to store the result
  3263. */
  3264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3265. }
  3266. /**
  3267. * Vector4 class created for EulerAngle class conversion to Quaternion
  3268. */
  3269. export class Vector4 {
  3270. /** x value of the vector */
  3271. x: number;
  3272. /** y value of the vector */
  3273. y: number;
  3274. /** z value of the vector */
  3275. z: number;
  3276. /** w value of the vector */
  3277. w: number;
  3278. /**
  3279. * Creates a Vector4 object from the given floats.
  3280. * @param x x value of the vector
  3281. * @param y y value of the vector
  3282. * @param z z value of the vector
  3283. * @param w w value of the vector
  3284. */
  3285. constructor(
  3286. /** x value of the vector */
  3287. x: number,
  3288. /** y value of the vector */
  3289. y: number,
  3290. /** z value of the vector */
  3291. z: number,
  3292. /** w value of the vector */
  3293. w: number);
  3294. /**
  3295. * Returns the string with the Vector4 coordinates.
  3296. * @returns a string containing all the vector values
  3297. */
  3298. toString(): string;
  3299. /**
  3300. * Returns the string "Vector4".
  3301. * @returns "Vector4"
  3302. */
  3303. getClassName(): string;
  3304. /**
  3305. * Returns the Vector4 hash code.
  3306. * @returns a unique hash code
  3307. */
  3308. getHashCode(): number;
  3309. /**
  3310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3311. * @returns the resulting array
  3312. */
  3313. asArray(): number[];
  3314. /**
  3315. * Populates the given array from the given index with the Vector4 coordinates.
  3316. * @param array array to populate
  3317. * @param index index of the array to start at (default: 0)
  3318. * @returns the Vector4.
  3319. */
  3320. toArray(array: FloatArray, index?: number): Vector4;
  3321. /**
  3322. * Update the current vector from an array
  3323. * @param array defines the destination array
  3324. * @param index defines the offset in the destination array
  3325. * @returns the current Vector3
  3326. */
  3327. fromArray(array: FloatArray, index?: number): Vector4;
  3328. /**
  3329. * Adds the given vector to the current Vector4.
  3330. * @param otherVector the vector to add
  3331. * @returns the updated Vector4.
  3332. */
  3333. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3336. * @param otherVector the vector to add
  3337. * @returns the resulting vector
  3338. */
  3339. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3342. * @param otherVector the vector to add
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Subtract in place the given vector from the current Vector4.
  3349. * @param otherVector the vector to subtract
  3350. * @returns the updated Vector4.
  3351. */
  3352. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3355. * @param otherVector the vector to add
  3356. * @returns the new vector with the result
  3357. */
  3358. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3361. * @param otherVector the vector to subtract
  3362. * @param result the vector to store the result
  3363. * @returns the current Vector4.
  3364. */
  3365. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3366. /**
  3367. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3368. */
  3369. /**
  3370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3371. * @param x value to subtract
  3372. * @param y value to subtract
  3373. * @param z value to subtract
  3374. * @param w value to subtract
  3375. * @returns new vector containing the result
  3376. */
  3377. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3378. /**
  3379. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3380. * @param x value to subtract
  3381. * @param y value to subtract
  3382. * @param z value to subtract
  3383. * @param w value to subtract
  3384. * @param result the vector to store the result in
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3390. * @returns a new vector with the negated values
  3391. */
  3392. negate(): Vector4;
  3393. /**
  3394. * Negate this vector in place
  3395. * @returns this
  3396. */
  3397. negateInPlace(): Vector4;
  3398. /**
  3399. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3400. * @param result defines the Vector3 object where to store the result
  3401. * @returns the current Vector4
  3402. */
  3403. negateToRef(result: Vector4): Vector4;
  3404. /**
  3405. * Multiplies the current Vector4 coordinates by scale (float).
  3406. * @param scale the number to scale with
  3407. * @returns the updated Vector4.
  3408. */
  3409. scaleInPlace(scale: number): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3412. * @param scale the number to scale with
  3413. * @returns a new vector with the result
  3414. */
  3415. scale(scale: number): Vector4;
  3416. /**
  3417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3418. * @param scale the number to scale with
  3419. * @param result a vector to store the result in
  3420. * @returns the current Vector4.
  3421. */
  3422. scaleToRef(scale: number, result: Vector4): Vector4;
  3423. /**
  3424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3425. * @param scale defines the scale factor
  3426. * @param result defines the Vector4 object where to store the result
  3427. * @returns the unmodified current Vector4
  3428. */
  3429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3430. /**
  3431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3432. * @param otherVector the vector to compare against
  3433. * @returns true if they are equal
  3434. */
  3435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3436. /**
  3437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3438. * @param otherVector vector to compare against
  3439. * @param epsilon (Default: very small number)
  3440. * @returns true if they are equal
  3441. */
  3442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3443. /**
  3444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3445. * @param x x value to compare against
  3446. * @param y y value to compare against
  3447. * @param z z value to compare against
  3448. * @param w w value to compare against
  3449. * @returns true if equal
  3450. */
  3451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3452. /**
  3453. * Multiplies in place the current Vector4 by the given one.
  3454. * @param otherVector vector to multiple with
  3455. * @returns the updated Vector4.
  3456. */
  3457. multiplyInPlace(otherVector: Vector4): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3460. * @param otherVector vector to multiple with
  3461. * @returns resulting new vector
  3462. */
  3463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3464. /**
  3465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3466. * @param otherVector vector to multiple with
  3467. * @param result vector to store the result
  3468. * @returns the current Vector4.
  3469. */
  3470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3471. /**
  3472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3473. * @param x x value multiply with
  3474. * @param y y value multiply with
  3475. * @param z z value multiply with
  3476. * @param w w value multiply with
  3477. * @returns resulting new vector
  3478. */
  3479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3482. * @param otherVector vector to devide with
  3483. * @returns resulting new vector
  3484. */
  3485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3488. * @param otherVector vector to devide with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Divides the current Vector3 coordinates by the given ones.
  3495. * @param otherVector vector to devide with
  3496. * @returns the updated Vector3.
  3497. */
  3498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3499. /**
  3500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3501. * @param other defines the second operand
  3502. * @returns the current updated Vector4
  3503. */
  3504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3505. /**
  3506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3507. * @param other defines the second operand
  3508. * @returns the current updated Vector4
  3509. */
  3510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3511. /**
  3512. * Gets a new Vector4 from current Vector4 floored values
  3513. * @returns a new Vector4
  3514. */
  3515. floor(): Vector4;
  3516. /**
  3517. * Gets a new Vector4 from current Vector3 floored values
  3518. * @returns a new Vector4
  3519. */
  3520. fract(): Vector4;
  3521. /**
  3522. * Returns the Vector4 length (float).
  3523. * @returns the length
  3524. */
  3525. length(): number;
  3526. /**
  3527. * Returns the Vector4 squared length (float).
  3528. * @returns the length squared
  3529. */
  3530. lengthSquared(): number;
  3531. /**
  3532. * Normalizes in place the Vector4.
  3533. * @returns the updated Vector4.
  3534. */
  3535. normalize(): Vector4;
  3536. /**
  3537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3538. * @returns this converted to a new vector3
  3539. */
  3540. toVector3(): Vector3;
  3541. /**
  3542. * Returns a new Vector4 copied from the current one.
  3543. * @returns the new cloned vector
  3544. */
  3545. clone(): Vector4;
  3546. /**
  3547. * Updates the current Vector4 with the given one coordinates.
  3548. * @param source the source vector to copy from
  3549. * @returns the updated Vector4.
  3550. */
  3551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3552. /**
  3553. * Updates the current Vector4 coordinates with the given floats.
  3554. * @param x float to copy from
  3555. * @param y float to copy from
  3556. * @param z float to copy from
  3557. * @param w float to copy from
  3558. * @returns the updated Vector4.
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3561. /**
  3562. * Updates the current Vector4 coordinates with the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @returns the updated Vector4.
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Vector4;
  3570. /**
  3571. * Copies the given float to the current Vector3 coordinates
  3572. * @param v defines the x, y, z and w coordinates of the operand
  3573. * @returns the current updated Vector3
  3574. */
  3575. setAll(v: number): Vector4;
  3576. /**
  3577. * Returns a new Vector4 set from the starting index of the given array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @returns the new vector
  3581. */
  3582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3583. /**
  3584. * Updates the given vector "result" from the starting index of the given array.
  3585. * @param array the array to pull values from
  3586. * @param offset the offset into the array to start at
  3587. * @param result the vector to store the result in
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3590. /**
  3591. * Updates the given vector "result" from the starting index of the given Float32Array.
  3592. * @param array the array to pull values from
  3593. * @param offset the offset into the array to start at
  3594. * @param result the vector to store the result in
  3595. */
  3596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3597. /**
  3598. * Updates the given vector "result" coordinates from the given floats.
  3599. * @param x float to set from
  3600. * @param y float to set from
  3601. * @param z float to set from
  3602. * @param w float to set from
  3603. * @param result the vector to the floats in
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3606. /**
  3607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3608. * @returns the new vector
  3609. */
  3610. static Zero(): Vector4;
  3611. /**
  3612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3613. * @returns the new vector
  3614. */
  3615. static One(): Vector4;
  3616. /**
  3617. * Returns a new normalized Vector4 from the given one.
  3618. * @param vector the vector to normalize
  3619. * @returns the vector
  3620. */
  3621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3622. /**
  3623. * Updates the given vector "result" from the normalization of the given one.
  3624. * @param vector the vector to normalize
  3625. * @param result the vector to store the result in
  3626. */
  3627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3628. /**
  3629. * Returns a vector with the minimum values from the left and right vectors
  3630. * @param left left vector to minimize
  3631. * @param right right vector to minimize
  3632. * @returns a new vector with the minimum of the left and right vector values
  3633. */
  3634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3635. /**
  3636. * Returns a vector with the maximum values from the left and right vectors
  3637. * @param left left vector to maximize
  3638. * @param right right vector to maximize
  3639. * @returns a new vector with the maximum of the left and right vector values
  3640. */
  3641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Returns the distance (float) between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the distance between
  3645. * @param value2 value to calulate the distance between
  3646. * @return the distance between the two vectors
  3647. */
  3648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3649. /**
  3650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3651. * @param value1 value to calulate the distance between
  3652. * @param value2 value to calulate the distance between
  3653. * @return the distance between the two vectors squared
  3654. */
  3655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3656. /**
  3657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3658. * @param value1 value to calulate the center between
  3659. * @param value2 value to calulate the center between
  3660. * @return the center between the two vectors
  3661. */
  3662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3663. /**
  3664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param vector the vector to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @returns the new vector
  3669. */
  3670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3671. /**
  3672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3673. * This methods computes transformed normalized direction vectors only.
  3674. * @param vector the vector to transform
  3675. * @param transformation the transformation matrix to apply
  3676. * @param result the vector to store the result in
  3677. */
  3678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3679. /**
  3680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3681. * This methods computes transformed normalized direction vectors only.
  3682. * @param x value to transform
  3683. * @param y value to transform
  3684. * @param z value to transform
  3685. * @param w value to transform
  3686. * @param transformation the transformation matrix to apply
  3687. * @param result the vector to store the results in
  3688. */
  3689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3690. /**
  3691. * Creates a new Vector4 from a Vector3
  3692. * @param source defines the source data
  3693. * @param w defines the 4th component (default is 0)
  3694. * @returns a new Vector4
  3695. */
  3696. static FromVector3(source: Vector3, w?: number): Vector4;
  3697. }
  3698. /**
  3699. * Class used to store quaternion data
  3700. * @see https://en.wikipedia.org/wiki/Quaternion
  3701. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3702. */
  3703. export class Quaternion {
  3704. /** @hidden */
  3705. _x: number;
  3706. /** @hidden */
  3707. _y: number;
  3708. /** @hidden */
  3709. _z: number;
  3710. /** @hidden */
  3711. _w: number;
  3712. /** @hidden */
  3713. _isDirty: boolean;
  3714. /** Gets or sets the x coordinate */
  3715. get x(): number;
  3716. set x(value: number);
  3717. /** Gets or sets the y coordinate */
  3718. get y(): number;
  3719. set y(value: number);
  3720. /** Gets or sets the z coordinate */
  3721. get z(): number;
  3722. set z(value: number);
  3723. /** Gets or sets the w coordinate */
  3724. get w(): number;
  3725. set w(value: number);
  3726. /**
  3727. * Creates a new Quaternion from the given floats
  3728. * @param x defines the first component (0 by default)
  3729. * @param y defines the second component (0 by default)
  3730. * @param z defines the third component (0 by default)
  3731. * @param w defines the fourth component (1.0 by default)
  3732. */
  3733. constructor(x?: number, y?: number, z?: number, w?: number);
  3734. /**
  3735. * Gets a string representation for the current quaternion
  3736. * @returns a string with the Quaternion coordinates
  3737. */
  3738. toString(): string;
  3739. /**
  3740. * Gets the class name of the quaternion
  3741. * @returns the string "Quaternion"
  3742. */
  3743. getClassName(): string;
  3744. /**
  3745. * Gets a hash code for this quaternion
  3746. * @returns the quaternion hash code
  3747. */
  3748. getHashCode(): number;
  3749. /**
  3750. * Copy the quaternion to an array
  3751. * @returns a new array populated with 4 elements from the quaternion coordinates
  3752. */
  3753. asArray(): number[];
  3754. /**
  3755. * Check if two quaternions are equals
  3756. * @param otherQuaternion defines the second operand
  3757. * @return true if the current quaternion and the given one coordinates are strictly equals
  3758. */
  3759. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3760. /**
  3761. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3762. * @param otherQuaternion defines the other quaternion
  3763. * @param epsilon defines the minimal distance to consider equality
  3764. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3765. */
  3766. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3767. /**
  3768. * Clone the current quaternion
  3769. * @returns a new quaternion copied from the current one
  3770. */
  3771. clone(): Quaternion;
  3772. /**
  3773. * Copy a quaternion to the current one
  3774. * @param other defines the other quaternion
  3775. * @returns the updated current quaternion
  3776. */
  3777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3778. /**
  3779. * Updates the current quaternion with the given float coordinates
  3780. * @param x defines the x coordinate
  3781. * @param y defines the y coordinate
  3782. * @param z defines the z coordinate
  3783. * @param w defines the w coordinate
  3784. * @returns the updated current quaternion
  3785. */
  3786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3787. /**
  3788. * Updates the current quaternion from the given float coordinates
  3789. * @param x defines the x coordinate
  3790. * @param y defines the y coordinate
  3791. * @param z defines the z coordinate
  3792. * @param w defines the w coordinate
  3793. * @returns the updated current quaternion
  3794. */
  3795. set(x: number, y: number, z: number, w: number): Quaternion;
  3796. /**
  3797. * Adds two quaternions
  3798. * @param other defines the second operand
  3799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3800. */
  3801. add(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Add a quaternion to the current one
  3804. * @param other defines the quaternion to add
  3805. * @returns the current quaternion
  3806. */
  3807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3808. /**
  3809. * Subtract two quaternions
  3810. * @param other defines the second operand
  3811. * @returns a new quaternion as the subtraction result of the given one from the current one
  3812. */
  3813. subtract(other: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies the current quaternion by a scale factor
  3816. * @param value defines the scale factor
  3817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3818. */
  3819. scale(value: number): Quaternion;
  3820. /**
  3821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3822. * @param scale defines the scale factor
  3823. * @param result defines the Quaternion object where to store the result
  3824. * @returns the unmodified current quaternion
  3825. */
  3826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3827. /**
  3828. * Multiplies in place the current quaternion by a scale factor
  3829. * @param value defines the scale factor
  3830. * @returns the current modified quaternion
  3831. */
  3832. scaleInPlace(value: number): Quaternion;
  3833. /**
  3834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3835. * @param scale defines the scale factor
  3836. * @param result defines the Quaternion object where to store the result
  3837. * @returns the unmodified current quaternion
  3838. */
  3839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3840. /**
  3841. * Multiplies two quaternions
  3842. * @param q1 defines the second operand
  3843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3844. */
  3845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3846. /**
  3847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3848. * @param q1 defines the second operand
  3849. * @param result defines the target quaternion
  3850. * @returns the current quaternion
  3851. */
  3852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3853. /**
  3854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3855. * @param q1 defines the second operand
  3856. * @returns the currentupdated quaternion
  3857. */
  3858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3859. /**
  3860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3861. * @param ref defines the target quaternion
  3862. * @returns the current quaternion
  3863. */
  3864. conjugateToRef(ref: Quaternion): Quaternion;
  3865. /**
  3866. * Conjugates in place (1-q) the current quaternion
  3867. * @returns the current updated quaternion
  3868. */
  3869. conjugateInPlace(): Quaternion;
  3870. /**
  3871. * Conjugates in place (1-q) the current quaternion
  3872. * @returns a new quaternion
  3873. */
  3874. conjugate(): Quaternion;
  3875. /**
  3876. * Gets length of current quaternion
  3877. * @returns the quaternion length (float)
  3878. */
  3879. length(): number;
  3880. /**
  3881. * Normalize in place the current quaternion
  3882. * @returns the current updated quaternion
  3883. */
  3884. normalize(): Quaternion;
  3885. /**
  3886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3887. * @param order is a reserved parameter and is ignored for now
  3888. * @returns a new Vector3 containing the Euler angles
  3889. */
  3890. toEulerAngles(order?: string): Vector3;
  3891. /**
  3892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3893. * @param result defines the vector which will be filled with the Euler angles
  3894. * @returns the current unchanged quaternion
  3895. */
  3896. toEulerAnglesToRef(result: Vector3): Quaternion;
  3897. /**
  3898. * Updates the given rotation matrix with the current quaternion values
  3899. * @param result defines the target matrix
  3900. * @returns the current unchanged quaternion
  3901. */
  3902. toRotationMatrix(result: Matrix): Quaternion;
  3903. /**
  3904. * Updates the current quaternion from the given rotation matrix values
  3905. * @param matrix defines the source matrix
  3906. * @returns the current updated quaternion
  3907. */
  3908. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from a rotation matrix
  3911. * @param matrix defines the source matrix
  3912. * @returns a new quaternion created from the given rotation matrix values
  3913. */
  3914. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3915. /**
  3916. * Updates the given quaternion with the given rotation matrix values
  3917. * @param matrix defines the source matrix
  3918. * @param result defines the target quaternion
  3919. */
  3920. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3921. /**
  3922. * Returns the dot product (float) between the quaternions "left" and "right"
  3923. * @param left defines the left operand
  3924. * @param right defines the right operand
  3925. * @returns the dot product
  3926. */
  3927. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3928. /**
  3929. * Checks if the two quaternions are close to each other
  3930. * @param quat0 defines the first quaternion to check
  3931. * @param quat1 defines the second quaternion to check
  3932. * @returns true if the two quaternions are close to each other
  3933. */
  3934. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3935. /**
  3936. * Creates an empty quaternion
  3937. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3938. */
  3939. static Zero(): Quaternion;
  3940. /**
  3941. * Inverse a given quaternion
  3942. * @param q defines the source quaternion
  3943. * @returns a new quaternion as the inverted current quaternion
  3944. */
  3945. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3946. /**
  3947. * Inverse a given quaternion
  3948. * @param q defines the source quaternion
  3949. * @param result the quaternion the result will be stored in
  3950. * @returns the result quaternion
  3951. */
  3952. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates an identity quaternion
  3955. * @returns the identity quaternion
  3956. */
  3957. static Identity(): Quaternion;
  3958. /**
  3959. * Gets a boolean indicating if the given quaternion is identity
  3960. * @param quaternion defines the quaternion to check
  3961. * @returns true if the quaternion is identity
  3962. */
  3963. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3964. /**
  3965. * Creates a quaternion from a rotation around an axis
  3966. * @param axis defines the axis to use
  3967. * @param angle defines the angle to use
  3968. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3969. */
  3970. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3971. /**
  3972. * Creates a rotation around an axis and stores it into the given quaternion
  3973. * @param axis defines the axis to use
  3974. * @param angle defines the angle to use
  3975. * @param result defines the target quaternion
  3976. * @returns the target quaternion
  3977. */
  3978. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3979. /**
  3980. * Creates a new quaternion from data stored into an array
  3981. * @param array defines the data source
  3982. * @param offset defines the offset in the source array where the data starts
  3983. * @returns a new quaternion
  3984. */
  3985. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3986. /**
  3987. * Updates the given quaternion "result" from the starting index of the given array.
  3988. * @param array the array to pull values from
  3989. * @param offset the offset into the array to start at
  3990. * @param result the quaternion to store the result in
  3991. */
  3992. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3993. /**
  3994. * Create a quaternion from Euler rotation angles
  3995. * @param x Pitch
  3996. * @param y Yaw
  3997. * @param z Roll
  3998. * @returns the new Quaternion
  3999. */
  4000. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4001. /**
  4002. * Updates a quaternion from Euler rotation angles
  4003. * @param x Pitch
  4004. * @param y Yaw
  4005. * @param z Roll
  4006. * @param result the quaternion to store the result
  4007. * @returns the updated quaternion
  4008. */
  4009. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4010. /**
  4011. * Create a quaternion from Euler rotation vector
  4012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4013. * @returns the new Quaternion
  4014. */
  4015. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4016. /**
  4017. * Updates a quaternion from Euler rotation vector
  4018. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4019. * @param result the quaternion to store the result
  4020. * @returns the updated quaternion
  4021. */
  4022. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4023. /**
  4024. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4025. * @param yaw defines the rotation around Y axis
  4026. * @param pitch defines the rotation around X axis
  4027. * @param roll defines the rotation around Z axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4031. /**
  4032. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4033. * @param yaw defines the rotation around Y axis
  4034. * @param pitch defines the rotation around X axis
  4035. * @param roll defines the rotation around Z axis
  4036. * @param result defines the target quaternion
  4037. */
  4038. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4039. /**
  4040. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4041. * @param alpha defines the rotation around first axis
  4042. * @param beta defines the rotation around second axis
  4043. * @param gamma defines the rotation around third axis
  4044. * @returns the new quaternion
  4045. */
  4046. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4049. * @param alpha defines the rotation around first axis
  4050. * @param beta defines the rotation around second axis
  4051. * @param gamma defines the rotation around third axis
  4052. * @param result defines the target quaternion
  4053. */
  4054. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4055. /**
  4056. * 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)
  4057. * @param axis1 defines the first axis
  4058. * @param axis2 defines the second axis
  4059. * @param axis3 defines the third axis
  4060. * @returns the new quaternion
  4061. */
  4062. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4063. /**
  4064. * 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
  4065. * @param axis1 defines the first axis
  4066. * @param axis2 defines the second axis
  4067. * @param axis3 defines the third axis
  4068. * @param ref defines the target quaternion
  4069. */
  4070. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4071. /**
  4072. * Interpolates between two quaternions
  4073. * @param left defines first quaternion
  4074. * @param right defines second quaternion
  4075. * @param amount defines the gradient to use
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. /**
  4080. * Interpolates between two quaternions and stores it into a target quaternion
  4081. * @param left defines first quaternion
  4082. * @param right defines second quaternion
  4083. * @param amount defines the gradient to use
  4084. * @param result defines the target quaternion
  4085. */
  4086. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4087. /**
  4088. * Interpolate between two quaternions using Hermite interpolation
  4089. * @param value1 defines first quaternion
  4090. * @param tangent1 defines the incoming tangent
  4091. * @param value2 defines second quaternion
  4092. * @param tangent2 defines the outgoing tangent
  4093. * @param amount defines the target quaternion
  4094. * @returns the new interpolated quaternion
  4095. */
  4096. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4097. }
  4098. /**
  4099. * Class used to store matrix data (4x4)
  4100. */
  4101. export class Matrix {
  4102. /**
  4103. * Gets the precision of matrix computations
  4104. */
  4105. static get Use64Bits(): boolean;
  4106. private static _updateFlagSeed;
  4107. private static _identityReadOnly;
  4108. private _isIdentity;
  4109. private _isIdentityDirty;
  4110. private _isIdentity3x2;
  4111. private _isIdentity3x2Dirty;
  4112. /**
  4113. * Gets the update flag of the matrix which is an unique number for the matrix.
  4114. * It will be incremented every time the matrix data change.
  4115. * You can use it to speed the comparison between two versions of the same matrix.
  4116. */
  4117. updateFlag: number;
  4118. private readonly _m;
  4119. /**
  4120. * Gets the internal data of the matrix
  4121. */
  4122. get m(): DeepImmutable<Float32Array | Array<number>>;
  4123. /** @hidden */
  4124. _markAsUpdated(): void;
  4125. /** @hidden */
  4126. private _updateIdentityStatus;
  4127. /**
  4128. * Creates an empty matrix (filled with zeros)
  4129. */
  4130. constructor();
  4131. /**
  4132. * Check if the current matrix is identity
  4133. * @returns true is the matrix is the identity matrix
  4134. */
  4135. isIdentity(): boolean;
  4136. /**
  4137. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4138. * @returns true is the matrix is the identity matrix
  4139. */
  4140. isIdentityAs3x2(): boolean;
  4141. /**
  4142. * Gets the determinant of the matrix
  4143. * @returns the matrix determinant
  4144. */
  4145. determinant(): number;
  4146. /**
  4147. * Returns the matrix as a Float32Array or Array<number>
  4148. * @returns the matrix underlying array
  4149. */
  4150. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4151. /**
  4152. * Returns the matrix as a Float32Array or Array<number>
  4153. * @returns the matrix underlying array.
  4154. */
  4155. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4156. /**
  4157. * Inverts the current matrix in place
  4158. * @returns the current inverted matrix
  4159. */
  4160. invert(): Matrix;
  4161. /**
  4162. * Sets all the matrix elements to zero
  4163. * @returns the current matrix
  4164. */
  4165. reset(): Matrix;
  4166. /**
  4167. * Adds the current matrix with a second one
  4168. * @param other defines the matrix to add
  4169. * @returns a new matrix as the addition of the current matrix and the given one
  4170. */
  4171. add(other: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4174. * @param other defines the matrix to add
  4175. * @param result defines the target matrix
  4176. * @returns the current matrix
  4177. */
  4178. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4179. /**
  4180. * Adds in place the given matrix to the current matrix
  4181. * @param other defines the second operand
  4182. * @returns the current updated matrix
  4183. */
  4184. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4185. /**
  4186. * Sets the given matrix to the current inverted Matrix
  4187. * @param other defines the target matrix
  4188. * @returns the unmodified current matrix
  4189. */
  4190. invertToRef(other: Matrix): Matrix;
  4191. /**
  4192. * add a value at the specified position in the current Matrix
  4193. * @param index the index of the value within the matrix. between 0 and 15.
  4194. * @param value the value to be added
  4195. * @returns the current updated matrix
  4196. */
  4197. addAtIndex(index: number, value: number): Matrix;
  4198. /**
  4199. * mutiply the specified position in the current Matrix by a value
  4200. * @param index the index of the value within the matrix. between 0 and 15.
  4201. * @param value the value to be added
  4202. * @returns the current updated matrix
  4203. */
  4204. multiplyAtIndex(index: number, value: number): Matrix;
  4205. /**
  4206. * Inserts the translation vector (using 3 floats) in the current matrix
  4207. * @param x defines the 1st component of the translation
  4208. * @param y defines the 2nd component of the translation
  4209. * @param z defines the 3rd component of the translation
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4213. /**
  4214. * Adds the translation vector (using 3 floats) in the current matrix
  4215. * @param x defines the 1st component of the translation
  4216. * @param y defines the 2nd component of the translation
  4217. * @param z defines the 3rd component of the translation
  4218. * @returns the current updated matrix
  4219. */
  4220. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4221. /**
  4222. * Inserts the translation vector in the current matrix
  4223. * @param vector3 defines the translation to insert
  4224. * @returns the current updated matrix
  4225. */
  4226. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4227. /**
  4228. * Gets the translation value of the current matrix
  4229. * @returns a new Vector3 as the extracted translation from the matrix
  4230. */
  4231. getTranslation(): Vector3;
  4232. /**
  4233. * Fill a Vector3 with the extracted translation from the matrix
  4234. * @param result defines the Vector3 where to store the translation
  4235. * @returns the current matrix
  4236. */
  4237. getTranslationToRef(result: Vector3): Matrix;
  4238. /**
  4239. * Remove rotation and scaling part from the matrix
  4240. * @returns the updated matrix
  4241. */
  4242. removeRotationAndScaling(): Matrix;
  4243. /**
  4244. * Multiply two matrices
  4245. * @param other defines the second operand
  4246. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4247. */
  4248. multiply(other: DeepImmutable<Matrix>): Matrix;
  4249. /**
  4250. * Copy the current matrix from the given one
  4251. * @param other defines the source matrix
  4252. * @returns the current updated matrix
  4253. */
  4254. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Populates the given array from the starting index with the current matrix values
  4257. * @param array defines the target array
  4258. * @param offset defines the offset in the target array where to start storing values
  4259. * @returns the current matrix
  4260. */
  4261. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4262. /**
  4263. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4264. * @param other defines the second operand
  4265. * @param result defines the matrix where to store the multiplication
  4266. * @returns the current matrix
  4267. */
  4268. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4269. /**
  4270. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4271. * @param other defines the second operand
  4272. * @param result defines the array where to store the multiplication
  4273. * @param offset defines the offset in the target array where to start storing values
  4274. * @returns the current matrix
  4275. */
  4276. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4277. /**
  4278. * Check equality between this matrix and a second one
  4279. * @param value defines the second matrix to compare
  4280. * @returns true is the current matrix and the given one values are strictly equal
  4281. */
  4282. equals(value: DeepImmutable<Matrix>): boolean;
  4283. /**
  4284. * Clone the current matrix
  4285. * @returns a new matrix from the current matrix
  4286. */
  4287. clone(): Matrix;
  4288. /**
  4289. * Returns the name of the current matrix class
  4290. * @returns the string "Matrix"
  4291. */
  4292. getClassName(): string;
  4293. /**
  4294. * Gets the hash code of the current matrix
  4295. * @returns the hash code
  4296. */
  4297. getHashCode(): number;
  4298. /**
  4299. * Decomposes the current Matrix into a translation, rotation and scaling components
  4300. * @param scale defines the scale vector3 given as a reference to update
  4301. * @param rotation defines the rotation quaternion given as a reference to update
  4302. * @param translation defines the translation vector3 given as a reference to update
  4303. * @returns true if operation was successful
  4304. */
  4305. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4306. /**
  4307. * Gets specific row of the matrix
  4308. * @param index defines the number of the row to get
  4309. * @returns the index-th row of the current matrix as a new Vector4
  4310. */
  4311. getRow(index: number): Nullable<Vector4>;
  4312. /**
  4313. * Sets the index-th row of the current matrix to the vector4 values
  4314. * @param index defines the number of the row to set
  4315. * @param row defines the target vector4
  4316. * @returns the updated current matrix
  4317. */
  4318. setRow(index: number, row: Vector4): Matrix;
  4319. /**
  4320. * Compute the transpose of the matrix
  4321. * @returns the new transposed matrix
  4322. */
  4323. transpose(): Matrix;
  4324. /**
  4325. * Compute the transpose of the matrix and store it in a given matrix
  4326. * @param result defines the target matrix
  4327. * @returns the current matrix
  4328. */
  4329. transposeToRef(result: Matrix): Matrix;
  4330. /**
  4331. * Sets the index-th row of the current matrix with the given 4 x float values
  4332. * @param index defines the row index
  4333. * @param x defines the x component to set
  4334. * @param y defines the y component to set
  4335. * @param z defines the z component to set
  4336. * @param w defines the w component to set
  4337. * @returns the updated current matrix
  4338. */
  4339. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4340. /**
  4341. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4342. * @param scale defines the scale factor
  4343. * @returns a new matrix
  4344. */
  4345. scale(scale: number): Matrix;
  4346. /**
  4347. * Scale the current matrix values by a factor to a given result matrix
  4348. * @param scale defines the scale factor
  4349. * @param result defines the matrix to store the result
  4350. * @returns the current matrix
  4351. */
  4352. scaleToRef(scale: number, result: Matrix): Matrix;
  4353. /**
  4354. * Scale the current matrix values by a factor and add the result to a given matrix
  4355. * @param scale defines the scale factor
  4356. * @param result defines the Matrix to store the result
  4357. * @returns the current matrix
  4358. */
  4359. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4360. /**
  4361. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4362. * @param ref matrix to store the result
  4363. */
  4364. toNormalMatrix(ref: Matrix): void;
  4365. /**
  4366. * Gets only rotation part of the current matrix
  4367. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4368. */
  4369. getRotationMatrix(): Matrix;
  4370. /**
  4371. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4372. * @param result defines the target matrix to store data to
  4373. * @returns the current matrix
  4374. */
  4375. getRotationMatrixToRef(result: Matrix): Matrix;
  4376. /**
  4377. * Toggles model matrix from being right handed to left handed in place and vice versa
  4378. */
  4379. toggleModelMatrixHandInPlace(): void;
  4380. /**
  4381. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleProjectionMatrixHandInPlace(): void;
  4384. /**
  4385. * Creates a matrix from an array
  4386. * @param array defines the source array
  4387. * @param offset defines an offset in the source array
  4388. * @returns a new Matrix set from the starting index of the given array
  4389. */
  4390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4391. /**
  4392. * Copy the content of an array into a given matrix
  4393. * @param array defines the source array
  4394. * @param offset defines an offset in the source array
  4395. * @param result defines the target matrix
  4396. */
  4397. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4398. /**
  4399. * Stores an array into a matrix after having multiplied each component by a given factor
  4400. * @param array defines the source array
  4401. * @param offset defines the offset in the source array
  4402. * @param scale defines the scaling factor
  4403. * @param result defines the target matrix
  4404. */
  4405. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4406. /**
  4407. * Gets an identity matrix that must not be updated
  4408. */
  4409. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4410. /**
  4411. * Stores a list of values (16) inside a given matrix
  4412. * @param initialM11 defines 1st value of 1st row
  4413. * @param initialM12 defines 2nd value of 1st row
  4414. * @param initialM13 defines 3rd value of 1st row
  4415. * @param initialM14 defines 4th value of 1st row
  4416. * @param initialM21 defines 1st value of 2nd row
  4417. * @param initialM22 defines 2nd value of 2nd row
  4418. * @param initialM23 defines 3rd value of 2nd row
  4419. * @param initialM24 defines 4th value of 2nd row
  4420. * @param initialM31 defines 1st value of 3rd row
  4421. * @param initialM32 defines 2nd value of 3rd row
  4422. * @param initialM33 defines 3rd value of 3rd row
  4423. * @param initialM34 defines 4th value of 3rd row
  4424. * @param initialM41 defines 1st value of 4th row
  4425. * @param initialM42 defines 2nd value of 4th row
  4426. * @param initialM43 defines 3rd value of 4th row
  4427. * @param initialM44 defines 4th value of 4th row
  4428. * @param result defines the target matrix
  4429. */
  4430. 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;
  4431. /**
  4432. * Creates new matrix from a list of values (16)
  4433. * @param initialM11 defines 1st value of 1st row
  4434. * @param initialM12 defines 2nd value of 1st row
  4435. * @param initialM13 defines 3rd value of 1st row
  4436. * @param initialM14 defines 4th value of 1st row
  4437. * @param initialM21 defines 1st value of 2nd row
  4438. * @param initialM22 defines 2nd value of 2nd row
  4439. * @param initialM23 defines 3rd value of 2nd row
  4440. * @param initialM24 defines 4th value of 2nd row
  4441. * @param initialM31 defines 1st value of 3rd row
  4442. * @param initialM32 defines 2nd value of 3rd row
  4443. * @param initialM33 defines 3rd value of 3rd row
  4444. * @param initialM34 defines 4th value of 3rd row
  4445. * @param initialM41 defines 1st value of 4th row
  4446. * @param initialM42 defines 2nd value of 4th row
  4447. * @param initialM43 defines 3rd value of 4th row
  4448. * @param initialM44 defines 4th value of 4th row
  4449. * @returns the new matrix
  4450. */
  4451. 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;
  4452. /**
  4453. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4454. * @param scale defines the scale vector3
  4455. * @param rotation defines the rotation quaternion
  4456. * @param translation defines the translation vector3
  4457. * @returns a new matrix
  4458. */
  4459. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4460. /**
  4461. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4462. * @param scale defines the scale vector3
  4463. * @param rotation defines the rotation quaternion
  4464. * @param translation defines the translation vector3
  4465. * @param result defines the target matrix
  4466. */
  4467. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4468. /**
  4469. * Creates a new identity matrix
  4470. * @returns a new identity matrix
  4471. */
  4472. static Identity(): Matrix;
  4473. /**
  4474. * Creates a new identity matrix and stores the result in a given matrix
  4475. * @param result defines the target matrix
  4476. */
  4477. static IdentityToRef(result: Matrix): void;
  4478. /**
  4479. * Creates a new zero matrix
  4480. * @returns a new zero matrix
  4481. */
  4482. static Zero(): Matrix;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the X axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationX(angle: number): Matrix;
  4489. /**
  4490. * Creates a new matrix as the invert of a given matrix
  4491. * @param source defines the source matrix
  4492. * @returns the new matrix
  4493. */
  4494. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4497. * @param angle defines the angle (in radians) to use
  4498. * @param result defines the target matrix
  4499. */
  4500. static RotationXToRef(angle: number, result: Matrix): void;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Y axis
  4503. * @param angle defines the angle (in radians) to use
  4504. * @return the new matrix
  4505. */
  4506. static RotationY(angle: number): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4509. * @param angle defines the angle (in radians) to use
  4510. * @param result defines the target matrix
  4511. */
  4512. static RotationYToRef(angle: number, result: Matrix): void;
  4513. /**
  4514. * Creates a new rotation matrix for "angle" radians around the Z axis
  4515. * @param angle defines the angle (in radians) to use
  4516. * @return the new matrix
  4517. */
  4518. static RotationZ(angle: number): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationZToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the given axis
  4527. * @param axis defines the axis to use
  4528. * @param angle defines the angle (in radians) to use
  4529. * @return the new matrix
  4530. */
  4531. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4532. /**
  4533. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4534. * @param axis defines the axis to use
  4535. * @param angle defines the angle (in radians) to use
  4536. * @param result defines the target matrix
  4537. */
  4538. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4539. /**
  4540. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4541. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4542. * @param from defines the vector to align
  4543. * @param to defines the vector to align to
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4547. /**
  4548. * Creates a rotation matrix
  4549. * @param yaw defines the yaw angle in radians (Y axis)
  4550. * @param pitch defines the pitch angle in radians (X axis)
  4551. * @param roll defines the roll angle in radians (Z axis)
  4552. * @returns the new rotation matrix
  4553. */
  4554. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4555. /**
  4556. * Creates a rotation matrix and stores it in a given matrix
  4557. * @param yaw defines the yaw angle in radians (Y axis)
  4558. * @param pitch defines the pitch angle in radians (X axis)
  4559. * @param roll defines the roll angle in radians (Z axis)
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4563. /**
  4564. * Creates a scaling matrix
  4565. * @param x defines the scale factor on X axis
  4566. * @param y defines the scale factor on Y axis
  4567. * @param z defines the scale factor on Z axis
  4568. * @returns the new matrix
  4569. */
  4570. static Scaling(x: number, y: number, z: number): Matrix;
  4571. /**
  4572. * Creates a scaling matrix and stores it in a given matrix
  4573. * @param x defines the scale factor on X axis
  4574. * @param y defines the scale factor on Y axis
  4575. * @param z defines the scale factor on Z axis
  4576. * @param result defines the target matrix
  4577. */
  4578. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4579. /**
  4580. * Creates a translation matrix
  4581. * @param x defines the translation on X axis
  4582. * @param y defines the translation on Y axis
  4583. * @param z defines the translationon Z axis
  4584. * @returns the new matrix
  4585. */
  4586. static Translation(x: number, y: number, z: number): Matrix;
  4587. /**
  4588. * Creates a translation matrix and stores it in a given matrix
  4589. * @param x defines the translation on X axis
  4590. * @param y defines the translation on Y axis
  4591. * @param z defines the translationon Z axis
  4592. * @param result defines the target matrix
  4593. */
  4594. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4595. /**
  4596. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4597. * @param startValue defines the start value
  4598. * @param endValue defines the end value
  4599. * @param gradient defines the gradient factor
  4600. * @returns the new matrix
  4601. */
  4602. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4603. /**
  4604. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4605. * @param startValue defines the start value
  4606. * @param endValue defines the end value
  4607. * @param gradient defines the gradient factor
  4608. * @param result defines the Matrix object where to store data
  4609. */
  4610. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4611. /**
  4612. * Builds a new matrix whose values are computed by:
  4613. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4614. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4615. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4616. * @param startValue defines the first matrix
  4617. * @param endValue defines the second matrix
  4618. * @param gradient defines the gradient between the two matrices
  4619. * @returns the new matrix
  4620. */
  4621. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4622. /**
  4623. * Update a matrix to values which are computed by:
  4624. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4625. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4626. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4627. * @param startValue defines the first matrix
  4628. * @param endValue defines the second matrix
  4629. * @param gradient defines the gradient between the two matrices
  4630. * @param result defines the target matrix
  4631. */
  4632. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * 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"
  4653. * This function works in right handed mode
  4654. * @param eye defines the final position of the entity
  4655. * @param target defines where the entity should look at
  4656. * @param up defines the up vector for the entity
  4657. * @returns the new matrix
  4658. */
  4659. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4660. /**
  4661. * 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".
  4662. * This function works in right handed mode
  4663. * @param eye defines the final position of the entity
  4664. * @param target defines where the entity should look at
  4665. * @param up defines the up vector for the entity
  4666. * @param result defines the target matrix
  4667. */
  4668. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param width defines the viewport width
  4672. * @param height defines the viewport height
  4673. * @param znear defines the near clip plane
  4674. * @param zfar defines the far clip plane
  4675. * @returns a new matrix as a left-handed orthographic projection matrix
  4676. */
  4677. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4678. /**
  4679. * Store a left-handed orthographic projection to a given matrix
  4680. * @param width defines the viewport width
  4681. * @param height defines the viewport height
  4682. * @param znear defines the near clip plane
  4683. * @param zfar defines the far clip plane
  4684. * @param result defines the target matrix
  4685. */
  4686. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4687. /**
  4688. * Create a left-handed orthographic projection matrix
  4689. * @param left defines the viewport left coordinate
  4690. * @param right defines the viewport right coordinate
  4691. * @param bottom defines the viewport bottom coordinate
  4692. * @param top defines the viewport top coordinate
  4693. * @param znear defines the near clip plane
  4694. * @param zfar defines the far clip plane
  4695. * @returns a new matrix as a left-handed orthographic projection matrix
  4696. */
  4697. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4698. /**
  4699. * Stores a left-handed orthographic projection into a given matrix
  4700. * @param left defines the viewport left coordinate
  4701. * @param right defines the viewport right coordinate
  4702. * @param bottom defines the viewport bottom coordinate
  4703. * @param top defines the viewport top coordinate
  4704. * @param znear defines the near clip plane
  4705. * @param zfar defines the far clip plane
  4706. * @param result defines the target matrix
  4707. */
  4708. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4709. /**
  4710. * Creates a right-handed orthographic projection matrix
  4711. * @param left defines the viewport left coordinate
  4712. * @param right defines the viewport right coordinate
  4713. * @param bottom defines the viewport bottom coordinate
  4714. * @param top defines the viewport top coordinate
  4715. * @param znear defines the near clip plane
  4716. * @param zfar defines the far clip plane
  4717. * @returns a new matrix as a right-handed orthographic projection matrix
  4718. */
  4719. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a right-handed orthographic projection into a given matrix
  4722. * @param left defines the viewport left coordinate
  4723. * @param right defines the viewport right coordinate
  4724. * @param bottom defines the viewport bottom coordinate
  4725. * @param top defines the viewport top coordinate
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. */
  4730. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4731. /**
  4732. * Creates a left-handed perspective projection matrix
  4733. * @param width defines the viewport width
  4734. * @param height defines the viewport height
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @returns a new matrix as a left-handed perspective projection matrix
  4738. */
  4739. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4740. /**
  4741. * Creates a left-handed perspective projection matrix
  4742. * @param fov defines the horizontal field of view
  4743. * @param aspect defines the aspect ratio
  4744. * @param znear defines the near clip plane
  4745. * @param zfar defines the far clip plane
  4746. * @returns a new matrix as a left-handed perspective projection matrix
  4747. */
  4748. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4749. /**
  4750. * Stores a left-handed perspective projection into a given matrix
  4751. * @param fov defines the horizontal field of view
  4752. * @param aspect defines the aspect ratio
  4753. * @param znear defines the near clip plane
  4754. * @param zfar defines the far clip plane
  4755. * @param result defines the target matrix
  4756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4757. */
  4758. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4761. * @param fov defines the horizontal field of view
  4762. * @param aspect defines the aspect ratio
  4763. * @param znear defines the near clip plane
  4764. * @param zfar not used as infinity is used as far clip
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Creates a right-handed perspective projection matrix
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar defines the far clip plane
  4775. * @returns a new matrix as a right-handed perspective projection matrix
  4776. */
  4777. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4778. /**
  4779. * Stores a right-handed perspective projection into a given matrix
  4780. * @param fov defines the horizontal field of view
  4781. * @param aspect defines the aspect ratio
  4782. * @param znear defines the near clip plane
  4783. * @param zfar defines the far clip plane
  4784. * @param result defines the target matrix
  4785. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4786. */
  4787. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4788. /**
  4789. * Stores a right-handed perspective projection into a given matrix
  4790. * @param fov defines the horizontal field of view
  4791. * @param aspect defines the aspect ratio
  4792. * @param znear defines the near clip plane
  4793. * @param zfar not used as infinity is used as far clip
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a perspective projection for WebVR info a given matrix
  4800. * @param fov defines the field of view
  4801. * @param znear defines the near clip plane
  4802. * @param zfar defines the far clip plane
  4803. * @param result defines the target matrix
  4804. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4805. */
  4806. static PerspectiveFovWebVRToRef(fov: {
  4807. upDegrees: number;
  4808. downDegrees: number;
  4809. leftDegrees: number;
  4810. rightDegrees: number;
  4811. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4812. /**
  4813. * Computes a complete transformation matrix
  4814. * @param viewport defines the viewport to use
  4815. * @param world defines the world matrix
  4816. * @param view defines the view matrix
  4817. * @param projection defines the projection matrix
  4818. * @param zmin defines the near clip plane
  4819. * @param zmax defines the far clip plane
  4820. * @returns the transformation matrix
  4821. */
  4822. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4823. /**
  4824. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4825. * @param matrix defines the matrix to use
  4826. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4827. */
  4828. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4829. /**
  4830. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4831. * @param matrix defines the matrix to use
  4832. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4833. */
  4834. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4835. /**
  4836. * Compute the transpose of a given matrix
  4837. * @param matrix defines the matrix to transpose
  4838. * @returns the new matrix
  4839. */
  4840. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4841. /**
  4842. * Compute the transpose of a matrix and store it in a target matrix
  4843. * @param matrix defines the matrix to transpose
  4844. * @param result defines the target matrix
  4845. */
  4846. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4847. /**
  4848. * Computes a reflection matrix from a plane
  4849. * @param plane defines the reflection plane
  4850. * @returns a new matrix
  4851. */
  4852. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4853. /**
  4854. * Computes a reflection matrix from a plane
  4855. * @param plane defines the reflection plane
  4856. * @param result defines the target matrix
  4857. */
  4858. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4859. /**
  4860. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4861. * @param xaxis defines the value of the 1st axis
  4862. * @param yaxis defines the value of the 2nd axis
  4863. * @param zaxis defines the value of the 3rd axis
  4864. * @param result defines the target matrix
  4865. */
  4866. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4867. /**
  4868. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4869. * @param quat defines the quaternion to use
  4870. * @param result defines the target matrix
  4871. */
  4872. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4873. }
  4874. /**
  4875. * @hidden
  4876. */
  4877. export class TmpVectors {
  4878. static Vector2: Vector2[];
  4879. static Vector3: Vector3[];
  4880. static Vector4: Vector4[];
  4881. static Quaternion: Quaternion[];
  4882. static Matrix: Matrix[];
  4883. }
  4884. }
  4885. declare module "babylonjs/Maths/math.path" {
  4886. import { DeepImmutable, Nullable } from "babylonjs/types";
  4887. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4888. /**
  4889. * Defines potential orientation for back face culling
  4890. */
  4891. export enum Orientation {
  4892. /**
  4893. * Clockwise
  4894. */
  4895. CW = 0,
  4896. /** Counter clockwise */
  4897. CCW = 1
  4898. }
  4899. /** Class used to represent a Bezier curve */
  4900. export class BezierCurve {
  4901. /**
  4902. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4903. * @param t defines the time
  4904. * @param x1 defines the left coordinate on X axis
  4905. * @param y1 defines the left coordinate on Y axis
  4906. * @param x2 defines the right coordinate on X axis
  4907. * @param y2 defines the right coordinate on Y axis
  4908. * @returns the interpolated value
  4909. */
  4910. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4911. }
  4912. /**
  4913. * Defines angle representation
  4914. */
  4915. export class Angle {
  4916. private _radians;
  4917. /**
  4918. * Creates an Angle object of "radians" radians (float).
  4919. * @param radians the angle in radians
  4920. */
  4921. constructor(radians: number);
  4922. /**
  4923. * Get value in degrees
  4924. * @returns the Angle value in degrees (float)
  4925. */
  4926. degrees(): number;
  4927. /**
  4928. * Get value in radians
  4929. * @returns the Angle value in radians (float)
  4930. */
  4931. radians(): number;
  4932. /**
  4933. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4934. * @param a defines first point as the origin
  4935. * @param b defines point
  4936. * @returns a new Angle
  4937. */
  4938. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4939. /**
  4940. * Gets a new Angle object from the given float in radians
  4941. * @param radians defines the angle value in radians
  4942. * @returns a new Angle
  4943. */
  4944. static FromRadians(radians: number): Angle;
  4945. /**
  4946. * Gets a new Angle object from the given float in degrees
  4947. * @param degrees defines the angle value in degrees
  4948. * @returns a new Angle
  4949. */
  4950. static FromDegrees(degrees: number): Angle;
  4951. }
  4952. /**
  4953. * This represents an arc in a 2d space.
  4954. */
  4955. export class Arc2 {
  4956. /** Defines the start point of the arc */
  4957. startPoint: Vector2;
  4958. /** Defines the mid point of the arc */
  4959. midPoint: Vector2;
  4960. /** Defines the end point of the arc */
  4961. endPoint: Vector2;
  4962. /**
  4963. * Defines the center point of the arc.
  4964. */
  4965. centerPoint: Vector2;
  4966. /**
  4967. * Defines the radius of the arc.
  4968. */
  4969. radius: number;
  4970. /**
  4971. * Defines the angle of the arc (from mid point to end point).
  4972. */
  4973. angle: Angle;
  4974. /**
  4975. * Defines the start angle of the arc (from start point to middle point).
  4976. */
  4977. startAngle: Angle;
  4978. /**
  4979. * Defines the orientation of the arc (clock wise/counter clock wise).
  4980. */
  4981. orientation: Orientation;
  4982. /**
  4983. * Creates an Arc object from the three given points : start, middle and end.
  4984. * @param startPoint Defines the start point of the arc
  4985. * @param midPoint Defines the midlle point of the arc
  4986. * @param endPoint Defines the end point of the arc
  4987. */
  4988. constructor(
  4989. /** Defines the start point of the arc */
  4990. startPoint: Vector2,
  4991. /** Defines the mid point of the arc */
  4992. midPoint: Vector2,
  4993. /** Defines the end point of the arc */
  4994. endPoint: Vector2);
  4995. }
  4996. /**
  4997. * Represents a 2D path made up of multiple 2D points
  4998. */
  4999. export class Path2 {
  5000. private _points;
  5001. private _length;
  5002. /**
  5003. * If the path start and end point are the same
  5004. */
  5005. closed: boolean;
  5006. /**
  5007. * Creates a Path2 object from the starting 2D coordinates x and y.
  5008. * @param x the starting points x value
  5009. * @param y the starting points y value
  5010. */
  5011. constructor(x: number, y: number);
  5012. /**
  5013. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5014. * @param x the added points x value
  5015. * @param y the added points y value
  5016. * @returns the updated Path2.
  5017. */
  5018. addLineTo(x: number, y: number): Path2;
  5019. /**
  5020. * 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.
  5021. * @param midX middle point x value
  5022. * @param midY middle point y value
  5023. * @param endX end point x value
  5024. * @param endY end point y value
  5025. * @param numberOfSegments (default: 36)
  5026. * @returns the updated Path2.
  5027. */
  5028. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5029. /**
  5030. * Closes the Path2.
  5031. * @returns the Path2.
  5032. */
  5033. close(): Path2;
  5034. /**
  5035. * Gets the sum of the distance between each sequential point in the path
  5036. * @returns the Path2 total length (float).
  5037. */
  5038. length(): number;
  5039. /**
  5040. * Gets the points which construct the path
  5041. * @returns the Path2 internal array of points.
  5042. */
  5043. getPoints(): Vector2[];
  5044. /**
  5045. * Retreives the point at the distance aways from the starting point
  5046. * @param normalizedLengthPosition the length along the path to retreive the point from
  5047. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5048. */
  5049. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5050. /**
  5051. * Creates a new path starting from an x and y position
  5052. * @param x starting x value
  5053. * @param y starting y value
  5054. * @returns a new Path2 starting at the coordinates (x, y).
  5055. */
  5056. static StartingAt(x: number, y: number): Path2;
  5057. }
  5058. /**
  5059. * Represents a 3D path made up of multiple 3D points
  5060. */
  5061. export class Path3D {
  5062. /**
  5063. * an array of Vector3, the curve axis of the Path3D
  5064. */
  5065. path: Vector3[];
  5066. private _curve;
  5067. private _distances;
  5068. private _tangents;
  5069. private _normals;
  5070. private _binormals;
  5071. private _raw;
  5072. private _alignTangentsWithPath;
  5073. private readonly _pointAtData;
  5074. /**
  5075. * new Path3D(path, normal, raw)
  5076. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5077. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5078. * @param path an array of Vector3, the curve axis of the Path3D
  5079. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5080. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5081. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5082. */
  5083. constructor(
  5084. /**
  5085. * an array of Vector3, the curve axis of the Path3D
  5086. */
  5087. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5088. /**
  5089. * Returns the Path3D array of successive Vector3 designing its curve.
  5090. * @returns the Path3D array of successive Vector3 designing its curve.
  5091. */
  5092. getCurve(): Vector3[];
  5093. /**
  5094. * Returns the Path3D array of successive Vector3 designing its curve.
  5095. * @returns the Path3D array of successive Vector3 designing its curve.
  5096. */
  5097. getPoints(): Vector3[];
  5098. /**
  5099. * @returns the computed length (float) of the path.
  5100. */
  5101. length(): number;
  5102. /**
  5103. * Returns an array populated with tangent vectors on each Path3D curve point.
  5104. * @returns an array populated with tangent vectors on each Path3D curve point.
  5105. */
  5106. getTangents(): Vector3[];
  5107. /**
  5108. * Returns an array populated with normal vectors on each Path3D curve point.
  5109. * @returns an array populated with normal vectors on each Path3D curve point.
  5110. */
  5111. getNormals(): Vector3[];
  5112. /**
  5113. * Returns an array populated with binormal vectors on each Path3D curve point.
  5114. * @returns an array populated with binormal vectors on each Path3D curve point.
  5115. */
  5116. getBinormals(): Vector3[];
  5117. /**
  5118. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5119. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5120. */
  5121. getDistances(): number[];
  5122. /**
  5123. * Returns an interpolated point along this path
  5124. * @param position the position of the point along this path, from 0.0 to 1.0
  5125. * @returns a new Vector3 as the point
  5126. */
  5127. getPointAt(position: number): Vector3;
  5128. /**
  5129. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5130. * @param position the position of the point along this path, from 0.0 to 1.0
  5131. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5132. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5133. */
  5134. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5135. /**
  5136. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5137. * @param position the position of the point along this path, from 0.0 to 1.0
  5138. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5139. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5140. */
  5141. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5142. /**
  5143. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5144. * @param position the position of the point along this path, from 0.0 to 1.0
  5145. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5146. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5147. */
  5148. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5149. /**
  5150. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5151. * @param position the position of the point along this path, from 0.0 to 1.0
  5152. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5153. */
  5154. getDistanceAt(position: number): number;
  5155. /**
  5156. * Returns the array index of the previous point of an interpolated point along this path
  5157. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5158. * @returns the array index
  5159. */
  5160. getPreviousPointIndexAt(position: number): number;
  5161. /**
  5162. * 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)
  5163. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5164. * @returns the sub position
  5165. */
  5166. getSubPositionAt(position: number): number;
  5167. /**
  5168. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5169. * @param target the vector of which to get the closest position to
  5170. * @returns the position of the closest virtual point on this path to the target vector
  5171. */
  5172. getClosestPositionTo(target: Vector3): number;
  5173. /**
  5174. * Returns a sub path (slice) of this path
  5175. * @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
  5176. * @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
  5177. * @returns a sub path (slice) of this path
  5178. */
  5179. slice(start?: number, end?: number): Path3D;
  5180. /**
  5181. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5182. * @param path path which all values are copied into the curves points
  5183. * @param firstNormal which should be projected onto the curve
  5184. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5185. * @returns the same object updated.
  5186. */
  5187. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5188. private _compute;
  5189. private _getFirstNonNullVector;
  5190. private _getLastNonNullVector;
  5191. private _normalVector;
  5192. /**
  5193. * Updates the point at data for an interpolated point along this curve
  5194. * @param position the position of the point along this curve, from 0.0 to 1.0
  5195. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5196. * @returns the (updated) point at data
  5197. */
  5198. private _updatePointAtData;
  5199. /**
  5200. * Updates the point at data from the specified parameters
  5201. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5202. * @param point the interpolated point
  5203. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5204. */
  5205. private _setPointAtData;
  5206. /**
  5207. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5208. */
  5209. private _updateInterpolationMatrix;
  5210. }
  5211. /**
  5212. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5213. * A Curve3 is designed from a series of successive Vector3.
  5214. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5215. */
  5216. export class Curve3 {
  5217. private _points;
  5218. private _length;
  5219. /**
  5220. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5221. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5222. * @param v1 (Vector3) the control point
  5223. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5224. * @param nbPoints (integer) the wanted number of points in the curve
  5225. * @returns the created Curve3
  5226. */
  5227. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5228. /**
  5229. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5230. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5231. * @param v1 (Vector3) the first control point
  5232. * @param v2 (Vector3) the second control point
  5233. * @param v3 (Vector3) the end point of the Cubic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5240. * @param p1 (Vector3) the origin point of the Hermite Spline
  5241. * @param t1 (Vector3) the tangent vector at the origin point
  5242. * @param p2 (Vector3) the end point of the Hermite Spline
  5243. * @param t2 (Vector3) the tangent vector at the end point
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a CatmullRom Spline curve :
  5250. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5251. * @param nbPoints (integer) the wanted number of points between each curve control points
  5252. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5253. * @returns the created Curve3
  5254. */
  5255. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5256. /**
  5257. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5258. * A Curve3 is designed from a series of successive Vector3.
  5259. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5260. * @param points points which make up the curve
  5261. */
  5262. constructor(points: Vector3[]);
  5263. /**
  5264. * @returns the Curve3 stored array of successive Vector3
  5265. */
  5266. getPoints(): Vector3[];
  5267. /**
  5268. * @returns the computed length (float) of the curve.
  5269. */
  5270. length(): number;
  5271. /**
  5272. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5273. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5274. * curveA and curveB keep unchanged.
  5275. * @param curve the curve to continue from this curve
  5276. * @returns the newly constructed curve
  5277. */
  5278. continue(curve: DeepImmutable<Curve3>): Curve3;
  5279. private _computeLength;
  5280. }
  5281. }
  5282. declare module "babylonjs/Animations/easing" {
  5283. /**
  5284. * This represents the main contract an easing function should follow.
  5285. * Easing functions are used throughout the animation system.
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export interface IEasingFunction {
  5289. /**
  5290. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5291. * of the easing function.
  5292. * The link below provides some of the most common examples of easing functions.
  5293. * @see https://easings.net/
  5294. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5295. * @returns the corresponding value on the curve defined by the easing function
  5296. */
  5297. ease(gradient: number): number;
  5298. }
  5299. /**
  5300. * Base class used for every default easing function.
  5301. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5302. */
  5303. export class EasingFunction implements IEasingFunction {
  5304. /**
  5305. * Interpolation follows the mathematical formula associated with the easing function.
  5306. */
  5307. static readonly EASINGMODE_EASEIN: number;
  5308. /**
  5309. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEOUT: number;
  5312. /**
  5313. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5314. */
  5315. static readonly EASINGMODE_EASEINOUT: number;
  5316. private _easingMode;
  5317. /**
  5318. * Sets the easing mode of the current function.
  5319. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5320. */
  5321. setEasingMode(easingMode: number): void;
  5322. /**
  5323. * Gets the current easing mode.
  5324. * @returns the easing mode
  5325. */
  5326. getEasingMode(): number;
  5327. /**
  5328. * @hidden
  5329. */
  5330. easeInCore(gradient: number): number;
  5331. /**
  5332. * Given an input gradient between 0 and 1, this returns the corresponding value
  5333. * of the easing function.
  5334. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5335. * @returns the corresponding value on the curve defined by the easing function
  5336. */
  5337. ease(gradient: number): number;
  5338. }
  5339. /**
  5340. * Easing function with a circle shape (see link below).
  5341. * @see https://easings.net/#easeInCirc
  5342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5343. */
  5344. export class CircleEase extends EasingFunction implements IEasingFunction {
  5345. /** @hidden */
  5346. easeInCore(gradient: number): number;
  5347. }
  5348. /**
  5349. * Easing function with a ease back shape (see link below).
  5350. * @see https://easings.net/#easeInBack
  5351. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5352. */
  5353. export class BackEase extends EasingFunction implements IEasingFunction {
  5354. /** Defines the amplitude of the function */
  5355. amplitude: number;
  5356. /**
  5357. * Instantiates a back ease easing
  5358. * @see https://easings.net/#easeInBack
  5359. * @param amplitude Defines the amplitude of the function
  5360. */
  5361. constructor(
  5362. /** Defines the amplitude of the function */
  5363. amplitude?: number);
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a bouncing shape (see link below).
  5369. * @see https://easings.net/#easeInBounce
  5370. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class BounceEase extends EasingFunction implements IEasingFunction {
  5373. /** Defines the number of bounces */
  5374. bounces: number;
  5375. /** Defines the amplitude of the bounce */
  5376. bounciness: number;
  5377. /**
  5378. * Instantiates a bounce easing
  5379. * @see https://easings.net/#easeInBounce
  5380. * @param bounces Defines the number of bounces
  5381. * @param bounciness Defines the amplitude of the bounce
  5382. */
  5383. constructor(
  5384. /** Defines the number of bounces */
  5385. bounces?: number,
  5386. /** Defines the amplitude of the bounce */
  5387. bounciness?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a power of 3 shape (see link below).
  5393. * @see https://easings.net/#easeInCubic
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class CubicEase extends EasingFunction implements IEasingFunction {
  5397. /** @hidden */
  5398. easeInCore(gradient: number): number;
  5399. }
  5400. /**
  5401. * Easing function with an elastic shape (see link below).
  5402. * @see https://easings.net/#easeInElastic
  5403. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5404. */
  5405. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5406. /** Defines the number of oscillations*/
  5407. oscillations: number;
  5408. /** Defines the amplitude of the oscillations*/
  5409. springiness: number;
  5410. /**
  5411. * Instantiates an elastic easing function
  5412. * @see https://easings.net/#easeInElastic
  5413. * @param oscillations Defines the number of oscillations
  5414. * @param springiness Defines the amplitude of the oscillations
  5415. */
  5416. constructor(
  5417. /** Defines the number of oscillations*/
  5418. oscillations?: number,
  5419. /** Defines the amplitude of the oscillations*/
  5420. springiness?: number);
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an exponential shape (see link below).
  5426. * @see https://easings.net/#easeInExpo
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the exponent of the function */
  5431. exponent: number;
  5432. /**
  5433. * Instantiates an exponential easing function
  5434. * @see https://easings.net/#easeInExpo
  5435. * @param exponent Defines the exponent of the function
  5436. */
  5437. constructor(
  5438. /** Defines the exponent of the function */
  5439. exponent?: number);
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power shape (see link below).
  5445. * @see https://easings.net/#easeInQuad
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class PowerEase extends EasingFunction implements IEasingFunction {
  5449. /** Defines the power of the function */
  5450. power: number;
  5451. /**
  5452. * Instantiates an power base easing function
  5453. * @see https://easings.net/#easeInQuad
  5454. * @param power Defines the power of the function
  5455. */
  5456. constructor(
  5457. /** Defines the power of the function */
  5458. power?: number);
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 2 shape (see link below).
  5464. * @see https://easings.net/#easeInQuad
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a power of 4 shape (see link below).
  5473. * @see https://easings.net/#easeInQuart
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a power of 5 shape (see link below).
  5482. * @see https://easings.net/#easeInQuint
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5486. /** @hidden */
  5487. easeInCore(gradient: number): number;
  5488. }
  5489. /**
  5490. * Easing function with a sin shape (see link below).
  5491. * @see https://easings.net/#easeInSine
  5492. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5493. */
  5494. export class SineEase extends EasingFunction implements IEasingFunction {
  5495. /** @hidden */
  5496. easeInCore(gradient: number): number;
  5497. }
  5498. /**
  5499. * Easing function with a bezier shape (see link below).
  5500. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5501. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5502. */
  5503. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5504. /** Defines the x component of the start tangent in the bezier curve */
  5505. x1: number;
  5506. /** Defines the y component of the start tangent in the bezier curve */
  5507. y1: number;
  5508. /** Defines the x component of the end tangent in the bezier curve */
  5509. x2: number;
  5510. /** Defines the y component of the end tangent in the bezier curve */
  5511. y2: number;
  5512. /**
  5513. * Instantiates a bezier function
  5514. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5515. * @param x1 Defines the x component of the start tangent in the bezier curve
  5516. * @param y1 Defines the y component of the start tangent in the bezier curve
  5517. * @param x2 Defines the x component of the end tangent in the bezier curve
  5518. * @param y2 Defines the y component of the end tangent in the bezier curve
  5519. */
  5520. constructor(
  5521. /** Defines the x component of the start tangent in the bezier curve */
  5522. x1?: number,
  5523. /** Defines the y component of the start tangent in the bezier curve */
  5524. y1?: number,
  5525. /** Defines the x component of the end tangent in the bezier curve */
  5526. x2?: number,
  5527. /** Defines the y component of the end tangent in the bezier curve */
  5528. y2?: number);
  5529. /** @hidden */
  5530. easeInCore(gradient: number): number;
  5531. }
  5532. }
  5533. declare module "babylonjs/Maths/math.color" {
  5534. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5535. /**
  5536. * Class used to hold a RBG color
  5537. */
  5538. export class Color3 {
  5539. /**
  5540. * Defines the red component (between 0 and 1, default is 0)
  5541. */
  5542. r: number;
  5543. /**
  5544. * Defines the green component (between 0 and 1, default is 0)
  5545. */
  5546. g: number;
  5547. /**
  5548. * Defines the blue component (between 0 and 1, default is 0)
  5549. */
  5550. b: number;
  5551. /**
  5552. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5553. * @param r defines the red component (between 0 and 1, default is 0)
  5554. * @param g defines the green component (between 0 and 1, default is 0)
  5555. * @param b defines the blue component (between 0 and 1, default is 0)
  5556. */
  5557. constructor(
  5558. /**
  5559. * Defines the red component (between 0 and 1, default is 0)
  5560. */
  5561. r?: number,
  5562. /**
  5563. * Defines the green component (between 0 and 1, default is 0)
  5564. */
  5565. g?: number,
  5566. /**
  5567. * Defines the blue component (between 0 and 1, default is 0)
  5568. */
  5569. b?: number);
  5570. /**
  5571. * Creates a string with the Color3 current values
  5572. * @returns the string representation of the Color3 object
  5573. */
  5574. toString(): string;
  5575. /**
  5576. * Returns the string "Color3"
  5577. * @returns "Color3"
  5578. */
  5579. getClassName(): string;
  5580. /**
  5581. * Compute the Color3 hash code
  5582. * @returns an unique number that can be used to hash Color3 objects
  5583. */
  5584. getHashCode(): number;
  5585. /**
  5586. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5587. * @param array defines the array where to store the r,g,b components
  5588. * @param index defines an optional index in the target array to define where to start storing values
  5589. * @returns the current Color3 object
  5590. */
  5591. toArray(array: FloatArray, index?: number): Color3;
  5592. /**
  5593. * Update the current color with values stored in an array from the starting index of the given array
  5594. * @param array defines the source array
  5595. * @param offset defines an offset in the source array
  5596. * @returns the current Color3 object
  5597. */
  5598. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5599. /**
  5600. * Returns a new Color4 object from the current Color3 and the given alpha
  5601. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5602. * @returns a new Color4 object
  5603. */
  5604. toColor4(alpha?: number): Color4;
  5605. /**
  5606. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5607. * @returns the new array
  5608. */
  5609. asArray(): number[];
  5610. /**
  5611. * Returns the luminance value
  5612. * @returns a float value
  5613. */
  5614. toLuminance(): number;
  5615. /**
  5616. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5617. * @param otherColor defines the second operand
  5618. * @returns the new Color3 object
  5619. */
  5620. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5621. /**
  5622. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5623. * @param otherColor defines the second operand
  5624. * @param result defines the Color3 object where to store the result
  5625. * @returns the current Color3
  5626. */
  5627. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5628. /**
  5629. * Determines equality between Color3 objects
  5630. * @param otherColor defines the second operand
  5631. * @returns true if the rgb values are equal to the given ones
  5632. */
  5633. equals(otherColor: DeepImmutable<Color3>): boolean;
  5634. /**
  5635. * Determines equality between the current Color3 object and a set of r,b,g values
  5636. * @param r defines the red component to check
  5637. * @param g defines the green component to check
  5638. * @param b defines the blue component to check
  5639. * @returns true if the rgb values are equal to the given ones
  5640. */
  5641. equalsFloats(r: number, g: number, b: number): boolean;
  5642. /**
  5643. * Multiplies in place each rgb value by scale
  5644. * @param scale defines the scaling factor
  5645. * @returns the updated Color3
  5646. */
  5647. scale(scale: number): Color3;
  5648. /**
  5649. * Multiplies the rgb values by scale and stores the result into "result"
  5650. * @param scale defines the scaling factor
  5651. * @param result defines the Color3 object where to store the result
  5652. * @returns the unmodified current Color3
  5653. */
  5654. scaleToRef(scale: number, result: Color3): Color3;
  5655. /**
  5656. * Scale the current Color3 values by a factor and add the result to a given Color3
  5657. * @param scale defines the scale factor
  5658. * @param result defines color to store the result into
  5659. * @returns the unmodified current Color3
  5660. */
  5661. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5662. /**
  5663. * Clamps the rgb values by the min and max values and stores the result into "result"
  5664. * @param min defines minimum clamping value (default is 0)
  5665. * @param max defines maximum clamping value (default is 1)
  5666. * @param result defines color to store the result into
  5667. * @returns the original Color3
  5668. */
  5669. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5670. /**
  5671. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5672. * @param otherColor defines the second operand
  5673. * @returns the new Color3
  5674. */
  5675. add(otherColor: DeepImmutable<Color3>): Color3;
  5676. /**
  5677. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5678. * @param otherColor defines the second operand
  5679. * @param result defines Color3 object to store the result into
  5680. * @returns the unmodified current Color3
  5681. */
  5682. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5683. /**
  5684. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5685. * @param otherColor defines the second operand
  5686. * @returns the new Color3
  5687. */
  5688. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5691. * @param otherColor defines the second operand
  5692. * @param result defines Color3 object to store the result into
  5693. * @returns the unmodified current Color3
  5694. */
  5695. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5696. /**
  5697. * Copy the current object
  5698. * @returns a new Color3 copied the current one
  5699. */
  5700. clone(): Color3;
  5701. /**
  5702. * Copies the rgb values from the source in the current Color3
  5703. * @param source defines the source Color3 object
  5704. * @returns the updated Color3 object
  5705. */
  5706. copyFrom(source: DeepImmutable<Color3>): Color3;
  5707. /**
  5708. * Updates the Color3 rgb values from the given floats
  5709. * @param r defines the red component to read from
  5710. * @param g defines the green component to read from
  5711. * @param b defines the blue component to read from
  5712. * @returns the current Color3 object
  5713. */
  5714. copyFromFloats(r: number, g: number, b: number): Color3;
  5715. /**
  5716. * Updates the Color3 rgb values from the given floats
  5717. * @param r defines the red component to read from
  5718. * @param g defines the green component to read from
  5719. * @param b defines the blue component to read from
  5720. * @returns the current Color3 object
  5721. */
  5722. set(r: number, g: number, b: number): Color3;
  5723. /**
  5724. * Compute the Color3 hexadecimal code as a string
  5725. * @returns a string containing the hexadecimal representation of the Color3 object
  5726. */
  5727. toHexString(): string;
  5728. /**
  5729. * Computes a new Color3 converted from the current one to linear space
  5730. * @returns a new Color3 object
  5731. */
  5732. toLinearSpace(): Color3;
  5733. /**
  5734. * Converts current color in rgb space to HSV values
  5735. * @returns a new color3 representing the HSV values
  5736. */
  5737. toHSV(): Color3;
  5738. /**
  5739. * Converts current color in rgb space to HSV values
  5740. * @param result defines the Color3 where to store the HSV values
  5741. */
  5742. toHSVToRef(result: Color3): void;
  5743. /**
  5744. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5745. * @param convertedColor defines the Color3 object where to store the linear space version
  5746. * @returns the unmodified Color3
  5747. */
  5748. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5749. /**
  5750. * Computes a new Color3 converted from the current one to gamma space
  5751. * @returns a new Color3 object
  5752. */
  5753. toGammaSpace(): Color3;
  5754. /**
  5755. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5756. * @param convertedColor defines the Color3 object where to store the gamma space version
  5757. * @returns the unmodified Color3
  5758. */
  5759. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5760. private static _BlackReadOnly;
  5761. /**
  5762. * Convert Hue, saturation and value to a Color3 (RGB)
  5763. * @param hue defines the hue
  5764. * @param saturation defines the saturation
  5765. * @param value defines the value
  5766. * @param result defines the Color3 where to store the RGB values
  5767. */
  5768. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5769. /**
  5770. * Creates a new Color3 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color3 object
  5773. */
  5774. static FromHexString(hex: string): Color3;
  5775. /**
  5776. * Creates a new Color3 from the starting index of the given array
  5777. * @param array defines the source array
  5778. * @param offset defines an offset in the source array
  5779. * @returns a new Color3 object
  5780. */
  5781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5782. /**
  5783. * Creates a new Color3 from the starting index element of the given array
  5784. * @param array defines the source array to read from
  5785. * @param offset defines the offset in the source array
  5786. * @param result defines the target Color3 object
  5787. */
  5788. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5789. /**
  5790. * Creates a new Color3 from integer values (< 256)
  5791. * @param r defines the red component to read from (value between 0 and 255)
  5792. * @param g defines the green component to read from (value between 0 and 255)
  5793. * @param b defines the blue component to read from (value between 0 and 255)
  5794. * @returns a new Color3 object
  5795. */
  5796. static FromInts(r: number, g: number, b: number): Color3;
  5797. /**
  5798. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5799. * @param start defines the start Color3 value
  5800. * @param end defines the end Color3 value
  5801. * @param amount defines the gradient value between start and end
  5802. * @returns a new Color3 object
  5803. */
  5804. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5805. /**
  5806. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5807. * @param left defines the start value
  5808. * @param right defines the end value
  5809. * @param amount defines the gradient factor
  5810. * @param result defines the Color3 object where to store the result
  5811. */
  5812. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5813. /**
  5814. * Returns a Color3 value containing a red color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Red(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a green color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Green(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a blue color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Blue(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a black color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Black(): Color3;
  5833. /**
  5834. * Gets a Color3 value containing a black color that must not be updated
  5835. */
  5836. static get BlackReadOnly(): DeepImmutable<Color3>;
  5837. /**
  5838. * Returns a Color3 value containing a white color
  5839. * @returns a new Color3 object
  5840. */
  5841. static White(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a purple color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Purple(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a magenta color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Magenta(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a yellow color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Yellow(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a gray color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Gray(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a teal color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Teal(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a random color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Random(): Color3;
  5872. }
  5873. /**
  5874. * Class used to hold a RBGA color
  5875. */
  5876. export class Color4 {
  5877. /**
  5878. * Defines the red component (between 0 and 1, default is 0)
  5879. */
  5880. r: number;
  5881. /**
  5882. * Defines the green component (between 0 and 1, default is 0)
  5883. */
  5884. g: number;
  5885. /**
  5886. * Defines the blue component (between 0 and 1, default is 0)
  5887. */
  5888. b: number;
  5889. /**
  5890. * Defines the alpha component (between 0 and 1, default is 1)
  5891. */
  5892. a: number;
  5893. /**
  5894. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5895. * @param r defines the red component (between 0 and 1, default is 0)
  5896. * @param g defines the green component (between 0 and 1, default is 0)
  5897. * @param b defines the blue component (between 0 and 1, default is 0)
  5898. * @param a defines the alpha component (between 0 and 1, default is 1)
  5899. */
  5900. constructor(
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r?: number,
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g?: number,
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b?: number,
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a?: number);
  5917. /**
  5918. * Adds in place the given Color4 values to the current Color4 object
  5919. * @param right defines the second operand
  5920. * @returns the current updated Color4 object
  5921. */
  5922. addInPlace(right: DeepImmutable<Color4>): Color4;
  5923. /**
  5924. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5925. * @returns the new array
  5926. */
  5927. asArray(): number[];
  5928. /**
  5929. * Stores from the starting index in the given array the Color4 successive values
  5930. * @param array defines the array where to store the r,g,b components
  5931. * @param index defines an optional index in the target array to define where to start storing values
  5932. * @returns the current Color4 object
  5933. */
  5934. toArray(array: number[], index?: number): Color4;
  5935. /**
  5936. * Update the current color with values stored in an array from the starting index of the given array
  5937. * @param array defines the source array
  5938. * @param offset defines an offset in the source array
  5939. * @returns the current Color4 object
  5940. */
  5941. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5942. /**
  5943. * Determines equality between Color4 objects
  5944. * @param otherColor defines the second operand
  5945. * @returns true if the rgba values are equal to the given ones
  5946. */
  5947. equals(otherColor: DeepImmutable<Color4>): boolean;
  5948. /**
  5949. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5950. * @param right defines the second operand
  5951. * @returns a new Color4 object
  5952. */
  5953. add(right: DeepImmutable<Color4>): Color4;
  5954. /**
  5955. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5956. * @param right defines the second operand
  5957. * @returns a new Color4 object
  5958. */
  5959. subtract(right: DeepImmutable<Color4>): Color4;
  5960. /**
  5961. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5962. * @param right defines the second operand
  5963. * @param result defines the Color4 object where to store the result
  5964. * @returns the current Color4 object
  5965. */
  5966. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5967. /**
  5968. * Creates a new Color4 with the current Color4 values multiplied by scale
  5969. * @param scale defines the scaling factor to apply
  5970. * @returns a new Color4 object
  5971. */
  5972. scale(scale: number): Color4;
  5973. /**
  5974. * Multiplies the current Color4 values by scale and stores the result in "result"
  5975. * @param scale defines the scaling factor to apply
  5976. * @param result defines the Color4 object where to store the result
  5977. * @returns the current unmodified Color4
  5978. */
  5979. scaleToRef(scale: number, result: Color4): Color4;
  5980. /**
  5981. * Scale the current Color4 values by a factor and add the result to a given Color4
  5982. * @param scale defines the scale factor
  5983. * @param result defines the Color4 object where to store the result
  5984. * @returns the unmodified current Color4
  5985. */
  5986. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5987. /**
  5988. * Clamps the rgb values by the min and max values and stores the result into "result"
  5989. * @param min defines minimum clamping value (default is 0)
  5990. * @param max defines maximum clamping value (default is 1)
  5991. * @param result defines color to store the result into.
  5992. * @returns the cuurent Color4
  5993. */
  5994. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5995. /**
  5996. * Multipy an Color4 value by another and return a new Color4 object
  5997. * @param color defines the Color4 value to multiply by
  5998. * @returns a new Color4 object
  5999. */
  6000. multiply(color: Color4): Color4;
  6001. /**
  6002. * Multipy a Color4 value by another and push the result in a reference value
  6003. * @param color defines the Color4 value to multiply by
  6004. * @param result defines the Color4 to fill the result in
  6005. * @returns the result Color4
  6006. */
  6007. multiplyToRef(color: Color4, result: Color4): Color4;
  6008. /**
  6009. * Creates a string with the Color4 current values
  6010. * @returns the string representation of the Color4 object
  6011. */
  6012. toString(): string;
  6013. /**
  6014. * Returns the string "Color4"
  6015. * @returns "Color4"
  6016. */
  6017. getClassName(): string;
  6018. /**
  6019. * Compute the Color4 hash code
  6020. * @returns an unique number that can be used to hash Color4 objects
  6021. */
  6022. getHashCode(): number;
  6023. /**
  6024. * Creates a new Color4 copied from the current one
  6025. * @returns a new Color4 object
  6026. */
  6027. clone(): Color4;
  6028. /**
  6029. * Copies the given Color4 values into the current one
  6030. * @param source defines the source Color4 object
  6031. * @returns the current updated Color4 object
  6032. */
  6033. copyFrom(source: Color4): Color4;
  6034. /**
  6035. * Copies the given float values into the current one
  6036. * @param r defines the red component to read from
  6037. * @param g defines the green component to read from
  6038. * @param b defines the blue component to read from
  6039. * @param a defines the alpha component to read from
  6040. * @returns the current updated Color4 object
  6041. */
  6042. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6043. /**
  6044. * Copies the given float values into the current one
  6045. * @param r defines the red component to read from
  6046. * @param g defines the green component to read from
  6047. * @param b defines the blue component to read from
  6048. * @param a defines the alpha component to read from
  6049. * @returns the current updated Color4 object
  6050. */
  6051. set(r: number, g: number, b: number, a: number): Color4;
  6052. /**
  6053. * Compute the Color4 hexadecimal code as a string
  6054. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6055. * @returns a string containing the hexadecimal representation of the Color4 object
  6056. */
  6057. toHexString(returnAsColor3?: boolean): string;
  6058. /**
  6059. * Computes a new Color4 converted from the current one to linear space
  6060. * @returns a new Color4 object
  6061. */
  6062. toLinearSpace(): Color4;
  6063. /**
  6064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6065. * @param convertedColor defines the Color4 object where to store the linear space version
  6066. * @returns the unmodified Color4
  6067. */
  6068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6069. /**
  6070. * Computes a new Color4 converted from the current one to gamma space
  6071. * @returns a new Color4 object
  6072. */
  6073. toGammaSpace(): Color4;
  6074. /**
  6075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6076. * @param convertedColor defines the Color4 object where to store the gamma space version
  6077. * @returns the unmodified Color4
  6078. */
  6079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6080. /**
  6081. * Creates a new Color4 from the string containing valid hexadecimal values
  6082. * @param hex defines a string containing valid hexadecimal values
  6083. * @returns a new Color4 object
  6084. */
  6085. static FromHexString(hex: string): Color4;
  6086. /**
  6087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6088. * @param left defines the start value
  6089. * @param right defines the end value
  6090. * @param amount defines the gradient factor
  6091. * @returns a new Color4 object
  6092. */
  6093. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6094. /**
  6095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6096. * @param left defines the start value
  6097. * @param right defines the end value
  6098. * @param amount defines the gradient factor
  6099. * @param result defines the Color4 object where to store data
  6100. */
  6101. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6102. /**
  6103. * Creates a new Color4 from a Color3 and an alpha value
  6104. * @param color3 defines the source Color3 to read from
  6105. * @param alpha defines the alpha component (1.0 by default)
  6106. * @returns a new Color4 object
  6107. */
  6108. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6109. /**
  6110. * Creates a new Color4 from the starting index element of the given array
  6111. * @param array defines the source array to read from
  6112. * @param offset defines the offset in the source array
  6113. * @returns a new Color4 object
  6114. */
  6115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6116. /**
  6117. * Creates a new Color4 from the starting index element of the given array
  6118. * @param array defines the source array to read from
  6119. * @param offset defines the offset in the source array
  6120. * @param result defines the target Color4 object
  6121. */
  6122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6123. /**
  6124. * Creates a new Color3 from integer values (< 256)
  6125. * @param r defines the red component to read from (value between 0 and 255)
  6126. * @param g defines the green component to read from (value between 0 and 255)
  6127. * @param b defines the blue component to read from (value between 0 and 255)
  6128. * @param a defines the alpha component to read from (value between 0 and 255)
  6129. * @returns a new Color3 object
  6130. */
  6131. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6132. /**
  6133. * Check the content of a given array and convert it to an array containing RGBA data
  6134. * If the original array was already containing count * 4 values then it is returned directly
  6135. * @param colors defines the array to check
  6136. * @param count defines the number of RGBA data to expect
  6137. * @returns an array containing count * 4 values (RGBA)
  6138. */
  6139. static CheckColors4(colors: number[], count: number): number[];
  6140. }
  6141. /**
  6142. * @hidden
  6143. */
  6144. export class TmpColors {
  6145. static Color3: Color3[];
  6146. static Color4: Color4[];
  6147. }
  6148. }
  6149. declare module "babylonjs/Animations/animationKey" {
  6150. /**
  6151. * Defines an interface which represents an animation key frame
  6152. */
  6153. export interface IAnimationKey {
  6154. /**
  6155. * Frame of the key frame
  6156. */
  6157. frame: number;
  6158. /**
  6159. * Value at the specifies key frame
  6160. */
  6161. value: any;
  6162. /**
  6163. * The input tangent for the cubic hermite spline
  6164. */
  6165. inTangent?: any;
  6166. /**
  6167. * The output tangent for the cubic hermite spline
  6168. */
  6169. outTangent?: any;
  6170. /**
  6171. * The animation interpolation type
  6172. */
  6173. interpolation?: AnimationKeyInterpolation;
  6174. }
  6175. /**
  6176. * Enum for the animation key frame interpolation type
  6177. */
  6178. export enum AnimationKeyInterpolation {
  6179. /**
  6180. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6181. */
  6182. STEP = 1
  6183. }
  6184. }
  6185. declare module "babylonjs/Animations/animationRange" {
  6186. /**
  6187. * Represents the range of an animation
  6188. */
  6189. export class AnimationRange {
  6190. /**The name of the animation range**/
  6191. name: string;
  6192. /**The starting frame of the animation */
  6193. from: number;
  6194. /**The ending frame of the animation*/
  6195. to: number;
  6196. /**
  6197. * Initializes the range of an animation
  6198. * @param name The name of the animation range
  6199. * @param from The starting frame of the animation
  6200. * @param to The ending frame of the animation
  6201. */
  6202. constructor(
  6203. /**The name of the animation range**/
  6204. name: string,
  6205. /**The starting frame of the animation */
  6206. from: number,
  6207. /**The ending frame of the animation*/
  6208. to: number);
  6209. /**
  6210. * Makes a copy of the animation range
  6211. * @returns A copy of the animation range
  6212. */
  6213. clone(): AnimationRange;
  6214. }
  6215. }
  6216. declare module "babylonjs/Animations/animationEvent" {
  6217. /**
  6218. * Composed of a frame, and an action function
  6219. */
  6220. export class AnimationEvent {
  6221. /** The frame for which the event is triggered **/
  6222. frame: number;
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void;
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined;
  6227. /**
  6228. * Specifies if the animation event is done
  6229. */
  6230. isDone: boolean;
  6231. /**
  6232. * Initializes the animation event
  6233. * @param frame The frame for which the event is triggered
  6234. * @param action The event to perform when triggered
  6235. * @param onlyOnce Specifies if the event should be triggered only once
  6236. */
  6237. constructor(
  6238. /** The frame for which the event is triggered **/
  6239. frame: number,
  6240. /** The event to perform when triggered **/
  6241. action: (currentFrame: number) => void,
  6242. /** Specifies if the event should be triggered only once**/
  6243. onlyOnce?: boolean | undefined);
  6244. /** @hidden */
  6245. _clone(): AnimationEvent;
  6246. }
  6247. }
  6248. declare module "babylonjs/Behaviors/behavior" {
  6249. import { Nullable } from "babylonjs/types";
  6250. /**
  6251. * Interface used to define a behavior
  6252. */
  6253. export interface Behavior<T> {
  6254. /** gets or sets behavior's name */
  6255. name: string;
  6256. /**
  6257. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6258. */
  6259. init(): void;
  6260. /**
  6261. * Called when the behavior is attached to a target
  6262. * @param target defines the target where the behavior is attached to
  6263. */
  6264. attach(target: T): void;
  6265. /**
  6266. * Called when the behavior is detached from its target
  6267. */
  6268. detach(): void;
  6269. }
  6270. /**
  6271. * Interface implemented by classes supporting behaviors
  6272. */
  6273. export interface IBehaviorAware<T> {
  6274. /**
  6275. * Attach a behavior
  6276. * @param behavior defines the behavior to attach
  6277. * @returns the current host
  6278. */
  6279. addBehavior(behavior: Behavior<T>): T;
  6280. /**
  6281. * Remove a behavior from the current object
  6282. * @param behavior defines the behavior to detach
  6283. * @returns the current host
  6284. */
  6285. removeBehavior(behavior: Behavior<T>): T;
  6286. /**
  6287. * Gets a behavior using its name to search
  6288. * @param name defines the name to search
  6289. * @returns the behavior or null if not found
  6290. */
  6291. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6292. }
  6293. }
  6294. declare module "babylonjs/Misc/smartArray" {
  6295. /**
  6296. * Defines an array and its length.
  6297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6298. */
  6299. export interface ISmartArrayLike<T> {
  6300. /**
  6301. * The data of the array.
  6302. */
  6303. data: Array<T>;
  6304. /**
  6305. * The active length of the array.
  6306. */
  6307. length: number;
  6308. }
  6309. /**
  6310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6311. */
  6312. export class SmartArray<T> implements ISmartArrayLike<T> {
  6313. /**
  6314. * The full set of data from the array.
  6315. */
  6316. data: Array<T>;
  6317. /**
  6318. * The active length of the array.
  6319. */
  6320. length: number;
  6321. protected _id: number;
  6322. /**
  6323. * Instantiates a Smart Array.
  6324. * @param capacity defines the default capacity of the array.
  6325. */
  6326. constructor(capacity: number);
  6327. /**
  6328. * Pushes a value at the end of the active data.
  6329. * @param value defines the object to push in the array.
  6330. */
  6331. push(value: T): void;
  6332. /**
  6333. * Iterates over the active data and apply the lambda to them.
  6334. * @param func defines the action to apply on each value.
  6335. */
  6336. forEach(func: (content: T) => void): void;
  6337. /**
  6338. * Sorts the full sets of data.
  6339. * @param compareFn defines the comparison function to apply.
  6340. */
  6341. sort(compareFn: (a: T, b: T) => number): void;
  6342. /**
  6343. * Resets the active data to an empty array.
  6344. */
  6345. reset(): void;
  6346. /**
  6347. * Releases all the data from the array as well as the array.
  6348. */
  6349. dispose(): void;
  6350. /**
  6351. * Concats the active data with a given array.
  6352. * @param array defines the data to concatenate with.
  6353. */
  6354. concat(array: any): void;
  6355. /**
  6356. * Returns the position of a value in the active data.
  6357. * @param value defines the value to find the index for
  6358. * @returns the index if found in the active data otherwise -1
  6359. */
  6360. indexOf(value: T): number;
  6361. /**
  6362. * Returns whether an element is part of the active data.
  6363. * @param value defines the value to look for
  6364. * @returns true if found in the active data otherwise false
  6365. */
  6366. contains(value: T): boolean;
  6367. private static _GlobalId;
  6368. }
  6369. /**
  6370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6371. * The data in this array can only be present once
  6372. */
  6373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6374. private _duplicateId;
  6375. /**
  6376. * Pushes a value at the end of the active data.
  6377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6378. * @param value defines the object to push in the array.
  6379. */
  6380. push(value: T): void;
  6381. /**
  6382. * Pushes a value at the end of the active data.
  6383. * If the data is already present, it won t be added again
  6384. * @param value defines the object to push in the array.
  6385. * @returns true if added false if it was already present
  6386. */
  6387. pushNoDuplicate(value: T): boolean;
  6388. /**
  6389. * Resets the active data to an empty array.
  6390. */
  6391. reset(): void;
  6392. /**
  6393. * Concats the active data with a given array.
  6394. * This ensures no dupplicate will be present in the result.
  6395. * @param array defines the data to concatenate with.
  6396. */
  6397. concatWithNoDuplicate(array: any): void;
  6398. }
  6399. }
  6400. declare module "babylonjs/Cameras/cameraInputsManager" {
  6401. import { Nullable } from "babylonjs/types";
  6402. import { Camera } from "babylonjs/Cameras/camera";
  6403. /**
  6404. * @ignore
  6405. * This is a list of all the different input types that are available in the application.
  6406. * Fo instance: ArcRotateCameraGamepadInput...
  6407. */
  6408. export var CameraInputTypes: {};
  6409. /**
  6410. * This is the contract to implement in order to create a new input class.
  6411. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6412. */
  6413. export interface ICameraInput<TCamera extends Camera> {
  6414. /**
  6415. * Defines the camera the input is attached to.
  6416. */
  6417. camera: Nullable<TCamera>;
  6418. /**
  6419. * Gets the class name of the current intput.
  6420. * @returns the class name
  6421. */
  6422. getClassName(): string;
  6423. /**
  6424. * Get the friendly name associated with the input class.
  6425. * @returns the input friendly name
  6426. */
  6427. getSimpleName(): string;
  6428. /**
  6429. * Attach the input controls to a specific dom element to get the input from.
  6430. * @param element Defines the element the controls should be listened from
  6431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6432. */
  6433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6434. /**
  6435. * Detach the current controls from the specified dom element.
  6436. * @param element Defines the element to stop listening the inputs from
  6437. */
  6438. detachControl(element: Nullable<HTMLElement>): void;
  6439. /**
  6440. * Update the current camera state depending on the inputs that have been used this frame.
  6441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6442. */
  6443. checkInputs?: () => void;
  6444. }
  6445. /**
  6446. * Represents a map of input types to input instance or input index to input instance.
  6447. */
  6448. export interface CameraInputsMap<TCamera extends Camera> {
  6449. /**
  6450. * Accessor to the input by input type.
  6451. */
  6452. [name: string]: ICameraInput<TCamera>;
  6453. /**
  6454. * Accessor to the input by input index.
  6455. */
  6456. [idx: number]: ICameraInput<TCamera>;
  6457. }
  6458. /**
  6459. * This represents the input manager used within a camera.
  6460. * It helps dealing with all the different kind of input attached to a camera.
  6461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6462. */
  6463. export class CameraInputsManager<TCamera extends Camera> {
  6464. /**
  6465. * Defines the list of inputs attahed to the camera.
  6466. */
  6467. attached: CameraInputsMap<TCamera>;
  6468. /**
  6469. * Defines the dom element the camera is collecting inputs from.
  6470. * This is null if the controls have not been attached.
  6471. */
  6472. attachedElement: Nullable<HTMLElement>;
  6473. /**
  6474. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6475. */
  6476. noPreventDefault: boolean;
  6477. /**
  6478. * Defined the camera the input manager belongs to.
  6479. */
  6480. camera: TCamera;
  6481. /**
  6482. * Update the current camera state depending on the inputs that have been used this frame.
  6483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6484. */
  6485. checkInputs: () => void;
  6486. /**
  6487. * Instantiate a new Camera Input Manager.
  6488. * @param camera Defines the camera the input manager blongs to
  6489. */
  6490. constructor(camera: TCamera);
  6491. /**
  6492. * Add an input method to a camera
  6493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6494. * @param input camera input method
  6495. */
  6496. add(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Remove a specific input method from a camera
  6499. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6500. * @param inputToRemove camera input method
  6501. */
  6502. remove(inputToRemove: ICameraInput<TCamera>): void;
  6503. /**
  6504. * Remove a specific input type from a camera
  6505. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6506. * @param inputType the type of the input to remove
  6507. */
  6508. removeByType(inputType: string): void;
  6509. private _addCheckInputs;
  6510. /**
  6511. * Attach the input controls to the currently attached dom element to listen the events from.
  6512. * @param input Defines the input to attach
  6513. */
  6514. attachInput(input: ICameraInput<TCamera>): void;
  6515. /**
  6516. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6517. * @param element Defines the dom element to collect the events from
  6518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6519. */
  6520. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6521. /**
  6522. * Detach the current manager inputs controls from a specific dom element.
  6523. * @param element Defines the dom element to collect the events from
  6524. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6525. */
  6526. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6527. /**
  6528. * Rebuild the dynamic inputCheck function from the current list of
  6529. * defined inputs in the manager.
  6530. */
  6531. rebuildInputCheck(): void;
  6532. /**
  6533. * Remove all attached input methods from a camera
  6534. */
  6535. clear(): void;
  6536. /**
  6537. * Serialize the current input manager attached to a camera.
  6538. * This ensures than once parsed,
  6539. * the input associated to the camera will be identical to the current ones
  6540. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6541. */
  6542. serialize(serializedCamera: any): void;
  6543. /**
  6544. * Parses an input manager serialized JSON to restore the previous list of inputs
  6545. * and states associated to a camera.
  6546. * @param parsedCamera Defines the JSON to parse
  6547. */
  6548. parse(parsedCamera: any): void;
  6549. }
  6550. }
  6551. declare module "babylonjs/Meshes/buffer" {
  6552. import { Nullable, DataArray } from "babylonjs/types";
  6553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6554. /**
  6555. * Class used to store data that will be store in GPU memory
  6556. */
  6557. export class Buffer {
  6558. private _engine;
  6559. private _buffer;
  6560. /** @hidden */
  6561. _data: Nullable<DataArray>;
  6562. private _updatable;
  6563. private _instanced;
  6564. private _divisor;
  6565. /**
  6566. * Gets the byte stride.
  6567. */
  6568. readonly byteStride: number;
  6569. /**
  6570. * Constructor
  6571. * @param engine the engine
  6572. * @param data the data to use for this buffer
  6573. * @param updatable whether the data is updatable
  6574. * @param stride the stride (optional)
  6575. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6576. * @param instanced whether the buffer is instanced (optional)
  6577. * @param useBytes set to true if the stride in in bytes (optional)
  6578. * @param divisor sets an optional divisor for instances (1 by default)
  6579. */
  6580. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6581. /**
  6582. * Create a new VertexBuffer based on the current buffer
  6583. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6584. * @param offset defines offset in the buffer (0 by default)
  6585. * @param size defines the size in floats of attributes (position is 3 for instance)
  6586. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6587. * @param instanced defines if the vertex buffer contains indexed data
  6588. * @param useBytes defines if the offset and stride are in bytes *
  6589. * @param divisor sets an optional divisor for instances (1 by default)
  6590. * @returns the new vertex buffer
  6591. */
  6592. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6593. /**
  6594. * Gets a boolean indicating if the Buffer is updatable?
  6595. * @returns true if the buffer is updatable
  6596. */
  6597. isUpdatable(): boolean;
  6598. /**
  6599. * Gets current buffer's data
  6600. * @returns a DataArray or null
  6601. */
  6602. getData(): Nullable<DataArray>;
  6603. /**
  6604. * Gets underlying native buffer
  6605. * @returns underlying native buffer
  6606. */
  6607. getBuffer(): Nullable<DataBuffer>;
  6608. /**
  6609. * Gets the stride in float32 units (i.e. byte stride / 4).
  6610. * May not be an integer if the byte stride is not divisible by 4.
  6611. * @returns the stride in float32 units
  6612. * @deprecated Please use byteStride instead.
  6613. */
  6614. getStrideSize(): number;
  6615. /**
  6616. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6617. * @param data defines the data to store
  6618. */
  6619. create(data?: Nullable<DataArray>): void;
  6620. /** @hidden */
  6621. _rebuild(): void;
  6622. /**
  6623. * Update current buffer data
  6624. * @param data defines the data to store
  6625. */
  6626. update(data: DataArray): void;
  6627. /**
  6628. * Updates the data directly.
  6629. * @param data the new data
  6630. * @param offset the new offset
  6631. * @param vertexCount the vertex count (optional)
  6632. * @param useBytes set to true if the offset is in bytes
  6633. */
  6634. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6635. /**
  6636. * Release all resources
  6637. */
  6638. dispose(): void;
  6639. }
  6640. /**
  6641. * Specialized buffer used to store vertex data
  6642. */
  6643. export class VertexBuffer {
  6644. /** @hidden */
  6645. _buffer: Buffer;
  6646. private _kind;
  6647. private _size;
  6648. private _ownsBuffer;
  6649. private _instanced;
  6650. private _instanceDivisor;
  6651. /**
  6652. * The byte type.
  6653. */
  6654. static readonly BYTE: number;
  6655. /**
  6656. * The unsigned byte type.
  6657. */
  6658. static readonly UNSIGNED_BYTE: number;
  6659. /**
  6660. * The short type.
  6661. */
  6662. static readonly SHORT: number;
  6663. /**
  6664. * The unsigned short type.
  6665. */
  6666. static readonly UNSIGNED_SHORT: number;
  6667. /**
  6668. * The integer type.
  6669. */
  6670. static readonly INT: number;
  6671. /**
  6672. * The unsigned integer type.
  6673. */
  6674. static readonly UNSIGNED_INT: number;
  6675. /**
  6676. * The float type.
  6677. */
  6678. static readonly FLOAT: number;
  6679. /**
  6680. * Gets or sets the instance divisor when in instanced mode
  6681. */
  6682. get instanceDivisor(): number;
  6683. set instanceDivisor(value: number);
  6684. /**
  6685. * Gets the byte stride.
  6686. */
  6687. readonly byteStride: number;
  6688. /**
  6689. * Gets the byte offset.
  6690. */
  6691. readonly byteOffset: number;
  6692. /**
  6693. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6694. */
  6695. readonly normalized: boolean;
  6696. /**
  6697. * Gets the data type of each component in the array.
  6698. */
  6699. readonly type: number;
  6700. /**
  6701. * Constructor
  6702. * @param engine the engine
  6703. * @param data the data to use for this vertex buffer
  6704. * @param kind the vertex buffer kind
  6705. * @param updatable whether the data is updatable
  6706. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6707. * @param stride the stride (optional)
  6708. * @param instanced whether the buffer is instanced (optional)
  6709. * @param offset the offset of the data (optional)
  6710. * @param size the number of components (optional)
  6711. * @param type the type of the component (optional)
  6712. * @param normalized whether the data contains normalized data (optional)
  6713. * @param useBytes set to true if stride and offset are in bytes (optional)
  6714. * @param divisor defines the instance divisor to use (1 by default)
  6715. */
  6716. 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);
  6717. /** @hidden */
  6718. _rebuild(): void;
  6719. /**
  6720. * Returns the kind of the VertexBuffer (string)
  6721. * @returns a string
  6722. */
  6723. getKind(): string;
  6724. /**
  6725. * Gets a boolean indicating if the VertexBuffer is updatable?
  6726. * @returns true if the buffer is updatable
  6727. */
  6728. isUpdatable(): boolean;
  6729. /**
  6730. * Gets current buffer's data
  6731. * @returns a DataArray or null
  6732. */
  6733. getData(): Nullable<DataArray>;
  6734. /**
  6735. * Gets underlying native buffer
  6736. * @returns underlying native buffer
  6737. */
  6738. getBuffer(): Nullable<DataBuffer>;
  6739. /**
  6740. * Gets the stride in float32 units (i.e. byte stride / 4).
  6741. * May not be an integer if the byte stride is not divisible by 4.
  6742. * @returns the stride in float32 units
  6743. * @deprecated Please use byteStride instead.
  6744. */
  6745. getStrideSize(): number;
  6746. /**
  6747. * Returns the offset as a multiple of the type byte length.
  6748. * @returns the offset in bytes
  6749. * @deprecated Please use byteOffset instead.
  6750. */
  6751. getOffset(): number;
  6752. /**
  6753. * Returns the number of components per vertex attribute (integer)
  6754. * @returns the size in float
  6755. */
  6756. getSize(): number;
  6757. /**
  6758. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6759. * @returns true if this buffer is instanced
  6760. */
  6761. getIsInstanced(): boolean;
  6762. /**
  6763. * Returns the instancing divisor, zero for non-instanced (integer).
  6764. * @returns a number
  6765. */
  6766. getInstanceDivisor(): number;
  6767. /**
  6768. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6769. * @param data defines the data to store
  6770. */
  6771. create(data?: DataArray): void;
  6772. /**
  6773. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6774. * This function will create a new buffer if the current one is not updatable
  6775. * @param data defines the data to store
  6776. */
  6777. update(data: DataArray): void;
  6778. /**
  6779. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6780. * Returns the directly updated WebGLBuffer.
  6781. * @param data the new data
  6782. * @param offset the new offset
  6783. * @param useBytes set to true if the offset is in bytes
  6784. */
  6785. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6786. /**
  6787. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6788. */
  6789. dispose(): void;
  6790. /**
  6791. * Enumerates each value of this vertex buffer as numbers.
  6792. * @param count the number of values to enumerate
  6793. * @param callback the callback function called for each value
  6794. */
  6795. forEach(count: number, callback: (value: number, index: number) => void): void;
  6796. /**
  6797. * Positions
  6798. */
  6799. static readonly PositionKind: string;
  6800. /**
  6801. * Normals
  6802. */
  6803. static readonly NormalKind: string;
  6804. /**
  6805. * Tangents
  6806. */
  6807. static readonly TangentKind: string;
  6808. /**
  6809. * Texture coordinates
  6810. */
  6811. static readonly UVKind: string;
  6812. /**
  6813. * Texture coordinates 2
  6814. */
  6815. static readonly UV2Kind: string;
  6816. /**
  6817. * Texture coordinates 3
  6818. */
  6819. static readonly UV3Kind: string;
  6820. /**
  6821. * Texture coordinates 4
  6822. */
  6823. static readonly UV4Kind: string;
  6824. /**
  6825. * Texture coordinates 5
  6826. */
  6827. static readonly UV5Kind: string;
  6828. /**
  6829. * Texture coordinates 6
  6830. */
  6831. static readonly UV6Kind: string;
  6832. /**
  6833. * Colors
  6834. */
  6835. static readonly ColorKind: string;
  6836. /**
  6837. * Matrix indices (for bones)
  6838. */
  6839. static readonly MatricesIndicesKind: string;
  6840. /**
  6841. * Matrix weights (for bones)
  6842. */
  6843. static readonly MatricesWeightsKind: string;
  6844. /**
  6845. * Additional matrix indices (for bones)
  6846. */
  6847. static readonly MatricesIndicesExtraKind: string;
  6848. /**
  6849. * Additional matrix weights (for bones)
  6850. */
  6851. static readonly MatricesWeightsExtraKind: string;
  6852. /**
  6853. * Deduces the stride given a kind.
  6854. * @param kind The kind string to deduce
  6855. * @returns The deduced stride
  6856. */
  6857. static DeduceStride(kind: string): number;
  6858. /**
  6859. * Gets the byte length of the given type.
  6860. * @param type the type
  6861. * @returns the number of bytes
  6862. */
  6863. static GetTypeByteLength(type: number): number;
  6864. /**
  6865. * Enumerates each value of the given parameters as numbers.
  6866. * @param data the data to enumerate
  6867. * @param byteOffset the byte offset of the data
  6868. * @param byteStride the byte stride of the data
  6869. * @param componentCount the number of components per element
  6870. * @param componentType the type of the component
  6871. * @param count the number of values to enumerate
  6872. * @param normalized whether the data is normalized
  6873. * @param callback the callback function called for each value
  6874. */
  6875. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6876. private static _GetFloatValue;
  6877. }
  6878. }
  6879. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6880. import { Vector3 } from "babylonjs/Maths/math.vector";
  6881. import { Mesh } from "babylonjs/Meshes/mesh";
  6882. /**
  6883. * The options Interface for creating a Capsule Mesh
  6884. */
  6885. export interface ICreateCapsuleOptions {
  6886. /** The Orientation of the capsule. Default : Vector3.Up() */
  6887. orientation?: Vector3;
  6888. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6889. subdivisions: number;
  6890. /** Number of cylindrical segments on the capsule. */
  6891. tessellation: number;
  6892. /** Height or Length of the capsule. */
  6893. height: number;
  6894. /** Radius of the capsule. */
  6895. radius: number;
  6896. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6897. capSubdivisions: number;
  6898. /** Overwrite for the top radius. */
  6899. radiusTop?: number;
  6900. /** Overwrite for the bottom radius. */
  6901. radiusBottom?: number;
  6902. /** Overwrite for the top capSubdivisions. */
  6903. topCapSubdivisions?: number;
  6904. /** Overwrite for the bottom capSubdivisions. */
  6905. bottomCapSubdivisions?: number;
  6906. }
  6907. /**
  6908. * Class containing static functions to help procedurally build meshes
  6909. */
  6910. export class CapsuleBuilder {
  6911. /**
  6912. * Creates a capsule or a pill mesh
  6913. * @param name defines the name of the mesh
  6914. * @param options The constructors options.
  6915. * @param scene The scene the mesh is scoped to.
  6916. * @returns Capsule Mesh
  6917. */
  6918. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6919. }
  6920. }
  6921. declare module "babylonjs/Collisions/intersectionInfo" {
  6922. import { Nullable } from "babylonjs/types";
  6923. /**
  6924. * @hidden
  6925. */
  6926. export class IntersectionInfo {
  6927. bu: Nullable<number>;
  6928. bv: Nullable<number>;
  6929. distance: number;
  6930. faceId: number;
  6931. subMeshId: number;
  6932. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6933. }
  6934. }
  6935. declare module "babylonjs/Culling/boundingSphere" {
  6936. import { DeepImmutable } from "babylonjs/types";
  6937. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6938. import { Plane } from "babylonjs/Maths/math.plane";
  6939. /**
  6940. * Class used to store bounding sphere information
  6941. */
  6942. export class BoundingSphere {
  6943. /**
  6944. * Gets the center of the bounding sphere in local space
  6945. */
  6946. readonly center: Vector3;
  6947. /**
  6948. * Radius of the bounding sphere in local space
  6949. */
  6950. radius: number;
  6951. /**
  6952. * Gets the center of the bounding sphere in world space
  6953. */
  6954. readonly centerWorld: Vector3;
  6955. /**
  6956. * Radius of the bounding sphere in world space
  6957. */
  6958. radiusWorld: number;
  6959. /**
  6960. * Gets the minimum vector in local space
  6961. */
  6962. readonly minimum: Vector3;
  6963. /**
  6964. * Gets the maximum vector in local space
  6965. */
  6966. readonly maximum: Vector3;
  6967. private _worldMatrix;
  6968. private static readonly TmpVector3;
  6969. /**
  6970. * Creates a new bounding sphere
  6971. * @param min defines the minimum vector (in local space)
  6972. * @param max defines the maximum vector (in local space)
  6973. * @param worldMatrix defines the new world matrix
  6974. */
  6975. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6976. /**
  6977. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6978. * @param min defines the new minimum vector (in local space)
  6979. * @param max defines the new maximum vector (in local space)
  6980. * @param worldMatrix defines the new world matrix
  6981. */
  6982. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6983. /**
  6984. * Scale the current bounding sphere by applying a scale factor
  6985. * @param factor defines the scale factor to apply
  6986. * @returns the current bounding box
  6987. */
  6988. scale(factor: number): BoundingSphere;
  6989. /**
  6990. * Gets the world matrix of the bounding box
  6991. * @returns a matrix
  6992. */
  6993. getWorldMatrix(): DeepImmutable<Matrix>;
  6994. /** @hidden */
  6995. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6996. /**
  6997. * Tests if the bounding sphere is intersecting the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if the bounding sphere center is in between the frustum planes.
  7004. * Used for optimistic fast inclusion.
  7005. * @param frustumPlanes defines the frustum planes to test
  7006. * @returns true if the sphere center is in between the frustum planes
  7007. */
  7008. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7009. /**
  7010. * Tests if a point is inside the bounding sphere
  7011. * @param point defines the point to test
  7012. * @returns true if the point is inside the bounding sphere
  7013. */
  7014. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Checks if two sphere intersct
  7017. * @param sphere0 sphere 0
  7018. * @param sphere1 sphere 1
  7019. * @returns true if the speres intersect
  7020. */
  7021. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7022. }
  7023. }
  7024. declare module "babylonjs/Culling/boundingBox" {
  7025. import { DeepImmutable } from "babylonjs/types";
  7026. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7027. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7028. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7029. import { Plane } from "babylonjs/Maths/math.plane";
  7030. /**
  7031. * Class used to store bounding box information
  7032. */
  7033. export class BoundingBox implements ICullable {
  7034. /**
  7035. * Gets the 8 vectors representing the bounding box in local space
  7036. */
  7037. readonly vectors: Vector3[];
  7038. /**
  7039. * Gets the center of the bounding box in local space
  7040. */
  7041. readonly center: Vector3;
  7042. /**
  7043. * Gets the center of the bounding box in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Gets the extend size in local space
  7048. */
  7049. readonly extendSize: Vector3;
  7050. /**
  7051. * Gets the extend size in world space
  7052. */
  7053. readonly extendSizeWorld: Vector3;
  7054. /**
  7055. * Gets the OBB (object bounding box) directions
  7056. */
  7057. readonly directions: Vector3[];
  7058. /**
  7059. * Gets the 8 vectors representing the bounding box in world space
  7060. */
  7061. readonly vectorsWorld: Vector3[];
  7062. /**
  7063. * Gets the minimum vector in world space
  7064. */
  7065. readonly minimumWorld: Vector3;
  7066. /**
  7067. * Gets the maximum vector in world space
  7068. */
  7069. readonly maximumWorld: Vector3;
  7070. /**
  7071. * Gets the minimum vector in local space
  7072. */
  7073. readonly minimum: Vector3;
  7074. /**
  7075. * Gets the maximum vector in local space
  7076. */
  7077. readonly maximum: Vector3;
  7078. private _worldMatrix;
  7079. private static readonly TmpVector3;
  7080. /**
  7081. * @hidden
  7082. */
  7083. _tag: number;
  7084. /**
  7085. * Creates a new bounding box
  7086. * @param min defines the minimum vector (in local space)
  7087. * @param max defines the maximum vector (in local space)
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Scale the current bounding box by applying a scale factor
  7100. * @param factor defines the scale factor to apply
  7101. * @returns the current bounding box
  7102. */
  7103. scale(factor: number): BoundingBox;
  7104. /**
  7105. * Gets the world matrix of the bounding box
  7106. * @returns a matrix
  7107. */
  7108. getWorldMatrix(): DeepImmutable<Matrix>;
  7109. /** @hidden */
  7110. _update(world: DeepImmutable<Matrix>): void;
  7111. /**
  7112. * Tests if the bounding box is intersecting the frustum planes
  7113. * @param frustumPlanes defines the frustum planes to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7117. /**
  7118. * Tests if the bounding box is entirely inside the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an inclusion
  7121. */
  7122. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if a point is inside the bounding box
  7125. * @param point defines the point to test
  7126. * @returns true if the point is inside the bounding box
  7127. */
  7128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7129. /**
  7130. * Tests if the bounding box intersects with a bounding sphere
  7131. * @param sphere defines the sphere to test
  7132. * @returns true if there is an intersection
  7133. */
  7134. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7135. /**
  7136. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7137. * @param min defines the min vector to use
  7138. * @param max defines the max vector to use
  7139. * @returns true if there is an intersection
  7140. */
  7141. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7142. /**
  7143. * Tests if two bounding boxes are intersections
  7144. * @param box0 defines the first box to test
  7145. * @param box1 defines the second box to test
  7146. * @returns true if there is an intersection
  7147. */
  7148. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7149. /**
  7150. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7151. * @param minPoint defines the minimum vector of the bounding box
  7152. * @param maxPoint defines the maximum vector of the bounding box
  7153. * @param sphereCenter defines the sphere center
  7154. * @param sphereRadius defines the sphere radius
  7155. * @returns true if there is an intersection
  7156. */
  7157. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7158. /**
  7159. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7160. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7161. * @param frustumPlanes defines the frustum planes to test
  7162. * @return true if there is an inclusion
  7163. */
  7164. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /**
  7166. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7167. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7168. * @param frustumPlanes defines the frustum planes to test
  7169. * @return true if there is an intersection
  7170. */
  7171. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7172. }
  7173. }
  7174. declare module "babylonjs/Collisions/collider" {
  7175. import { Nullable, IndicesArray } from "babylonjs/types";
  7176. import { Vector3 } from "babylonjs/Maths/math.vector";
  7177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7178. import { Plane } from "babylonjs/Maths/math.plane";
  7179. /** @hidden */
  7180. export class Collider {
  7181. /** Define if a collision was found */
  7182. collisionFound: boolean;
  7183. /**
  7184. * Define last intersection point in local space
  7185. */
  7186. intersectionPoint: Vector3;
  7187. /**
  7188. * Define last collided mesh
  7189. */
  7190. collidedMesh: Nullable<AbstractMesh>;
  7191. private _collisionPoint;
  7192. private _planeIntersectionPoint;
  7193. private _tempVector;
  7194. private _tempVector2;
  7195. private _tempVector3;
  7196. private _tempVector4;
  7197. private _edge;
  7198. private _baseToVertex;
  7199. private _destinationPoint;
  7200. private _slidePlaneNormal;
  7201. private _displacementVector;
  7202. /** @hidden */
  7203. _radius: Vector3;
  7204. /** @hidden */
  7205. _retry: number;
  7206. private _velocity;
  7207. private _basePoint;
  7208. private _epsilon;
  7209. /** @hidden */
  7210. _velocityWorldLength: number;
  7211. /** @hidden */
  7212. _basePointWorld: Vector3;
  7213. private _velocityWorld;
  7214. private _normalizedVelocity;
  7215. /** @hidden */
  7216. _initialVelocity: Vector3;
  7217. /** @hidden */
  7218. _initialPosition: Vector3;
  7219. private _nearestDistance;
  7220. private _collisionMask;
  7221. get collisionMask(): number;
  7222. set collisionMask(mask: number);
  7223. /**
  7224. * Gets the plane normal used to compute the sliding response (in local space)
  7225. */
  7226. get slidePlaneNormal(): Vector3;
  7227. /** @hidden */
  7228. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7229. /** @hidden */
  7230. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7231. /** @hidden */
  7232. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7233. /** @hidden */
  7234. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7235. /** @hidden */
  7236. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7237. /** @hidden */
  7238. _getResponse(pos: Vector3, vel: Vector3): void;
  7239. }
  7240. }
  7241. declare module "babylonjs/Culling/boundingInfo" {
  7242. import { DeepImmutable } from "babylonjs/types";
  7243. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7245. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7246. import { Plane } from "babylonjs/Maths/math.plane";
  7247. import { Collider } from "babylonjs/Collisions/collider";
  7248. /**
  7249. * Interface for cullable objects
  7250. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7251. */
  7252. export interface ICullable {
  7253. /**
  7254. * Checks if the object or part of the object is in the frustum
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isInFrustum(frustumPlanes: Plane[]): boolean;
  7259. /**
  7260. * Checks if a cullable object (mesh...) is in the camera frustum
  7261. * Unlike isInFrustum this cheks the full bounding box
  7262. * @param frustumPlanes Camera near/planes
  7263. * @returns true if the object is in frustum otherwise false
  7264. */
  7265. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7266. }
  7267. /**
  7268. * Info for a bounding data of a mesh
  7269. */
  7270. export class BoundingInfo implements ICullable {
  7271. /**
  7272. * Bounding box for the mesh
  7273. */
  7274. readonly boundingBox: BoundingBox;
  7275. /**
  7276. * Bounding sphere for the mesh
  7277. */
  7278. readonly boundingSphere: BoundingSphere;
  7279. private _isLocked;
  7280. private static readonly TmpVector3;
  7281. /**
  7282. * Constructs bounding info
  7283. * @param minimum min vector of the bounding box/sphere
  7284. * @param maximum max vector of the bounding box/sphere
  7285. * @param worldMatrix defines the new world matrix
  7286. */
  7287. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7288. /**
  7289. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7290. * @param min defines the new minimum vector (in local space)
  7291. * @param max defines the new maximum vector (in local space)
  7292. * @param worldMatrix defines the new world matrix
  7293. */
  7294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * min vector of the bounding box/sphere
  7297. */
  7298. get minimum(): Vector3;
  7299. /**
  7300. * max vector of the bounding box/sphere
  7301. */
  7302. get maximum(): Vector3;
  7303. /**
  7304. * If the info is locked and won't be updated to avoid perf overhead
  7305. */
  7306. get isLocked(): boolean;
  7307. set isLocked(value: boolean);
  7308. /**
  7309. * Updates the bounding sphere and box
  7310. * @param world world matrix to be used to update
  7311. */
  7312. update(world: DeepImmutable<Matrix>): void;
  7313. /**
  7314. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7315. * @param center New center of the bounding info
  7316. * @param extend New extend of the bounding info
  7317. * @returns the current bounding info
  7318. */
  7319. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7320. /**
  7321. * Scale the current bounding info by applying a scale factor
  7322. * @param factor defines the scale factor to apply
  7323. * @returns the current bounding info
  7324. */
  7325. scale(factor: number): BoundingInfo;
  7326. /**
  7327. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7328. * @param frustumPlanes defines the frustum to test
  7329. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7330. * @returns true if the bounding info is in the frustum planes
  7331. */
  7332. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7333. /**
  7334. * Gets the world distance between the min and max points of the bounding box
  7335. */
  7336. get diagonalLength(): number;
  7337. /**
  7338. * Checks if a cullable object (mesh...) is in the camera frustum
  7339. * Unlike isInFrustum this cheks the full bounding box
  7340. * @param frustumPlanes Camera near/planes
  7341. * @returns true if the object is in frustum otherwise false
  7342. */
  7343. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7344. /** @hidden */
  7345. _checkCollision(collider: Collider): boolean;
  7346. /**
  7347. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7348. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7349. * @param point the point to check intersection with
  7350. * @returns if the point intersects
  7351. */
  7352. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7353. /**
  7354. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7355. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7356. * @param boundingInfo the bounding info to check intersection with
  7357. * @param precise if the intersection should be done using OBB
  7358. * @returns if the bounding info intersects
  7359. */
  7360. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7361. }
  7362. }
  7363. declare module "babylonjs/Maths/math.functions" {
  7364. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7365. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7366. /**
  7367. * Extracts minimum and maximum values from a list of indexed positions
  7368. * @param positions defines the positions to use
  7369. * @param indices defines the indices to the positions
  7370. * @param indexStart defines the start index
  7371. * @param indexCount defines the end index
  7372. * @param bias defines bias value to add to the result
  7373. * @return minimum and maximum values
  7374. */
  7375. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7376. minimum: Vector3;
  7377. maximum: Vector3;
  7378. };
  7379. /**
  7380. * Extracts minimum and maximum values from a list of positions
  7381. * @param positions defines the positions to use
  7382. * @param start defines the start index in the positions array
  7383. * @param count defines the number of positions to handle
  7384. * @param bias defines bias value to add to the result
  7385. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7386. * @return minimum and maximum values
  7387. */
  7388. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7389. minimum: Vector3;
  7390. maximum: Vector3;
  7391. };
  7392. }
  7393. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7394. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7395. /** @hidden */
  7396. export class WebGLDataBuffer extends DataBuffer {
  7397. private _buffer;
  7398. constructor(resource: WebGLBuffer);
  7399. get underlyingResource(): any;
  7400. }
  7401. }
  7402. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7403. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7404. import { Nullable } from "babylonjs/types";
  7405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7406. /** @hidden */
  7407. export class WebGLPipelineContext implements IPipelineContext {
  7408. engine: ThinEngine;
  7409. program: Nullable<WebGLProgram>;
  7410. context?: WebGLRenderingContext;
  7411. vertexShader?: WebGLShader;
  7412. fragmentShader?: WebGLShader;
  7413. isParallelCompiled: boolean;
  7414. onCompiled?: () => void;
  7415. transformFeedback?: WebGLTransformFeedback | null;
  7416. vertexCompilationError: Nullable<string>;
  7417. fragmentCompilationError: Nullable<string>;
  7418. programLinkError: Nullable<string>;
  7419. programValidationError: Nullable<string>;
  7420. get isAsync(): boolean;
  7421. get isReady(): boolean;
  7422. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7423. _getVertexShaderCode(): string | null;
  7424. _getFragmentShaderCode(): string | null;
  7425. }
  7426. }
  7427. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7428. import { FloatArray, Nullable } from "babylonjs/types";
  7429. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7430. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7431. module "babylonjs/Engines/thinEngine" {
  7432. interface ThinEngine {
  7433. /**
  7434. * Create an uniform buffer
  7435. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7436. * @param elements defines the content of the uniform buffer
  7437. * @returns the webGL uniform buffer
  7438. */
  7439. createUniformBuffer(elements: FloatArray): DataBuffer;
  7440. /**
  7441. * Create a dynamic uniform buffer
  7442. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7443. * @param elements defines the content of the uniform buffer
  7444. * @returns the webGL uniform buffer
  7445. */
  7446. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7447. /**
  7448. * Update an existing uniform buffer
  7449. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7450. * @param uniformBuffer defines the target uniform buffer
  7451. * @param elements defines the content to update
  7452. * @param offset defines the offset in the uniform buffer where update should start
  7453. * @param count defines the size of the data to update
  7454. */
  7455. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7456. /**
  7457. * Bind an uniform buffer to the current webGL context
  7458. * @param buffer defines the buffer to bind
  7459. */
  7460. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7461. /**
  7462. * Bind a buffer to the current webGL context at a given location
  7463. * @param buffer defines the buffer to bind
  7464. * @param location defines the index where to bind the buffer
  7465. */
  7466. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7467. /**
  7468. * Bind a specific block at a given index in a specific shader program
  7469. * @param pipelineContext defines the pipeline context to use
  7470. * @param blockName defines the block name
  7471. * @param index defines the index where to bind the block
  7472. */
  7473. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7474. }
  7475. }
  7476. }
  7477. declare module "babylonjs/Materials/uniformBuffer" {
  7478. import { Nullable, FloatArray } from "babylonjs/types";
  7479. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7480. import { Engine } from "babylonjs/Engines/engine";
  7481. import { Effect } from "babylonjs/Materials/effect";
  7482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7483. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7484. import { Color3 } from "babylonjs/Maths/math.color";
  7485. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7486. /**
  7487. * Uniform buffer objects.
  7488. *
  7489. * Handles blocks of uniform on the GPU.
  7490. *
  7491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7492. *
  7493. * For more information, please refer to :
  7494. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7495. */
  7496. export class UniformBuffer {
  7497. private _engine;
  7498. private _buffer;
  7499. private _data;
  7500. private _bufferData;
  7501. private _dynamic?;
  7502. private _uniformLocations;
  7503. private _uniformSizes;
  7504. private _uniformLocationPointer;
  7505. private _needSync;
  7506. private _noUBO;
  7507. private _currentEffect;
  7508. /** @hidden */
  7509. _alreadyBound: boolean;
  7510. private static _MAX_UNIFORM_SIZE;
  7511. private static _tempBuffer;
  7512. /**
  7513. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7518. /**
  7519. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7524. /**
  7525. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7530. /**
  7531. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7536. /**
  7537. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7542. /**
  7543. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7548. /**
  7549. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7554. /**
  7555. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7560. /**
  7561. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7562. * This is dynamic to allow compat with webgl 1 and 2.
  7563. * You will need to pass the name of the uniform as well as the value.
  7564. */
  7565. updateVector4: (name: string, vector: Vector4) => void;
  7566. /**
  7567. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7568. * This is dynamic to allow compat with webgl 1 and 2.
  7569. * You will need to pass the name of the uniform as well as the value.
  7570. */
  7571. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7572. /**
  7573. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7574. * This is dynamic to allow compat with webgl 1 and 2.
  7575. * You will need to pass the name of the uniform as well as the value.
  7576. */
  7577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7578. /**
  7579. * Instantiates a new Uniform buffer objects.
  7580. *
  7581. * Handles blocks of uniform on the GPU.
  7582. *
  7583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7584. *
  7585. * For more information, please refer to :
  7586. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7587. * @param engine Define the engine the buffer is associated with
  7588. * @param data Define the data contained in the buffer
  7589. * @param dynamic Define if the buffer is updatable
  7590. */
  7591. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7592. /**
  7593. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7594. * or just falling back on setUniformXXX calls.
  7595. */
  7596. get useUbo(): boolean;
  7597. /**
  7598. * Indicates if the WebGL underlying uniform buffer is in sync
  7599. * with the javascript cache data.
  7600. */
  7601. get isSync(): boolean;
  7602. /**
  7603. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7604. * Also, a dynamic UniformBuffer will disable cache verification and always
  7605. * update the underlying WebGL uniform buffer to the GPU.
  7606. * @returns if Dynamic, otherwise false
  7607. */
  7608. isDynamic(): boolean;
  7609. /**
  7610. * The data cache on JS side.
  7611. * @returns the underlying data as a float array
  7612. */
  7613. getData(): Float32Array;
  7614. /**
  7615. * The underlying WebGL Uniform buffer.
  7616. * @returns the webgl buffer
  7617. */
  7618. getBuffer(): Nullable<DataBuffer>;
  7619. /**
  7620. * std140 layout specifies how to align data within an UBO structure.
  7621. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7622. * for specs.
  7623. */
  7624. private _fillAlignment;
  7625. /**
  7626. * Adds an uniform in the buffer.
  7627. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7628. * for the layout to be correct !
  7629. * @param name Name of the uniform, as used in the uniform block in the shader.
  7630. * @param size Data size, or data directly.
  7631. */
  7632. addUniform(name: string, size: number | number[]): void;
  7633. /**
  7634. * Adds a Matrix 4x4 to the uniform buffer.
  7635. * @param name Name of the uniform, as used in the uniform block in the shader.
  7636. * @param mat A 4x4 matrix.
  7637. */
  7638. addMatrix(name: string, mat: Matrix): void;
  7639. /**
  7640. * Adds a vec2 to the uniform buffer.
  7641. * @param name Name of the uniform, as used in the uniform block in the shader.
  7642. * @param x Define the x component value of the vec2
  7643. * @param y Define the y component value of the vec2
  7644. */
  7645. addFloat2(name: string, x: number, y: number): void;
  7646. /**
  7647. * Adds a vec3 to the uniform buffer.
  7648. * @param name Name of the uniform, as used in the uniform block in the shader.
  7649. * @param x Define the x component value of the vec3
  7650. * @param y Define the y component value of the vec3
  7651. * @param z Define the z component value of the vec3
  7652. */
  7653. addFloat3(name: string, x: number, y: number, z: number): void;
  7654. /**
  7655. * Adds a vec3 to the uniform buffer.
  7656. * @param name Name of the uniform, as used in the uniform block in the shader.
  7657. * @param color Define the vec3 from a Color
  7658. */
  7659. addColor3(name: string, color: Color3): void;
  7660. /**
  7661. * Adds a vec4 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. * @param color Define the rgb components from a Color
  7664. * @param alpha Define the a component of the vec4
  7665. */
  7666. addColor4(name: string, color: Color3, alpha: number): void;
  7667. /**
  7668. * Adds a vec3 to the uniform buffer.
  7669. * @param name Name of the uniform, as used in the uniform block in the shader.
  7670. * @param vector Define the vec3 components from a Vector
  7671. */
  7672. addVector3(name: string, vector: Vector3): void;
  7673. /**
  7674. * Adds a Matrix 3x3 to the uniform buffer.
  7675. * @param name Name of the uniform, as used in the uniform block in the shader.
  7676. */
  7677. addMatrix3x3(name: string): void;
  7678. /**
  7679. * Adds a Matrix 2x2 to the uniform buffer.
  7680. * @param name Name of the uniform, as used in the uniform block in the shader.
  7681. */
  7682. addMatrix2x2(name: string): void;
  7683. /**
  7684. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7685. */
  7686. create(): void;
  7687. /** @hidden */
  7688. _rebuild(): void;
  7689. /**
  7690. * Updates the WebGL Uniform Buffer on the GPU.
  7691. * If the `dynamic` flag is set to true, no cache comparison is done.
  7692. * Otherwise, the buffer will be updated only if the cache differs.
  7693. */
  7694. update(): void;
  7695. /**
  7696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7697. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7698. * @param data Define the flattened data
  7699. * @param size Define the size of the data.
  7700. */
  7701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7702. private _valueCache;
  7703. private _cacheMatrix;
  7704. private _updateMatrix3x3ForUniform;
  7705. private _updateMatrix3x3ForEffect;
  7706. private _updateMatrix2x2ForEffect;
  7707. private _updateMatrix2x2ForUniform;
  7708. private _updateFloatForEffect;
  7709. private _updateFloatForUniform;
  7710. private _updateFloat2ForEffect;
  7711. private _updateFloat2ForUniform;
  7712. private _updateFloat3ForEffect;
  7713. private _updateFloat3ForUniform;
  7714. private _updateFloat4ForEffect;
  7715. private _updateFloat4ForUniform;
  7716. private _updateMatrixForEffect;
  7717. private _updateMatrixForUniform;
  7718. private _updateVector3ForEffect;
  7719. private _updateVector3ForUniform;
  7720. private _updateVector4ForEffect;
  7721. private _updateVector4ForUniform;
  7722. private _updateColor3ForEffect;
  7723. private _updateColor3ForUniform;
  7724. private _updateColor4ForEffect;
  7725. private _updateColor4ForUniform;
  7726. /**
  7727. * Sets a sampler uniform on the effect.
  7728. * @param name Define the name of the sampler.
  7729. * @param texture Define the texture to set in the sampler
  7730. */
  7731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7732. /**
  7733. * Directly updates the value of the uniform in the cache AND on the GPU.
  7734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7735. * @param data Define the flattened data
  7736. */
  7737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7738. /**
  7739. * Binds this uniform buffer to an effect.
  7740. * @param effect Define the effect to bind the buffer to
  7741. * @param name Name of the uniform block in the shader.
  7742. */
  7743. bindToEffect(effect: Effect, name: string): void;
  7744. /**
  7745. * Disposes the uniform buffer.
  7746. */
  7747. dispose(): void;
  7748. }
  7749. }
  7750. declare module "babylonjs/Misc/iInspectable" {
  7751. /**
  7752. * Enum that determines the text-wrapping mode to use.
  7753. */
  7754. export enum InspectableType {
  7755. /**
  7756. * Checkbox for booleans
  7757. */
  7758. Checkbox = 0,
  7759. /**
  7760. * Sliders for numbers
  7761. */
  7762. Slider = 1,
  7763. /**
  7764. * Vector3
  7765. */
  7766. Vector3 = 2,
  7767. /**
  7768. * Quaternions
  7769. */
  7770. Quaternion = 3,
  7771. /**
  7772. * Color3
  7773. */
  7774. Color3 = 4,
  7775. /**
  7776. * String
  7777. */
  7778. String = 5
  7779. }
  7780. /**
  7781. * Interface used to define custom inspectable properties.
  7782. * This interface is used by the inspector to display custom property grids
  7783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7784. */
  7785. export interface IInspectable {
  7786. /**
  7787. * Gets the label to display
  7788. */
  7789. label: string;
  7790. /**
  7791. * Gets the name of the property to edit
  7792. */
  7793. propertyName: string;
  7794. /**
  7795. * Gets the type of the editor to use
  7796. */
  7797. type: InspectableType;
  7798. /**
  7799. * Gets the minimum value of the property when using in "slider" mode
  7800. */
  7801. min?: number;
  7802. /**
  7803. * Gets the maximum value of the property when using in "slider" mode
  7804. */
  7805. max?: number;
  7806. /**
  7807. * Gets the setp to use when using in "slider" mode
  7808. */
  7809. step?: number;
  7810. }
  7811. }
  7812. declare module "babylonjs/Misc/timingTools" {
  7813. /**
  7814. * Class used to provide helper for timing
  7815. */
  7816. export class TimingTools {
  7817. /**
  7818. * Polyfill for setImmediate
  7819. * @param action defines the action to execute after the current execution block
  7820. */
  7821. static SetImmediate(action: () => void): void;
  7822. }
  7823. }
  7824. declare module "babylonjs/Misc/instantiationTools" {
  7825. /**
  7826. * Class used to enable instatition of objects by class name
  7827. */
  7828. export class InstantiationTools {
  7829. /**
  7830. * Use this object to register external classes like custom textures or material
  7831. * to allow the laoders to instantiate them
  7832. */
  7833. static RegisteredExternalClasses: {
  7834. [key: string]: Object;
  7835. };
  7836. /**
  7837. * Tries to instantiate a new object from a given class name
  7838. * @param className defines the class name to instantiate
  7839. * @returns the new object or null if the system was not able to do the instantiation
  7840. */
  7841. static Instantiate(className: string): any;
  7842. }
  7843. }
  7844. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7845. /**
  7846. * Define options used to create a depth texture
  7847. */
  7848. export class DepthTextureCreationOptions {
  7849. /** Specifies whether or not a stencil should be allocated in the texture */
  7850. generateStencil?: boolean;
  7851. /** Specifies whether or not bilinear filtering is enable on the texture */
  7852. bilinearFiltering?: boolean;
  7853. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7854. comparisonFunction?: number;
  7855. /** Specifies if the created texture is a cube texture */
  7856. isCube?: boolean;
  7857. }
  7858. }
  7859. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7860. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7861. import { Nullable } from "babylonjs/types";
  7862. import { Scene } from "babylonjs/scene";
  7863. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7864. module "babylonjs/Engines/thinEngine" {
  7865. interface ThinEngine {
  7866. /**
  7867. * Creates a depth stencil cube texture.
  7868. * This is only available in WebGL 2.
  7869. * @param size The size of face edge in the cube texture.
  7870. * @param options The options defining the cube texture.
  7871. * @returns The cube texture
  7872. */
  7873. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7874. /**
  7875. * Creates a cube texture
  7876. * @param rootUrl defines the url where the files to load is located
  7877. * @param scene defines the current scene
  7878. * @param files defines the list of files to load (1 per face)
  7879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7880. * @param onLoad defines an optional callback raised when the texture is loaded
  7881. * @param onError defines an optional callback raised if there is an issue to load the texture
  7882. * @param format defines the format of the data
  7883. * @param forcedExtension defines the extension to use to pick the right loader
  7884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7888. * @returns the cube texture as an InternalTexture
  7889. */
  7890. 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;
  7891. /**
  7892. * Creates a cube texture
  7893. * @param rootUrl defines the url where the files to load is located
  7894. * @param scene defines the current scene
  7895. * @param files defines the list of files to load (1 per face)
  7896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7897. * @param onLoad defines an optional callback raised when the texture is loaded
  7898. * @param onError defines an optional callback raised if there is an issue to load the texture
  7899. * @param format defines the format of the data
  7900. * @param forcedExtension defines the extension to use to pick the right loader
  7901. * @returns the cube texture as an InternalTexture
  7902. */
  7903. 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;
  7904. /**
  7905. * Creates a cube texture
  7906. * @param rootUrl defines the url where the files to load is located
  7907. * @param scene defines the current scene
  7908. * @param files defines the list of files to load (1 per face)
  7909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7910. * @param onLoad defines an optional callback raised when the texture is loaded
  7911. * @param onError defines an optional callback raised if there is an issue to load the texture
  7912. * @param format defines the format of the data
  7913. * @param forcedExtension defines the extension to use to pick the right loader
  7914. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7917. * @returns the cube texture as an InternalTexture
  7918. */
  7919. 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;
  7920. /** @hidden */
  7921. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7922. /** @hidden */
  7923. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7924. /** @hidden */
  7925. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7926. /** @hidden */
  7927. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7928. /**
  7929. * @hidden
  7930. */
  7931. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7932. }
  7933. }
  7934. }
  7935. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7936. import { Nullable } from "babylonjs/types";
  7937. import { Scene } from "babylonjs/scene";
  7938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7940. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7941. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7942. import { Observable } from "babylonjs/Misc/observable";
  7943. /**
  7944. * Class for creating a cube texture
  7945. */
  7946. export class CubeTexture extends BaseTexture {
  7947. private _delayedOnLoad;
  7948. /**
  7949. * Observable triggered once the texture has been loaded.
  7950. */
  7951. onLoadObservable: Observable<CubeTexture>;
  7952. /**
  7953. * The url of the texture
  7954. */
  7955. url: string;
  7956. /**
  7957. * Gets or sets the center of the bounding box associated with the cube texture.
  7958. * It must define where the camera used to render the texture was set
  7959. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7960. */
  7961. boundingBoxPosition: Vector3;
  7962. private _boundingBoxSize;
  7963. /**
  7964. * Gets or sets the size of the bounding box associated with the cube texture
  7965. * When defined, the cubemap will switch to local mode
  7966. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7967. * @example https://www.babylonjs-playground.com/#RNASML
  7968. */
  7969. set boundingBoxSize(value: Vector3);
  7970. /**
  7971. * Returns the bounding box size
  7972. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7973. */
  7974. get boundingBoxSize(): Vector3;
  7975. protected _rotationY: number;
  7976. /**
  7977. * Sets texture matrix rotation angle around Y axis in radians.
  7978. */
  7979. set rotationY(value: number);
  7980. /**
  7981. * Gets texture matrix rotation angle around Y axis radians.
  7982. */
  7983. get rotationY(): number;
  7984. /**
  7985. * Are mip maps generated for this texture or not.
  7986. */
  7987. get noMipmap(): boolean;
  7988. private _noMipmap;
  7989. private _files;
  7990. protected _forcedExtension: Nullable<string>;
  7991. private _extensions;
  7992. private _textureMatrix;
  7993. private _format;
  7994. private _createPolynomials;
  7995. /**
  7996. * Creates a cube texture from an array of image urls
  7997. * @param files defines an array of image urls
  7998. * @param scene defines the hosting scene
  7999. * @param noMipmap specifies if mip maps are not used
  8000. * @returns a cube texture
  8001. */
  8002. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8003. /**
  8004. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8005. * @param url defines the url of the prefiltered texture
  8006. * @param scene defines the scene the texture is attached to
  8007. * @param forcedExtension defines the extension of the file if different from the url
  8008. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8009. * @return the prefiltered texture
  8010. */
  8011. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8012. /**
  8013. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8014. * as prefiltered data.
  8015. * @param rootUrl defines the url of the texture or the root name of the six images
  8016. * @param null defines the scene or engine the texture is attached to
  8017. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8018. * @param noMipmap defines if mipmaps should be created or not
  8019. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8020. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8021. * @param onError defines a callback triggered in case of error during load
  8022. * @param format defines the internal format to use for the texture once loaded
  8023. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8024. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8025. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8028. * @return the cube texture
  8029. */
  8030. 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);
  8031. /**
  8032. * Get the current class name of the texture useful for serialization or dynamic coding.
  8033. * @returns "CubeTexture"
  8034. */
  8035. getClassName(): string;
  8036. /**
  8037. * Update the url (and optional buffer) of this texture if url was null during construction.
  8038. * @param url the url of the texture
  8039. * @param forcedExtension defines the extension to use
  8040. * @param onLoad callback called when the texture is loaded (defaults to null)
  8041. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8042. */
  8043. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8044. /**
  8045. * Delays loading of the cube texture
  8046. * @param forcedExtension defines the extension to use
  8047. */
  8048. delayLoad(forcedExtension?: string): void;
  8049. /**
  8050. * Returns the reflection texture matrix
  8051. * @returns the reflection texture matrix
  8052. */
  8053. getReflectionTextureMatrix(): Matrix;
  8054. /**
  8055. * Sets the reflection texture matrix
  8056. * @param value Reflection texture matrix
  8057. */
  8058. setReflectionTextureMatrix(value: Matrix): void;
  8059. /**
  8060. * Parses text to create a cube texture
  8061. * @param parsedTexture define the serialized text to read from
  8062. * @param scene defines the hosting scene
  8063. * @param rootUrl defines the root url of the cube texture
  8064. * @returns a cube texture
  8065. */
  8066. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8067. /**
  8068. * Makes a clone, or deep copy, of the cube texture
  8069. * @returns a new cube texture
  8070. */
  8071. clone(): CubeTexture;
  8072. }
  8073. }
  8074. declare module "babylonjs/Materials/materialDefines" {
  8075. /**
  8076. * Manages the defines for the Material
  8077. */
  8078. export class MaterialDefines {
  8079. /** @hidden */
  8080. protected _keys: string[];
  8081. private _isDirty;
  8082. /** @hidden */
  8083. _renderId: number;
  8084. /** @hidden */
  8085. _areLightsDirty: boolean;
  8086. /** @hidden */
  8087. _areLightsDisposed: boolean;
  8088. /** @hidden */
  8089. _areAttributesDirty: boolean;
  8090. /** @hidden */
  8091. _areTexturesDirty: boolean;
  8092. /** @hidden */
  8093. _areFresnelDirty: boolean;
  8094. /** @hidden */
  8095. _areMiscDirty: boolean;
  8096. /** @hidden */
  8097. _areImageProcessingDirty: boolean;
  8098. /** @hidden */
  8099. _normals: boolean;
  8100. /** @hidden */
  8101. _uvs: boolean;
  8102. /** @hidden */
  8103. _needNormals: boolean;
  8104. /** @hidden */
  8105. _needUVs: boolean;
  8106. [id: string]: any;
  8107. /**
  8108. * Specifies if the material needs to be re-calculated
  8109. */
  8110. get isDirty(): boolean;
  8111. /**
  8112. * Marks the material to indicate that it has been re-calculated
  8113. */
  8114. markAsProcessed(): void;
  8115. /**
  8116. * Marks the material to indicate that it needs to be re-calculated
  8117. */
  8118. markAsUnprocessed(): void;
  8119. /**
  8120. * Marks the material to indicate all of its defines need to be re-calculated
  8121. */
  8122. markAllAsDirty(): void;
  8123. /**
  8124. * Marks the material to indicate that image processing needs to be re-calculated
  8125. */
  8126. markAsImageProcessingDirty(): void;
  8127. /**
  8128. * Marks the material to indicate the lights need to be re-calculated
  8129. * @param disposed Defines whether the light is dirty due to dispose or not
  8130. */
  8131. markAsLightDirty(disposed?: boolean): void;
  8132. /**
  8133. * Marks the attribute state as changed
  8134. */
  8135. markAsAttributesDirty(): void;
  8136. /**
  8137. * Marks the texture state as changed
  8138. */
  8139. markAsTexturesDirty(): void;
  8140. /**
  8141. * Marks the fresnel state as changed
  8142. */
  8143. markAsFresnelDirty(): void;
  8144. /**
  8145. * Marks the misc state as changed
  8146. */
  8147. markAsMiscDirty(): void;
  8148. /**
  8149. * Rebuilds the material defines
  8150. */
  8151. rebuild(): void;
  8152. /**
  8153. * Specifies if two material defines are equal
  8154. * @param other - A material define instance to compare to
  8155. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8156. */
  8157. isEqual(other: MaterialDefines): boolean;
  8158. /**
  8159. * Clones this instance's defines to another instance
  8160. * @param other - material defines to clone values to
  8161. */
  8162. cloneTo(other: MaterialDefines): void;
  8163. /**
  8164. * Resets the material define values
  8165. */
  8166. reset(): void;
  8167. /**
  8168. * Converts the material define values to a string
  8169. * @returns - String of material define information
  8170. */
  8171. toString(): string;
  8172. }
  8173. }
  8174. declare module "babylonjs/Materials/colorCurves" {
  8175. import { Effect } from "babylonjs/Materials/effect";
  8176. /**
  8177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8179. * 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;
  8180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8181. */
  8182. export class ColorCurves {
  8183. private _dirty;
  8184. private _tempColor;
  8185. private _globalCurve;
  8186. private _highlightsCurve;
  8187. private _midtonesCurve;
  8188. private _shadowsCurve;
  8189. private _positiveCurve;
  8190. private _negativeCurve;
  8191. private _globalHue;
  8192. private _globalDensity;
  8193. private _globalSaturation;
  8194. private _globalExposure;
  8195. /**
  8196. * Gets the global Hue value.
  8197. * 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).
  8198. */
  8199. get globalHue(): number;
  8200. /**
  8201. * Sets the global Hue value.
  8202. * 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).
  8203. */
  8204. set globalHue(value: number);
  8205. /**
  8206. * Gets the global Density value.
  8207. * 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.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. get globalDensity(): number;
  8211. /**
  8212. * Sets the global Density value.
  8213. * 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.
  8214. * Values less than zero provide a filter of opposite hue.
  8215. */
  8216. set globalDensity(value: number);
  8217. /**
  8218. * Gets the global Saturation value.
  8219. * 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.
  8220. */
  8221. get globalSaturation(): number;
  8222. /**
  8223. * Sets the global Saturation value.
  8224. * 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.
  8225. */
  8226. set globalSaturation(value: number);
  8227. /**
  8228. * Gets the global Exposure value.
  8229. * 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.
  8230. */
  8231. get globalExposure(): number;
  8232. /**
  8233. * Sets the global Exposure value.
  8234. * 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.
  8235. */
  8236. set globalExposure(value: number);
  8237. private _highlightsHue;
  8238. private _highlightsDensity;
  8239. private _highlightsSaturation;
  8240. private _highlightsExposure;
  8241. /**
  8242. * Gets the highlights Hue value.
  8243. * 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).
  8244. */
  8245. get highlightsHue(): number;
  8246. /**
  8247. * Sets the highlights Hue value.
  8248. * 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).
  8249. */
  8250. set highlightsHue(value: number);
  8251. /**
  8252. * Gets the highlights Density value.
  8253. * 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.
  8254. * Values less than zero provide a filter of opposite hue.
  8255. */
  8256. get highlightsDensity(): number;
  8257. /**
  8258. * Sets the highlights Density value.
  8259. * 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.
  8260. * Values less than zero provide a filter of opposite hue.
  8261. */
  8262. set highlightsDensity(value: number);
  8263. /**
  8264. * Gets the highlights Saturation value.
  8265. * 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.
  8266. */
  8267. get highlightsSaturation(): number;
  8268. /**
  8269. * Sets the highlights Saturation value.
  8270. * 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.
  8271. */
  8272. set highlightsSaturation(value: number);
  8273. /**
  8274. * Gets the highlights Exposure value.
  8275. * 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.
  8276. */
  8277. get highlightsExposure(): number;
  8278. /**
  8279. * Sets the highlights Exposure value.
  8280. * 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.
  8281. */
  8282. set highlightsExposure(value: number);
  8283. private _midtonesHue;
  8284. private _midtonesDensity;
  8285. private _midtonesSaturation;
  8286. private _midtonesExposure;
  8287. /**
  8288. * Gets the midtones Hue value.
  8289. * 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).
  8290. */
  8291. get midtonesHue(): number;
  8292. /**
  8293. * Sets the midtones Hue value.
  8294. * 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).
  8295. */
  8296. set midtonesHue(value: number);
  8297. /**
  8298. * Gets the midtones Density value.
  8299. * 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.
  8300. * Values less than zero provide a filter of opposite hue.
  8301. */
  8302. get midtonesDensity(): number;
  8303. /**
  8304. * Sets the midtones Density value.
  8305. * 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.
  8306. * Values less than zero provide a filter of opposite hue.
  8307. */
  8308. set midtonesDensity(value: number);
  8309. /**
  8310. * Gets the midtones Saturation value.
  8311. * 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.
  8312. */
  8313. get midtonesSaturation(): number;
  8314. /**
  8315. * Sets the midtones Saturation value.
  8316. * 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.
  8317. */
  8318. set midtonesSaturation(value: number);
  8319. /**
  8320. * Gets the midtones Exposure value.
  8321. * 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.
  8322. */
  8323. get midtonesExposure(): number;
  8324. /**
  8325. * Sets the midtones Exposure value.
  8326. * 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.
  8327. */
  8328. set midtonesExposure(value: number);
  8329. private _shadowsHue;
  8330. private _shadowsDensity;
  8331. private _shadowsSaturation;
  8332. private _shadowsExposure;
  8333. /**
  8334. * Gets the shadows Hue value.
  8335. * 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).
  8336. */
  8337. get shadowsHue(): number;
  8338. /**
  8339. * Sets the shadows Hue value.
  8340. * 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).
  8341. */
  8342. set shadowsHue(value: number);
  8343. /**
  8344. * Gets the shadows Density value.
  8345. * 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.
  8346. * Values less than zero provide a filter of opposite hue.
  8347. */
  8348. get shadowsDensity(): number;
  8349. /**
  8350. * Sets the shadows Density value.
  8351. * 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.
  8352. * Values less than zero provide a filter of opposite hue.
  8353. */
  8354. set shadowsDensity(value: number);
  8355. /**
  8356. * Gets the shadows Saturation value.
  8357. * 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.
  8358. */
  8359. get shadowsSaturation(): number;
  8360. /**
  8361. * Sets the shadows Saturation value.
  8362. * 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.
  8363. */
  8364. set shadowsSaturation(value: number);
  8365. /**
  8366. * Gets the shadows Exposure value.
  8367. * 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.
  8368. */
  8369. get shadowsExposure(): number;
  8370. /**
  8371. * Sets the shadows Exposure value.
  8372. * 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.
  8373. */
  8374. set shadowsExposure(value: number);
  8375. /**
  8376. * Returns the class name
  8377. * @returns The class name
  8378. */
  8379. getClassName(): string;
  8380. /**
  8381. * Binds the color curves to the shader.
  8382. * @param colorCurves The color curve to bind
  8383. * @param effect The effect to bind to
  8384. * @param positiveUniform The positive uniform shader parameter
  8385. * @param neutralUniform The neutral uniform shader parameter
  8386. * @param negativeUniform The negative uniform shader parameter
  8387. */
  8388. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8389. /**
  8390. * Prepare the list of uniforms associated with the ColorCurves effects.
  8391. * @param uniformsList The list of uniforms used in the effect
  8392. */
  8393. static PrepareUniforms(uniformsList: string[]): void;
  8394. /**
  8395. * Returns color grading data based on a hue, density, saturation and exposure value.
  8396. * @param filterHue The hue of the color filter.
  8397. * @param filterDensity The density of the color filter.
  8398. * @param saturation The saturation.
  8399. * @param exposure The exposure.
  8400. * @param result The result data container.
  8401. */
  8402. private getColorGradingDataToRef;
  8403. /**
  8404. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8405. * @param value The input slider value in range [-100,100].
  8406. * @returns Adjusted value.
  8407. */
  8408. private static applyColorGradingSliderNonlinear;
  8409. /**
  8410. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8411. * @param hue The hue (H) input.
  8412. * @param saturation The saturation (S) input.
  8413. * @param brightness The brightness (B) input.
  8414. * @result An RGBA color represented as Vector4.
  8415. */
  8416. private static fromHSBToRef;
  8417. /**
  8418. * Returns a value clamped between min and max
  8419. * @param value The value to clamp
  8420. * @param min The minimum of value
  8421. * @param max The maximum of value
  8422. * @returns The clamped value.
  8423. */
  8424. private static clamp;
  8425. /**
  8426. * Clones the current color curve instance.
  8427. * @return The cloned curves
  8428. */
  8429. clone(): ColorCurves;
  8430. /**
  8431. * Serializes the current color curve instance to a json representation.
  8432. * @return a JSON representation
  8433. */
  8434. serialize(): any;
  8435. /**
  8436. * Parses the color curve from a json representation.
  8437. * @param source the JSON source to parse
  8438. * @return The parsed curves
  8439. */
  8440. static Parse(source: any): ColorCurves;
  8441. }
  8442. }
  8443. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8444. import { Observable } from "babylonjs/Misc/observable";
  8445. import { Nullable } from "babylonjs/types";
  8446. import { Color4 } from "babylonjs/Maths/math.color";
  8447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8448. import { Effect } from "babylonjs/Materials/effect";
  8449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8450. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8451. /**
  8452. * Interface to follow in your material defines to integrate easily the
  8453. * Image proccessing functions.
  8454. * @hidden
  8455. */
  8456. export interface IImageProcessingConfigurationDefines {
  8457. IMAGEPROCESSING: boolean;
  8458. VIGNETTE: boolean;
  8459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8460. VIGNETTEBLENDMODEOPAQUE: boolean;
  8461. TONEMAPPING: boolean;
  8462. TONEMAPPING_ACES: boolean;
  8463. CONTRAST: boolean;
  8464. EXPOSURE: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. }
  8472. /**
  8473. * @hidden
  8474. */
  8475. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8476. IMAGEPROCESSING: boolean;
  8477. VIGNETTE: boolean;
  8478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8479. VIGNETTEBLENDMODEOPAQUE: boolean;
  8480. TONEMAPPING: boolean;
  8481. TONEMAPPING_ACES: boolean;
  8482. CONTRAST: boolean;
  8483. COLORCURVES: boolean;
  8484. COLORGRADING: boolean;
  8485. COLORGRADING3D: boolean;
  8486. SAMPLER3DGREENDEPTH: boolean;
  8487. SAMPLER3DBGRMAP: boolean;
  8488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8489. EXPOSURE: boolean;
  8490. constructor();
  8491. }
  8492. /**
  8493. * This groups together the common properties used for image processing either in direct forward pass
  8494. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8495. * or not.
  8496. */
  8497. export class ImageProcessingConfiguration {
  8498. /**
  8499. * Default tone mapping applied in BabylonJS.
  8500. */
  8501. static readonly TONEMAPPING_STANDARD: number;
  8502. /**
  8503. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8504. * to other engines rendering to increase portability.
  8505. */
  8506. static readonly TONEMAPPING_ACES: number;
  8507. /**
  8508. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8509. */
  8510. colorCurves: Nullable<ColorCurves>;
  8511. private _colorCurvesEnabled;
  8512. /**
  8513. * Gets wether the color curves effect is enabled.
  8514. */
  8515. get colorCurvesEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color curves effect is enabled.
  8518. */
  8519. set colorCurvesEnabled(value: boolean);
  8520. private _colorGradingTexture;
  8521. /**
  8522. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8523. */
  8524. get colorGradingTexture(): Nullable<BaseTexture>;
  8525. /**
  8526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8527. */
  8528. set colorGradingTexture(value: Nullable<BaseTexture>);
  8529. private _colorGradingEnabled;
  8530. /**
  8531. * Gets wether the color grading effect is enabled.
  8532. */
  8533. get colorGradingEnabled(): boolean;
  8534. /**
  8535. * Sets wether the color grading effect is enabled.
  8536. */
  8537. set colorGradingEnabled(value: boolean);
  8538. private _colorGradingWithGreenDepth;
  8539. /**
  8540. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8541. */
  8542. get colorGradingWithGreenDepth(): boolean;
  8543. /**
  8544. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8545. */
  8546. set colorGradingWithGreenDepth(value: boolean);
  8547. private _colorGradingBGR;
  8548. /**
  8549. * Gets wether the color grading texture contains BGR values.
  8550. */
  8551. get colorGradingBGR(): boolean;
  8552. /**
  8553. * Sets wether the color grading texture contains BGR values.
  8554. */
  8555. set colorGradingBGR(value: boolean);
  8556. /** @hidden */
  8557. _exposure: number;
  8558. /**
  8559. * Gets the Exposure used in the effect.
  8560. */
  8561. get exposure(): number;
  8562. /**
  8563. * Sets the Exposure used in the effect.
  8564. */
  8565. set exposure(value: number);
  8566. private _toneMappingEnabled;
  8567. /**
  8568. * Gets wether the tone mapping effect is enabled.
  8569. */
  8570. get toneMappingEnabled(): boolean;
  8571. /**
  8572. * Sets wether the tone mapping effect is enabled.
  8573. */
  8574. set toneMappingEnabled(value: boolean);
  8575. private _toneMappingType;
  8576. /**
  8577. * Gets the type of tone mapping effect.
  8578. */
  8579. get toneMappingType(): number;
  8580. /**
  8581. * Sets the type of tone mapping effect used in BabylonJS.
  8582. */
  8583. set toneMappingType(value: number);
  8584. protected _contrast: number;
  8585. /**
  8586. * Gets the contrast used in the effect.
  8587. */
  8588. get contrast(): number;
  8589. /**
  8590. * Sets the contrast used in the effect.
  8591. */
  8592. set contrast(value: number);
  8593. /**
  8594. * Vignette stretch size.
  8595. */
  8596. vignetteStretch: number;
  8597. /**
  8598. * Vignette centre X Offset.
  8599. */
  8600. vignetteCentreX: number;
  8601. /**
  8602. * Vignette centre Y Offset.
  8603. */
  8604. vignetteCentreY: number;
  8605. /**
  8606. * Vignette weight or intensity of the vignette effect.
  8607. */
  8608. vignetteWeight: number;
  8609. /**
  8610. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8611. * if vignetteEnabled is set to true.
  8612. */
  8613. vignetteColor: Color4;
  8614. /**
  8615. * Camera field of view used by the Vignette effect.
  8616. */
  8617. vignetteCameraFov: number;
  8618. private _vignetteBlendMode;
  8619. /**
  8620. * Gets the vignette blend mode allowing different kind of effect.
  8621. */
  8622. get vignetteBlendMode(): number;
  8623. /**
  8624. * Sets the vignette blend mode allowing different kind of effect.
  8625. */
  8626. set vignetteBlendMode(value: number);
  8627. private _vignetteEnabled;
  8628. /**
  8629. * Gets wether the vignette effect is enabled.
  8630. */
  8631. get vignetteEnabled(): boolean;
  8632. /**
  8633. * Sets wether the vignette effect is enabled.
  8634. */
  8635. set vignetteEnabled(value: boolean);
  8636. private _applyByPostProcess;
  8637. /**
  8638. * Gets wether the image processing is applied through a post process or not.
  8639. */
  8640. get applyByPostProcess(): boolean;
  8641. /**
  8642. * Sets wether the image processing is applied through a post process or not.
  8643. */
  8644. set applyByPostProcess(value: boolean);
  8645. private _isEnabled;
  8646. /**
  8647. * Gets wether the image processing is enabled or not.
  8648. */
  8649. get isEnabled(): boolean;
  8650. /**
  8651. * Sets wether the image processing is enabled or not.
  8652. */
  8653. set isEnabled(value: boolean);
  8654. /**
  8655. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8656. */
  8657. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8658. /**
  8659. * Method called each time the image processing information changes requires to recompile the effect.
  8660. */
  8661. protected _updateParameters(): void;
  8662. /**
  8663. * Gets the current class name.
  8664. * @return "ImageProcessingConfiguration"
  8665. */
  8666. getClassName(): string;
  8667. /**
  8668. * Prepare the list of uniforms associated with the Image Processing effects.
  8669. * @param uniforms The list of uniforms used in the effect
  8670. * @param defines the list of defines currently in use
  8671. */
  8672. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8673. /**
  8674. * Prepare the list of samplers associated with the Image Processing effects.
  8675. * @param samplersList The list of uniforms used in the effect
  8676. * @param defines the list of defines currently in use
  8677. */
  8678. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8679. /**
  8680. * Prepare the list of defines associated to the shader.
  8681. * @param defines the list of defines to complete
  8682. * @param forPostProcess Define if we are currently in post process mode or not
  8683. */
  8684. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8685. /**
  8686. * Returns true if all the image processing information are ready.
  8687. * @returns True if ready, otherwise, false
  8688. */
  8689. isReady(): boolean;
  8690. /**
  8691. * Binds the image processing to the shader.
  8692. * @param effect The effect to bind to
  8693. * @param overrideAspectRatio Override the aspect ratio of the effect
  8694. */
  8695. bind(effect: Effect, overrideAspectRatio?: number): void;
  8696. /**
  8697. * Clones the current image processing instance.
  8698. * @return The cloned image processing
  8699. */
  8700. clone(): ImageProcessingConfiguration;
  8701. /**
  8702. * Serializes the current image processing instance to a json representation.
  8703. * @return a JSON representation
  8704. */
  8705. serialize(): any;
  8706. /**
  8707. * Parses the image processing from a json representation.
  8708. * @param source the JSON source to parse
  8709. * @return The parsed image processing
  8710. */
  8711. static Parse(source: any): ImageProcessingConfiguration;
  8712. private static _VIGNETTEMODE_MULTIPLY;
  8713. private static _VIGNETTEMODE_OPAQUE;
  8714. /**
  8715. * Used to apply the vignette as a mix with the pixel color.
  8716. */
  8717. static get VIGNETTEMODE_MULTIPLY(): number;
  8718. /**
  8719. * Used to apply the vignette as a replacement of the pixel color.
  8720. */
  8721. static get VIGNETTEMODE_OPAQUE(): number;
  8722. }
  8723. }
  8724. declare module "babylonjs/Shaders/postprocess.vertex" {
  8725. /** @hidden */
  8726. export var postprocessVertexShader: {
  8727. name: string;
  8728. shader: string;
  8729. };
  8730. }
  8731. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8733. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8734. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8735. /**
  8736. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8737. */
  8738. export type RenderTargetTextureSize = number | {
  8739. width: number;
  8740. height: number;
  8741. layers?: number;
  8742. };
  8743. module "babylonjs/Engines/thinEngine" {
  8744. interface ThinEngine {
  8745. /**
  8746. * Creates a new render target texture
  8747. * @param size defines the size of the texture
  8748. * @param options defines the options used to create the texture
  8749. * @returns a new render target texture stored in an InternalTexture
  8750. */
  8751. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8752. /**
  8753. * Creates a depth stencil texture.
  8754. * This is only available in WebGL 2 or with the depth texture extension available.
  8755. * @param size The size of face edge in the texture.
  8756. * @param options The options defining the texture.
  8757. * @returns The texture
  8758. */
  8759. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8760. /** @hidden */
  8761. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8762. }
  8763. }
  8764. }
  8765. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8766. /**
  8767. * Defines the kind of connection point for node based material
  8768. */
  8769. export enum NodeMaterialBlockConnectionPointTypes {
  8770. /** Float */
  8771. Float = 1,
  8772. /** Int */
  8773. Int = 2,
  8774. /** Vector2 */
  8775. Vector2 = 4,
  8776. /** Vector3 */
  8777. Vector3 = 8,
  8778. /** Vector4 */
  8779. Vector4 = 16,
  8780. /** Color3 */
  8781. Color3 = 32,
  8782. /** Color4 */
  8783. Color4 = 64,
  8784. /** Matrix */
  8785. Matrix = 128,
  8786. /** Custom object */
  8787. Object = 256,
  8788. /** Detect type based on connection */
  8789. AutoDetect = 1024,
  8790. /** Output type that will be defined by input type */
  8791. BasedOnInput = 2048
  8792. }
  8793. }
  8794. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8795. /**
  8796. * Enum used to define the target of a block
  8797. */
  8798. export enum NodeMaterialBlockTargets {
  8799. /** Vertex shader */
  8800. Vertex = 1,
  8801. /** Fragment shader */
  8802. Fragment = 2,
  8803. /** Neutral */
  8804. Neutral = 4,
  8805. /** Vertex and Fragment */
  8806. VertexAndFragment = 3
  8807. }
  8808. }
  8809. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8810. /**
  8811. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8812. */
  8813. export enum NodeMaterialBlockConnectionPointMode {
  8814. /** Value is an uniform */
  8815. Uniform = 0,
  8816. /** Value is a mesh attribute */
  8817. Attribute = 1,
  8818. /** Value is a varying between vertex and fragment shaders */
  8819. Varying = 2,
  8820. /** Mode is undefined */
  8821. Undefined = 3
  8822. }
  8823. }
  8824. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8825. /**
  8826. * Enum used to define system values e.g. values automatically provided by the system
  8827. */
  8828. export enum NodeMaterialSystemValues {
  8829. /** World */
  8830. World = 1,
  8831. /** View */
  8832. View = 2,
  8833. /** Projection */
  8834. Projection = 3,
  8835. /** ViewProjection */
  8836. ViewProjection = 4,
  8837. /** WorldView */
  8838. WorldView = 5,
  8839. /** WorldViewProjection */
  8840. WorldViewProjection = 6,
  8841. /** CameraPosition */
  8842. CameraPosition = 7,
  8843. /** Fog Color */
  8844. FogColor = 8,
  8845. /** Delta time */
  8846. DeltaTime = 9
  8847. }
  8848. }
  8849. declare module "babylonjs/Maths/math.axis" {
  8850. import { Vector3 } from "babylonjs/Maths/math.vector";
  8851. /** Defines supported spaces */
  8852. export enum Space {
  8853. /** Local (object) space */
  8854. LOCAL = 0,
  8855. /** World space */
  8856. WORLD = 1,
  8857. /** Bone space */
  8858. BONE = 2
  8859. }
  8860. /** Defines the 3 main axes */
  8861. export class Axis {
  8862. /** X axis */
  8863. static X: Vector3;
  8864. /** Y axis */
  8865. static Y: Vector3;
  8866. /** Z axis */
  8867. static Z: Vector3;
  8868. }
  8869. }
  8870. declare module "babylonjs/Maths/math.frustum" {
  8871. import { Matrix } from "babylonjs/Maths/math.vector";
  8872. import { DeepImmutable } from "babylonjs/types";
  8873. import { Plane } from "babylonjs/Maths/math.plane";
  8874. /**
  8875. * Represents a camera frustum
  8876. */
  8877. export class Frustum {
  8878. /**
  8879. * Gets the planes representing the frustum
  8880. * @param transform matrix to be applied to the returned planes
  8881. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8882. */
  8883. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8884. /**
  8885. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8890. /**
  8891. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8896. /**
  8897. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8902. /**
  8903. * Gets the right frustum plane transformed by the transform matrix
  8904. * @param transform transformation matrix to be applied to the resulting frustum plane
  8905. * @param frustumPlane the resuling frustum plane
  8906. */
  8907. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8908. /**
  8909. * Gets the top frustum plane transformed by the transform matrix
  8910. * @param transform transformation matrix to be applied to the resulting frustum plane
  8911. * @param frustumPlane the resuling frustum plane
  8912. */
  8913. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8914. /**
  8915. * Gets the bottom frustum plane transformed by the transform matrix
  8916. * @param transform transformation matrix to be applied to the resulting frustum plane
  8917. * @param frustumPlane the resuling frustum plane
  8918. */
  8919. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8920. /**
  8921. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8922. * @param transform transformation matrix to be applied to the resulting frustum planes
  8923. * @param frustumPlanes the resuling frustum planes
  8924. */
  8925. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8926. }
  8927. }
  8928. declare module "babylonjs/Maths/math.size" {
  8929. /**
  8930. * Interface for the size containing width and height
  8931. */
  8932. export interface ISize {
  8933. /**
  8934. * Width
  8935. */
  8936. width: number;
  8937. /**
  8938. * Heighht
  8939. */
  8940. height: number;
  8941. }
  8942. /**
  8943. * Size containing widht and height
  8944. */
  8945. export class Size implements ISize {
  8946. /**
  8947. * Width
  8948. */
  8949. width: number;
  8950. /**
  8951. * Height
  8952. */
  8953. height: number;
  8954. /**
  8955. * Creates a Size object from the given width and height (floats).
  8956. * @param width width of the new size
  8957. * @param height height of the new size
  8958. */
  8959. constructor(width: number, height: number);
  8960. /**
  8961. * Returns a string with the Size width and height
  8962. * @returns a string with the Size width and height
  8963. */
  8964. toString(): string;
  8965. /**
  8966. * "Size"
  8967. * @returns the string "Size"
  8968. */
  8969. getClassName(): string;
  8970. /**
  8971. * Returns the Size hash code.
  8972. * @returns a hash code for a unique width and height
  8973. */
  8974. getHashCode(): number;
  8975. /**
  8976. * Updates the current size from the given one.
  8977. * @param src the given size
  8978. */
  8979. copyFrom(src: Size): void;
  8980. /**
  8981. * Updates in place the current Size from the given floats.
  8982. * @param width width of the new size
  8983. * @param height height of the new size
  8984. * @returns the updated Size.
  8985. */
  8986. copyFromFloats(width: number, height: number): Size;
  8987. /**
  8988. * Updates in place the current Size from the given floats.
  8989. * @param width width to set
  8990. * @param height height to set
  8991. * @returns the updated Size.
  8992. */
  8993. set(width: number, height: number): Size;
  8994. /**
  8995. * Multiplies the width and height by numbers
  8996. * @param w factor to multiple the width by
  8997. * @param h factor to multiple the height by
  8998. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8999. */
  9000. multiplyByFloats(w: number, h: number): Size;
  9001. /**
  9002. * Clones the size
  9003. * @returns a new Size copied from the given one.
  9004. */
  9005. clone(): Size;
  9006. /**
  9007. * True if the current Size and the given one width and height are strictly equal.
  9008. * @param other the other size to compare against
  9009. * @returns True if the current Size and the given one width and height are strictly equal.
  9010. */
  9011. equals(other: Size): boolean;
  9012. /**
  9013. * The surface of the Size : width * height (float).
  9014. */
  9015. get surface(): number;
  9016. /**
  9017. * Create a new size of zero
  9018. * @returns a new Size set to (0.0, 0.0)
  9019. */
  9020. static Zero(): Size;
  9021. /**
  9022. * Sums the width and height of two sizes
  9023. * @param otherSize size to add to this size
  9024. * @returns a new Size set as the addition result of the current Size and the given one.
  9025. */
  9026. add(otherSize: Size): Size;
  9027. /**
  9028. * Subtracts the width and height of two
  9029. * @param otherSize size to subtract to this size
  9030. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9031. */
  9032. subtract(otherSize: Size): Size;
  9033. /**
  9034. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9035. * @param start starting size to lerp between
  9036. * @param end end size to lerp between
  9037. * @param amount amount to lerp between the start and end values
  9038. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9039. */
  9040. static Lerp(start: Size, end: Size, amount: number): Size;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math.vertexFormat" {
  9044. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9045. /**
  9046. * Contains position and normal vectors for a vertex
  9047. */
  9048. export class PositionNormalVertex {
  9049. /** the position of the vertex (defaut: 0,0,0) */
  9050. position: Vector3;
  9051. /** the normal of the vertex (defaut: 0,1,0) */
  9052. normal: Vector3;
  9053. /**
  9054. * Creates a PositionNormalVertex
  9055. * @param position the position of the vertex (defaut: 0,0,0)
  9056. * @param normal the normal of the vertex (defaut: 0,1,0)
  9057. */
  9058. constructor(
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position?: Vector3,
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal?: Vector3);
  9063. /**
  9064. * Clones the PositionNormalVertex
  9065. * @returns the cloned PositionNormalVertex
  9066. */
  9067. clone(): PositionNormalVertex;
  9068. }
  9069. /**
  9070. * Contains position, normal and uv vectors for a vertex
  9071. */
  9072. export class PositionNormalTextureVertex {
  9073. /** the position of the vertex (defaut: 0,0,0) */
  9074. position: Vector3;
  9075. /** the normal of the vertex (defaut: 0,1,0) */
  9076. normal: Vector3;
  9077. /** the uv of the vertex (default: 0,0) */
  9078. uv: Vector2;
  9079. /**
  9080. * Creates a PositionNormalTextureVertex
  9081. * @param position the position of the vertex (defaut: 0,0,0)
  9082. * @param normal the normal of the vertex (defaut: 0,1,0)
  9083. * @param uv the uv of the vertex (default: 0,0)
  9084. */
  9085. constructor(
  9086. /** the position of the vertex (defaut: 0,0,0) */
  9087. position?: Vector3,
  9088. /** the normal of the vertex (defaut: 0,1,0) */
  9089. normal?: Vector3,
  9090. /** the uv of the vertex (default: 0,0) */
  9091. uv?: Vector2);
  9092. /**
  9093. * Clones the PositionNormalTextureVertex
  9094. * @returns the cloned PositionNormalTextureVertex
  9095. */
  9096. clone(): PositionNormalTextureVertex;
  9097. }
  9098. }
  9099. declare module "babylonjs/Maths/math" {
  9100. export * from "babylonjs/Maths/math.axis";
  9101. export * from "babylonjs/Maths/math.color";
  9102. export * from "babylonjs/Maths/math.constants";
  9103. export * from "babylonjs/Maths/math.frustum";
  9104. export * from "babylonjs/Maths/math.path";
  9105. export * from "babylonjs/Maths/math.plane";
  9106. export * from "babylonjs/Maths/math.size";
  9107. export * from "babylonjs/Maths/math.vector";
  9108. export * from "babylonjs/Maths/math.vertexFormat";
  9109. export * from "babylonjs/Maths/math.viewport";
  9110. }
  9111. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9112. /**
  9113. * Enum defining the type of animations supported by InputBlock
  9114. */
  9115. export enum AnimatedInputBlockTypes {
  9116. /** No animation */
  9117. None = 0,
  9118. /** Time based animation. Will only work for floats */
  9119. Time = 1
  9120. }
  9121. }
  9122. declare module "babylonjs/Lights/shadowLight" {
  9123. import { Camera } from "babylonjs/Cameras/camera";
  9124. import { Scene } from "babylonjs/scene";
  9125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9127. import { Light } from "babylonjs/Lights/light";
  9128. /**
  9129. * Interface describing all the common properties and methods a shadow light needs to implement.
  9130. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9131. * as well as binding the different shadow properties to the effects.
  9132. */
  9133. export interface IShadowLight extends Light {
  9134. /**
  9135. * The light id in the scene (used in scene.findLighById for instance)
  9136. */
  9137. id: string;
  9138. /**
  9139. * The position the shdow will be casted from.
  9140. */
  9141. position: Vector3;
  9142. /**
  9143. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9144. */
  9145. direction: Vector3;
  9146. /**
  9147. * The transformed position. Position of the light in world space taking parenting in account.
  9148. */
  9149. transformedPosition: Vector3;
  9150. /**
  9151. * The transformed direction. Direction of the light in world space taking parenting in account.
  9152. */
  9153. transformedDirection: Vector3;
  9154. /**
  9155. * The friendly name of the light in the scene.
  9156. */
  9157. name: string;
  9158. /**
  9159. * Defines the shadow projection clipping minimum z value.
  9160. */
  9161. shadowMinZ: number;
  9162. /**
  9163. * Defines the shadow projection clipping maximum z value.
  9164. */
  9165. shadowMaxZ: number;
  9166. /**
  9167. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9168. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9169. */
  9170. computeTransformedInformation(): boolean;
  9171. /**
  9172. * Gets the scene the light belongs to.
  9173. * @returns The scene
  9174. */
  9175. getScene(): Scene;
  9176. /**
  9177. * Callback defining a custom Projection Matrix Builder.
  9178. * This can be used to override the default projection matrix computation.
  9179. */
  9180. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9181. /**
  9182. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9183. * @param matrix The materix to updated with the projection information
  9184. * @param viewMatrix The transform matrix of the light
  9185. * @param renderList The list of mesh to render in the map
  9186. * @returns The current light
  9187. */
  9188. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9189. /**
  9190. * Gets the current depth scale used in ESM.
  9191. * @returns The scale
  9192. */
  9193. getDepthScale(): number;
  9194. /**
  9195. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9196. * @returns true if a cube texture needs to be use
  9197. */
  9198. needCube(): boolean;
  9199. /**
  9200. * Detects if the projection matrix requires to be recomputed this frame.
  9201. * @returns true if it requires to be recomputed otherwise, false.
  9202. */
  9203. needProjectionMatrixCompute(): boolean;
  9204. /**
  9205. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9206. */
  9207. forceProjectionMatrixCompute(): void;
  9208. /**
  9209. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9210. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9211. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9212. */
  9213. getShadowDirection(faceIndex?: number): Vector3;
  9214. /**
  9215. * Gets the minZ used for shadow according to both the scene and the light.
  9216. * @param activeCamera The camera we are returning the min for
  9217. * @returns the depth min z
  9218. */
  9219. getDepthMinZ(activeCamera: Camera): number;
  9220. /**
  9221. * Gets the maxZ used for shadow according to both the scene and the light.
  9222. * @param activeCamera The camera we are returning the max for
  9223. * @returns the depth max z
  9224. */
  9225. getDepthMaxZ(activeCamera: Camera): number;
  9226. }
  9227. /**
  9228. * Base implementation IShadowLight
  9229. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9230. */
  9231. export abstract class ShadowLight extends Light implements IShadowLight {
  9232. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9233. protected _position: Vector3;
  9234. protected _setPosition(value: Vector3): void;
  9235. /**
  9236. * Sets the position the shadow will be casted from. Also use as the light position for both
  9237. * point and spot lights.
  9238. */
  9239. get position(): Vector3;
  9240. /**
  9241. * Sets the position the shadow will be casted from. Also use as the light position for both
  9242. * point and spot lights.
  9243. */
  9244. set position(value: Vector3);
  9245. protected _direction: Vector3;
  9246. protected _setDirection(value: Vector3): void;
  9247. /**
  9248. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9249. * Also use as the light direction on spot and directional lights.
  9250. */
  9251. get direction(): Vector3;
  9252. /**
  9253. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9254. * Also use as the light direction on spot and directional lights.
  9255. */
  9256. set direction(value: Vector3);
  9257. protected _shadowMinZ: number;
  9258. /**
  9259. * Gets the shadow projection clipping minimum z value.
  9260. */
  9261. get shadowMinZ(): number;
  9262. /**
  9263. * Sets the shadow projection clipping minimum z value.
  9264. */
  9265. set shadowMinZ(value: number);
  9266. protected _shadowMaxZ: number;
  9267. /**
  9268. * Sets the shadow projection clipping maximum z value.
  9269. */
  9270. get shadowMaxZ(): number;
  9271. /**
  9272. * Gets the shadow projection clipping maximum z value.
  9273. */
  9274. set shadowMaxZ(value: number);
  9275. /**
  9276. * Callback defining a custom Projection Matrix Builder.
  9277. * This can be used to override the default projection matrix computation.
  9278. */
  9279. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9280. /**
  9281. * The transformed position. Position of the light in world space taking parenting in account.
  9282. */
  9283. transformedPosition: Vector3;
  9284. /**
  9285. * The transformed direction. Direction of the light in world space taking parenting in account.
  9286. */
  9287. transformedDirection: Vector3;
  9288. private _needProjectionMatrixCompute;
  9289. /**
  9290. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9291. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9292. */
  9293. computeTransformedInformation(): boolean;
  9294. /**
  9295. * Return the depth scale used for the shadow map.
  9296. * @returns the depth scale.
  9297. */
  9298. getDepthScale(): number;
  9299. /**
  9300. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9303. */
  9304. getShadowDirection(faceIndex?: number): Vector3;
  9305. /**
  9306. * Returns the ShadowLight absolute position in the World.
  9307. * @returns the position vector in world space
  9308. */
  9309. getAbsolutePosition(): Vector3;
  9310. /**
  9311. * Sets the ShadowLight direction toward the passed target.
  9312. * @param target The point to target in local space
  9313. * @returns the updated ShadowLight direction
  9314. */
  9315. setDirectionToTarget(target: Vector3): Vector3;
  9316. /**
  9317. * Returns the light rotation in euler definition.
  9318. * @returns the x y z rotation in local space.
  9319. */
  9320. getRotation(): Vector3;
  9321. /**
  9322. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9323. * @returns true if a cube texture needs to be use
  9324. */
  9325. needCube(): boolean;
  9326. /**
  9327. * Detects if the projection matrix requires to be recomputed this frame.
  9328. * @returns true if it requires to be recomputed otherwise, false.
  9329. */
  9330. needProjectionMatrixCompute(): boolean;
  9331. /**
  9332. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9333. */
  9334. forceProjectionMatrixCompute(): void;
  9335. /** @hidden */
  9336. _initCache(): void;
  9337. /** @hidden */
  9338. _isSynchronized(): boolean;
  9339. /**
  9340. * Computes the world matrix of the node
  9341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9342. * @returns the world matrix
  9343. */
  9344. computeWorldMatrix(force?: boolean): Matrix;
  9345. /**
  9346. * Gets the minZ used for shadow according to both the scene and the light.
  9347. * @param activeCamera The camera we are returning the min for
  9348. * @returns the depth min z
  9349. */
  9350. getDepthMinZ(activeCamera: Camera): number;
  9351. /**
  9352. * Gets the maxZ used for shadow according to both the scene and the light.
  9353. * @param activeCamera The camera we are returning the max for
  9354. * @returns the depth max z
  9355. */
  9356. getDepthMaxZ(activeCamera: Camera): number;
  9357. /**
  9358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9359. * @param matrix The materix to updated with the projection information
  9360. * @param viewMatrix The transform matrix of the light
  9361. * @param renderList The list of mesh to render in the map
  9362. * @returns The current light
  9363. */
  9364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9368. /** @hidden */
  9369. export var packingFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9375. /** @hidden */
  9376. export var bayerDitherFunctions: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9382. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9383. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9384. /** @hidden */
  9385. export var shadowMapFragmentDeclaration: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9391. /** @hidden */
  9392. export var clipPlaneFragmentDeclaration: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9398. /** @hidden */
  9399. export var clipPlaneFragment: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9405. /** @hidden */
  9406. export var shadowMapFragment: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9412. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9413. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9415. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9416. /** @hidden */
  9417. export var shadowMapPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9423. /** @hidden */
  9424. export var bonesDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9430. /** @hidden */
  9431. export var morphTargetsVertexGlobalDeclaration: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9437. /** @hidden */
  9438. export var morphTargetsVertexDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9444. /** @hidden */
  9445. export var instancesDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9451. /** @hidden */
  9452. export var helperFunctions: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9458. /** @hidden */
  9459. export var shadowMapVertexDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9465. /** @hidden */
  9466. export var clipPlaneVertexDeclaration: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9493. /** @hidden */
  9494. export var shadowMapVertexNormalBias: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9500. /** @hidden */
  9501. export var shadowMapVertexMetric: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9507. /** @hidden */
  9508. export var clipPlaneVertex: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9514. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9517. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9519. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9527. /** @hidden */
  9528. export var shadowMapVertexShader: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9534. /** @hidden */
  9535. export var depthBoxBlurPixelShader: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9541. /** @hidden */
  9542. export var shadowMapFragmentSoftTransparentShadow: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Materials/effectFallbacks" {
  9548. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9549. import { Effect } from "babylonjs/Materials/effect";
  9550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9551. /**
  9552. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9553. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9554. */
  9555. export class EffectFallbacks implements IEffectFallbacks {
  9556. private _defines;
  9557. private _currentRank;
  9558. private _maxRank;
  9559. private _mesh;
  9560. /**
  9561. * Removes the fallback from the bound mesh.
  9562. */
  9563. unBindMesh(): void;
  9564. /**
  9565. * Adds a fallback on the specified property.
  9566. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9567. * @param define The name of the define in the shader
  9568. */
  9569. addFallback(rank: number, define: string): void;
  9570. /**
  9571. * Sets the mesh to use CPU skinning when needing to fallback.
  9572. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9573. * @param mesh The mesh to use the fallbacks.
  9574. */
  9575. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9576. /**
  9577. * Checks to see if more fallbacks are still availible.
  9578. */
  9579. get hasMoreFallbacks(): boolean;
  9580. /**
  9581. * Removes the defines that should be removed when falling back.
  9582. * @param currentDefines defines the current define statements for the shader.
  9583. * @param effect defines the current effect we try to compile
  9584. * @returns The resulting defines with defines of the current rank removed.
  9585. */
  9586. reduce(currentDefines: string, effect: Effect): string;
  9587. }
  9588. }
  9589. declare module "babylonjs/Actions/action" {
  9590. import { Observable } from "babylonjs/Misc/observable";
  9591. import { Condition } from "babylonjs/Actions/condition";
  9592. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9593. import { Nullable } from "babylonjs/types";
  9594. import { Scene } from "babylonjs/scene";
  9595. import { ActionManager } from "babylonjs/Actions/actionManager";
  9596. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9597. import { Node } from "babylonjs/node";
  9598. /**
  9599. * Interface used to define Action
  9600. */
  9601. export interface IAction {
  9602. /**
  9603. * Trigger for the action
  9604. */
  9605. trigger: number;
  9606. /** Options of the trigger */
  9607. triggerOptions: any;
  9608. /**
  9609. * Gets the trigger parameters
  9610. * @returns the trigger parameters
  9611. */
  9612. getTriggerParameter(): any;
  9613. /**
  9614. * Internal only - executes current action event
  9615. * @hidden
  9616. */
  9617. _executeCurrent(evt?: ActionEvent): void;
  9618. /**
  9619. * Serialize placeholder for child classes
  9620. * @param parent of child
  9621. * @returns the serialized object
  9622. */
  9623. serialize(parent: any): any;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. _prepare(): void;
  9629. /**
  9630. * Internal only - manager for action
  9631. * @hidden
  9632. */
  9633. _actionManager: Nullable<AbstractActionManager>;
  9634. /**
  9635. * Adds action to chain of actions, may be a DoNothingAction
  9636. * @param action defines the next action to execute
  9637. * @returns The action passed in
  9638. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9639. */
  9640. then(action: IAction): IAction;
  9641. }
  9642. /**
  9643. * The action to be carried out following a trigger
  9644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9645. */
  9646. export class Action implements IAction {
  9647. /** the trigger, with or without parameters, for the action */
  9648. triggerOptions: any;
  9649. /**
  9650. * Trigger for the action
  9651. */
  9652. trigger: number;
  9653. /**
  9654. * Internal only - manager for action
  9655. * @hidden
  9656. */
  9657. _actionManager: ActionManager;
  9658. private _nextActiveAction;
  9659. private _child;
  9660. private _condition?;
  9661. private _triggerParameter;
  9662. /**
  9663. * An event triggered prior to action being executed.
  9664. */
  9665. onBeforeExecuteObservable: Observable<Action>;
  9666. /**
  9667. * Creates a new Action
  9668. * @param triggerOptions the trigger, with or without parameters, for the action
  9669. * @param condition an optional determinant of action
  9670. */
  9671. constructor(
  9672. /** the trigger, with or without parameters, for the action */
  9673. triggerOptions: any, condition?: Condition);
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. _prepare(): void;
  9679. /**
  9680. * Gets the trigger parameters
  9681. * @returns the trigger parameters
  9682. */
  9683. getTriggerParameter(): any;
  9684. /**
  9685. * Internal only - executes current action event
  9686. * @hidden
  9687. */
  9688. _executeCurrent(evt?: ActionEvent): void;
  9689. /**
  9690. * Execute placeholder for child classes
  9691. * @param evt optional action event
  9692. */
  9693. execute(evt?: ActionEvent): void;
  9694. /**
  9695. * Skips to next active action
  9696. */
  9697. skipToNextActiveAction(): void;
  9698. /**
  9699. * Adds action to chain of actions, may be a DoNothingAction
  9700. * @param action defines the next action to execute
  9701. * @returns The action passed in
  9702. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9703. */
  9704. then(action: Action): Action;
  9705. /**
  9706. * Internal only
  9707. * @hidden
  9708. */
  9709. _getProperty(propertyPath: string): string;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. _getEffectiveTarget(target: any, propertyPath: string): any;
  9715. /**
  9716. * Serialize placeholder for child classes
  9717. * @param parent of child
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. /**
  9722. * Internal only called by serialize
  9723. * @hidden
  9724. */
  9725. protected _serialize(serializedAction: any, parent?: any): any;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. static _SerializeValueAsString: (value: any) => string;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. static _GetTargetProperty: (target: Scene | Node) => {
  9736. name: string;
  9737. targetType: string;
  9738. value: string;
  9739. };
  9740. }
  9741. }
  9742. declare module "babylonjs/Actions/condition" {
  9743. import { ActionManager } from "babylonjs/Actions/actionManager";
  9744. /**
  9745. * A Condition applied to an Action
  9746. */
  9747. export class Condition {
  9748. /**
  9749. * Internal only - manager for action
  9750. * @hidden
  9751. */
  9752. _actionManager: ActionManager;
  9753. /**
  9754. * Internal only
  9755. * @hidden
  9756. */
  9757. _evaluationId: number;
  9758. /**
  9759. * Internal only
  9760. * @hidden
  9761. */
  9762. _currentResult: boolean;
  9763. /**
  9764. * Creates a new Condition
  9765. * @param actionManager the manager of the action the condition is applied to
  9766. */
  9767. constructor(actionManager: ActionManager);
  9768. /**
  9769. * Check if the current condition is valid
  9770. * @returns a boolean
  9771. */
  9772. isValid(): boolean;
  9773. /**
  9774. * Internal only
  9775. * @hidden
  9776. */
  9777. _getProperty(propertyPath: string): string;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. _getEffectiveTarget(target: any, propertyPath: string): any;
  9783. /**
  9784. * Serialize placeholder for child classes
  9785. * @returns the serialized object
  9786. */
  9787. serialize(): any;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. protected _serialize(serializedCondition: any): any;
  9793. }
  9794. /**
  9795. * Defines specific conditional operators as extensions of Condition
  9796. */
  9797. export class ValueCondition extends Condition {
  9798. /** path to specify the property of the target the conditional operator uses */
  9799. propertyPath: string;
  9800. /** the value compared by the conditional operator against the current value of the property */
  9801. value: any;
  9802. /** the conditional operator, default ValueCondition.IsEqual */
  9803. operator: number;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. private static _IsEqual;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. private static _IsDifferent;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsGreater;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsLesser;
  9824. /**
  9825. * returns the number for IsEqual
  9826. */
  9827. static get IsEqual(): number;
  9828. /**
  9829. * Returns the number for IsDifferent
  9830. */
  9831. static get IsDifferent(): number;
  9832. /**
  9833. * Returns the number for IsGreater
  9834. */
  9835. static get IsGreater(): number;
  9836. /**
  9837. * Returns the number for IsLesser
  9838. */
  9839. static get IsLesser(): number;
  9840. /**
  9841. * Internal only The action manager for the condition
  9842. * @hidden
  9843. */
  9844. _actionManager: ActionManager;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private _target;
  9850. /**
  9851. * Internal only
  9852. * @hidden
  9853. */
  9854. private _effectiveTarget;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _property;
  9860. /**
  9861. * Creates a new ValueCondition
  9862. * @param actionManager manager for the action the condition applies to
  9863. * @param target for the action
  9864. * @param propertyPath path to specify the property of the target the conditional operator uses
  9865. * @param value the value compared by the conditional operator against the current value of the property
  9866. * @param operator the conditional operator, default ValueCondition.IsEqual
  9867. */
  9868. constructor(actionManager: ActionManager, target: any,
  9869. /** path to specify the property of the target the conditional operator uses */
  9870. propertyPath: string,
  9871. /** the value compared by the conditional operator against the current value of the property */
  9872. value: any,
  9873. /** the conditional operator, default ValueCondition.IsEqual */
  9874. operator?: number);
  9875. /**
  9876. * Compares the given value with the property value for the specified conditional operator
  9877. * @returns the result of the comparison
  9878. */
  9879. isValid(): boolean;
  9880. /**
  9881. * Serialize the ValueCondition into a JSON compatible object
  9882. * @returns serialization object
  9883. */
  9884. serialize(): any;
  9885. /**
  9886. * Gets the name of the conditional operator for the ValueCondition
  9887. * @param operator the conditional operator
  9888. * @returns the name
  9889. */
  9890. static GetOperatorName(operator: number): string;
  9891. }
  9892. /**
  9893. * Defines a predicate condition as an extension of Condition
  9894. */
  9895. export class PredicateCondition extends Condition {
  9896. /** defines the predicate function used to validate the condition */
  9897. predicate: () => boolean;
  9898. /**
  9899. * Internal only - manager for action
  9900. * @hidden
  9901. */
  9902. _actionManager: ActionManager;
  9903. /**
  9904. * Creates a new PredicateCondition
  9905. * @param actionManager manager for the action the condition applies to
  9906. * @param predicate defines the predicate function used to validate the condition
  9907. */
  9908. constructor(actionManager: ActionManager,
  9909. /** defines the predicate function used to validate the condition */
  9910. predicate: () => boolean);
  9911. /**
  9912. * @returns the validity of the predicate condition
  9913. */
  9914. isValid(): boolean;
  9915. }
  9916. /**
  9917. * Defines a state condition as an extension of Condition
  9918. */
  9919. export class StateCondition extends Condition {
  9920. /** Value to compare with target state */
  9921. value: string;
  9922. /**
  9923. * Internal only - manager for action
  9924. * @hidden
  9925. */
  9926. _actionManager: ActionManager;
  9927. /**
  9928. * Internal only
  9929. * @hidden
  9930. */
  9931. private _target;
  9932. /**
  9933. * Creates a new StateCondition
  9934. * @param actionManager manager for the action the condition applies to
  9935. * @param target of the condition
  9936. * @param value to compare with target state
  9937. */
  9938. constructor(actionManager: ActionManager, target: any,
  9939. /** Value to compare with target state */
  9940. value: string);
  9941. /**
  9942. * Gets a boolean indicating if the current condition is met
  9943. * @returns the validity of the state
  9944. */
  9945. isValid(): boolean;
  9946. /**
  9947. * Serialize the StateCondition into a JSON compatible object
  9948. * @returns serialization object
  9949. */
  9950. serialize(): any;
  9951. }
  9952. }
  9953. declare module "babylonjs/Actions/directActions" {
  9954. import { Action } from "babylonjs/Actions/action";
  9955. import { Condition } from "babylonjs/Actions/condition";
  9956. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9957. /**
  9958. * This defines an action responsible to toggle a boolean once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class SwitchBooleanAction extends Action {
  9962. /**
  9963. * The path to the boolean property in the target object
  9964. */
  9965. propertyPath: string;
  9966. private _target;
  9967. private _effectiveTarget;
  9968. private _property;
  9969. /**
  9970. * Instantiate the action
  9971. * @param triggerOptions defines the trigger options
  9972. * @param target defines the object containing the boolean
  9973. * @param propertyPath defines the path to the boolean property in the target object
  9974. * @param condition defines the trigger related conditions
  9975. */
  9976. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9977. /** @hidden */
  9978. _prepare(): void;
  9979. /**
  9980. * Execute the action toggle the boolean value.
  9981. */
  9982. execute(): void;
  9983. /**
  9984. * Serializes the actions and its related information.
  9985. * @param parent defines the object to serialize in
  9986. * @returns the serialized object
  9987. */
  9988. serialize(parent: any): any;
  9989. }
  9990. /**
  9991. * This defines an action responsible to set a the state field of the target
  9992. * to a desired value once triggered.
  9993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9994. */
  9995. export class SetStateAction extends Action {
  9996. /**
  9997. * The value to store in the state field.
  9998. */
  9999. value: string;
  10000. private _target;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the object containing the state property
  10005. * @param value defines the value to store in the state field
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10009. /**
  10010. * Execute the action and store the value on the target state property.
  10011. */
  10012. execute(): void;
  10013. /**
  10014. * Serializes the actions and its related information.
  10015. * @param parent defines the object to serialize in
  10016. * @returns the serialized object
  10017. */
  10018. serialize(parent: any): any;
  10019. }
  10020. /**
  10021. * This defines an action responsible to set a property of the target
  10022. * to a desired value once triggered.
  10023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class SetValueAction extends Action {
  10026. /**
  10027. * The path of the property to set in the target.
  10028. */
  10029. propertyPath: string;
  10030. /**
  10031. * The value to set in the property
  10032. */
  10033. value: any;
  10034. private _target;
  10035. private _effectiveTarget;
  10036. private _property;
  10037. /**
  10038. * Instantiate the action
  10039. * @param triggerOptions defines the trigger options
  10040. * @param target defines the object containing the property
  10041. * @param propertyPath defines the path of the property to set in the target
  10042. * @param value defines the value to set in the property
  10043. * @param condition defines the trigger related conditions
  10044. */
  10045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10046. /** @hidden */
  10047. _prepare(): void;
  10048. /**
  10049. * Execute the action and set the targetted property to the desired value.
  10050. */
  10051. execute(): void;
  10052. /**
  10053. * Serializes the actions and its related information.
  10054. * @param parent defines the object to serialize in
  10055. * @returns the serialized object
  10056. */
  10057. serialize(parent: any): any;
  10058. }
  10059. /**
  10060. * This defines an action responsible to increment the target value
  10061. * to a desired value once triggered.
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10063. */
  10064. export class IncrementValueAction extends Action {
  10065. /**
  10066. * The path of the property to increment in the target.
  10067. */
  10068. propertyPath: string;
  10069. /**
  10070. * The value we should increment the property by.
  10071. */
  10072. value: any;
  10073. private _target;
  10074. private _effectiveTarget;
  10075. private _property;
  10076. /**
  10077. * Instantiate the action
  10078. * @param triggerOptions defines the trigger options
  10079. * @param target defines the object containing the property
  10080. * @param propertyPath defines the path of the property to increment in the target
  10081. * @param value defines the value value we should increment the property by
  10082. * @param condition defines the trigger related conditions
  10083. */
  10084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10085. /** @hidden */
  10086. _prepare(): void;
  10087. /**
  10088. * Execute the action and increment the target of the value amount.
  10089. */
  10090. execute(): void;
  10091. /**
  10092. * Serializes the actions and its related information.
  10093. * @param parent defines the object to serialize in
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. }
  10098. /**
  10099. * This defines an action responsible to start an animation once triggered.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class PlayAnimationAction extends Action {
  10103. /**
  10104. * Where the animation should start (animation frame)
  10105. */
  10106. from: number;
  10107. /**
  10108. * Where the animation should stop (animation frame)
  10109. */
  10110. to: number;
  10111. /**
  10112. * Define if the animation should loop or stop after the first play.
  10113. */
  10114. loop?: boolean;
  10115. private _target;
  10116. /**
  10117. * Instantiate the action
  10118. * @param triggerOptions defines the trigger options
  10119. * @param target defines the target animation or animation name
  10120. * @param from defines from where the animation should start (animation frame)
  10121. * @param end defines where the animation should stop (animation frame)
  10122. * @param loop defines if the animation should loop or stop after the first play
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10126. /** @hidden */
  10127. _prepare(): void;
  10128. /**
  10129. * Execute the action and play the animation.
  10130. */
  10131. execute(): void;
  10132. /**
  10133. * Serializes the actions and its related information.
  10134. * @param parent defines the object to serialize in
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. }
  10139. /**
  10140. * This defines an action responsible to stop an animation once triggered.
  10141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10142. */
  10143. export class StopAnimationAction extends Action {
  10144. private _target;
  10145. /**
  10146. * Instantiate the action
  10147. * @param triggerOptions defines the trigger options
  10148. * @param target defines the target animation or animation name
  10149. * @param condition defines the trigger related conditions
  10150. */
  10151. constructor(triggerOptions: any, target: any, condition?: Condition);
  10152. /** @hidden */
  10153. _prepare(): void;
  10154. /**
  10155. * Execute the action and stop the animation.
  10156. */
  10157. execute(): void;
  10158. /**
  10159. * Serializes the actions and its related information.
  10160. * @param parent defines the object to serialize in
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. }
  10165. /**
  10166. * This defines an action responsible that does nothing once triggered.
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10168. */
  10169. export class DoNothingAction extends Action {
  10170. /**
  10171. * Instantiate the action
  10172. * @param triggerOptions defines the trigger options
  10173. * @param condition defines the trigger related conditions
  10174. */
  10175. constructor(triggerOptions?: any, condition?: Condition);
  10176. /**
  10177. * Execute the action and do nothing.
  10178. */
  10179. execute(): void;
  10180. /**
  10181. * Serializes the actions and its related information.
  10182. * @param parent defines the object to serialize in
  10183. * @returns the serialized object
  10184. */
  10185. serialize(parent: any): any;
  10186. }
  10187. /**
  10188. * This defines an action responsible to trigger several actions once triggered.
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10190. */
  10191. export class CombineAction extends Action {
  10192. /**
  10193. * The list of aggregated animations to run.
  10194. */
  10195. children: Action[];
  10196. /**
  10197. * Instantiate the action
  10198. * @param triggerOptions defines the trigger options
  10199. * @param children defines the list of aggregated animations to run
  10200. * @param condition defines the trigger related conditions
  10201. */
  10202. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10203. /** @hidden */
  10204. _prepare(): void;
  10205. /**
  10206. * Execute the action and executes all the aggregated actions.
  10207. */
  10208. execute(evt: ActionEvent): void;
  10209. /**
  10210. * Serializes the actions and its related information.
  10211. * @param parent defines the object to serialize in
  10212. * @returns the serialized object
  10213. */
  10214. serialize(parent: any): any;
  10215. }
  10216. /**
  10217. * This defines an action responsible to run code (external event) once triggered.
  10218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10219. */
  10220. export class ExecuteCodeAction extends Action {
  10221. /**
  10222. * The callback function to run.
  10223. */
  10224. func: (evt: ActionEvent) => void;
  10225. /**
  10226. * Instantiate the action
  10227. * @param triggerOptions defines the trigger options
  10228. * @param func defines the callback function to run
  10229. * @param condition defines the trigger related conditions
  10230. */
  10231. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10232. /**
  10233. * Execute the action and run the attached code.
  10234. */
  10235. execute(evt: ActionEvent): void;
  10236. }
  10237. /**
  10238. * This defines an action responsible to set the parent property of the target once triggered.
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10240. */
  10241. export class SetParentAction extends Action {
  10242. private _parent;
  10243. private _target;
  10244. /**
  10245. * Instantiate the action
  10246. * @param triggerOptions defines the trigger options
  10247. * @param target defines the target containing the parent property
  10248. * @param parent defines from where the animation should start (animation frame)
  10249. * @param condition defines the trigger related conditions
  10250. */
  10251. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10252. /** @hidden */
  10253. _prepare(): void;
  10254. /**
  10255. * Execute the action and set the parent property.
  10256. */
  10257. execute(): void;
  10258. /**
  10259. * Serializes the actions and its related information.
  10260. * @param parent defines the object to serialize in
  10261. * @returns the serialized object
  10262. */
  10263. serialize(parent: any): any;
  10264. }
  10265. }
  10266. declare module "babylonjs/Actions/actionManager" {
  10267. import { Nullable } from "babylonjs/types";
  10268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10269. import { Scene } from "babylonjs/scene";
  10270. import { IAction } from "babylonjs/Actions/action";
  10271. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10272. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10273. /**
  10274. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10275. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10277. */
  10278. export class ActionManager extends AbstractActionManager {
  10279. /**
  10280. * Nothing
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10282. */
  10283. static readonly NothingTrigger: number;
  10284. /**
  10285. * On pick
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnPickTrigger: number;
  10289. /**
  10290. * On left pick
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnLeftPickTrigger: number;
  10294. /**
  10295. * On right pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnRightPickTrigger: number;
  10299. /**
  10300. * On center pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnCenterPickTrigger: number;
  10304. /**
  10305. * On pick down
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnPickDownTrigger: number;
  10309. /**
  10310. * On double pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnDoublePickTrigger: number;
  10314. /**
  10315. * On pick up
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickUpTrigger: number;
  10319. /**
  10320. * On pick out.
  10321. * This trigger will only be raised if you also declared a OnPickDown
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickOutTrigger: number;
  10325. /**
  10326. * On long press
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnLongPressTrigger: number;
  10330. /**
  10331. * On pointer over
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPointerOverTrigger: number;
  10335. /**
  10336. * On pointer out
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnPointerOutTrigger: number;
  10340. /**
  10341. * On every frame
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnEveryFrameTrigger: number;
  10345. /**
  10346. * On intersection enter
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnIntersectionEnterTrigger: number;
  10350. /**
  10351. * On intersection exit
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnIntersectionExitTrigger: number;
  10355. /**
  10356. * On key down
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnKeyDownTrigger: number;
  10360. /**
  10361. * On key up
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnKeyUpTrigger: number;
  10365. private _scene;
  10366. /**
  10367. * Creates a new action manager
  10368. * @param scene defines the hosting scene
  10369. */
  10370. constructor(scene: Scene);
  10371. /**
  10372. * Releases all associated resources
  10373. */
  10374. dispose(): void;
  10375. /**
  10376. * Gets hosting scene
  10377. * @returns the hosting scene
  10378. */
  10379. getScene(): Scene;
  10380. /**
  10381. * Does this action manager handles actions of any of the given triggers
  10382. * @param triggers defines the triggers to be tested
  10383. * @return a boolean indicating whether one (or more) of the triggers is handled
  10384. */
  10385. hasSpecificTriggers(triggers: number[]): boolean;
  10386. /**
  10387. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10388. * speed.
  10389. * @param triggerA defines the trigger to be tested
  10390. * @param triggerB defines the trigger to be tested
  10391. * @return a boolean indicating whether one (or more) of the triggers is handled
  10392. */
  10393. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10394. /**
  10395. * Does this action manager handles actions of a given trigger
  10396. * @param trigger defines the trigger to be tested
  10397. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10398. * @return whether the trigger is handled
  10399. */
  10400. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10401. /**
  10402. * Does this action manager has pointer triggers
  10403. */
  10404. get hasPointerTriggers(): boolean;
  10405. /**
  10406. * Does this action manager has pick triggers
  10407. */
  10408. get hasPickTriggers(): boolean;
  10409. /**
  10410. * Registers an action to this action manager
  10411. * @param action defines the action to be registered
  10412. * @return the action amended (prepared) after registration
  10413. */
  10414. registerAction(action: IAction): Nullable<IAction>;
  10415. /**
  10416. * Unregisters an action to this action manager
  10417. * @param action defines the action to be unregistered
  10418. * @return a boolean indicating whether the action has been unregistered
  10419. */
  10420. unregisterAction(action: IAction): Boolean;
  10421. /**
  10422. * Process a specific trigger
  10423. * @param trigger defines the trigger to process
  10424. * @param evt defines the event details to be processed
  10425. */
  10426. processTrigger(trigger: number, evt?: IActionEvent): void;
  10427. /** @hidden */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /** @hidden */
  10430. _getProperty(propertyPath: string): string;
  10431. /**
  10432. * Serialize this manager to a JSON object
  10433. * @param name defines the property name to store this manager
  10434. * @returns a JSON representation of this manager
  10435. */
  10436. serialize(name: string): any;
  10437. /**
  10438. * Creates a new ActionManager from a JSON data
  10439. * @param parsedActions defines the JSON data to read from
  10440. * @param object defines the hosting mesh
  10441. * @param scene defines the hosting scene
  10442. */
  10443. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10444. /**
  10445. * Get a trigger name by index
  10446. * @param trigger defines the trigger index
  10447. * @returns a trigger name
  10448. */
  10449. static GetTriggerName(trigger: number): string;
  10450. }
  10451. }
  10452. declare module "babylonjs/Sprites/sprite" {
  10453. import { Vector3 } from "babylonjs/Maths/math.vector";
  10454. import { Nullable } from "babylonjs/types";
  10455. import { ActionManager } from "babylonjs/Actions/actionManager";
  10456. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10457. import { Color4 } from "babylonjs/Maths/math.color";
  10458. import { Observable } from "babylonjs/Misc/observable";
  10459. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10460. import { Animation } from "babylonjs/Animations/animation";
  10461. /**
  10462. * Class used to represent a sprite
  10463. * @see https://doc.babylonjs.com/babylon101/sprites
  10464. */
  10465. export class Sprite implements IAnimatable {
  10466. /** defines the name */
  10467. name: string;
  10468. /** Gets or sets the current world position */
  10469. position: Vector3;
  10470. /** Gets or sets the main color */
  10471. color: Color4;
  10472. /** Gets or sets the width */
  10473. width: number;
  10474. /** Gets or sets the height */
  10475. height: number;
  10476. /** Gets or sets rotation angle */
  10477. angle: number;
  10478. /** Gets or sets the cell index in the sprite sheet */
  10479. cellIndex: number;
  10480. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10481. cellRef: string;
  10482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10483. invertU: boolean;
  10484. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10485. invertV: boolean;
  10486. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10487. disposeWhenFinishedAnimating: boolean;
  10488. /** Gets the list of attached animations */
  10489. animations: Nullable<Array<Animation>>;
  10490. /** Gets or sets a boolean indicating if the sprite can be picked */
  10491. isPickable: boolean;
  10492. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10493. useAlphaForPicking: boolean;
  10494. /** @hidden */
  10495. _xOffset: number;
  10496. /** @hidden */
  10497. _yOffset: number;
  10498. /** @hidden */
  10499. _xSize: number;
  10500. /** @hidden */
  10501. _ySize: number;
  10502. /**
  10503. * Gets or sets the associated action manager
  10504. */
  10505. actionManager: Nullable<ActionManager>;
  10506. /**
  10507. * An event triggered when the control has been disposed
  10508. */
  10509. onDisposeObservable: Observable<Sprite>;
  10510. private _animationStarted;
  10511. private _loopAnimation;
  10512. private _fromIndex;
  10513. private _toIndex;
  10514. private _delay;
  10515. private _direction;
  10516. private _manager;
  10517. private _time;
  10518. private _onAnimationEnd;
  10519. /**
  10520. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10521. */
  10522. isVisible: boolean;
  10523. /**
  10524. * Gets or sets the sprite size
  10525. */
  10526. get size(): number;
  10527. set size(value: number);
  10528. /**
  10529. * Returns a boolean indicating if the animation is started
  10530. */
  10531. get animationStarted(): boolean;
  10532. /**
  10533. * Gets or sets the unique id of the sprite
  10534. */
  10535. uniqueId: number;
  10536. /**
  10537. * Gets the manager of this sprite
  10538. */
  10539. get manager(): ISpriteManager;
  10540. /**
  10541. * Creates a new Sprite
  10542. * @param name defines the name
  10543. * @param manager defines the manager
  10544. */
  10545. constructor(
  10546. /** defines the name */
  10547. name: string, manager: ISpriteManager);
  10548. /**
  10549. * Returns the string "Sprite"
  10550. * @returns "Sprite"
  10551. */
  10552. getClassName(): string;
  10553. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10554. get fromIndex(): number;
  10555. set fromIndex(value: number);
  10556. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10557. get toIndex(): number;
  10558. set toIndex(value: number);
  10559. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10560. get loopAnimation(): boolean;
  10561. set loopAnimation(value: boolean);
  10562. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10563. get delay(): number;
  10564. set delay(value: number);
  10565. /**
  10566. * Starts an animation
  10567. * @param from defines the initial key
  10568. * @param to defines the end key
  10569. * @param loop defines if the animation must loop
  10570. * @param delay defines the start delay (in ms)
  10571. * @param onAnimationEnd defines a callback to call when animation ends
  10572. */
  10573. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10574. /** Stops current animation (if any) */
  10575. stopAnimation(): void;
  10576. /** @hidden */
  10577. _animate(deltaTime: number): void;
  10578. /** Release associated resources */
  10579. dispose(): void;
  10580. /**
  10581. * Serializes the sprite to a JSON object
  10582. * @returns the JSON object
  10583. */
  10584. serialize(): any;
  10585. /**
  10586. * Parses a JSON object to create a new sprite
  10587. * @param parsedSprite The JSON object to parse
  10588. * @param manager defines the hosting manager
  10589. * @returns the new sprite
  10590. */
  10591. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10592. }
  10593. }
  10594. declare module "babylonjs/Collisions/pickingInfo" {
  10595. import { Nullable } from "babylonjs/types";
  10596. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10598. import { Sprite } from "babylonjs/Sprites/sprite";
  10599. import { Ray } from "babylonjs/Culling/ray";
  10600. /**
  10601. * Information about the result of picking within a scene
  10602. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10603. */
  10604. export class PickingInfo {
  10605. /** @hidden */
  10606. _pickingUnavailable: boolean;
  10607. /**
  10608. * If the pick collided with an object
  10609. */
  10610. hit: boolean;
  10611. /**
  10612. * Distance away where the pick collided
  10613. */
  10614. distance: number;
  10615. /**
  10616. * The location of pick collision
  10617. */
  10618. pickedPoint: Nullable<Vector3>;
  10619. /**
  10620. * The mesh corresponding the the pick collision
  10621. */
  10622. pickedMesh: Nullable<AbstractMesh>;
  10623. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10624. bu: number;
  10625. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10626. bv: number;
  10627. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10628. faceId: number;
  10629. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10630. subMeshFaceId: number;
  10631. /** Id of the the submesh that was picked */
  10632. subMeshId: number;
  10633. /** If a sprite was picked, this will be the sprite the pick collided with */
  10634. pickedSprite: Nullable<Sprite>;
  10635. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10636. thinInstanceIndex: number;
  10637. /**
  10638. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10639. */
  10640. originMesh: Nullable<AbstractMesh>;
  10641. /**
  10642. * The ray that was used to perform the picking.
  10643. */
  10644. ray: Nullable<Ray>;
  10645. /**
  10646. * Gets the normal correspodning to the face the pick collided with
  10647. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10648. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10649. * @returns The normal correspodning to the face the pick collided with
  10650. */
  10651. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10652. /**
  10653. * Gets the texture coordinates of where the pick occured
  10654. * @returns the vector containing the coordnates of the texture
  10655. */
  10656. getTextureCoordinates(): Nullable<Vector2>;
  10657. }
  10658. }
  10659. declare module "babylonjs/Culling/ray" {
  10660. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10663. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10664. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10665. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10666. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10667. import { Plane } from "babylonjs/Maths/math.plane";
  10668. /**
  10669. * Class representing a ray with position and direction
  10670. */
  10671. export class Ray {
  10672. /** origin point */
  10673. origin: Vector3;
  10674. /** direction */
  10675. direction: Vector3;
  10676. /** length of the ray */
  10677. length: number;
  10678. private static readonly _TmpVector3;
  10679. private _tmpRay;
  10680. /**
  10681. * Creates a new ray
  10682. * @param origin origin point
  10683. * @param direction direction
  10684. * @param length length of the ray
  10685. */
  10686. constructor(
  10687. /** origin point */
  10688. origin: Vector3,
  10689. /** direction */
  10690. direction: Vector3,
  10691. /** length of the ray */
  10692. length?: number);
  10693. /**
  10694. * Checks if the ray intersects a box
  10695. * This does not account for the ray lenght by design to improve perfs.
  10696. * @param minimum bound of the box
  10697. * @param maximum bound of the box
  10698. * @param intersectionTreshold extra extend to be added to the box in all direction
  10699. * @returns if the box was hit
  10700. */
  10701. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10702. /**
  10703. * Checks if the ray intersects a box
  10704. * This does not account for the ray lenght by design to improve perfs.
  10705. * @param box the bounding box to check
  10706. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10707. * @returns if the box was hit
  10708. */
  10709. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10710. /**
  10711. * If the ray hits a sphere
  10712. * @param sphere the bounding sphere to check
  10713. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10714. * @returns true if it hits the sphere
  10715. */
  10716. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10717. /**
  10718. * If the ray hits a triange
  10719. * @param vertex0 triangle vertex
  10720. * @param vertex1 triangle vertex
  10721. * @param vertex2 triangle vertex
  10722. * @returns intersection information if hit
  10723. */
  10724. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10725. /**
  10726. * Checks if ray intersects a plane
  10727. * @param plane the plane to check
  10728. * @returns the distance away it was hit
  10729. */
  10730. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10731. /**
  10732. * Calculate the intercept of a ray on a given axis
  10733. * @param axis to check 'x' | 'y' | 'z'
  10734. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10735. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10736. */
  10737. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10738. /**
  10739. * Checks if ray intersects a mesh
  10740. * @param mesh the mesh to check
  10741. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10742. * @returns picking info of the intersecton
  10743. */
  10744. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10745. /**
  10746. * Checks if ray intersects a mesh
  10747. * @param meshes the meshes to check
  10748. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10749. * @param results array to store result in
  10750. * @returns Array of picking infos
  10751. */
  10752. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10753. private _comparePickingInfo;
  10754. private static smallnum;
  10755. private static rayl;
  10756. /**
  10757. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10758. * @param sega the first point of the segment to test the intersection against
  10759. * @param segb the second point of the segment to test the intersection against
  10760. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10761. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10762. */
  10763. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10764. /**
  10765. * Update the ray from viewport position
  10766. * @param x position
  10767. * @param y y position
  10768. * @param viewportWidth viewport width
  10769. * @param viewportHeight viewport height
  10770. * @param world world matrix
  10771. * @param view view matrix
  10772. * @param projection projection matrix
  10773. * @returns this ray updated
  10774. */
  10775. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10776. /**
  10777. * Creates a ray with origin and direction of 0,0,0
  10778. * @returns the new ray
  10779. */
  10780. static Zero(): Ray;
  10781. /**
  10782. * Creates a new ray from screen space and viewport
  10783. * @param x position
  10784. * @param y y position
  10785. * @param viewportWidth viewport width
  10786. * @param viewportHeight viewport height
  10787. * @param world world matrix
  10788. * @param view view matrix
  10789. * @param projection projection matrix
  10790. * @returns new ray
  10791. */
  10792. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10793. /**
  10794. * 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
  10795. * transformed to the given world matrix.
  10796. * @param origin The origin point
  10797. * @param end The end point
  10798. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10799. * @returns the new ray
  10800. */
  10801. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10802. /**
  10803. * Transforms a ray by a matrix
  10804. * @param ray ray to transform
  10805. * @param matrix matrix to apply
  10806. * @returns the resulting new ray
  10807. */
  10808. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Transforms a ray by a matrix
  10811. * @param ray ray to transform
  10812. * @param matrix matrix to apply
  10813. * @param result ray to store result in
  10814. */
  10815. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10816. /**
  10817. * Unproject a ray from screen space to object space
  10818. * @param sourceX defines the screen space x coordinate to use
  10819. * @param sourceY defines the screen space y coordinate to use
  10820. * @param viewportWidth defines the current width of the viewport
  10821. * @param viewportHeight defines the current height of the viewport
  10822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10823. * @param view defines the view matrix to use
  10824. * @param projection defines the projection matrix to use
  10825. */
  10826. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10827. }
  10828. /**
  10829. * Type used to define predicate used to select faces when a mesh intersection is detected
  10830. */
  10831. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10832. module "babylonjs/scene" {
  10833. interface Scene {
  10834. /** @hidden */
  10835. _tempPickingRay: Nullable<Ray>;
  10836. /** @hidden */
  10837. _cachedRayForTransform: Ray;
  10838. /** @hidden */
  10839. _pickWithRayInverseMatrix: Matrix;
  10840. /** @hidden */
  10841. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10842. /** @hidden */
  10843. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10844. /** @hidden */
  10845. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10846. }
  10847. }
  10848. }
  10849. declare module "babylonjs/sceneComponent" {
  10850. import { Scene } from "babylonjs/scene";
  10851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10853. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10854. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10855. import { Nullable } from "babylonjs/types";
  10856. import { Camera } from "babylonjs/Cameras/camera";
  10857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10858. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10859. import { AbstractScene } from "babylonjs/abstractScene";
  10860. import { Mesh } from "babylonjs/Meshes/mesh";
  10861. /**
  10862. * Groups all the scene component constants in one place to ease maintenance.
  10863. * @hidden
  10864. */
  10865. export class SceneComponentConstants {
  10866. static readonly NAME_EFFECTLAYER: string;
  10867. static readonly NAME_LAYER: string;
  10868. static readonly NAME_LENSFLARESYSTEM: string;
  10869. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10870. static readonly NAME_PARTICLESYSTEM: string;
  10871. static readonly NAME_GAMEPAD: string;
  10872. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10873. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10874. static readonly NAME_PREPASSRENDERER: string;
  10875. static readonly NAME_DEPTHRENDERER: string;
  10876. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10877. static readonly NAME_SPRITE: string;
  10878. static readonly NAME_SUBSURFACE: string;
  10879. static readonly NAME_OUTLINERENDERER: string;
  10880. static readonly NAME_PROCEDURALTEXTURE: string;
  10881. static readonly NAME_SHADOWGENERATOR: string;
  10882. static readonly NAME_OCTREE: string;
  10883. static readonly NAME_PHYSICSENGINE: string;
  10884. static readonly NAME_AUDIO: string;
  10885. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10886. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10887. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10888. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10889. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10890. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10891. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10892. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10893. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10894. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10895. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10896. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10897. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10899. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10900. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10901. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10902. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10903. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10904. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10905. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10906. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10907. static readonly STEP_AFTERRENDER_AUDIO: number;
  10908. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10909. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10910. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10911. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10912. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10913. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10914. static readonly STEP_POINTERMOVE_SPRITE: number;
  10915. static readonly STEP_POINTERDOWN_SPRITE: number;
  10916. static readonly STEP_POINTERUP_SPRITE: number;
  10917. }
  10918. /**
  10919. * This represents a scene component.
  10920. *
  10921. * This is used to decouple the dependency the scene is having on the different workloads like
  10922. * layers, post processes...
  10923. */
  10924. export interface ISceneComponent {
  10925. /**
  10926. * The name of the component. Each component must have a unique name.
  10927. */
  10928. name: string;
  10929. /**
  10930. * The scene the component belongs to.
  10931. */
  10932. scene: Scene;
  10933. /**
  10934. * Register the component to one instance of a scene.
  10935. */
  10936. register(): void;
  10937. /**
  10938. * Rebuilds the elements related to this component in case of
  10939. * context lost for instance.
  10940. */
  10941. rebuild(): void;
  10942. /**
  10943. * Disposes the component and the associated ressources.
  10944. */
  10945. dispose(): void;
  10946. }
  10947. /**
  10948. * This represents a SERIALIZABLE scene component.
  10949. *
  10950. * This extends Scene Component to add Serialization methods on top.
  10951. */
  10952. export interface ISceneSerializableComponent extends ISceneComponent {
  10953. /**
  10954. * Adds all the elements from the container to the scene
  10955. * @param container the container holding the elements
  10956. */
  10957. addFromContainer(container: AbstractScene): void;
  10958. /**
  10959. * Removes all the elements in the container from the scene
  10960. * @param container contains the elements to remove
  10961. * @param dispose if the removed element should be disposed (default: false)
  10962. */
  10963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10964. /**
  10965. * Serializes the component data to the specified json object
  10966. * @param serializationObject The object to serialize to
  10967. */
  10968. serialize(serializationObject: any): void;
  10969. }
  10970. /**
  10971. * Strong typing of a Mesh related stage step action
  10972. */
  10973. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10974. /**
  10975. * Strong typing of a Evaluate Sub Mesh related stage step action
  10976. */
  10977. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10978. /**
  10979. * Strong typing of a Active Mesh related stage step action
  10980. */
  10981. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10982. /**
  10983. * Strong typing of a Camera related stage step action
  10984. */
  10985. export type CameraStageAction = (camera: Camera) => void;
  10986. /**
  10987. * Strong typing of a Camera Frame buffer related stage step action
  10988. */
  10989. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10990. /**
  10991. * Strong typing of a Render Target related stage step action
  10992. */
  10993. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10994. /**
  10995. * Strong typing of a RenderingGroup related stage step action
  10996. */
  10997. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10998. /**
  10999. * Strong typing of a Mesh Render related stage step action
  11000. */
  11001. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11002. /**
  11003. * Strong typing of a simple stage step action
  11004. */
  11005. export type SimpleStageAction = () => void;
  11006. /**
  11007. * Strong typing of a render target action.
  11008. */
  11009. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11010. /**
  11011. * Strong typing of a pointer move action.
  11012. */
  11013. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11014. /**
  11015. * Strong typing of a pointer up/down action.
  11016. */
  11017. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11018. /**
  11019. * Representation of a stage in the scene (Basically a list of ordered steps)
  11020. * @hidden
  11021. */
  11022. export class Stage<T extends Function> extends Array<{
  11023. index: number;
  11024. component: ISceneComponent;
  11025. action: T;
  11026. }> {
  11027. /**
  11028. * Hide ctor from the rest of the world.
  11029. * @param items The items to add.
  11030. */
  11031. private constructor();
  11032. /**
  11033. * Creates a new Stage.
  11034. * @returns A new instance of a Stage
  11035. */
  11036. static Create<T extends Function>(): Stage<T>;
  11037. /**
  11038. * Registers a step in an ordered way in the targeted stage.
  11039. * @param index Defines the position to register the step in
  11040. * @param component Defines the component attached to the step
  11041. * @param action Defines the action to launch during the step
  11042. */
  11043. registerStep(index: number, component: ISceneComponent, action: T): void;
  11044. /**
  11045. * Clears all the steps from the stage.
  11046. */
  11047. clear(): void;
  11048. }
  11049. }
  11050. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11051. import { Nullable } from "babylonjs/types";
  11052. import { Observable } from "babylonjs/Misc/observable";
  11053. import { Scene } from "babylonjs/scene";
  11054. import { Sprite } from "babylonjs/Sprites/sprite";
  11055. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11056. import { Ray } from "babylonjs/Culling/ray";
  11057. import { Camera } from "babylonjs/Cameras/camera";
  11058. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11059. import { ISceneComponent } from "babylonjs/sceneComponent";
  11060. module "babylonjs/scene" {
  11061. interface Scene {
  11062. /** @hidden */
  11063. _pointerOverSprite: Nullable<Sprite>;
  11064. /** @hidden */
  11065. _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */
  11067. _tempSpritePickingRay: Nullable<Ray>;
  11068. /**
  11069. * All of the sprite managers added to this scene
  11070. * @see https://doc.babylonjs.com/babylon101/sprites
  11071. */
  11072. spriteManagers: Array<ISpriteManager>;
  11073. /**
  11074. * An event triggered when sprites rendering is about to start
  11075. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11076. */
  11077. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11078. /**
  11079. * An event triggered when sprites rendering is done
  11080. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11081. */
  11082. onAfterSpritesRenderingObservable: Observable<Scene>;
  11083. /** @hidden */
  11084. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11085. /** Launch a ray to try to pick a sprite 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 fastCheck defines if the first intersection will be used (and not the closest)
  11090. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11091. * @returns a PickingInfo
  11092. */
  11093. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11094. /** Use the given ray to pick a sprite in the scene
  11095. * @param ray The ray (in world space) to use to pick meshes
  11096. * @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
  11097. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11098. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11099. * @returns a PickingInfo
  11100. */
  11101. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11102. /** @hidden */
  11103. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11104. /** Launch a ray to try to pick sprites in the scene
  11105. * @param x position on screen
  11106. * @param y position on screen
  11107. * @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
  11108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo array
  11110. */
  11111. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11112. /** Use the given ray to pick sprites in the scene
  11113. * @param ray The ray (in world space) to use to pick meshes
  11114. * @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
  11115. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11116. * @returns a PickingInfo array
  11117. */
  11118. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11119. /**
  11120. * Force the sprite under the pointer
  11121. * @param sprite defines the sprite to use
  11122. */
  11123. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11124. /**
  11125. * Gets the sprite under the pointer
  11126. * @returns a Sprite or null if no sprite is under the pointer
  11127. */
  11128. getPointerOverSprite(): Nullable<Sprite>;
  11129. }
  11130. }
  11131. /**
  11132. * Defines the sprite scene component responsible to manage sprites
  11133. * in a given scene.
  11134. */
  11135. export class SpriteSceneComponent implements ISceneComponent {
  11136. /**
  11137. * The component name helpfull to identify the component in the list of scene components.
  11138. */
  11139. readonly name: string;
  11140. /**
  11141. * The scene the component belongs to.
  11142. */
  11143. scene: Scene;
  11144. /** @hidden */
  11145. private _spritePredicate;
  11146. /**
  11147. * Creates a new instance of the component for the given scene
  11148. * @param scene Defines the scene to register the component in
  11149. */
  11150. constructor(scene: Scene);
  11151. /**
  11152. * Registers the component in a given scene
  11153. */
  11154. register(): void;
  11155. /**
  11156. * Rebuilds the elements related to this component in case of
  11157. * context lost for instance.
  11158. */
  11159. rebuild(): void;
  11160. /**
  11161. * Disposes the component and the associated ressources.
  11162. */
  11163. dispose(): void;
  11164. private _pickSpriteButKeepRay;
  11165. private _pointerMove;
  11166. private _pointerDown;
  11167. private _pointerUp;
  11168. }
  11169. }
  11170. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11171. /** @hidden */
  11172. export var fogFragmentDeclaration: {
  11173. name: string;
  11174. shader: string;
  11175. };
  11176. }
  11177. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11178. /** @hidden */
  11179. export var fogFragment: {
  11180. name: string;
  11181. shader: string;
  11182. };
  11183. }
  11184. declare module "babylonjs/Shaders/sprites.fragment" {
  11185. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11186. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11187. /** @hidden */
  11188. export var spritesPixelShader: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11194. /** @hidden */
  11195. export var fogVertexDeclaration: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/sprites.vertex" {
  11201. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11202. /** @hidden */
  11203. export var spritesVertexShader: {
  11204. name: string;
  11205. shader: string;
  11206. };
  11207. }
  11208. declare module "babylonjs/Sprites/spriteManager" {
  11209. import { IDisposable, Scene } from "babylonjs/scene";
  11210. import { Nullable } from "babylonjs/types";
  11211. import { Observable } from "babylonjs/Misc/observable";
  11212. import { Sprite } from "babylonjs/Sprites/sprite";
  11213. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11214. import { Camera } from "babylonjs/Cameras/camera";
  11215. import { Texture } from "babylonjs/Materials/Textures/texture";
  11216. import "babylonjs/Shaders/sprites.fragment";
  11217. import "babylonjs/Shaders/sprites.vertex";
  11218. import { Ray } from "babylonjs/Culling/ray";
  11219. /**
  11220. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11221. */
  11222. export interface ISpriteManager extends IDisposable {
  11223. /**
  11224. * Gets manager's name
  11225. */
  11226. name: string;
  11227. /**
  11228. * Restricts the camera to viewing objects with the same layerMask.
  11229. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11230. */
  11231. layerMask: number;
  11232. /**
  11233. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11234. */
  11235. isPickable: boolean;
  11236. /**
  11237. * Gets the hosting scene
  11238. */
  11239. scene: Scene;
  11240. /**
  11241. * Specifies the rendering group id for this mesh (0 by default)
  11242. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11243. */
  11244. renderingGroupId: number;
  11245. /**
  11246. * Defines the list of sprites managed by the manager.
  11247. */
  11248. sprites: Array<Sprite>;
  11249. /**
  11250. * Gets or sets the spritesheet texture
  11251. */
  11252. texture: Texture;
  11253. /** Defines the default width of a cell in the spritesheet */
  11254. cellWidth: number;
  11255. /** Defines the default height of a cell in the spritesheet */
  11256. cellHeight: number;
  11257. /**
  11258. * Tests the intersection of a sprite with a specific ray.
  11259. * @param ray The ray we are sending to test the collision
  11260. * @param camera The camera space we are sending rays in
  11261. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11262. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11263. * @returns picking info or null.
  11264. */
  11265. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11266. /**
  11267. * Intersects the sprites with a ray
  11268. * @param ray defines the ray to intersect with
  11269. * @param camera defines the current active camera
  11270. * @param predicate defines a predicate used to select candidate sprites
  11271. * @returns null if no hit or a PickingInfo array
  11272. */
  11273. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11274. /**
  11275. * Renders the list of sprites on screen.
  11276. */
  11277. render(): void;
  11278. }
  11279. /**
  11280. * Class used to manage multiple sprites on the same spritesheet
  11281. * @see https://doc.babylonjs.com/babylon101/sprites
  11282. */
  11283. export class SpriteManager implements ISpriteManager {
  11284. /** defines the manager's name */
  11285. name: string;
  11286. /** Define the Url to load snippets */
  11287. static SnippetUrl: string;
  11288. /** Snippet ID if the manager was created from the snippet server */
  11289. snippetId: string;
  11290. /** Gets the list of sprites */
  11291. sprites: Sprite[];
  11292. /** Gets or sets the rendering group id (0 by default) */
  11293. renderingGroupId: number;
  11294. /** Gets or sets camera layer mask */
  11295. layerMask: number;
  11296. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11297. fogEnabled: boolean;
  11298. /** Gets or sets a boolean indicating if the sprites are pickable */
  11299. isPickable: boolean;
  11300. /** Defines the default width of a cell in the spritesheet */
  11301. cellWidth: number;
  11302. /** Defines the default height of a cell in the spritesheet */
  11303. cellHeight: number;
  11304. /** Associative array from JSON sprite data file */
  11305. private _cellData;
  11306. /** Array of sprite names from JSON sprite data file */
  11307. private _spriteMap;
  11308. /** True when packed cell data from JSON file is ready*/
  11309. private _packedAndReady;
  11310. private _textureContent;
  11311. private _useInstancing;
  11312. /**
  11313. * An event triggered when the manager is disposed.
  11314. */
  11315. onDisposeObservable: Observable<SpriteManager>;
  11316. private _onDisposeObserver;
  11317. /**
  11318. * Callback called when the manager is disposed
  11319. */
  11320. set onDispose(callback: () => void);
  11321. private _capacity;
  11322. private _fromPacked;
  11323. private _spriteTexture;
  11324. private _epsilon;
  11325. private _scene;
  11326. private _vertexData;
  11327. private _buffer;
  11328. private _vertexBuffers;
  11329. private _spriteBuffer;
  11330. private _indexBuffer;
  11331. private _effectBase;
  11332. private _effectFog;
  11333. private _vertexBufferSize;
  11334. /**
  11335. * Gets or sets the unique id of the sprite
  11336. */
  11337. uniqueId: number;
  11338. /**
  11339. * Gets the array of sprites
  11340. */
  11341. get children(): Sprite[];
  11342. /**
  11343. * Gets the hosting scene
  11344. */
  11345. get scene(): Scene;
  11346. /**
  11347. * Gets the capacity of the manager
  11348. */
  11349. get capacity(): number;
  11350. /**
  11351. * Gets or sets the spritesheet texture
  11352. */
  11353. get texture(): Texture;
  11354. set texture(value: Texture);
  11355. private _blendMode;
  11356. /**
  11357. * Blend mode use to render the particle, it can be any of
  11358. * the static Constants.ALPHA_x properties provided in this class.
  11359. * Default value is Constants.ALPHA_COMBINE
  11360. */
  11361. get blendMode(): number;
  11362. set blendMode(blendMode: number);
  11363. /** Disables writing to the depth buffer when rendering the sprites.
  11364. * It can be handy to disable depth writing when using textures without alpha channel
  11365. * and setting some specific blend modes.
  11366. */
  11367. disableDepthWrite: boolean;
  11368. /**
  11369. * Creates a new sprite manager
  11370. * @param name defines the manager's name
  11371. * @param imgUrl defines the sprite sheet url
  11372. * @param capacity defines the maximum allowed number of sprites
  11373. * @param cellSize defines the size of a sprite cell
  11374. * @param scene defines the hosting scene
  11375. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11376. * @param samplingMode defines the smapling mode to use with spritesheet
  11377. * @param fromPacked set to false; do not alter
  11378. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11379. */
  11380. constructor(
  11381. /** defines the manager's name */
  11382. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11383. /**
  11384. * Returns the string "SpriteManager"
  11385. * @returns "SpriteManager"
  11386. */
  11387. getClassName(): string;
  11388. private _makePacked;
  11389. private _appendSpriteVertex;
  11390. private _checkTextureAlpha;
  11391. /**
  11392. * Intersects the sprites with a ray
  11393. * @param ray defines the ray to intersect with
  11394. * @param camera defines the current active camera
  11395. * @param predicate defines a predicate used to select candidate sprites
  11396. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11397. * @returns null if no hit or a PickingInfo
  11398. */
  11399. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11400. /**
  11401. * Intersects the sprites with a ray
  11402. * @param ray defines the ray to intersect with
  11403. * @param camera defines the current active camera
  11404. * @param predicate defines a predicate used to select candidate sprites
  11405. * @returns null if no hit or a PickingInfo array
  11406. */
  11407. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11408. /**
  11409. * Render all child sprites
  11410. */
  11411. render(): void;
  11412. /**
  11413. * Release associated resources
  11414. */
  11415. dispose(): void;
  11416. /**
  11417. * Serializes the sprite manager to a JSON object
  11418. * @param serializeTexture defines if the texture must be serialized as well
  11419. * @returns the JSON object
  11420. */
  11421. serialize(serializeTexture?: boolean): any;
  11422. /**
  11423. * Parses a JSON object to create a new sprite manager.
  11424. * @param parsedManager The JSON object to parse
  11425. * @param scene The scene to create the sprite managerin
  11426. * @param rootUrl The root url to use to load external dependencies like texture
  11427. * @returns the new sprite manager
  11428. */
  11429. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11430. /**
  11431. * Creates a sprite manager from a snippet saved in a remote file
  11432. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11433. * @param url defines the url to load from
  11434. * @param scene defines the hosting scene
  11435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11436. * @returns a promise that will resolve to the new sprite manager
  11437. */
  11438. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11439. /**
  11440. * Creates a sprite manager from a snippet saved by the sprite editor
  11441. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11442. * @param scene defines the hosting scene
  11443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11444. * @returns a promise that will resolve to the new sprite manager
  11445. */
  11446. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11447. }
  11448. }
  11449. declare module "babylonjs/Misc/gradients" {
  11450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11451. /** Interface used by value gradients (color, factor, ...) */
  11452. export interface IValueGradient {
  11453. /**
  11454. * Gets or sets the gradient value (between 0 and 1)
  11455. */
  11456. gradient: number;
  11457. }
  11458. /** Class used to store color4 gradient */
  11459. export class ColorGradient implements IValueGradient {
  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. * Creates a new color4 gradient
  11474. * @param gradient gets or sets the gradient value (between 0 and 1)
  11475. * @param color1 gets or sets first associated color
  11476. * @param color2 gets or sets first second color
  11477. */
  11478. constructor(
  11479. /**
  11480. * Gets or sets the gradient value (between 0 and 1)
  11481. */
  11482. gradient: number,
  11483. /**
  11484. * Gets or sets first associated color
  11485. */
  11486. color1: Color4,
  11487. /**
  11488. * Gets or sets second associated color
  11489. */
  11490. color2?: Color4 | undefined);
  11491. /**
  11492. * Will get a color picked randomly between color1 and color2.
  11493. * If color2 is undefined then color1 will be used
  11494. * @param result defines the target Color4 to store the result in
  11495. */
  11496. getColorToRef(result: Color4): void;
  11497. }
  11498. /** Class used to store color 3 gradient */
  11499. export class Color3Gradient implements IValueGradient {
  11500. /**
  11501. * Gets or sets the gradient value (between 0 and 1)
  11502. */
  11503. gradient: number;
  11504. /**
  11505. * Gets or sets the associated color
  11506. */
  11507. color: Color3;
  11508. /**
  11509. * Creates a new color3 gradient
  11510. * @param gradient gets or sets the gradient value (between 0 and 1)
  11511. * @param color gets or sets associated color
  11512. */
  11513. constructor(
  11514. /**
  11515. * Gets or sets the gradient value (between 0 and 1)
  11516. */
  11517. gradient: number,
  11518. /**
  11519. * Gets or sets the associated color
  11520. */
  11521. color: Color3);
  11522. }
  11523. /** Class used to store factor gradient */
  11524. export class FactorGradient implements IValueGradient {
  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. * Creates a new factor gradient
  11539. * @param gradient gets or sets the gradient value (between 0 and 1)
  11540. * @param factor1 gets or sets first associated factor
  11541. * @param factor2 gets or sets second associated factor
  11542. */
  11543. constructor(
  11544. /**
  11545. * Gets or sets the gradient value (between 0 and 1)
  11546. */
  11547. gradient: number,
  11548. /**
  11549. * Gets or sets first associated factor
  11550. */
  11551. factor1: number,
  11552. /**
  11553. * Gets or sets second associated factor
  11554. */
  11555. factor2?: number | undefined);
  11556. /**
  11557. * Will get a number picked randomly between factor1 and factor2.
  11558. * If factor2 is undefined then factor1 will be used
  11559. * @returns the picked number
  11560. */
  11561. getFactor(): number;
  11562. }
  11563. /**
  11564. * Helper used to simplify some generic gradient tasks
  11565. */
  11566. export class GradientHelper {
  11567. /**
  11568. * Gets the current gradient from an array of IValueGradient
  11569. * @param ratio defines the current ratio to get
  11570. * @param gradients defines the array of IValueGradient
  11571. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11572. */
  11573. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11574. }
  11575. }
  11576. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11577. import { Nullable } from "babylonjs/types";
  11578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11579. import { Scene } from "babylonjs/scene";
  11580. module "babylonjs/Engines/thinEngine" {
  11581. interface ThinEngine {
  11582. /**
  11583. * Creates a raw texture
  11584. * @param data defines the data to store in the texture
  11585. * @param width defines the width of the texture
  11586. * @param height defines the height of the texture
  11587. * @param format defines the format of the data
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  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. * @returns the raw texture inside an InternalTexture
  11594. */
  11595. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11596. /**
  11597. * Update a raw texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store in the texture
  11600. * @param format defines the format of the data
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw texture
  11606. * @param texture defines the texture to update
  11607. * @param data defines the data to store in the texture
  11608. * @param format defines the format of the data
  11609. * @param invertY defines if data must be stored with Y axis inverted
  11610. * @param compression defines the compression used (null by default)
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11614. /**
  11615. * Creates a new raw cube texture
  11616. * @param data defines the array of data to use to create each face
  11617. * @param size defines the size of the textures
  11618. * @param format defines the format of the data
  11619. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11620. * @param generateMipMaps defines if the engine should generate the mip levels
  11621. * @param invertY defines if data must be stored with Y axis inverted
  11622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11623. * @param compression defines the compression used (null by default)
  11624. * @returns the cube texture as an InternalTexture
  11625. */
  11626. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  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. */
  11635. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11636. /**
  11637. * Update a raw cube texture
  11638. * @param texture defines the texture to udpdate
  11639. * @param data defines the data to store
  11640. * @param format defines the data format
  11641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11642. * @param invertY defines if data must be stored with Y axis inverted
  11643. * @param compression defines the compression used (null by default)
  11644. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. * @param level defines which level of the texture to update
  11655. */
  11656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11657. /**
  11658. * Creates a new raw cube texture from a specified url
  11659. * @param url defines the url where the data is located
  11660. * @param scene defines the current scene
  11661. * @param size defines the size of the textures
  11662. * @param format defines the format of the data
  11663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11664. * @param noMipmap defines if the engine should avoid generating the mip levels
  11665. * @param callback defines a callback used to extract texture data from loaded data
  11666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11667. * @param onLoad defines a callback called when texture is loaded
  11668. * @param onError defines a callback called if there is an error
  11669. * @returns the cube texture as an InternalTexture
  11670. */
  11671. 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;
  11672. /**
  11673. * Creates a new raw cube texture from a specified url
  11674. * @param url defines the url where the data is located
  11675. * @param scene defines the current scene
  11676. * @param size defines the size of the textures
  11677. * @param format defines the format of the data
  11678. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11679. * @param noMipmap defines if the engine should avoid generating the mip levels
  11680. * @param callback defines a callback used to extract texture data from loaded data
  11681. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11682. * @param onLoad defines a callback called when texture is loaded
  11683. * @param onError defines a callback called if there is an error
  11684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @returns the cube texture as an InternalTexture
  11687. */
  11688. 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;
  11689. /**
  11690. * Creates a new raw 3D texture
  11691. * @param data defines the data used to create the texture
  11692. * @param width defines the width of the texture
  11693. * @param height defines the height of the texture
  11694. * @param depth defines the depth of the texture
  11695. * @param format defines the format of the texture
  11696. * @param generateMipMaps defines if the engine must generate mip levels
  11697. * @param invertY defines if data must be stored with Y axis inverted
  11698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11699. * @param compression defines the compressed used (can be null)
  11700. * @param textureType defines the compressed used (can be null)
  11701. * @returns a new raw 3D texture (stored in an InternalTexture)
  11702. */
  11703. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11704. /**
  11705. * Update a raw 3D texture
  11706. * @param texture defines the texture to update
  11707. * @param data defines the data to store
  11708. * @param format defines the data format
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11712. /**
  11713. * Update a raw 3D texture
  11714. * @param texture defines the texture to update
  11715. * @param data defines the data to store
  11716. * @param format defines the data format
  11717. * @param invertY defines if data must be stored with Y axis inverted
  11718. * @param compression defines the used compression (can be null)
  11719. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11722. /**
  11723. * Creates a new raw 2D array texture
  11724. * @param data defines the data used to create the texture
  11725. * @param width defines the width of the texture
  11726. * @param height defines the height of the texture
  11727. * @param depth defines the number of layers of the texture
  11728. * @param format defines the format of the texture
  11729. * @param generateMipMaps defines if the engine must generate mip levels
  11730. * @param invertY defines if data must be stored with Y axis inverted
  11731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11732. * @param compression defines the compressed used (can be null)
  11733. * @param textureType defines the compressed used (can be null)
  11734. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11735. */
  11736. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11737. /**
  11738. * Update a raw 2D array texture
  11739. * @param texture defines the texture to update
  11740. * @param data defines the data to store
  11741. * @param format defines the data format
  11742. * @param invertY defines if data must be stored with Y axis inverted
  11743. */
  11744. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11745. /**
  11746. * Update a raw 2D array texture
  11747. * @param texture defines the texture to update
  11748. * @param data defines the data to store
  11749. * @param format defines the data format
  11750. * @param invertY defines if data must be stored with Y axis inverted
  11751. * @param compression defines the used compression (can be null)
  11752. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11755. }
  11756. }
  11757. }
  11758. declare module "babylonjs/Materials/Textures/rawTexture" {
  11759. import { Texture } from "babylonjs/Materials/Textures/texture";
  11760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11761. import { Nullable } from "babylonjs/types";
  11762. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11763. import { Scene } from "babylonjs/scene";
  11764. /**
  11765. * Raw texture can help creating a texture directly from an array of data.
  11766. * This can be super useful if you either get the data from an uncompressed source or
  11767. * if you wish to create your texture pixel by pixel.
  11768. */
  11769. export class RawTexture extends Texture {
  11770. /**
  11771. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11772. */
  11773. format: number;
  11774. /**
  11775. * Instantiates a new RawTexture.
  11776. * Raw texture can help creating a texture directly from an array of data.
  11777. * This can be super useful if you either get the data from an uncompressed source or
  11778. * if you wish to create your texture pixel by pixel.
  11779. * @param data define the array of data to use to create the texture
  11780. * @param width define the width of the texture
  11781. * @param height define the height of the texture
  11782. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11783. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11784. * @param generateMipMaps define whether mip maps should be generated or not
  11785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11787. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11788. */
  11789. constructor(data: ArrayBufferView, width: number, height: number,
  11790. /**
  11791. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11792. */
  11793. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11794. /**
  11795. * Updates the texture underlying data.
  11796. * @param data Define the new data of the texture
  11797. */
  11798. update(data: ArrayBufferView): void;
  11799. /**
  11800. * Creates a luminance texture from some data.
  11801. * @param data Define the texture data
  11802. * @param width Define the width of the texture
  11803. * @param height Define the height of the texture
  11804. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11805. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11806. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11807. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11808. * @returns the luminance texture
  11809. */
  11810. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11811. /**
  11812. * Creates a luminance alpha texture from some data.
  11813. * @param data Define the texture data
  11814. * @param width Define the width of the texture
  11815. * @param height Define the height of the texture
  11816. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11817. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11820. * @returns the luminance alpha texture
  11821. */
  11822. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11823. /**
  11824. * Creates an alpha texture from some data.
  11825. * @param data Define the texture data
  11826. * @param width Define the width of the texture
  11827. * @param height Define the height of the texture
  11828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11832. * @returns the alpha texture
  11833. */
  11834. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a RGB texture from some data.
  11837. * @param data Define the texture data
  11838. * @param width Define the width of the texture
  11839. * @param height Define the height of the texture
  11840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11844. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11845. * @returns the RGB alpha texture
  11846. */
  11847. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11848. /**
  11849. * Creates a RGBA texture from some data.
  11850. * @param data Define the texture data
  11851. * @param width Define the width of the texture
  11852. * @param height Define the height of the texture
  11853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11858. * @returns the RGBA texture
  11859. */
  11860. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11861. /**
  11862. * Creates a R texture from some data.
  11863. * @param data Define the texture data
  11864. * @param width Define the width of the texture
  11865. * @param height Define the height of the texture
  11866. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11867. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11868. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11869. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11870. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11871. * @returns the R texture
  11872. */
  11873. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11874. }
  11875. }
  11876. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11877. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11878. import { IndicesArray, DataArray } from "babylonjs/types";
  11879. module "babylonjs/Engines/thinEngine" {
  11880. interface ThinEngine {
  11881. /**
  11882. * Update a dynamic index buffer
  11883. * @param indexBuffer defines the target index buffer
  11884. * @param indices defines the data to update
  11885. * @param offset defines the offset in the target index buffer where update should start
  11886. */
  11887. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11888. /**
  11889. * Updates a dynamic vertex buffer.
  11890. * @param vertexBuffer the vertex buffer to update
  11891. * @param data the data used to update the vertex buffer
  11892. * @param byteOffset the byte offset of the data
  11893. * @param byteLength the byte length of the data
  11894. */
  11895. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11896. }
  11897. }
  11898. }
  11899. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11900. import { Scene } from "babylonjs/scene";
  11901. import { ISceneComponent } from "babylonjs/sceneComponent";
  11902. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11903. module "babylonjs/abstractScene" {
  11904. interface AbstractScene {
  11905. /**
  11906. * The list of procedural textures added to the scene
  11907. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11908. */
  11909. proceduralTextures: Array<ProceduralTexture>;
  11910. }
  11911. }
  11912. /**
  11913. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11914. * in a given scene.
  11915. */
  11916. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11917. /**
  11918. * The component name helpfull to identify the component in the list of scene components.
  11919. */
  11920. readonly name: string;
  11921. /**
  11922. * The scene the component belongs to.
  11923. */
  11924. scene: Scene;
  11925. /**
  11926. * Creates a new instance of the component for the given scene
  11927. * @param scene Defines the scene to register the component in
  11928. */
  11929. constructor(scene: Scene);
  11930. /**
  11931. * Registers the component in a given scene
  11932. */
  11933. register(): void;
  11934. /**
  11935. * Rebuilds the elements related to this component in case of
  11936. * context lost for instance.
  11937. */
  11938. rebuild(): void;
  11939. /**
  11940. * Disposes the component and the associated ressources.
  11941. */
  11942. dispose(): void;
  11943. private _beforeClear;
  11944. }
  11945. }
  11946. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11948. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11949. module "babylonjs/Engines/thinEngine" {
  11950. interface ThinEngine {
  11951. /**
  11952. * Creates a new render target cube texture
  11953. * @param size defines the size of the texture
  11954. * @param options defines the options used to create the texture
  11955. * @returns a new render target cube texture stored in an InternalTexture
  11956. */
  11957. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11958. }
  11959. }
  11960. }
  11961. declare module "babylonjs/Shaders/procedural.vertex" {
  11962. /** @hidden */
  11963. export var proceduralVertexShader: {
  11964. name: string;
  11965. shader: string;
  11966. };
  11967. }
  11968. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11969. import { Observable } from "babylonjs/Misc/observable";
  11970. import { Nullable } from "babylonjs/types";
  11971. import { Scene } from "babylonjs/scene";
  11972. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11973. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11974. import { Effect } from "babylonjs/Materials/effect";
  11975. import { Texture } from "babylonjs/Materials/Textures/texture";
  11976. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11977. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11978. import "babylonjs/Shaders/procedural.vertex";
  11979. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11980. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11981. /**
  11982. * 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.
  11983. * This is the base class of any Procedural texture and contains most of the shareable code.
  11984. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11985. */
  11986. export class ProceduralTexture extends Texture {
  11987. /**
  11988. * Define if the texture is enabled or not (disabled texture will not render)
  11989. */
  11990. isEnabled: boolean;
  11991. /**
  11992. * Define if the texture must be cleared before rendering (default is true)
  11993. */
  11994. autoClear: boolean;
  11995. /**
  11996. * Callback called when the texture is generated
  11997. */
  11998. onGenerated: () => void;
  11999. /**
  12000. * Event raised when the texture is generated
  12001. */
  12002. onGeneratedObservable: Observable<ProceduralTexture>;
  12003. /**
  12004. * Event raised before the texture is generated
  12005. */
  12006. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12007. /**
  12008. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12009. */
  12010. nodeMaterialSource: Nullable<NodeMaterial>;
  12011. /** @hidden */
  12012. _generateMipMaps: boolean;
  12013. /** @hidden **/
  12014. _effect: Effect;
  12015. /** @hidden */
  12016. _textures: {
  12017. [key: string]: Texture;
  12018. };
  12019. /** @hidden */
  12020. protected _fallbackTexture: Nullable<Texture>;
  12021. private _size;
  12022. private _currentRefreshId;
  12023. private _frameId;
  12024. private _refreshRate;
  12025. private _vertexBuffers;
  12026. private _indexBuffer;
  12027. private _uniforms;
  12028. private _samplers;
  12029. private _fragment;
  12030. private _floats;
  12031. private _ints;
  12032. private _floatsArrays;
  12033. private _colors3;
  12034. private _colors4;
  12035. private _vectors2;
  12036. private _vectors3;
  12037. private _matrices;
  12038. private _fallbackTextureUsed;
  12039. private _fullEngine;
  12040. private _cachedDefines;
  12041. private _contentUpdateId;
  12042. private _contentData;
  12043. /**
  12044. * Instantiates a new procedural texture.
  12045. * 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.
  12046. * This is the base class of any Procedural texture and contains most of the shareable code.
  12047. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12048. * @param name Define the name of the texture
  12049. * @param size Define the size of the texture to create
  12050. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12051. * @param scene Define the scene the texture belongs to
  12052. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12053. * @param generateMipMaps Define if the texture should creates mip maps or not
  12054. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12055. */
  12056. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12057. /**
  12058. * The effect that is created when initializing the post process.
  12059. * @returns The created effect corresponding the the postprocess.
  12060. */
  12061. getEffect(): Effect;
  12062. /**
  12063. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12064. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12065. */
  12066. getContent(): Nullable<ArrayBufferView>;
  12067. private _createIndexBuffer;
  12068. /** @hidden */
  12069. _rebuild(): void;
  12070. /**
  12071. * Resets the texture in order to recreate its associated resources.
  12072. * This can be called in case of context loss
  12073. */
  12074. reset(): void;
  12075. protected _getDefines(): string;
  12076. /**
  12077. * Is the texture ready to be used ? (rendered at least once)
  12078. * @returns true if ready, otherwise, false.
  12079. */
  12080. isReady(): boolean;
  12081. /**
  12082. * Resets the refresh counter of the texture and start bak from scratch.
  12083. * Could be useful to regenerate the texture if it is setup to render only once.
  12084. */
  12085. resetRefreshCounter(): void;
  12086. /**
  12087. * Set the fragment shader to use in order to render the texture.
  12088. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12089. */
  12090. setFragment(fragment: any): void;
  12091. /**
  12092. * Define the refresh rate of the texture or the rendering frequency.
  12093. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12094. */
  12095. get refreshRate(): number;
  12096. set refreshRate(value: number);
  12097. /** @hidden */
  12098. _shouldRender(): boolean;
  12099. /**
  12100. * Get the size the texture is rendering at.
  12101. * @returns the size (on cube texture it is always squared)
  12102. */
  12103. getRenderSize(): RenderTargetTextureSize;
  12104. /**
  12105. * Resize the texture to new value.
  12106. * @param size Define the new size the texture should have
  12107. * @param generateMipMaps Define whether the new texture should create mip maps
  12108. */
  12109. resize(size: number, generateMipMaps: boolean): void;
  12110. private _checkUniform;
  12111. /**
  12112. * Set a texture in the shader program used to render.
  12113. * @param name Define the name of the uniform samplers as defined in the shader
  12114. * @param texture Define the texture to bind to this sampler
  12115. * @return the texture itself allowing "fluent" like uniform updates
  12116. */
  12117. setTexture(name: string, texture: Texture): ProceduralTexture;
  12118. /**
  12119. * Set a float in the shader.
  12120. * @param name Define the name of the uniform as defined in the shader
  12121. * @param value Define the value to give to the uniform
  12122. * @return the texture itself allowing "fluent" like uniform updates
  12123. */
  12124. setFloat(name: string, value: number): ProceduralTexture;
  12125. /**
  12126. * Set a int in the shader.
  12127. * @param name Define the name of the uniform as defined in the shader
  12128. * @param value Define the value to give to the uniform
  12129. * @return the texture itself allowing "fluent" like uniform updates
  12130. */
  12131. setInt(name: string, value: number): ProceduralTexture;
  12132. /**
  12133. * Set an array of floats in the shader.
  12134. * @param name Define the name of the uniform as defined in the shader
  12135. * @param value Define the value to give to the uniform
  12136. * @return the texture itself allowing "fluent" like uniform updates
  12137. */
  12138. setFloats(name: string, value: number[]): ProceduralTexture;
  12139. /**
  12140. * Set a vec3 in the shader from a Color3.
  12141. * @param name Define the name of the uniform as defined in the shader
  12142. * @param value Define the value to give to the uniform
  12143. * @return the texture itself allowing "fluent" like uniform updates
  12144. */
  12145. setColor3(name: string, value: Color3): ProceduralTexture;
  12146. /**
  12147. * Set a vec4 in the shader from a Color4.
  12148. * @param name Define the name of the uniform as defined in the shader
  12149. * @param value Define the value to give to the uniform
  12150. * @return the texture itself allowing "fluent" like uniform updates
  12151. */
  12152. setColor4(name: string, value: Color4): ProceduralTexture;
  12153. /**
  12154. * Set a vec2 in the shader from a Vector2.
  12155. * @param name Define the name of the uniform as defined in the shader
  12156. * @param value Define the value to give to the uniform
  12157. * @return the texture itself allowing "fluent" like uniform updates
  12158. */
  12159. setVector2(name: string, value: Vector2): ProceduralTexture;
  12160. /**
  12161. * Set a vec3 in the shader from a Vector3.
  12162. * @param name Define the name of the uniform as defined in the shader
  12163. * @param value Define the value to give to the uniform
  12164. * @return the texture itself allowing "fluent" like uniform updates
  12165. */
  12166. setVector3(name: string, value: Vector3): ProceduralTexture;
  12167. /**
  12168. * Set a mat4 in the shader from a MAtrix.
  12169. * @param name Define the name of the uniform as defined in the shader
  12170. * @param value Define the value to give to the uniform
  12171. * @return the texture itself allowing "fluent" like uniform updates
  12172. */
  12173. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12174. /**
  12175. * Render the texture to its associated render target.
  12176. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12177. */
  12178. render(useCameraPostProcess?: boolean): void;
  12179. /**
  12180. * Clone the texture.
  12181. * @returns the cloned texture
  12182. */
  12183. clone(): ProceduralTexture;
  12184. /**
  12185. * Dispose the texture and release its asoociated resources.
  12186. */
  12187. dispose(): void;
  12188. }
  12189. }
  12190. declare module "babylonjs/Particles/baseParticleSystem" {
  12191. import { Nullable } from "babylonjs/types";
  12192. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12194. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12195. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12196. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12198. import { Color4 } from "babylonjs/Maths/math.color";
  12199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12200. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12201. import { Animation } from "babylonjs/Animations/animation";
  12202. import { Scene } from "babylonjs/scene";
  12203. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12204. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12205. /**
  12206. * This represents the base class for particle system in Babylon.
  12207. * 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.
  12208. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12209. * @example https://doc.babylonjs.com/babylon101/particles
  12210. */
  12211. export class BaseParticleSystem {
  12212. /**
  12213. * Source color is added to the destination color without alpha affecting the result
  12214. */
  12215. static BLENDMODE_ONEONE: number;
  12216. /**
  12217. * Blend current color and particle color using particle’s alpha
  12218. */
  12219. static BLENDMODE_STANDARD: number;
  12220. /**
  12221. * Add current color and particle color multiplied by particle’s alpha
  12222. */
  12223. static BLENDMODE_ADD: number;
  12224. /**
  12225. * Multiply current color with particle color
  12226. */
  12227. static BLENDMODE_MULTIPLY: number;
  12228. /**
  12229. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12230. */
  12231. static BLENDMODE_MULTIPLYADD: number;
  12232. /**
  12233. * List of animations used by the particle system.
  12234. */
  12235. animations: Animation[];
  12236. /**
  12237. * Gets or sets the unique id of the particle system
  12238. */
  12239. uniqueId: number;
  12240. /**
  12241. * The id of the Particle system.
  12242. */
  12243. id: string;
  12244. /**
  12245. * The friendly name of the Particle system.
  12246. */
  12247. name: string;
  12248. /**
  12249. * Snippet ID if the particle system was created from the snippet server
  12250. */
  12251. snippetId: string;
  12252. /**
  12253. * The rendering group used by the Particle system to chose when to render.
  12254. */
  12255. renderingGroupId: number;
  12256. /**
  12257. * The emitter represents the Mesh or position we are attaching the particle system to.
  12258. */
  12259. emitter: Nullable<AbstractMesh | Vector3>;
  12260. /**
  12261. * The maximum number of particles to emit per frame
  12262. */
  12263. emitRate: number;
  12264. /**
  12265. * If you want to launch only a few particles at once, that can be done, as well.
  12266. */
  12267. manualEmitCount: number;
  12268. /**
  12269. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12270. */
  12271. updateSpeed: number;
  12272. /**
  12273. * The amount of time the particle system is running (depends of the overall update speed).
  12274. */
  12275. targetStopDuration: number;
  12276. /**
  12277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12278. */
  12279. disposeOnStop: boolean;
  12280. /**
  12281. * Minimum power of emitting particles.
  12282. */
  12283. minEmitPower: number;
  12284. /**
  12285. * Maximum power of emitting particles.
  12286. */
  12287. maxEmitPower: number;
  12288. /**
  12289. * Minimum life time of emitting particles.
  12290. */
  12291. minLifeTime: number;
  12292. /**
  12293. * Maximum life time of emitting particles.
  12294. */
  12295. maxLifeTime: number;
  12296. /**
  12297. * Minimum Size of emitting particles.
  12298. */
  12299. minSize: number;
  12300. /**
  12301. * Maximum Size of emitting particles.
  12302. */
  12303. maxSize: number;
  12304. /**
  12305. * Minimum scale of emitting particles on X axis.
  12306. */
  12307. minScaleX: number;
  12308. /**
  12309. * Maximum scale of emitting particles on X axis.
  12310. */
  12311. maxScaleX: number;
  12312. /**
  12313. * Minimum scale of emitting particles on Y axis.
  12314. */
  12315. minScaleY: number;
  12316. /**
  12317. * Maximum scale of emitting particles on Y axis.
  12318. */
  12319. maxScaleY: number;
  12320. /**
  12321. * Gets or sets the minimal initial rotation in radians.
  12322. */
  12323. minInitialRotation: number;
  12324. /**
  12325. * Gets or sets the maximal initial rotation in radians.
  12326. */
  12327. maxInitialRotation: number;
  12328. /**
  12329. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12330. */
  12331. minAngularSpeed: number;
  12332. /**
  12333. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12334. */
  12335. maxAngularSpeed: number;
  12336. /**
  12337. * The texture used to render each particle. (this can be a spritesheet)
  12338. */
  12339. particleTexture: Nullable<BaseTexture>;
  12340. /**
  12341. * The layer mask we are rendering the particles through.
  12342. */
  12343. layerMask: number;
  12344. /**
  12345. * This can help using your own shader to render the particle system.
  12346. * The according effect will be created
  12347. */
  12348. customShader: any;
  12349. /**
  12350. * By default particle system starts as soon as they are created. This prevents the
  12351. * automatic start to happen and let you decide when to start emitting particles.
  12352. */
  12353. preventAutoStart: boolean;
  12354. private _noiseTexture;
  12355. /**
  12356. * Gets or sets a texture used to add random noise to particle positions
  12357. */
  12358. get noiseTexture(): Nullable<ProceduralTexture>;
  12359. set noiseTexture(value: Nullable<ProceduralTexture>);
  12360. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12361. noiseStrength: Vector3;
  12362. /**
  12363. * Callback triggered when the particle animation is ending.
  12364. */
  12365. onAnimationEnd: Nullable<() => void>;
  12366. /**
  12367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12368. */
  12369. blendMode: number;
  12370. /**
  12371. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12372. * to override the particles.
  12373. */
  12374. forceDepthWrite: boolean;
  12375. /** 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 */
  12376. preWarmCycles: number;
  12377. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12378. preWarmStepOffset: number;
  12379. /**
  12380. * 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)
  12381. */
  12382. spriteCellChangeSpeed: number;
  12383. /**
  12384. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12385. */
  12386. startSpriteCellID: number;
  12387. /**
  12388. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12389. */
  12390. endSpriteCellID: number;
  12391. /**
  12392. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12393. */
  12394. spriteCellWidth: number;
  12395. /**
  12396. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12397. */
  12398. spriteCellHeight: number;
  12399. /**
  12400. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12401. */
  12402. spriteRandomStartCell: boolean;
  12403. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12404. translationPivot: Vector2;
  12405. /** @hidden */
  12406. protected _isAnimationSheetEnabled: boolean;
  12407. /**
  12408. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12409. */
  12410. beginAnimationOnStart: boolean;
  12411. /**
  12412. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12413. */
  12414. beginAnimationFrom: number;
  12415. /**
  12416. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12417. */
  12418. beginAnimationTo: number;
  12419. /**
  12420. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12421. */
  12422. beginAnimationLoop: boolean;
  12423. /**
  12424. * Gets or sets a world offset applied to all particles
  12425. */
  12426. worldOffset: Vector3;
  12427. /**
  12428. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12429. */
  12430. get isAnimationSheetEnabled(): boolean;
  12431. set isAnimationSheetEnabled(value: boolean);
  12432. /**
  12433. * Get hosting scene
  12434. * @returns the scene
  12435. */
  12436. getScene(): Nullable<Scene>;
  12437. /**
  12438. * You can use gravity if you want to give an orientation to your particles.
  12439. */
  12440. gravity: Vector3;
  12441. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12442. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12443. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12444. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12445. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12446. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12447. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12448. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12449. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12450. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12451. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12452. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12453. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12454. /**
  12455. * Defines the delay in milliseconds before starting the system (0 by default)
  12456. */
  12457. startDelay: number;
  12458. /**
  12459. * Gets the current list of drag gradients.
  12460. * You must use addDragGradient and removeDragGradient to udpate this list
  12461. * @returns the list of drag gradients
  12462. */
  12463. getDragGradients(): Nullable<Array<FactorGradient>>;
  12464. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12465. limitVelocityDamping: number;
  12466. /**
  12467. * Gets the current list of limit velocity gradients.
  12468. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12469. * @returns the list of limit velocity gradients
  12470. */
  12471. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12472. /**
  12473. * Gets the current list of color gradients.
  12474. * You must use addColorGradient and removeColorGradient to udpate this list
  12475. * @returns the list of color gradients
  12476. */
  12477. getColorGradients(): Nullable<Array<ColorGradient>>;
  12478. /**
  12479. * Gets the current list of size gradients.
  12480. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12481. * @returns the list of size gradients
  12482. */
  12483. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12484. /**
  12485. * Gets the current list of color remap gradients.
  12486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12487. * @returns the list of color remap gradients
  12488. */
  12489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12490. /**
  12491. * Gets the current list of alpha remap gradients.
  12492. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12493. * @returns the list of alpha remap gradients
  12494. */
  12495. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12496. /**
  12497. * Gets the current list of life time gradients.
  12498. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12499. * @returns the list of life time gradients
  12500. */
  12501. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12502. /**
  12503. * Gets the current list of angular speed gradients.
  12504. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12505. * @returns the list of angular speed gradients
  12506. */
  12507. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12508. /**
  12509. * Gets the current list of velocity gradients.
  12510. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12511. * @returns the list of velocity gradients
  12512. */
  12513. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12514. /**
  12515. * Gets the current list of start size gradients.
  12516. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12517. * @returns the list of start size gradients
  12518. */
  12519. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12520. /**
  12521. * Gets the current list of emit rate gradients.
  12522. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12523. * @returns the list of emit rate gradients
  12524. */
  12525. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12526. /**
  12527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12529. */
  12530. get direction1(): Vector3;
  12531. set direction1(value: Vector3);
  12532. /**
  12533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12535. */
  12536. get direction2(): Vector3;
  12537. set direction2(value: Vector3);
  12538. /**
  12539. * 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.
  12540. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12541. */
  12542. get minEmitBox(): Vector3;
  12543. set minEmitBox(value: Vector3);
  12544. /**
  12545. * 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.
  12546. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12547. */
  12548. get maxEmitBox(): Vector3;
  12549. set maxEmitBox(value: Vector3);
  12550. /**
  12551. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12552. */
  12553. color1: Color4;
  12554. /**
  12555. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12556. */
  12557. color2: Color4;
  12558. /**
  12559. * Color the particle will have at the end of its lifetime
  12560. */
  12561. colorDead: Color4;
  12562. /**
  12563. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12564. */
  12565. textureMask: Color4;
  12566. /**
  12567. * The particle emitter type defines the emitter used by the particle system.
  12568. * It can be for example box, sphere, or cone...
  12569. */
  12570. particleEmitterType: IParticleEmitterType;
  12571. /** @hidden */
  12572. _isSubEmitter: boolean;
  12573. /**
  12574. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12575. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12576. */
  12577. billboardMode: number;
  12578. protected _isBillboardBased: boolean;
  12579. /**
  12580. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12581. */
  12582. get isBillboardBased(): boolean;
  12583. set isBillboardBased(value: boolean);
  12584. /**
  12585. * The scene the particle system belongs to.
  12586. */
  12587. protected _scene: Nullable<Scene>;
  12588. /**
  12589. * The engine the particle system belongs to.
  12590. */
  12591. protected _engine: ThinEngine;
  12592. /**
  12593. * Local cache of defines for image processing.
  12594. */
  12595. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12596. /**
  12597. * Default configuration related to image processing available in the standard Material.
  12598. */
  12599. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12600. /**
  12601. * Gets the image processing configuration used either in this material.
  12602. */
  12603. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12604. /**
  12605. * Sets the Default image processing configuration used either in the this material.
  12606. *
  12607. * If sets to null, the scene one is in use.
  12608. */
  12609. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12610. /**
  12611. * Attaches a new image processing configuration to the Standard Material.
  12612. * @param configuration
  12613. */
  12614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12615. /** @hidden */
  12616. protected _reset(): void;
  12617. /** @hidden */
  12618. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12619. /**
  12620. * Instantiates a particle system.
  12621. * 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.
  12622. * @param name The name of the particle system
  12623. */
  12624. constructor(name: string);
  12625. /**
  12626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12629. * @returns the emitter
  12630. */
  12631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12632. /**
  12633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12634. * @param radius The radius of the hemisphere to emit from
  12635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12636. * @returns the emitter
  12637. */
  12638. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12639. /**
  12640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12641. * @param radius The radius of the sphere to emit from
  12642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12643. * @returns the emitter
  12644. */
  12645. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12646. /**
  12647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12648. * @param radius The radius of the sphere to emit from
  12649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12651. * @returns the emitter
  12652. */
  12653. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12654. /**
  12655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12656. * @param radius The radius of the emission cylinder
  12657. * @param height The height of the emission cylinder
  12658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12660. * @returns the emitter
  12661. */
  12662. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12663. /**
  12664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12665. * @param radius The radius of the cylinder to emit from
  12666. * @param height The height of the emission cylinder
  12667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12670. * @returns the emitter
  12671. */
  12672. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12673. /**
  12674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12675. * @param radius The radius of the cone to emit from
  12676. * @param angle The base angle of the cone
  12677. * @returns the emitter
  12678. */
  12679. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12680. /**
  12681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12686. * @returns the emitter
  12687. */
  12688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12689. }
  12690. }
  12691. declare module "babylonjs/Particles/subEmitter" {
  12692. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12693. import { Scene } from "babylonjs/scene";
  12694. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12695. /**
  12696. * Type of sub emitter
  12697. */
  12698. export enum SubEmitterType {
  12699. /**
  12700. * Attached to the particle over it's lifetime
  12701. */
  12702. ATTACHED = 0,
  12703. /**
  12704. * Created when the particle dies
  12705. */
  12706. END = 1
  12707. }
  12708. /**
  12709. * Sub emitter class used to emit particles from an existing particle
  12710. */
  12711. export class SubEmitter {
  12712. /**
  12713. * the particle system to be used by the sub emitter
  12714. */
  12715. particleSystem: ParticleSystem;
  12716. /**
  12717. * Type of the submitter (Default: END)
  12718. */
  12719. type: SubEmitterType;
  12720. /**
  12721. * 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)
  12722. * Note: This only is supported when using an emitter of type Mesh
  12723. */
  12724. inheritDirection: boolean;
  12725. /**
  12726. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12727. */
  12728. inheritedVelocityAmount: number;
  12729. /**
  12730. * Creates a sub emitter
  12731. * @param particleSystem the particle system to be used by the sub emitter
  12732. */
  12733. constructor(
  12734. /**
  12735. * the particle system to be used by the sub emitter
  12736. */
  12737. particleSystem: ParticleSystem);
  12738. /**
  12739. * Clones the sub emitter
  12740. * @returns the cloned sub emitter
  12741. */
  12742. clone(): SubEmitter;
  12743. /**
  12744. * Serialize current object to a JSON object
  12745. * @returns the serialized object
  12746. */
  12747. serialize(): any;
  12748. /** @hidden */
  12749. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12750. /**
  12751. * Creates a new SubEmitter from a serialized JSON version
  12752. * @param serializationObject defines the JSON object to read from
  12753. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12754. * @param rootUrl defines the rootUrl for data loading
  12755. * @returns a new SubEmitter
  12756. */
  12757. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12758. /** Release associated resources */
  12759. dispose(): void;
  12760. }
  12761. }
  12762. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12763. /** @hidden */
  12764. export var imageProcessingDeclaration: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12770. /** @hidden */
  12771. export var imageProcessingFunctions: {
  12772. name: string;
  12773. shader: string;
  12774. };
  12775. }
  12776. declare module "babylonjs/Shaders/particles.fragment" {
  12777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12778. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12779. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12782. /** @hidden */
  12783. export var particlesPixelShader: {
  12784. name: string;
  12785. shader: string;
  12786. };
  12787. }
  12788. declare module "babylonjs/Shaders/particles.vertex" {
  12789. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12791. /** @hidden */
  12792. export var particlesVertexShader: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12798. import { Nullable } from "babylonjs/types";
  12799. import { Plane } from "babylonjs/Maths/math";
  12800. /**
  12801. * Interface used to define entities containing multiple clip planes
  12802. */
  12803. export interface IClipPlanesHolder {
  12804. /**
  12805. * Gets or sets the active clipplane 1
  12806. */
  12807. clipPlane: Nullable<Plane>;
  12808. /**
  12809. * Gets or sets the active clipplane 2
  12810. */
  12811. clipPlane2: Nullable<Plane>;
  12812. /**
  12813. * Gets or sets the active clipplane 3
  12814. */
  12815. clipPlane3: Nullable<Plane>;
  12816. /**
  12817. * Gets or sets the active clipplane 4
  12818. */
  12819. clipPlane4: Nullable<Plane>;
  12820. /**
  12821. * Gets or sets the active clipplane 5
  12822. */
  12823. clipPlane5: Nullable<Plane>;
  12824. /**
  12825. * Gets or sets the active clipplane 6
  12826. */
  12827. clipPlane6: Nullable<Plane>;
  12828. }
  12829. }
  12830. declare module "babylonjs/Materials/thinMaterialHelper" {
  12831. import { Effect } from "babylonjs/Materials/effect";
  12832. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12833. /**
  12834. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12835. *
  12836. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12837. *
  12838. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12839. */
  12840. export class ThinMaterialHelper {
  12841. /**
  12842. * Binds the clip plane information from the holder to the effect.
  12843. * @param effect The effect we are binding the data to
  12844. * @param holder The entity containing the clip plane information
  12845. */
  12846. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12847. }
  12848. }
  12849. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12850. module "babylonjs/Engines/thinEngine" {
  12851. interface ThinEngine {
  12852. /**
  12853. * Sets alpha constants used by some alpha blending modes
  12854. * @param r defines the red component
  12855. * @param g defines the green component
  12856. * @param b defines the blue component
  12857. * @param a defines the alpha component
  12858. */
  12859. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12860. /**
  12861. * Sets the current alpha mode
  12862. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12863. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12864. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12865. */
  12866. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12867. /**
  12868. * Gets the current alpha mode
  12869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12870. * @returns the current alpha mode
  12871. */
  12872. getAlphaMode(): number;
  12873. /**
  12874. * Sets the current alpha equation
  12875. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12876. */
  12877. setAlphaEquation(equation: number): void;
  12878. /**
  12879. * Gets the current alpha equation.
  12880. * @returns the current alpha equation
  12881. */
  12882. getAlphaEquation(): number;
  12883. }
  12884. }
  12885. }
  12886. declare module "babylonjs/Particles/particleSystem" {
  12887. import { Nullable } from "babylonjs/types";
  12888. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12889. import { Observable } from "babylonjs/Misc/observable";
  12890. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12891. import { Effect } from "babylonjs/Materials/effect";
  12892. import { IDisposable } from "babylonjs/scene";
  12893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12894. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12895. import { Particle } from "babylonjs/Particles/particle";
  12896. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12897. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12898. import "babylonjs/Shaders/particles.fragment";
  12899. import "babylonjs/Shaders/particles.vertex";
  12900. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12901. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12902. import "babylonjs/Engines/Extensions/engine.alpha";
  12903. import { Scene } from "babylonjs/scene";
  12904. /**
  12905. * This represents a particle system in Babylon.
  12906. * 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.
  12907. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12908. * @example https://doc.babylonjs.com/babylon101/particles
  12909. */
  12910. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12911. /**
  12912. * Billboard mode will only apply to Y axis
  12913. */
  12914. static readonly BILLBOARDMODE_Y: number;
  12915. /**
  12916. * Billboard mode will apply to all axes
  12917. */
  12918. static readonly BILLBOARDMODE_ALL: number;
  12919. /**
  12920. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12921. */
  12922. static readonly BILLBOARDMODE_STRETCHED: number;
  12923. /**
  12924. * This function can be defined to provide custom update for active particles.
  12925. * This function will be called instead of regular update (age, position, color, etc.).
  12926. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12927. */
  12928. updateFunction: (particles: Particle[]) => void;
  12929. private _emitterWorldMatrix;
  12930. /**
  12931. * This function can be defined to specify initial direction for every new particle.
  12932. * It by default use the emitterType defined function
  12933. */
  12934. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12935. /**
  12936. * This function can be defined to specify initial position for every new particle.
  12937. * It by default use the emitterType defined function
  12938. */
  12939. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12940. /**
  12941. * @hidden
  12942. */
  12943. _inheritedVelocityOffset: Vector3;
  12944. /**
  12945. * An event triggered when the system is disposed
  12946. */
  12947. onDisposeObservable: Observable<IParticleSystem>;
  12948. private _onDisposeObserver;
  12949. /**
  12950. * Sets a callback that will be triggered when the system is disposed
  12951. */
  12952. set onDispose(callback: () => void);
  12953. private _particles;
  12954. private _epsilon;
  12955. private _capacity;
  12956. private _stockParticles;
  12957. private _newPartsExcess;
  12958. private _vertexData;
  12959. private _vertexBuffer;
  12960. private _vertexBuffers;
  12961. private _spriteBuffer;
  12962. private _indexBuffer;
  12963. private _effect;
  12964. private _customEffect;
  12965. private _cachedDefines;
  12966. private _scaledColorStep;
  12967. private _colorDiff;
  12968. private _scaledDirection;
  12969. private _scaledGravity;
  12970. private _currentRenderId;
  12971. private _alive;
  12972. private _useInstancing;
  12973. private _started;
  12974. private _stopped;
  12975. private _actualFrame;
  12976. private _scaledUpdateSpeed;
  12977. private _vertexBufferSize;
  12978. /** @hidden */
  12979. _currentEmitRateGradient: Nullable<FactorGradient>;
  12980. /** @hidden */
  12981. _currentEmitRate1: number;
  12982. /** @hidden */
  12983. _currentEmitRate2: number;
  12984. /** @hidden */
  12985. _currentStartSizeGradient: Nullable<FactorGradient>;
  12986. /** @hidden */
  12987. _currentStartSize1: number;
  12988. /** @hidden */
  12989. _currentStartSize2: number;
  12990. private readonly _rawTextureWidth;
  12991. private _rampGradientsTexture;
  12992. private _useRampGradients;
  12993. /** Gets or sets a matrix to use to compute projection */
  12994. defaultProjectionMatrix: Matrix;
  12995. /** Gets or sets a matrix to use to compute view */
  12996. defaultViewMatrix: Matrix;
  12997. /** Gets or sets a boolean indicating that ramp gradients must be used
  12998. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12999. */
  13000. get useRampGradients(): boolean;
  13001. set useRampGradients(value: boolean);
  13002. /**
  13003. * 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.
  13004. * 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: [])
  13005. */
  13006. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13007. private _subEmitters;
  13008. /**
  13009. * @hidden
  13010. * If the particle systems emitter should be disposed when the particle system is disposed
  13011. */
  13012. _disposeEmitterOnDispose: boolean;
  13013. /**
  13014. * The current active Sub-systems, this property is used by the root particle system only.
  13015. */
  13016. activeSubSystems: Array<ParticleSystem>;
  13017. /**
  13018. * Specifies if the particles are updated in emitter local space or world space
  13019. */
  13020. isLocal: boolean;
  13021. private _rootParticleSystem;
  13022. /**
  13023. * Gets the current list of active particles
  13024. */
  13025. get particles(): Particle[];
  13026. /**
  13027. * Gets the number of particles active at the same time.
  13028. * @returns The number of active particles.
  13029. */
  13030. getActiveCount(): number;
  13031. /**
  13032. * Returns the string "ParticleSystem"
  13033. * @returns a string containing the class name
  13034. */
  13035. getClassName(): string;
  13036. /**
  13037. * Gets a boolean indicating that the system is stopping
  13038. * @returns true if the system is currently stopping
  13039. */
  13040. isStopping(): boolean;
  13041. /**
  13042. * Gets the custom effect used to render the particles
  13043. * @param blendMode Blend mode for which the effect should be retrieved
  13044. * @returns The effect
  13045. */
  13046. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13047. /**
  13048. * Sets the custom effect used to render the particles
  13049. * @param effect The effect to set
  13050. * @param blendMode Blend mode for which the effect should be set
  13051. */
  13052. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13053. /** @hidden */
  13054. private _onBeforeDrawParticlesObservable;
  13055. /**
  13056. * Observable that will be called just before the particles are drawn
  13057. */
  13058. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13059. /**
  13060. * Gets the name of the particle vertex shader
  13061. */
  13062. get vertexShaderName(): string;
  13063. /**
  13064. * Instantiates a particle system.
  13065. * 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.
  13066. * @param name The name of the particle system
  13067. * @param capacity The max number of particles alive at the same time
  13068. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13069. * @param customEffect a custom effect used to change the way particles are rendered by default
  13070. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13071. * @param epsilon Offset used to render the particles
  13072. */
  13073. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13074. private _addFactorGradient;
  13075. private _removeFactorGradient;
  13076. /**
  13077. * Adds a new life time gradient
  13078. * @param gradient defines the gradient to use (between 0 and 1)
  13079. * @param factor defines the life time factor to affect to the specified gradient
  13080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13081. * @returns the current particle system
  13082. */
  13083. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13084. /**
  13085. * Remove a specific life time gradient
  13086. * @param gradient defines the gradient to remove
  13087. * @returns the current particle system
  13088. */
  13089. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13090. /**
  13091. * Adds a new size gradient
  13092. * @param gradient defines the gradient to use (between 0 and 1)
  13093. * @param factor defines the size factor to affect to the specified gradient
  13094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13095. * @returns the current particle system
  13096. */
  13097. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13098. /**
  13099. * Remove a specific size gradient
  13100. * @param gradient defines the gradient to remove
  13101. * @returns the current particle system
  13102. */
  13103. removeSizeGradient(gradient: number): IParticleSystem;
  13104. /**
  13105. * Adds a new color remap gradient
  13106. * @param gradient defines the gradient to use (between 0 and 1)
  13107. * @param min defines the color remap minimal range
  13108. * @param max defines the color remap maximal range
  13109. * @returns the current particle system
  13110. */
  13111. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13112. /**
  13113. * Remove a specific color remap gradient
  13114. * @param gradient defines the gradient to remove
  13115. * @returns the current particle system
  13116. */
  13117. removeColorRemapGradient(gradient: number): IParticleSystem;
  13118. /**
  13119. * Adds a new alpha remap gradient
  13120. * @param gradient defines the gradient to use (between 0 and 1)
  13121. * @param min defines the alpha remap minimal range
  13122. * @param max defines the alpha remap maximal range
  13123. * @returns the current particle system
  13124. */
  13125. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13126. /**
  13127. * Remove a specific alpha remap gradient
  13128. * @param gradient defines the gradient to remove
  13129. * @returns the current particle system
  13130. */
  13131. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13132. /**
  13133. * Adds a new angular speed gradient
  13134. * @param gradient defines the gradient to use (between 0 and 1)
  13135. * @param factor defines the angular speed to affect to the specified gradient
  13136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13137. * @returns the current particle system
  13138. */
  13139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13140. /**
  13141. * Remove a specific angular speed gradient
  13142. * @param gradient defines the gradient to remove
  13143. * @returns the current particle system
  13144. */
  13145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13146. /**
  13147. * Adds a new velocity gradient
  13148. * @param gradient defines the gradient to use (between 0 and 1)
  13149. * @param factor defines the velocity to affect to the specified gradient
  13150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13151. * @returns the current particle system
  13152. */
  13153. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13154. /**
  13155. * Remove a specific velocity gradient
  13156. * @param gradient defines the gradient to remove
  13157. * @returns the current particle system
  13158. */
  13159. removeVelocityGradient(gradient: number): IParticleSystem;
  13160. /**
  13161. * Adds a new limit velocity gradient
  13162. * @param gradient defines the gradient to use (between 0 and 1)
  13163. * @param factor defines the limit velocity value to affect to the specified gradient
  13164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13165. * @returns the current particle system
  13166. */
  13167. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13168. /**
  13169. * Remove a specific limit velocity gradient
  13170. * @param gradient defines the gradient to remove
  13171. * @returns the current particle system
  13172. */
  13173. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13174. /**
  13175. * Adds a new drag gradient
  13176. * @param gradient defines the gradient to use (between 0 and 1)
  13177. * @param factor defines the drag value to affect to the specified gradient
  13178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13179. * @returns the current particle system
  13180. */
  13181. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13182. /**
  13183. * Remove a specific drag gradient
  13184. * @param gradient defines the gradient to remove
  13185. * @returns the current particle system
  13186. */
  13187. removeDragGradient(gradient: number): IParticleSystem;
  13188. /**
  13189. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13190. * @param gradient defines the gradient to use (between 0 and 1)
  13191. * @param factor defines the emit rate value to affect to the specified gradient
  13192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13193. * @returns the current particle system
  13194. */
  13195. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13196. /**
  13197. * Remove a specific emit rate gradient
  13198. * @param gradient defines the gradient to remove
  13199. * @returns the current particle system
  13200. */
  13201. removeEmitRateGradient(gradient: number): IParticleSystem;
  13202. /**
  13203. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the start size value to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific start size gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeStartSizeGradient(gradient: number): IParticleSystem;
  13216. private _createRampGradientTexture;
  13217. /**
  13218. * Gets the current list of ramp gradients.
  13219. * You must use addRampGradient and removeRampGradient to udpate this list
  13220. * @returns the list of ramp gradients
  13221. */
  13222. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13223. /** Force the system to rebuild all gradients that need to be resync */
  13224. forceRefreshGradients(): void;
  13225. private _syncRampGradientTexture;
  13226. /**
  13227. * Adds a new ramp gradient used to remap particle colors
  13228. * @param gradient defines the gradient to use (between 0 and 1)
  13229. * @param color defines the color to affect to the specified gradient
  13230. * @returns the current particle system
  13231. */
  13232. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13233. /**
  13234. * Remove a specific ramp gradient
  13235. * @param gradient defines the gradient to remove
  13236. * @returns the current particle system
  13237. */
  13238. removeRampGradient(gradient: number): ParticleSystem;
  13239. /**
  13240. * Adds a new color gradient
  13241. * @param gradient defines the gradient to use (between 0 and 1)
  13242. * @param color1 defines the color to affect to the specified gradient
  13243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13244. * @returns this particle system
  13245. */
  13246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13247. /**
  13248. * Remove a specific color gradient
  13249. * @param gradient defines the gradient to remove
  13250. * @returns this particle system
  13251. */
  13252. removeColorGradient(gradient: number): IParticleSystem;
  13253. private _fetchR;
  13254. protected _reset(): void;
  13255. private _resetEffect;
  13256. private _createVertexBuffers;
  13257. private _createIndexBuffer;
  13258. /**
  13259. * Gets the maximum number of particles active at the same time.
  13260. * @returns The max number of active particles.
  13261. */
  13262. getCapacity(): number;
  13263. /**
  13264. * Gets whether there are still active particles in the system.
  13265. * @returns True if it is alive, otherwise false.
  13266. */
  13267. isAlive(): boolean;
  13268. /**
  13269. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13270. * @returns True if it has been started, otherwise false.
  13271. */
  13272. isStarted(): boolean;
  13273. private _prepareSubEmitterInternalArray;
  13274. /**
  13275. * Starts the particle system and begins to emit
  13276. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13277. */
  13278. start(delay?: number): void;
  13279. /**
  13280. * Stops the particle system.
  13281. * @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.
  13282. */
  13283. stop(stopSubEmitters?: boolean): void;
  13284. /**
  13285. * Remove all active particles
  13286. */
  13287. reset(): void;
  13288. /**
  13289. * @hidden (for internal use only)
  13290. */
  13291. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13292. /**
  13293. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13294. * Its lifetime will start back at 0.
  13295. */
  13296. recycleParticle: (particle: Particle) => void;
  13297. private _stopSubEmitters;
  13298. private _createParticle;
  13299. private _removeFromRoot;
  13300. private _emitFromParticle;
  13301. private _update;
  13302. /** @hidden */
  13303. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13304. /** @hidden */
  13305. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13306. /**
  13307. * Fill the defines array according to the current settings of the particle system
  13308. * @param defines Array to be updated
  13309. * @param blendMode blend mode to take into account when updating the array
  13310. */
  13311. fillDefines(defines: Array<string>, blendMode: number): void;
  13312. /**
  13313. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13314. * @param uniforms Uniforms array to fill
  13315. * @param attributes Attributes array to fill
  13316. * @param samplers Samplers array to fill
  13317. */
  13318. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13319. /** @hidden */
  13320. private _getEffect;
  13321. /**
  13322. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13323. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13324. */
  13325. animate(preWarmOnly?: boolean): void;
  13326. private _appendParticleVertices;
  13327. /**
  13328. * Rebuilds the particle system.
  13329. */
  13330. rebuild(): void;
  13331. /**
  13332. * Is this system ready to be used/rendered
  13333. * @return true if the system is ready
  13334. */
  13335. isReady(): boolean;
  13336. private _render;
  13337. /**
  13338. * Renders the particle system in its current state.
  13339. * @returns the current number of particles
  13340. */
  13341. render(): number;
  13342. /**
  13343. * Disposes the particle system and free the associated resources
  13344. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13345. */
  13346. dispose(disposeTexture?: boolean): void;
  13347. /**
  13348. * Clones the particle system.
  13349. * @param name The name of the cloned object
  13350. * @param newEmitter The new emitter to use
  13351. * @returns the cloned particle system
  13352. */
  13353. clone(name: string, newEmitter: any): ParticleSystem;
  13354. /**
  13355. * Serializes the particle system to a JSON object
  13356. * @param serializeTexture defines if the texture must be serialized as well
  13357. * @returns the JSON object
  13358. */
  13359. serialize(serializeTexture?: boolean): any;
  13360. /** @hidden */
  13361. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13362. /** @hidden */
  13363. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13364. /**
  13365. * Parses a JSON object to create a particle system.
  13366. * @param parsedParticleSystem The JSON object to parse
  13367. * @param sceneOrEngine The scene or the engine to create the particle system in
  13368. * @param rootUrl The root url to use to load external dependencies like texture
  13369. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13370. * @returns the Parsed particle system
  13371. */
  13372. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13373. }
  13374. }
  13375. declare module "babylonjs/Particles/particle" {
  13376. import { Nullable } from "babylonjs/types";
  13377. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13378. import { Color4 } from "babylonjs/Maths/math.color";
  13379. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13380. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13381. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13382. /**
  13383. * A particle represents one of the element emitted by a particle system.
  13384. * This is mainly define by its coordinates, direction, velocity and age.
  13385. */
  13386. export class Particle {
  13387. /**
  13388. * The particle system the particle belongs to.
  13389. */
  13390. particleSystem: ParticleSystem;
  13391. private static _Count;
  13392. /**
  13393. * Unique ID of the particle
  13394. */
  13395. id: number;
  13396. /**
  13397. * The world position of the particle in the scene.
  13398. */
  13399. position: Vector3;
  13400. /**
  13401. * The world direction of the particle in the scene.
  13402. */
  13403. direction: Vector3;
  13404. /**
  13405. * The color of the particle.
  13406. */
  13407. color: Color4;
  13408. /**
  13409. * The color change of the particle per step.
  13410. */
  13411. colorStep: Color4;
  13412. /**
  13413. * Defines how long will the life of the particle be.
  13414. */
  13415. lifeTime: number;
  13416. /**
  13417. * The current age of the particle.
  13418. */
  13419. age: number;
  13420. /**
  13421. * The current size of the particle.
  13422. */
  13423. size: number;
  13424. /**
  13425. * The current scale of the particle.
  13426. */
  13427. scale: Vector2;
  13428. /**
  13429. * The current angle of the particle.
  13430. */
  13431. angle: number;
  13432. /**
  13433. * Defines how fast is the angle changing.
  13434. */
  13435. angularSpeed: number;
  13436. /**
  13437. * Defines the cell index used by the particle to be rendered from a sprite.
  13438. */
  13439. cellIndex: number;
  13440. /**
  13441. * The information required to support color remapping
  13442. */
  13443. remapData: Vector4;
  13444. /** @hidden */
  13445. _randomCellOffset?: number;
  13446. /** @hidden */
  13447. _initialDirection: Nullable<Vector3>;
  13448. /** @hidden */
  13449. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13450. /** @hidden */
  13451. _initialStartSpriteCellID: number;
  13452. /** @hidden */
  13453. _initialEndSpriteCellID: number;
  13454. /** @hidden */
  13455. _currentColorGradient: Nullable<ColorGradient>;
  13456. /** @hidden */
  13457. _currentColor1: Color4;
  13458. /** @hidden */
  13459. _currentColor2: Color4;
  13460. /** @hidden */
  13461. _currentSizeGradient: Nullable<FactorGradient>;
  13462. /** @hidden */
  13463. _currentSize1: number;
  13464. /** @hidden */
  13465. _currentSize2: number;
  13466. /** @hidden */
  13467. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13468. /** @hidden */
  13469. _currentAngularSpeed1: number;
  13470. /** @hidden */
  13471. _currentAngularSpeed2: number;
  13472. /** @hidden */
  13473. _currentVelocityGradient: Nullable<FactorGradient>;
  13474. /** @hidden */
  13475. _currentVelocity1: number;
  13476. /** @hidden */
  13477. _currentVelocity2: number;
  13478. /** @hidden */
  13479. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13480. /** @hidden */
  13481. _currentLimitVelocity1: number;
  13482. /** @hidden */
  13483. _currentLimitVelocity2: number;
  13484. /** @hidden */
  13485. _currentDragGradient: Nullable<FactorGradient>;
  13486. /** @hidden */
  13487. _currentDrag1: number;
  13488. /** @hidden */
  13489. _currentDrag2: number;
  13490. /** @hidden */
  13491. _randomNoiseCoordinates1: Vector3;
  13492. /** @hidden */
  13493. _randomNoiseCoordinates2: Vector3;
  13494. /** @hidden */
  13495. _localPosition?: Vector3;
  13496. /**
  13497. * Creates a new instance Particle
  13498. * @param particleSystem the particle system the particle belongs to
  13499. */
  13500. constructor(
  13501. /**
  13502. * The particle system the particle belongs to.
  13503. */
  13504. particleSystem: ParticleSystem);
  13505. private updateCellInfoFromSystem;
  13506. /**
  13507. * Defines how the sprite cell index is updated for the particle
  13508. */
  13509. updateCellIndex(): void;
  13510. /** @hidden */
  13511. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13512. /** @hidden */
  13513. _inheritParticleInfoToSubEmitters(): void;
  13514. /** @hidden */
  13515. _reset(): void;
  13516. /**
  13517. * Copy the properties of particle to another one.
  13518. * @param other the particle to copy the information to.
  13519. */
  13520. copyTo(other: Particle): void;
  13521. }
  13522. }
  13523. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13524. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13525. import { Effect } from "babylonjs/Materials/effect";
  13526. import { Particle } from "babylonjs/Particles/particle";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { Scene } from "babylonjs/scene";
  13529. /**
  13530. * Particle emitter represents a volume emitting particles.
  13531. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13532. */
  13533. export interface IParticleEmitterType {
  13534. /**
  13535. * Called by the particle System when the direction is computed for the created particle.
  13536. * @param worldMatrix is the world matrix of the particle system
  13537. * @param directionToUpdate is the direction vector to update with the result
  13538. * @param particle is the particle we are computed the direction for
  13539. * @param isLocal defines if the direction should be set in local space
  13540. */
  13541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13542. /**
  13543. * Called by the particle System when the position is computed for the created particle.
  13544. * @param worldMatrix is the world matrix of the particle system
  13545. * @param positionToUpdate is the position vector to update with the result
  13546. * @param particle is the particle we are computed the position for
  13547. * @param isLocal defines if the position should be set in local space
  13548. */
  13549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13550. /**
  13551. * Clones the current emitter and returns a copy of it
  13552. * @returns the new emitter
  13553. */
  13554. clone(): IParticleEmitterType;
  13555. /**
  13556. * Called by the GPUParticleSystem to setup the update shader
  13557. * @param effect defines the update shader
  13558. */
  13559. applyToShader(effect: Effect): void;
  13560. /**
  13561. * Returns a string to use to update the GPU particles update shader
  13562. * @returns the effect defines string
  13563. */
  13564. getEffectDefines(): string;
  13565. /**
  13566. * Returns a string representing the class name
  13567. * @returns a string containing the class name
  13568. */
  13569. getClassName(): string;
  13570. /**
  13571. * Serializes the particle system to a JSON object.
  13572. * @returns the JSON object
  13573. */
  13574. serialize(): any;
  13575. /**
  13576. * Parse properties from a JSON object
  13577. * @param serializationObject defines the JSON object
  13578. * @param scene defines the hosting scene
  13579. */
  13580. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13581. }
  13582. }
  13583. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13585. import { Effect } from "babylonjs/Materials/effect";
  13586. import { Particle } from "babylonjs/Particles/particle";
  13587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a box.
  13590. * It emits the particles randomly between 2 given directions.
  13591. */
  13592. export class BoxParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13595. */
  13596. direction1: Vector3;
  13597. /**
  13598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13599. */
  13600. direction2: Vector3;
  13601. /**
  13602. * 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.
  13603. */
  13604. minEmitBox: Vector3;
  13605. /**
  13606. * 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.
  13607. */
  13608. maxEmitBox: Vector3;
  13609. /**
  13610. * Creates a new instance BoxParticleEmitter
  13611. */
  13612. constructor();
  13613. /**
  13614. * Called by the particle System when the direction is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param directionToUpdate is the direction vector to update with the result
  13617. * @param particle is the particle we are computed the direction for
  13618. * @param isLocal defines if the direction should be set in local space
  13619. */
  13620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13621. /**
  13622. * Called by the particle System when the position is computed for the created particle.
  13623. * @param worldMatrix is the world matrix of the particle system
  13624. * @param positionToUpdate is the position vector to update with the result
  13625. * @param particle is the particle we are computed the position for
  13626. * @param isLocal defines if the position should be set in local space
  13627. */
  13628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13629. /**
  13630. * Clones the current emitter and returns a copy of it
  13631. * @returns the new emitter
  13632. */
  13633. clone(): BoxParticleEmitter;
  13634. /**
  13635. * Called by the GPUParticleSystem to setup the update shader
  13636. * @param effect defines the update shader
  13637. */
  13638. applyToShader(effect: Effect): void;
  13639. /**
  13640. * Returns a string to use to update the GPU particles update shader
  13641. * @returns a string containng the defines string
  13642. */
  13643. getEffectDefines(): string;
  13644. /**
  13645. * Returns the string "BoxParticleEmitter"
  13646. * @returns a string containing the class name
  13647. */
  13648. getClassName(): string;
  13649. /**
  13650. * Serializes the particle system to a JSON object.
  13651. * @returns the JSON object
  13652. */
  13653. serialize(): any;
  13654. /**
  13655. * Parse properties from a JSON object
  13656. * @param serializationObject defines the JSON object
  13657. */
  13658. parse(serializationObject: any): void;
  13659. }
  13660. }
  13661. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13662. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13663. import { Effect } from "babylonjs/Materials/effect";
  13664. import { Particle } from "babylonjs/Particles/particle";
  13665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13666. /**
  13667. * Particle emitter emitting particles from the inside of a cone.
  13668. * It emits the particles alongside the cone volume from the base to the particle.
  13669. * The emission direction might be randomized.
  13670. */
  13671. export class ConeParticleEmitter implements IParticleEmitterType {
  13672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13673. directionRandomizer: number;
  13674. private _radius;
  13675. private _angle;
  13676. private _height;
  13677. /**
  13678. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13679. */
  13680. radiusRange: number;
  13681. /**
  13682. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13683. */
  13684. heightRange: number;
  13685. /**
  13686. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13687. */
  13688. emitFromSpawnPointOnly: boolean;
  13689. /**
  13690. * Gets or sets the radius of the emission cone
  13691. */
  13692. get radius(): number;
  13693. set radius(value: number);
  13694. /**
  13695. * Gets or sets the angle of the emission cone
  13696. */
  13697. get angle(): number;
  13698. set angle(value: number);
  13699. private _buildHeight;
  13700. /**
  13701. * Creates a new instance ConeParticleEmitter
  13702. * @param radius the radius of the emission cone (1 by default)
  13703. * @param angle the cone base angle (PI by default)
  13704. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13705. */
  13706. constructor(radius?: number, angle?: number,
  13707. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13708. directionRandomizer?: number);
  13709. /**
  13710. * Called by the particle System when the direction is computed for the created particle.
  13711. * @param worldMatrix is the world matrix of the particle system
  13712. * @param directionToUpdate is the direction vector to update with the result
  13713. * @param particle is the particle we are computed the direction for
  13714. * @param isLocal defines if the direction should be set in local space
  13715. */
  13716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13717. /**
  13718. * Called by the particle System when the position is computed for the created particle.
  13719. * @param worldMatrix is the world matrix of the particle system
  13720. * @param positionToUpdate is the position vector to update with the result
  13721. * @param particle is the particle we are computed the position for
  13722. * @param isLocal defines if the position should be set in local space
  13723. */
  13724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13725. /**
  13726. * Clones the current emitter and returns a copy of it
  13727. * @returns the new emitter
  13728. */
  13729. clone(): ConeParticleEmitter;
  13730. /**
  13731. * Called by the GPUParticleSystem to setup the update shader
  13732. * @param effect defines the update shader
  13733. */
  13734. applyToShader(effect: Effect): void;
  13735. /**
  13736. * Returns a string to use to update the GPU particles update shader
  13737. * @returns a string containng the defines string
  13738. */
  13739. getEffectDefines(): string;
  13740. /**
  13741. * Returns the string "ConeParticleEmitter"
  13742. * @returns a string containing the class name
  13743. */
  13744. getClassName(): string;
  13745. /**
  13746. * Serializes the particle system to a JSON object.
  13747. * @returns the JSON object
  13748. */
  13749. serialize(): any;
  13750. /**
  13751. * Parse properties from a JSON object
  13752. * @param serializationObject defines the JSON object
  13753. */
  13754. parse(serializationObject: any): void;
  13755. }
  13756. }
  13757. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13759. import { Effect } from "babylonjs/Materials/effect";
  13760. import { Particle } from "babylonjs/Particles/particle";
  13761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13762. /**
  13763. * Particle emitter emitting particles from the inside of a cylinder.
  13764. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13765. */
  13766. export class CylinderParticleEmitter implements IParticleEmitterType {
  13767. /**
  13768. * The radius of the emission cylinder.
  13769. */
  13770. radius: number;
  13771. /**
  13772. * The height of the emission cylinder.
  13773. */
  13774. height: number;
  13775. /**
  13776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13777. */
  13778. radiusRange: number;
  13779. /**
  13780. * How much to randomize the particle direction [0-1].
  13781. */
  13782. directionRandomizer: number;
  13783. /**
  13784. * Creates a new instance CylinderParticleEmitter
  13785. * @param radius the radius of the emission cylinder (1 by default)
  13786. * @param height the height of the emission cylinder (1 by default)
  13787. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13789. */
  13790. constructor(
  13791. /**
  13792. * The radius of the emission cylinder.
  13793. */
  13794. radius?: number,
  13795. /**
  13796. * The height of the emission cylinder.
  13797. */
  13798. height?: number,
  13799. /**
  13800. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13801. */
  13802. radiusRange?: number,
  13803. /**
  13804. * How much to randomize the particle direction [0-1].
  13805. */
  13806. directionRandomizer?: number);
  13807. /**
  13808. * Called by the particle System when the direction is computed for the created particle.
  13809. * @param worldMatrix is the world matrix of the particle system
  13810. * @param directionToUpdate is the direction vector to update with the result
  13811. * @param particle is the particle we are computed the direction for
  13812. * @param isLocal defines if the direction should be set in local space
  13813. */
  13814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13815. /**
  13816. * Called by the particle System when the position is computed for the created particle.
  13817. * @param worldMatrix is the world matrix of the particle system
  13818. * @param positionToUpdate is the position vector to update with the result
  13819. * @param particle is the particle we are computed the position for
  13820. * @param isLocal defines if the position should be set in local space
  13821. */
  13822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13823. /**
  13824. * Clones the current emitter and returns a copy of it
  13825. * @returns the new emitter
  13826. */
  13827. clone(): CylinderParticleEmitter;
  13828. /**
  13829. * Called by the GPUParticleSystem to setup the update shader
  13830. * @param effect defines the update shader
  13831. */
  13832. applyToShader(effect: Effect): void;
  13833. /**
  13834. * Returns a string to use to update the GPU particles update shader
  13835. * @returns a string containng the defines string
  13836. */
  13837. getEffectDefines(): string;
  13838. /**
  13839. * Returns the string "CylinderParticleEmitter"
  13840. * @returns a string containing the class name
  13841. */
  13842. getClassName(): string;
  13843. /**
  13844. * Serializes the particle system to a JSON object.
  13845. * @returns the JSON object
  13846. */
  13847. serialize(): any;
  13848. /**
  13849. * Parse properties from a JSON object
  13850. * @param serializationObject defines the JSON object
  13851. */
  13852. parse(serializationObject: any): void;
  13853. }
  13854. /**
  13855. * Particle emitter emitting particles from the inside of a cylinder.
  13856. * It emits the particles randomly between two vectors.
  13857. */
  13858. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13859. /**
  13860. * The min limit of the emission direction.
  13861. */
  13862. direction1: Vector3;
  13863. /**
  13864. * The max limit of the emission direction.
  13865. */
  13866. direction2: Vector3;
  13867. /**
  13868. * Creates a new instance CylinderDirectedParticleEmitter
  13869. * @param radius the radius of the emission cylinder (1 by default)
  13870. * @param height the height of the emission cylinder (1 by default)
  13871. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13872. * @param direction1 the min limit of the emission direction (up vector by default)
  13873. * @param direction2 the max limit of the emission direction (up vector by default)
  13874. */
  13875. constructor(radius?: number, height?: number, radiusRange?: number,
  13876. /**
  13877. * The min limit of the emission direction.
  13878. */
  13879. direction1?: Vector3,
  13880. /**
  13881. * The max limit of the emission direction.
  13882. */
  13883. direction2?: Vector3);
  13884. /**
  13885. * Called by the particle System when the direction is computed for the created particle.
  13886. * @param worldMatrix is the world matrix of the particle system
  13887. * @param directionToUpdate is the direction vector to update with the result
  13888. * @param particle is the particle we are computed the direction for
  13889. */
  13890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13891. /**
  13892. * Clones the current emitter and returns a copy of it
  13893. * @returns the new emitter
  13894. */
  13895. clone(): CylinderDirectedParticleEmitter;
  13896. /**
  13897. * Called by the GPUParticleSystem to setup the update shader
  13898. * @param effect defines the update shader
  13899. */
  13900. applyToShader(effect: Effect): void;
  13901. /**
  13902. * Returns a string to use to update the GPU particles update shader
  13903. * @returns a string containng the defines string
  13904. */
  13905. getEffectDefines(): string;
  13906. /**
  13907. * Returns the string "CylinderDirectedParticleEmitter"
  13908. * @returns a string containing the class name
  13909. */
  13910. getClassName(): string;
  13911. /**
  13912. * Serializes the particle system to a JSON object.
  13913. * @returns the JSON object
  13914. */
  13915. serialize(): any;
  13916. /**
  13917. * Parse properties from a JSON object
  13918. * @param serializationObject defines the JSON object
  13919. */
  13920. parse(serializationObject: any): void;
  13921. }
  13922. }
  13923. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13924. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13925. import { Effect } from "babylonjs/Materials/effect";
  13926. import { Particle } from "babylonjs/Particles/particle";
  13927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13928. /**
  13929. * Particle emitter emitting particles from the inside of a hemisphere.
  13930. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13931. */
  13932. export class HemisphericParticleEmitter implements IParticleEmitterType {
  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. * Creates a new instance HemisphericParticleEmitter
  13947. * @param radius the radius of the emission hemisphere (1 by default)
  13948. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13950. */
  13951. constructor(
  13952. /**
  13953. * The radius of the emission hemisphere.
  13954. */
  13955. radius?: number,
  13956. /**
  13957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13958. */
  13959. radiusRange?: number,
  13960. /**
  13961. * How much to randomize the particle direction [0-1].
  13962. */
  13963. directionRandomizer?: number);
  13964. /**
  13965. * Called by the particle System when the direction is computed for the created particle.
  13966. * @param worldMatrix is the world matrix of the particle system
  13967. * @param directionToUpdate is the direction vector to update with the result
  13968. * @param particle is the particle we are computed the direction for
  13969. * @param isLocal defines if the direction should be set in local space
  13970. */
  13971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13972. /**
  13973. * Called by the particle System when the position is computed for the created particle.
  13974. * @param worldMatrix is the world matrix of the particle system
  13975. * @param positionToUpdate is the position vector to update with the result
  13976. * @param particle is the particle we are computed the position for
  13977. * @param isLocal defines if the position should be set in local space
  13978. */
  13979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13980. /**
  13981. * Clones the current emitter and returns a copy of it
  13982. * @returns the new emitter
  13983. */
  13984. clone(): HemisphericParticleEmitter;
  13985. /**
  13986. * Called by the GPUParticleSystem to setup the update shader
  13987. * @param effect defines the update shader
  13988. */
  13989. applyToShader(effect: Effect): void;
  13990. /**
  13991. * Returns a string to use to update the GPU particles update shader
  13992. * @returns a string containng the defines string
  13993. */
  13994. getEffectDefines(): string;
  13995. /**
  13996. * Returns the string "HemisphericParticleEmitter"
  13997. * @returns a string containing the class name
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Serializes the particle system to a JSON object.
  14002. * @returns the JSON object
  14003. */
  14004. serialize(): any;
  14005. /**
  14006. * Parse properties from a JSON object
  14007. * @param serializationObject defines the JSON object
  14008. */
  14009. parse(serializationObject: any): void;
  14010. }
  14011. }
  14012. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14013. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14014. import { Effect } from "babylonjs/Materials/effect";
  14015. import { Particle } from "babylonjs/Particles/particle";
  14016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14017. /**
  14018. * Particle emitter emitting particles from a point.
  14019. * It emits the particles randomly between 2 given directions.
  14020. */
  14021. export class PointParticleEmitter implements IParticleEmitterType {
  14022. /**
  14023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14024. */
  14025. direction1: Vector3;
  14026. /**
  14027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14028. */
  14029. direction2: Vector3;
  14030. /**
  14031. * Creates a new instance PointParticleEmitter
  14032. */
  14033. constructor();
  14034. /**
  14035. * Called by the particle System when the direction is computed for the created particle.
  14036. * @param worldMatrix is the world matrix of the particle system
  14037. * @param directionToUpdate is the direction vector to update with the result
  14038. * @param particle is the particle we are computed the direction for
  14039. * @param isLocal defines if the direction should be set in local space
  14040. */
  14041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14042. /**
  14043. * Called by the particle System when the position is computed for the created particle.
  14044. * @param worldMatrix is the world matrix of the particle system
  14045. * @param positionToUpdate is the position vector to update with the result
  14046. * @param particle is the particle we are computed the position for
  14047. * @param isLocal defines if the position should be set in local space
  14048. */
  14049. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14050. /**
  14051. * Clones the current emitter and returns a copy of it
  14052. * @returns the new emitter
  14053. */
  14054. clone(): PointParticleEmitter;
  14055. /**
  14056. * Called by the GPUParticleSystem to setup the update shader
  14057. * @param effect defines the update shader
  14058. */
  14059. applyToShader(effect: Effect): void;
  14060. /**
  14061. * Returns a string to use to update the GPU particles update shader
  14062. * @returns a string containng the defines string
  14063. */
  14064. getEffectDefines(): string;
  14065. /**
  14066. * Returns the string "PointParticleEmitter"
  14067. * @returns a string containing the class name
  14068. */
  14069. getClassName(): string;
  14070. /**
  14071. * Serializes the particle system to a JSON object.
  14072. * @returns the JSON object
  14073. */
  14074. serialize(): any;
  14075. /**
  14076. * Parse properties from a JSON object
  14077. * @param serializationObject defines the JSON object
  14078. */
  14079. parse(serializationObject: any): void;
  14080. }
  14081. }
  14082. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14083. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14084. import { Effect } from "babylonjs/Materials/effect";
  14085. import { Particle } from "babylonjs/Particles/particle";
  14086. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14087. /**
  14088. * Particle emitter emitting particles from the inside of a sphere.
  14089. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14090. */
  14091. export class SphereParticleEmitter implements IParticleEmitterType {
  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. * Creates a new instance SphereParticleEmitter
  14106. * @param radius the radius of the emission sphere (1 by default)
  14107. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14108. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14109. */
  14110. constructor(
  14111. /**
  14112. * The radius of the emission sphere.
  14113. */
  14114. radius?: number,
  14115. /**
  14116. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14117. */
  14118. radiusRange?: number,
  14119. /**
  14120. * How much to randomize the particle direction [0-1].
  14121. */
  14122. directionRandomizer?: number);
  14123. /**
  14124. * Called by the particle System when the direction is computed for the created particle.
  14125. * @param worldMatrix is the world matrix of the particle system
  14126. * @param directionToUpdate is the direction vector to update with the result
  14127. * @param particle is the particle we are computed the direction for
  14128. * @param isLocal defines if the direction should be set in local space
  14129. */
  14130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14131. /**
  14132. * Called by the particle System when the position is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param positionToUpdate is the position vector to update with the result
  14135. * @param particle is the particle we are computed the position for
  14136. * @param isLocal defines if the position should be set in local space
  14137. */
  14138. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14139. /**
  14140. * Clones the current emitter and returns a copy of it
  14141. * @returns the new emitter
  14142. */
  14143. clone(): SphereParticleEmitter;
  14144. /**
  14145. * Called by the GPUParticleSystem to setup the update shader
  14146. * @param effect defines the update shader
  14147. */
  14148. applyToShader(effect: Effect): void;
  14149. /**
  14150. * Returns a string to use to update the GPU particles update shader
  14151. * @returns a string containng the defines string
  14152. */
  14153. getEffectDefines(): string;
  14154. /**
  14155. * Returns the string "SphereParticleEmitter"
  14156. * @returns a string containing the class name
  14157. */
  14158. getClassName(): string;
  14159. /**
  14160. * Serializes the particle system to a JSON object.
  14161. * @returns the JSON object
  14162. */
  14163. serialize(): any;
  14164. /**
  14165. * Parse properties from a JSON object
  14166. * @param serializationObject defines the JSON object
  14167. */
  14168. parse(serializationObject: any): void;
  14169. }
  14170. /**
  14171. * Particle emitter emitting particles from the inside of a sphere.
  14172. * It emits the particles randomly between two vectors.
  14173. */
  14174. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14175. /**
  14176. * The min limit of the emission direction.
  14177. */
  14178. direction1: Vector3;
  14179. /**
  14180. * The max limit of the emission direction.
  14181. */
  14182. direction2: Vector3;
  14183. /**
  14184. * Creates a new instance SphereDirectedParticleEmitter
  14185. * @param radius the radius of the emission sphere (1 by default)
  14186. * @param direction1 the min limit of the emission direction (up vector by default)
  14187. * @param direction2 the max limit of the emission direction (up vector by default)
  14188. */
  14189. constructor(radius?: number,
  14190. /**
  14191. * The min limit of the emission direction.
  14192. */
  14193. direction1?: Vector3,
  14194. /**
  14195. * The max limit of the emission direction.
  14196. */
  14197. direction2?: Vector3);
  14198. /**
  14199. * Called by the particle System when the direction is computed for the created particle.
  14200. * @param worldMatrix is the world matrix of the particle system
  14201. * @param directionToUpdate is the direction vector to update with the result
  14202. * @param particle is the particle we are computed the direction for
  14203. */
  14204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14205. /**
  14206. * Clones the current emitter and returns a copy of it
  14207. * @returns the new emitter
  14208. */
  14209. clone(): SphereDirectedParticleEmitter;
  14210. /**
  14211. * Called by the GPUParticleSystem to setup the update shader
  14212. * @param effect defines the update shader
  14213. */
  14214. applyToShader(effect: Effect): void;
  14215. /**
  14216. * Returns a string to use to update the GPU particles update shader
  14217. * @returns a string containng the defines string
  14218. */
  14219. getEffectDefines(): string;
  14220. /**
  14221. * Returns the string "SphereDirectedParticleEmitter"
  14222. * @returns a string containing the class name
  14223. */
  14224. getClassName(): string;
  14225. /**
  14226. * Serializes the particle system to a JSON object.
  14227. * @returns the JSON object
  14228. */
  14229. serialize(): any;
  14230. /**
  14231. * Parse properties from a JSON object
  14232. * @param serializationObject defines the JSON object
  14233. */
  14234. parse(serializationObject: any): void;
  14235. }
  14236. }
  14237. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14239. import { Effect } from "babylonjs/Materials/effect";
  14240. import { Particle } from "babylonjs/Particles/particle";
  14241. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14242. import { Nullable } from "babylonjs/types";
  14243. /**
  14244. * Particle emitter emitting particles from a custom list of positions.
  14245. */
  14246. export class CustomParticleEmitter implements IParticleEmitterType {
  14247. /**
  14248. * Gets or sets the position generator that will create the inital position of each particle.
  14249. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14250. */
  14251. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14252. /**
  14253. * Gets or sets the destination generator that will create the final destination of each particle.
  14254. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14255. */
  14256. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14257. /**
  14258. * Creates a new instance CustomParticleEmitter
  14259. */
  14260. constructor();
  14261. /**
  14262. * Called by the particle System when the direction is computed for the created particle.
  14263. * @param worldMatrix is the world matrix of the particle system
  14264. * @param directionToUpdate is the direction vector to update with the result
  14265. * @param particle is the particle we are computed the direction for
  14266. * @param isLocal defines if the direction should be set in local space
  14267. */
  14268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14269. /**
  14270. * Called by the particle System when the position is computed for the created particle.
  14271. * @param worldMatrix is the world matrix of the particle system
  14272. * @param positionToUpdate is the position vector to update with the result
  14273. * @param particle is the particle we are computed the position for
  14274. * @param isLocal defines if the position should be set in local space
  14275. */
  14276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14277. /**
  14278. * Clones the current emitter and returns a copy of it
  14279. * @returns the new emitter
  14280. */
  14281. clone(): CustomParticleEmitter;
  14282. /**
  14283. * Called by the GPUParticleSystem to setup the update shader
  14284. * @param effect defines the update shader
  14285. */
  14286. applyToShader(effect: Effect): void;
  14287. /**
  14288. * Returns a string to use to update the GPU particles update shader
  14289. * @returns a string containng the defines string
  14290. */
  14291. getEffectDefines(): string;
  14292. /**
  14293. * Returns the string "PointParticleEmitter"
  14294. * @returns a string containing the class name
  14295. */
  14296. getClassName(): string;
  14297. /**
  14298. * Serializes the particle system to a JSON object.
  14299. * @returns the JSON object
  14300. */
  14301. serialize(): any;
  14302. /**
  14303. * Parse properties from a JSON object
  14304. * @param serializationObject defines the JSON object
  14305. */
  14306. parse(serializationObject: any): void;
  14307. }
  14308. }
  14309. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14310. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14311. import { Effect } from "babylonjs/Materials/effect";
  14312. import { Particle } from "babylonjs/Particles/particle";
  14313. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14314. import { Nullable } from "babylonjs/types";
  14315. import { Scene } from "babylonjs/scene";
  14316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14317. /**
  14318. * Particle emitter emitting particles from the inside of a box.
  14319. * It emits the particles randomly between 2 given directions.
  14320. */
  14321. export class MeshParticleEmitter implements IParticleEmitterType {
  14322. private _indices;
  14323. private _positions;
  14324. private _normals;
  14325. private _storedNormal;
  14326. private _mesh;
  14327. /**
  14328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14329. */
  14330. direction1: Vector3;
  14331. /**
  14332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14333. */
  14334. direction2: Vector3;
  14335. /**
  14336. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14337. */
  14338. useMeshNormalsForDirection: boolean;
  14339. /** Defines the mesh to use as source */
  14340. get mesh(): Nullable<AbstractMesh>;
  14341. set mesh(value: Nullable<AbstractMesh>);
  14342. /**
  14343. * Creates a new instance MeshParticleEmitter
  14344. * @param mesh defines the mesh to use as source
  14345. */
  14346. constructor(mesh?: Nullable<AbstractMesh>);
  14347. /**
  14348. * Called by the particle System when the direction is computed for the created particle.
  14349. * @param worldMatrix is the world matrix of the particle system
  14350. * @param directionToUpdate is the direction vector to update with the result
  14351. * @param particle is the particle we are computed the direction for
  14352. * @param isLocal defines if the direction should be set in local space
  14353. */
  14354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14355. /**
  14356. * Called by the particle System when the position is computed for the created particle.
  14357. * @param worldMatrix is the world matrix of the particle system
  14358. * @param positionToUpdate is the position vector to update with the result
  14359. * @param particle is the particle we are computed the position for
  14360. * @param isLocal defines if the position should be set in local space
  14361. */
  14362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14363. /**
  14364. * Clones the current emitter and returns a copy of it
  14365. * @returns the new emitter
  14366. */
  14367. clone(): MeshParticleEmitter;
  14368. /**
  14369. * Called by the GPUParticleSystem to setup the update shader
  14370. * @param effect defines the update shader
  14371. */
  14372. applyToShader(effect: Effect): void;
  14373. /**
  14374. * Returns a string to use to update the GPU particles update shader
  14375. * @returns a string containng the defines string
  14376. */
  14377. getEffectDefines(): string;
  14378. /**
  14379. * Returns the string "BoxParticleEmitter"
  14380. * @returns a string containing the class name
  14381. */
  14382. getClassName(): string;
  14383. /**
  14384. * Serializes the particle system to a JSON object.
  14385. * @returns the JSON object
  14386. */
  14387. serialize(): any;
  14388. /**
  14389. * Parse properties from a JSON object
  14390. * @param serializationObject defines the JSON object
  14391. * @param scene defines the hosting scene
  14392. */
  14393. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14394. }
  14395. }
  14396. declare module "babylonjs/Particles/EmitterTypes/index" {
  14397. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14398. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14399. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14400. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14401. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14402. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14403. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14404. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14405. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14406. }
  14407. declare module "babylonjs/Particles/IParticleSystem" {
  14408. import { Nullable } from "babylonjs/types";
  14409. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14410. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14412. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14415. import { Effect } from "babylonjs/Materials/effect";
  14416. import { Observable } from "babylonjs/Misc/observable";
  14417. import { Animation } from "babylonjs/Animations/animation";
  14418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14419. /**
  14420. * Interface representing a particle system in Babylon.js.
  14421. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14422. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14423. */
  14424. export interface IParticleSystem {
  14425. /**
  14426. * List of animations used by the particle system.
  14427. */
  14428. animations: Animation[];
  14429. /**
  14430. * The id of the Particle system.
  14431. */
  14432. id: string;
  14433. /**
  14434. * The name of the Particle system.
  14435. */
  14436. name: string;
  14437. /**
  14438. * The emitter represents the Mesh or position we are attaching the particle system to.
  14439. */
  14440. emitter: Nullable<AbstractMesh | Vector3>;
  14441. /**
  14442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14443. */
  14444. isBillboardBased: boolean;
  14445. /**
  14446. * The rendering group used by the Particle system to chose when to render.
  14447. */
  14448. renderingGroupId: number;
  14449. /**
  14450. * The layer mask we are rendering the particles through.
  14451. */
  14452. layerMask: number;
  14453. /**
  14454. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14455. */
  14456. updateSpeed: number;
  14457. /**
  14458. * The amount of time the particle system is running (depends of the overall update speed).
  14459. */
  14460. targetStopDuration: number;
  14461. /**
  14462. * The texture used to render each particle. (this can be a spritesheet)
  14463. */
  14464. particleTexture: Nullable<BaseTexture>;
  14465. /**
  14466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14467. */
  14468. blendMode: number;
  14469. /**
  14470. * Minimum life time of emitting particles.
  14471. */
  14472. minLifeTime: number;
  14473. /**
  14474. * Maximum life time of emitting particles.
  14475. */
  14476. maxLifeTime: number;
  14477. /**
  14478. * Minimum Size of emitting particles.
  14479. */
  14480. minSize: number;
  14481. /**
  14482. * Maximum Size of emitting particles.
  14483. */
  14484. maxSize: number;
  14485. /**
  14486. * Minimum scale of emitting particles on X axis.
  14487. */
  14488. minScaleX: number;
  14489. /**
  14490. * Maximum scale of emitting particles on X axis.
  14491. */
  14492. maxScaleX: number;
  14493. /**
  14494. * Minimum scale of emitting particles on Y axis.
  14495. */
  14496. minScaleY: number;
  14497. /**
  14498. * Maximum scale of emitting particles on Y axis.
  14499. */
  14500. maxScaleY: number;
  14501. /**
  14502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14503. */
  14504. color1: Color4;
  14505. /**
  14506. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14507. */
  14508. color2: Color4;
  14509. /**
  14510. * Color the particle will have at the end of its lifetime.
  14511. */
  14512. colorDead: Color4;
  14513. /**
  14514. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14515. */
  14516. emitRate: number;
  14517. /**
  14518. * You can use gravity if you want to give an orientation to your particles.
  14519. */
  14520. gravity: Vector3;
  14521. /**
  14522. * Minimum power of emitting particles.
  14523. */
  14524. minEmitPower: number;
  14525. /**
  14526. * Maximum power of emitting particles.
  14527. */
  14528. maxEmitPower: number;
  14529. /**
  14530. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14531. */
  14532. minAngularSpeed: number;
  14533. /**
  14534. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14535. */
  14536. maxAngularSpeed: number;
  14537. /**
  14538. * Gets or sets the minimal initial rotation in radians.
  14539. */
  14540. minInitialRotation: number;
  14541. /**
  14542. * Gets or sets the maximal initial rotation in radians.
  14543. */
  14544. maxInitialRotation: number;
  14545. /**
  14546. * The particle emitter type defines the emitter used by the particle system.
  14547. * It can be for example box, sphere, or cone...
  14548. */
  14549. particleEmitterType: Nullable<IParticleEmitterType>;
  14550. /**
  14551. * Defines the delay in milliseconds before starting the system (0 by default)
  14552. */
  14553. startDelay: number;
  14554. /**
  14555. * 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
  14556. */
  14557. preWarmCycles: number;
  14558. /**
  14559. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14560. */
  14561. preWarmStepOffset: number;
  14562. /**
  14563. * 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)
  14564. */
  14565. spriteCellChangeSpeed: number;
  14566. /**
  14567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14568. */
  14569. startSpriteCellID: number;
  14570. /**
  14571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14572. */
  14573. endSpriteCellID: number;
  14574. /**
  14575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14576. */
  14577. spriteCellWidth: number;
  14578. /**
  14579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14580. */
  14581. spriteCellHeight: number;
  14582. /**
  14583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14584. */
  14585. spriteRandomStartCell: boolean;
  14586. /**
  14587. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14588. */
  14589. isAnimationSheetEnabled: boolean;
  14590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14591. translationPivot: Vector2;
  14592. /**
  14593. * Gets or sets a texture used to add random noise to particle positions
  14594. */
  14595. noiseTexture: Nullable<BaseTexture>;
  14596. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14597. noiseStrength: Vector3;
  14598. /**
  14599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14601. */
  14602. billboardMode: number;
  14603. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14604. limitVelocityDamping: number;
  14605. /**
  14606. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14607. */
  14608. beginAnimationOnStart: boolean;
  14609. /**
  14610. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14611. */
  14612. beginAnimationFrom: number;
  14613. /**
  14614. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14615. */
  14616. beginAnimationTo: number;
  14617. /**
  14618. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14619. */
  14620. beginAnimationLoop: boolean;
  14621. /**
  14622. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14623. */
  14624. disposeOnStop: boolean;
  14625. /**
  14626. * Specifies if the particles are updated in emitter local space or world space
  14627. */
  14628. isLocal: boolean;
  14629. /** Snippet ID if the particle system was created from the snippet server */
  14630. snippetId: string;
  14631. /** Gets or sets a matrix to use to compute projection */
  14632. defaultProjectionMatrix: Matrix;
  14633. /**
  14634. * Gets the maximum number of particles active at the same time.
  14635. * @returns The max number of active particles.
  14636. */
  14637. getCapacity(): number;
  14638. /**
  14639. * Gets the number of particles active at the same time.
  14640. * @returns The number of active particles.
  14641. */
  14642. getActiveCount(): number;
  14643. /**
  14644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14645. * @returns True if it has been started, otherwise false.
  14646. */
  14647. isStarted(): boolean;
  14648. /**
  14649. * Animates the particle system for this frame.
  14650. */
  14651. animate(): void;
  14652. /**
  14653. * Renders the particle system in its current state.
  14654. * @returns the current number of particles
  14655. */
  14656. render(): number;
  14657. /**
  14658. * Dispose the particle system and frees its associated resources.
  14659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14660. */
  14661. dispose(disposeTexture?: boolean): void;
  14662. /**
  14663. * An event triggered when the system is disposed
  14664. */
  14665. onDisposeObservable: Observable<IParticleSystem>;
  14666. /**
  14667. * Clones the particle system.
  14668. * @param name The name of the cloned object
  14669. * @param newEmitter The new emitter to use
  14670. * @returns the cloned particle system
  14671. */
  14672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14673. /**
  14674. * Serializes the particle system to a JSON object
  14675. * @param serializeTexture defines if the texture must be serialized as well
  14676. * @returns the JSON object
  14677. */
  14678. serialize(serializeTexture: boolean): any;
  14679. /**
  14680. * Rebuild the particle system
  14681. */
  14682. rebuild(): void;
  14683. /** Force the system to rebuild all gradients that need to be resync */
  14684. forceRefreshGradients(): void;
  14685. /**
  14686. * Starts the particle system and begins to emit
  14687. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14688. */
  14689. start(delay?: number): void;
  14690. /**
  14691. * Stops the particle system.
  14692. */
  14693. stop(): void;
  14694. /**
  14695. * Remove all active particles
  14696. */
  14697. reset(): void;
  14698. /**
  14699. * Gets a boolean indicating that the system is stopping
  14700. * @returns true if the system is currently stopping
  14701. */
  14702. isStopping(): boolean;
  14703. /**
  14704. * Is this system ready to be used/rendered
  14705. * @return true if the system is ready
  14706. */
  14707. isReady(): boolean;
  14708. /**
  14709. * Returns the string "ParticleSystem"
  14710. * @returns a string containing the class name
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets the custom effect used to render the particles
  14715. * @param blendMode Blend mode for which the effect should be retrieved
  14716. * @returns The effect
  14717. */
  14718. getCustomEffect(blendMode: number): Nullable<Effect>;
  14719. /**
  14720. * Sets the custom effect used to render the particles
  14721. * @param effect The effect to set
  14722. * @param blendMode Blend mode for which the effect should be set
  14723. */
  14724. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14725. /**
  14726. * Fill the defines array according to the current settings of the particle system
  14727. * @param defines Array to be updated
  14728. * @param blendMode blend mode to take into account when updating the array
  14729. */
  14730. fillDefines(defines: Array<string>, blendMode: number): void;
  14731. /**
  14732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14733. * @param uniforms Uniforms array to fill
  14734. * @param attributes Attributes array to fill
  14735. * @param samplers Samplers array to fill
  14736. */
  14737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14738. /**
  14739. * Observable that will be called just before the particles are drawn
  14740. */
  14741. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14742. /**
  14743. * Gets the name of the particle vertex shader
  14744. */
  14745. vertexShaderName: string;
  14746. /**
  14747. * Adds a new color gradient
  14748. * @param gradient defines the gradient to use (between 0 and 1)
  14749. * @param color1 defines the color to affect to the specified gradient
  14750. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14751. * @returns the current particle system
  14752. */
  14753. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14754. /**
  14755. * Remove a specific color gradient
  14756. * @param gradient defines the gradient to remove
  14757. * @returns the current particle system
  14758. */
  14759. removeColorGradient(gradient: number): IParticleSystem;
  14760. /**
  14761. * Adds a new size gradient
  14762. * @param gradient defines the gradient to use (between 0 and 1)
  14763. * @param factor defines the size factor to affect to the specified gradient
  14764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14765. * @returns the current particle system
  14766. */
  14767. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14768. /**
  14769. * Remove a specific size gradient
  14770. * @param gradient defines the gradient to remove
  14771. * @returns the current particle system
  14772. */
  14773. removeSizeGradient(gradient: number): IParticleSystem;
  14774. /**
  14775. * Gets the current list of color gradients.
  14776. * You must use addColorGradient and removeColorGradient to udpate this list
  14777. * @returns the list of color gradients
  14778. */
  14779. getColorGradients(): Nullable<Array<ColorGradient>>;
  14780. /**
  14781. * Gets the current list of size gradients.
  14782. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14783. * @returns the list of size gradients
  14784. */
  14785. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14786. /**
  14787. * Gets the current list of angular speed gradients.
  14788. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14789. * @returns the list of angular speed gradients
  14790. */
  14791. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new angular speed gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param factor defines the angular speed to affect to the specified gradient
  14796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14797. * @returns the current particle system
  14798. */
  14799. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14800. /**
  14801. * Remove a specific angular speed gradient
  14802. * @param gradient defines the gradient to remove
  14803. * @returns the current particle system
  14804. */
  14805. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14806. /**
  14807. * Gets the current list of velocity gradients.
  14808. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14809. * @returns the list of velocity gradients
  14810. */
  14811. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14812. /**
  14813. * Adds a new velocity gradient
  14814. * @param gradient defines the gradient to use (between 0 and 1)
  14815. * @param factor defines the velocity to affect to the specified gradient
  14816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14817. * @returns the current particle system
  14818. */
  14819. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14820. /**
  14821. * Remove a specific velocity gradient
  14822. * @param gradient defines the gradient to remove
  14823. * @returns the current particle system
  14824. */
  14825. removeVelocityGradient(gradient: number): IParticleSystem;
  14826. /**
  14827. * Gets the current list of limit velocity gradients.
  14828. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14829. * @returns the list of limit velocity gradients
  14830. */
  14831. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14832. /**
  14833. * Adds a new limit velocity gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param factor defines the limit velocity to affect to the specified gradient
  14836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14837. * @returns the current particle system
  14838. */
  14839. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14840. /**
  14841. * Remove a specific limit velocity gradient
  14842. * @param gradient defines the gradient to remove
  14843. * @returns the current particle system
  14844. */
  14845. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14846. /**
  14847. * Adds a new drag gradient
  14848. * @param gradient defines the gradient to use (between 0 and 1)
  14849. * @param factor defines the drag to affect to the specified gradient
  14850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14851. * @returns the current particle system
  14852. */
  14853. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14854. /**
  14855. * Remove a specific drag gradient
  14856. * @param gradient defines the gradient to remove
  14857. * @returns the current particle system
  14858. */
  14859. removeDragGradient(gradient: number): IParticleSystem;
  14860. /**
  14861. * Gets the current list of drag gradients.
  14862. * You must use addDragGradient and removeDragGradient to udpate this list
  14863. * @returns the list of drag gradients
  14864. */
  14865. getDragGradients(): Nullable<Array<FactorGradient>>;
  14866. /**
  14867. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14868. * @param gradient defines the gradient to use (between 0 and 1)
  14869. * @param factor defines the emit rate to affect to the specified gradient
  14870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14871. * @returns the current particle system
  14872. */
  14873. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14874. /**
  14875. * Remove a specific emit rate gradient
  14876. * @param gradient defines the gradient to remove
  14877. * @returns the current particle system
  14878. */
  14879. removeEmitRateGradient(gradient: number): IParticleSystem;
  14880. /**
  14881. * Gets the current list of emit rate gradients.
  14882. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14883. * @returns the list of emit rate gradients
  14884. */
  14885. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14886. /**
  14887. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14888. * @param gradient defines the gradient to use (between 0 and 1)
  14889. * @param factor defines the start size to affect to the specified gradient
  14890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14891. * @returns the current particle system
  14892. */
  14893. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14894. /**
  14895. * Remove a specific start size gradient
  14896. * @param gradient defines the gradient to remove
  14897. * @returns the current particle system
  14898. */
  14899. removeStartSizeGradient(gradient: number): IParticleSystem;
  14900. /**
  14901. * Gets the current list of start size gradients.
  14902. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14903. * @returns the list of start size gradients
  14904. */
  14905. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14906. /**
  14907. * Adds a new life time gradient
  14908. * @param gradient defines the gradient to use (between 0 and 1)
  14909. * @param factor defines the life time factor to affect to the specified gradient
  14910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14911. * @returns the current particle system
  14912. */
  14913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14914. /**
  14915. * Remove a specific life time gradient
  14916. * @param gradient defines the gradient to remove
  14917. * @returns the current particle system
  14918. */
  14919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14920. /**
  14921. * Gets the current list of life time gradients.
  14922. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14923. * @returns the list of life time gradients
  14924. */
  14925. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14926. /**
  14927. * Gets the current list of color gradients.
  14928. * You must use addColorGradient and removeColorGradient to udpate this list
  14929. * @returns the list of color gradients
  14930. */
  14931. getColorGradients(): Nullable<Array<ColorGradient>>;
  14932. /**
  14933. * Adds a new ramp gradient used to remap particle colors
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param color defines the color to affect to the specified gradient
  14936. * @returns the current particle system
  14937. */
  14938. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14939. /**
  14940. * Gets the current list of ramp gradients.
  14941. * You must use addRampGradient and removeRampGradient to udpate this list
  14942. * @returns the list of ramp gradients
  14943. */
  14944. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14945. /** Gets or sets a boolean indicating that ramp gradients must be used
  14946. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14947. */
  14948. useRampGradients: boolean;
  14949. /**
  14950. * Adds a new color remap gradient
  14951. * @param gradient defines the gradient to use (between 0 and 1)
  14952. * @param min defines the color remap minimal range
  14953. * @param max defines the color remap maximal range
  14954. * @returns the current particle system
  14955. */
  14956. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14957. /**
  14958. * Gets the current list of color remap gradients.
  14959. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14960. * @returns the list of color remap gradients
  14961. */
  14962. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14963. /**
  14964. * Adds a new alpha remap gradient
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param min defines the alpha remap minimal range
  14967. * @param max defines the alpha remap maximal range
  14968. * @returns the current particle system
  14969. */
  14970. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14971. /**
  14972. * Gets the current list of alpha remap gradients.
  14973. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14974. * @returns the list of alpha remap gradients
  14975. */
  14976. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14977. /**
  14978. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14981. * @returns the emitter
  14982. */
  14983. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14984. /**
  14985. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14986. * @param radius The radius of the hemisphere to emit from
  14987. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14988. * @returns the emitter
  14989. */
  14990. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14991. /**
  14992. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14993. * @param radius The radius of the sphere to emit from
  14994. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14995. * @returns the emitter
  14996. */
  14997. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14998. /**
  14999. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15000. * @param radius The radius of the sphere to emit from
  15001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15003. * @returns the emitter
  15004. */
  15005. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15006. /**
  15007. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15008. * @param radius The radius of the emission cylinder
  15009. * @param height The height of the emission cylinder
  15010. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15011. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15012. * @returns the emitter
  15013. */
  15014. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15015. /**
  15016. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15017. * @param radius The radius of the cylinder to emit from
  15018. * @param height The height of the emission cylinder
  15019. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15022. * @returns the emitter
  15023. */
  15024. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15025. /**
  15026. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15027. * @param radius The radius of the cone to emit from
  15028. * @param angle The base angle of the cone
  15029. * @returns the emitter
  15030. */
  15031. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15032. /**
  15033. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15036. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15037. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15038. * @returns the emitter
  15039. */
  15040. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15041. /**
  15042. * Get hosting scene
  15043. * @returns the scene
  15044. */
  15045. getScene(): Nullable<Scene>;
  15046. }
  15047. }
  15048. declare module "babylonjs/Meshes/transformNode" {
  15049. import { DeepImmutable } from "babylonjs/types";
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Nullable } from "babylonjs/types";
  15052. import { Camera } from "babylonjs/Cameras/camera";
  15053. import { Scene } from "babylonjs/scene";
  15054. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15055. import { Node } from "babylonjs/node";
  15056. import { Bone } from "babylonjs/Bones/bone";
  15057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15058. import { Space } from "babylonjs/Maths/math.axis";
  15059. /**
  15060. * 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.
  15061. * @see https://doc.babylonjs.com/how_to/transformnode
  15062. */
  15063. export class TransformNode extends Node {
  15064. /**
  15065. * Object will not rotate to face the camera
  15066. */
  15067. static BILLBOARDMODE_NONE: number;
  15068. /**
  15069. * Object will rotate to face the camera but only on the x axis
  15070. */
  15071. static BILLBOARDMODE_X: number;
  15072. /**
  15073. * Object will rotate to face the camera but only on the y axis
  15074. */
  15075. static BILLBOARDMODE_Y: number;
  15076. /**
  15077. * Object will rotate to face the camera but only on the z axis
  15078. */
  15079. static BILLBOARDMODE_Z: number;
  15080. /**
  15081. * Object will rotate to face the camera
  15082. */
  15083. static BILLBOARDMODE_ALL: number;
  15084. /**
  15085. * Object will rotate to face the camera's position instead of orientation
  15086. */
  15087. static BILLBOARDMODE_USE_POSITION: number;
  15088. private static _TmpRotation;
  15089. private static _TmpScaling;
  15090. private static _TmpTranslation;
  15091. private _forward;
  15092. private _forwardInverted;
  15093. private _up;
  15094. private _right;
  15095. private _rightInverted;
  15096. private _position;
  15097. private _rotation;
  15098. private _rotationQuaternion;
  15099. protected _scaling: Vector3;
  15100. protected _isDirty: boolean;
  15101. private _transformToBoneReferal;
  15102. private _isAbsoluteSynced;
  15103. private _billboardMode;
  15104. /**
  15105. * Gets or sets the billboard mode. Default is 0.
  15106. *
  15107. * | Value | Type | Description |
  15108. * | --- | --- | --- |
  15109. * | 0 | BILLBOARDMODE_NONE | |
  15110. * | 1 | BILLBOARDMODE_X | |
  15111. * | 2 | BILLBOARDMODE_Y | |
  15112. * | 4 | BILLBOARDMODE_Z | |
  15113. * | 7 | BILLBOARDMODE_ALL | |
  15114. *
  15115. */
  15116. get billboardMode(): number;
  15117. set billboardMode(value: number);
  15118. private _preserveParentRotationForBillboard;
  15119. /**
  15120. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15121. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15122. */
  15123. get preserveParentRotationForBillboard(): boolean;
  15124. set preserveParentRotationForBillboard(value: boolean);
  15125. /**
  15126. * 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
  15127. */
  15128. scalingDeterminant: number;
  15129. private _infiniteDistance;
  15130. /**
  15131. * Gets or sets the distance of the object to max, often used by skybox
  15132. */
  15133. get infiniteDistance(): boolean;
  15134. set infiniteDistance(value: boolean);
  15135. /**
  15136. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15137. * By default the system will update normals to compensate
  15138. */
  15139. ignoreNonUniformScaling: boolean;
  15140. /**
  15141. * 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
  15142. */
  15143. reIntegrateRotationIntoRotationQuaternion: boolean;
  15144. /** @hidden */
  15145. _poseMatrix: Nullable<Matrix>;
  15146. /** @hidden */
  15147. _localMatrix: Matrix;
  15148. private _usePivotMatrix;
  15149. private _absolutePosition;
  15150. private _absoluteScaling;
  15151. private _absoluteRotationQuaternion;
  15152. private _pivotMatrix;
  15153. private _pivotMatrixInverse;
  15154. /** @hidden */
  15155. _postMultiplyPivotMatrix: boolean;
  15156. protected _isWorldMatrixFrozen: boolean;
  15157. /** @hidden */
  15158. _indexInSceneTransformNodesArray: number;
  15159. /**
  15160. * An event triggered after the world matrix is updated
  15161. */
  15162. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15163. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15164. /**
  15165. * Gets a string identifying the name of the class
  15166. * @returns "TransformNode" string
  15167. */
  15168. getClassName(): string;
  15169. /**
  15170. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15171. */
  15172. get position(): Vector3;
  15173. set position(newPosition: Vector3);
  15174. /**
  15175. * 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)).
  15176. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15177. */
  15178. get rotation(): Vector3;
  15179. set rotation(newRotation: Vector3);
  15180. /**
  15181. * 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)).
  15182. */
  15183. get scaling(): Vector3;
  15184. set scaling(newScaling: Vector3);
  15185. /**
  15186. * 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).
  15187. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15188. */
  15189. get rotationQuaternion(): Nullable<Quaternion>;
  15190. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15191. /**
  15192. * The forward direction of that transform in world space.
  15193. */
  15194. get forward(): Vector3;
  15195. /**
  15196. * The up direction of that transform in world space.
  15197. */
  15198. get up(): Vector3;
  15199. /**
  15200. * The right direction of that transform in world space.
  15201. */
  15202. get right(): Vector3;
  15203. /**
  15204. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15205. * @param matrix the matrix to copy the pose from
  15206. * @returns this TransformNode.
  15207. */
  15208. updatePoseMatrix(matrix: Matrix): TransformNode;
  15209. /**
  15210. * Returns the mesh Pose matrix.
  15211. * @returns the pose matrix
  15212. */
  15213. getPoseMatrix(): Matrix;
  15214. /** @hidden */
  15215. _isSynchronized(): boolean;
  15216. /** @hidden */
  15217. _initCache(): void;
  15218. /**
  15219. * Flag the transform node as dirty (Forcing it to update everything)
  15220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15221. * @returns this transform node
  15222. */
  15223. markAsDirty(property: string): TransformNode;
  15224. /**
  15225. * Returns the current mesh absolute position.
  15226. * Returns a Vector3.
  15227. */
  15228. get absolutePosition(): Vector3;
  15229. /**
  15230. * Returns the current mesh absolute scaling.
  15231. * Returns a Vector3.
  15232. */
  15233. get absoluteScaling(): Vector3;
  15234. /**
  15235. * Returns the current mesh absolute rotation.
  15236. * Returns a Quaternion.
  15237. */
  15238. get absoluteRotationQuaternion(): Quaternion;
  15239. /**
  15240. * Sets a new matrix to apply before all other transformation
  15241. * @param matrix defines the transform matrix
  15242. * @returns the current TransformNode
  15243. */
  15244. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15245. /**
  15246. * Sets a new pivot matrix to the current node
  15247. * @param matrix defines the new pivot matrix to use
  15248. * @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
  15249. * @returns the current TransformNode
  15250. */
  15251. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15252. /**
  15253. * Returns the mesh pivot matrix.
  15254. * Default : Identity.
  15255. * @returns the matrix
  15256. */
  15257. getPivotMatrix(): Matrix;
  15258. /**
  15259. * Instantiate (when possible) or clone that node with its hierarchy
  15260. * @param newParent defines the new parent to use for the instance (or clone)
  15261. * @param options defines options to configure how copy is done
  15262. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15263. * @returns an instance (or a clone) of the current node with its hiearchy
  15264. */
  15265. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15266. doNotInstantiate: boolean;
  15267. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15268. /**
  15269. * Prevents the World matrix to be computed any longer
  15270. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15271. * @returns the TransformNode.
  15272. */
  15273. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15274. /**
  15275. * Allows back the World matrix computation.
  15276. * @returns the TransformNode.
  15277. */
  15278. unfreezeWorldMatrix(): this;
  15279. /**
  15280. * True if the World matrix has been frozen.
  15281. */
  15282. get isWorldMatrixFrozen(): boolean;
  15283. /**
  15284. * Retuns the mesh absolute position in the World.
  15285. * @returns a Vector3.
  15286. */
  15287. getAbsolutePosition(): Vector3;
  15288. /**
  15289. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15290. * @param absolutePosition the absolute position to set
  15291. * @returns the TransformNode.
  15292. */
  15293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15294. /**
  15295. * Sets the mesh position in its local space.
  15296. * @param vector3 the position to set in localspace
  15297. * @returns the TransformNode.
  15298. */
  15299. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15300. /**
  15301. * Returns the mesh position in the local space from the current World matrix values.
  15302. * @returns a new Vector3.
  15303. */
  15304. getPositionExpressedInLocalSpace(): Vector3;
  15305. /**
  15306. * Translates the mesh along the passed Vector3 in its local space.
  15307. * @param vector3 the distance to translate in localspace
  15308. * @returns the TransformNode.
  15309. */
  15310. locallyTranslate(vector3: Vector3): TransformNode;
  15311. private static _lookAtVectorCache;
  15312. /**
  15313. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15314. * @param targetPoint the position (must be in same space as current mesh) to look at
  15315. * @param yawCor optional yaw (y-axis) correction in radians
  15316. * @param pitchCor optional pitch (x-axis) correction in radians
  15317. * @param rollCor optional roll (z-axis) correction in radians
  15318. * @param space the choosen space of the target
  15319. * @returns the TransformNode.
  15320. */
  15321. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15322. /**
  15323. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15324. * This Vector3 is expressed in the World space.
  15325. * @param localAxis axis to rotate
  15326. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15327. */
  15328. getDirection(localAxis: Vector3): Vector3;
  15329. /**
  15330. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15331. * localAxis is expressed in the mesh local space.
  15332. * result is computed in the Wordl space from the mesh World matrix.
  15333. * @param localAxis axis to rotate
  15334. * @param result the resulting transformnode
  15335. * @returns this TransformNode.
  15336. */
  15337. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15338. /**
  15339. * Sets this transform node rotation to the given local axis.
  15340. * @param localAxis the axis in local space
  15341. * @param yawCor optional yaw (y-axis) correction in radians
  15342. * @param pitchCor optional pitch (x-axis) correction in radians
  15343. * @param rollCor optional roll (z-axis) correction in radians
  15344. * @returns this TransformNode
  15345. */
  15346. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15347. /**
  15348. * Sets a new pivot point to the current node
  15349. * @param point defines the new pivot point to use
  15350. * @param space defines if the point is in world or local space (local by default)
  15351. * @returns the current TransformNode
  15352. */
  15353. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15354. /**
  15355. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15356. * @returns the pivot point
  15357. */
  15358. getPivotPoint(): Vector3;
  15359. /**
  15360. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15361. * @param result the vector3 to store the result
  15362. * @returns this TransformNode.
  15363. */
  15364. getPivotPointToRef(result: Vector3): TransformNode;
  15365. /**
  15366. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15367. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15368. */
  15369. getAbsolutePivotPoint(): Vector3;
  15370. /**
  15371. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15372. * @param result vector3 to store the result
  15373. * @returns this TransformNode.
  15374. */
  15375. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15376. /**
  15377. * Defines the passed node as the parent of the current node.
  15378. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15379. * @see https://doc.babylonjs.com/how_to/parenting
  15380. * @param node the node ot set as the parent
  15381. * @returns this TransformNode.
  15382. */
  15383. setParent(node: Nullable<Node>): TransformNode;
  15384. private _nonUniformScaling;
  15385. /**
  15386. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15387. */
  15388. get nonUniformScaling(): boolean;
  15389. /** @hidden */
  15390. _updateNonUniformScalingState(value: boolean): boolean;
  15391. /**
  15392. * Attach the current TransformNode to another TransformNode associated with a bone
  15393. * @param bone Bone affecting the TransformNode
  15394. * @param affectedTransformNode TransformNode associated with the bone
  15395. * @returns this object
  15396. */
  15397. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15398. /**
  15399. * Detach the transform node if its associated with a bone
  15400. * @returns this object
  15401. */
  15402. detachFromBone(): TransformNode;
  15403. private static _rotationAxisCache;
  15404. /**
  15405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15406. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15408. * The passed axis is also normalized.
  15409. * @param axis the axis to rotate around
  15410. * @param amount the amount to rotate in radians
  15411. * @param space Space to rotate in (Default: local)
  15412. * @returns the TransformNode.
  15413. */
  15414. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15415. /**
  15416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15418. * The passed axis is also normalized. .
  15419. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15420. * @param point the point to rotate around
  15421. * @param axis the axis to rotate around
  15422. * @param amount the amount to rotate in radians
  15423. * @returns the TransformNode
  15424. */
  15425. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15426. /**
  15427. * Translates the mesh along the axis vector for the passed distance in the given space.
  15428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15429. * @param axis the axis to translate in
  15430. * @param distance the distance to translate
  15431. * @param space Space to rotate in (Default: local)
  15432. * @returns the TransformNode.
  15433. */
  15434. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15435. /**
  15436. * Adds a rotation step to the mesh current rotation.
  15437. * x, y, z are Euler angles expressed in radians.
  15438. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15439. * This means this rotation is made in the mesh local space only.
  15440. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15441. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15442. * ```javascript
  15443. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15444. * ```
  15445. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15446. * 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.
  15447. * @param x Rotation to add
  15448. * @param y Rotation to add
  15449. * @param z Rotation to add
  15450. * @returns the TransformNode.
  15451. */
  15452. addRotation(x: number, y: number, z: number): TransformNode;
  15453. /**
  15454. * @hidden
  15455. */
  15456. protected _getEffectiveParent(): Nullable<Node>;
  15457. /**
  15458. * Computes the world matrix of the node
  15459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15460. * @returns the world matrix
  15461. */
  15462. computeWorldMatrix(force?: boolean): Matrix;
  15463. /**
  15464. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15465. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15466. */
  15467. resetLocalMatrix(independentOfChildren?: boolean): void;
  15468. protected _afterComputeWorldMatrix(): void;
  15469. /**
  15470. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15471. * @param func callback function to add
  15472. *
  15473. * @returns the TransformNode.
  15474. */
  15475. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15476. /**
  15477. * Removes a registered callback function.
  15478. * @param func callback function to remove
  15479. * @returns the TransformNode.
  15480. */
  15481. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15482. /**
  15483. * Gets the position of the current mesh in camera space
  15484. * @param camera defines the camera to use
  15485. * @returns a position
  15486. */
  15487. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15488. /**
  15489. * Returns the distance from the mesh to the active camera
  15490. * @param camera defines the camera to use
  15491. * @returns the distance
  15492. */
  15493. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15494. /**
  15495. * Clone the current transform node
  15496. * @param name Name of the new clone
  15497. * @param newParent New parent for the clone
  15498. * @param doNotCloneChildren Do not clone children hierarchy
  15499. * @returns the new transform node
  15500. */
  15501. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15502. /**
  15503. * Serializes the objects information.
  15504. * @param currentSerializationObject defines the object to serialize in
  15505. * @returns the serialized object
  15506. */
  15507. serialize(currentSerializationObject?: any): any;
  15508. /**
  15509. * Returns a new TransformNode object parsed from the source provided.
  15510. * @param parsedTransformNode is the source.
  15511. * @param scene the scne the object belongs to
  15512. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15513. * @returns a new TransformNode object parsed from the source provided.
  15514. */
  15515. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15516. /**
  15517. * Get all child-transformNodes of this node
  15518. * @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
  15519. * @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
  15520. * @returns an array of TransformNode
  15521. */
  15522. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15523. /**
  15524. * Releases resources associated with this transform node.
  15525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15527. */
  15528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15529. /**
  15530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15532. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15533. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15534. * @returns the current mesh
  15535. */
  15536. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15537. private _syncAbsoluteScalingAndRotation;
  15538. }
  15539. }
  15540. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15541. /**
  15542. * Class used to override all child animations of a given target
  15543. */
  15544. export class AnimationPropertiesOverride {
  15545. /**
  15546. * Gets or sets a value indicating if animation blending must be used
  15547. */
  15548. enableBlending: boolean;
  15549. /**
  15550. * Gets or sets the blending speed to use when enableBlending is true
  15551. */
  15552. blendingSpeed: number;
  15553. /**
  15554. * Gets or sets the default loop mode to use
  15555. */
  15556. loopMode: number;
  15557. }
  15558. }
  15559. declare module "babylonjs/Bones/bone" {
  15560. import { Skeleton } from "babylonjs/Bones/skeleton";
  15561. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15562. import { Nullable } from "babylonjs/types";
  15563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15565. import { Node } from "babylonjs/node";
  15566. import { Space } from "babylonjs/Maths/math.axis";
  15567. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15568. /**
  15569. * Class used to store bone information
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15571. */
  15572. export class Bone extends Node {
  15573. /**
  15574. * defines the bone name
  15575. */
  15576. name: string;
  15577. private static _tmpVecs;
  15578. private static _tmpQuat;
  15579. private static _tmpMats;
  15580. /**
  15581. * Gets the list of child bones
  15582. */
  15583. children: Bone[];
  15584. /** Gets the animations associated with this bone */
  15585. animations: import("babylonjs/Animations/animation").Animation[];
  15586. /**
  15587. * Gets or sets bone length
  15588. */
  15589. length: number;
  15590. /**
  15591. * @hidden Internal only
  15592. * Set this value to map this bone to a different index in the transform matrices
  15593. * Set this value to -1 to exclude the bone from the transform matrices
  15594. */
  15595. _index: Nullable<number>;
  15596. private _skeleton;
  15597. private _localMatrix;
  15598. private _restPose;
  15599. private _bindPose;
  15600. private _baseMatrix;
  15601. private _absoluteTransform;
  15602. private _invertedAbsoluteTransform;
  15603. private _parent;
  15604. private _scalingDeterminant;
  15605. private _worldTransform;
  15606. private _localScaling;
  15607. private _localRotation;
  15608. private _localPosition;
  15609. private _needToDecompose;
  15610. private _needToCompose;
  15611. /** @hidden */
  15612. _linkedTransformNode: Nullable<TransformNode>;
  15613. /** @hidden */
  15614. _waitingTransformNodeId: Nullable<string>;
  15615. /** @hidden */
  15616. get _matrix(): Matrix;
  15617. /** @hidden */
  15618. set _matrix(value: Matrix);
  15619. /**
  15620. * Create a new bone
  15621. * @param name defines the bone name
  15622. * @param skeleton defines the parent skeleton
  15623. * @param parentBone defines the parent (can be null if the bone is the root)
  15624. * @param localMatrix defines the local matrix
  15625. * @param restPose defines the rest pose matrix
  15626. * @param baseMatrix defines the base matrix
  15627. * @param index defines index of the bone in the hiearchy
  15628. */
  15629. constructor(
  15630. /**
  15631. * defines the bone name
  15632. */
  15633. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15634. /**
  15635. * Gets the current object class name.
  15636. * @return the class name
  15637. */
  15638. getClassName(): string;
  15639. /**
  15640. * Gets the parent skeleton
  15641. * @returns a skeleton
  15642. */
  15643. getSkeleton(): Skeleton;
  15644. /**
  15645. * Gets parent bone
  15646. * @returns a bone or null if the bone is the root of the bone hierarchy
  15647. */
  15648. getParent(): Nullable<Bone>;
  15649. /**
  15650. * Returns an array containing the root bones
  15651. * @returns an array containing the root bones
  15652. */
  15653. getChildren(): Array<Bone>;
  15654. /**
  15655. * Gets the node index in matrix array generated for rendering
  15656. * @returns the node index
  15657. */
  15658. getIndex(): number;
  15659. /**
  15660. * Sets the parent bone
  15661. * @param parent defines the parent (can be null if the bone is the root)
  15662. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15663. */
  15664. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15665. /**
  15666. * Gets the local matrix
  15667. * @returns a matrix
  15668. */
  15669. getLocalMatrix(): Matrix;
  15670. /**
  15671. * Gets the base matrix (initial matrix which remains unchanged)
  15672. * @returns a matrix
  15673. */
  15674. getBaseMatrix(): Matrix;
  15675. /**
  15676. * Gets the rest pose matrix
  15677. * @returns a matrix
  15678. */
  15679. getRestPose(): Matrix;
  15680. /**
  15681. * Sets the rest pose matrix
  15682. * @param matrix the local-space rest pose to set for this bone
  15683. */
  15684. setRestPose(matrix: Matrix): void;
  15685. /**
  15686. * Gets the bind pose matrix
  15687. * @returns the bind pose matrix
  15688. */
  15689. getBindPose(): Matrix;
  15690. /**
  15691. * Sets the bind pose matrix
  15692. * @param matrix the local-space bind pose to set for this bone
  15693. */
  15694. setBindPose(matrix: Matrix): void;
  15695. /**
  15696. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15697. */
  15698. getWorldMatrix(): Matrix;
  15699. /**
  15700. * Sets the local matrix to rest pose matrix
  15701. */
  15702. returnToRest(): void;
  15703. /**
  15704. * Gets the inverse of the absolute transform matrix.
  15705. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15706. * @returns a matrix
  15707. */
  15708. getInvertedAbsoluteTransform(): Matrix;
  15709. /**
  15710. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15711. * @returns a matrix
  15712. */
  15713. getAbsoluteTransform(): Matrix;
  15714. /**
  15715. * Links with the given transform node.
  15716. * The local matrix of this bone is copied from the transform node every frame.
  15717. * @param transformNode defines the transform node to link to
  15718. */
  15719. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15720. /**
  15721. * Gets the node used to drive the bone's transformation
  15722. * @returns a transform node or null
  15723. */
  15724. getTransformNode(): Nullable<TransformNode>;
  15725. /** Gets or sets current position (in local space) */
  15726. get position(): Vector3;
  15727. set position(newPosition: Vector3);
  15728. /** Gets or sets current rotation (in local space) */
  15729. get rotation(): Vector3;
  15730. set rotation(newRotation: Vector3);
  15731. /** Gets or sets current rotation quaternion (in local space) */
  15732. get rotationQuaternion(): Quaternion;
  15733. set rotationQuaternion(newRotation: Quaternion);
  15734. /** Gets or sets current scaling (in local space) */
  15735. get scaling(): Vector3;
  15736. set scaling(newScaling: Vector3);
  15737. /**
  15738. * Gets the animation properties override
  15739. */
  15740. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15741. private _decompose;
  15742. private _compose;
  15743. /**
  15744. * Update the base and local matrices
  15745. * @param matrix defines the new base or local matrix
  15746. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15747. * @param updateLocalMatrix defines if the local matrix should be updated
  15748. */
  15749. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15750. /** @hidden */
  15751. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15752. /**
  15753. * Flag the bone as dirty (Forcing it to update everything)
  15754. */
  15755. markAsDirty(): void;
  15756. /** @hidden */
  15757. _markAsDirtyAndCompose(): void;
  15758. private _markAsDirtyAndDecompose;
  15759. /**
  15760. * Translate the bone in local or world space
  15761. * @param vec The amount to translate the bone
  15762. * @param space The space that the translation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the postion of the bone in local or world space
  15768. * @param position The position to set the bone
  15769. * @param space The space that the position is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the absolute position of the bone (world space)
  15775. * @param position The position to set the bone
  15776. * @param mesh The mesh that this bone is attached to
  15777. */
  15778. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15779. /**
  15780. * Scale the bone on the x, y and z axes (in local space)
  15781. * @param x The amount to scale the bone on the x axis
  15782. * @param y The amount to scale the bone on the y axis
  15783. * @param z The amount to scale the bone on the z axis
  15784. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15785. */
  15786. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15787. /**
  15788. * Set the bone scaling in local space
  15789. * @param scale defines the scaling vector
  15790. */
  15791. setScale(scale: Vector3): void;
  15792. /**
  15793. * Gets the current scaling in local space
  15794. * @returns the current scaling vector
  15795. */
  15796. getScale(): Vector3;
  15797. /**
  15798. * Gets the current scaling in local space and stores it in a target vector
  15799. * @param result defines the target vector
  15800. */
  15801. getScaleToRef(result: Vector3): void;
  15802. /**
  15803. * Set the yaw, pitch, and roll of the bone in local or world space
  15804. * @param yaw The rotation of the bone on the y axis
  15805. * @param pitch The rotation of the bone on the x axis
  15806. * @param roll The rotation of the bone on the z axis
  15807. * @param space The space that the axes of rotation are in
  15808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15809. */
  15810. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15811. /**
  15812. * Add a rotation to the bone on an axis in local or world space
  15813. * @param axis The axis to rotate the bone on
  15814. * @param amount The amount to rotate the bone
  15815. * @param space The space that the axis is in
  15816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15817. */
  15818. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15819. /**
  15820. * Set the rotation of the bone to a particular axis angle in local or world space
  15821. * @param axis The axis to rotate the bone on
  15822. * @param angle The angle that the bone should be rotated to
  15823. * @param space The space that the axis is in
  15824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15825. */
  15826. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15827. /**
  15828. * Set the euler rotation of the bone in local or world space
  15829. * @param rotation The euler rotation that the bone should be set to
  15830. * @param space The space that the rotation is in
  15831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15832. */
  15833. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15834. /**
  15835. * Set the quaternion rotation of the bone in local or world space
  15836. * @param quat The quaternion rotation that the bone should be set to
  15837. * @param space The space that the rotation is in
  15838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15839. */
  15840. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15841. /**
  15842. * Set the rotation matrix of the bone in local or world space
  15843. * @param rotMat The rotation matrix that the bone should be set to
  15844. * @param space The space that the rotation is in
  15845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15846. */
  15847. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15848. private _rotateWithMatrix;
  15849. private _getNegativeRotationToRef;
  15850. /**
  15851. * Get the position of the bone in local or world space
  15852. * @param space The space that the returned position is in
  15853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15854. * @returns The position of the bone
  15855. */
  15856. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15857. /**
  15858. * Copy the position of the bone to a vector3 in local or world space
  15859. * @param space The space that the returned position is in
  15860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15861. * @param result The vector3 to copy the position to
  15862. */
  15863. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15864. /**
  15865. * Get the absolute position of the bone (world space)
  15866. * @param mesh The mesh that this bone is attached to
  15867. * @returns The absolute position of the bone
  15868. */
  15869. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15870. /**
  15871. * Copy the absolute position of the bone (world space) to the result param
  15872. * @param mesh The mesh that this bone is attached to
  15873. * @param result The vector3 to copy the absolute position to
  15874. */
  15875. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15876. /**
  15877. * Compute the absolute transforms of this bone and its children
  15878. */
  15879. computeAbsoluteTransforms(): void;
  15880. /**
  15881. * Get the world direction from an axis that is in the local space of the bone
  15882. * @param localAxis The local direction that is used to compute the world direction
  15883. * @param mesh The mesh that this bone is attached to
  15884. * @returns The world direction
  15885. */
  15886. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15887. /**
  15888. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15889. * @param localAxis The local direction that is used to compute the world direction
  15890. * @param mesh The mesh that this bone is attached to
  15891. * @param result The vector3 that the world direction will be copied to
  15892. */
  15893. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15894. /**
  15895. * Get the euler rotation of the bone in local or world space
  15896. * @param space The space that the rotation should be in
  15897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15898. * @returns The euler rotation
  15899. */
  15900. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15901. /**
  15902. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15903. * @param space The space that the rotation should be in
  15904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15905. * @param result The vector3 that the rotation should be copied to
  15906. */
  15907. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15908. /**
  15909. * Get the quaternion rotation of the bone in either local or world space
  15910. * @param space The space that the rotation should be in
  15911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15912. * @returns The quaternion rotation
  15913. */
  15914. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15915. /**
  15916. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15917. * @param space The space that the rotation should be in
  15918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15919. * @param result The quaternion that the rotation should be copied to
  15920. */
  15921. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15922. /**
  15923. * Get the rotation matrix of the bone in local or world space
  15924. * @param space The space that the rotation should be in
  15925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15926. * @returns The rotation matrix
  15927. */
  15928. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15929. /**
  15930. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15931. * @param space The space that the rotation should be in
  15932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15933. * @param result The quaternion that the rotation should be copied to
  15934. */
  15935. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15936. /**
  15937. * Get the world position of a point that is in the local space of the bone
  15938. * @param position The local position
  15939. * @param mesh The mesh that this bone is attached to
  15940. * @returns The world position
  15941. */
  15942. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15943. /**
  15944. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15945. * @param position The local position
  15946. * @param mesh The mesh that this bone is attached to
  15947. * @param result The vector3 that the world position should be copied to
  15948. */
  15949. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15950. /**
  15951. * Get the local position of a point that is in world space
  15952. * @param position The world position
  15953. * @param mesh The mesh that this bone is attached to
  15954. * @returns The local position
  15955. */
  15956. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15957. /**
  15958. * Get the local position of a point that is in world space and copy it to the result param
  15959. * @param position The world position
  15960. * @param mesh The mesh that this bone is attached to
  15961. * @param result The vector3 that the local position should be copied to
  15962. */
  15963. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15964. /**
  15965. * Set the current local matrix as the restPose for this bone.
  15966. */
  15967. setCurrentPoseAsRest(): void;
  15968. }
  15969. }
  15970. declare module "babylonjs/Animations/runtimeAnimation" {
  15971. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15972. import { Animatable } from "babylonjs/Animations/animatable";
  15973. import { Scene } from "babylonjs/scene";
  15974. /**
  15975. * Defines a runtime animation
  15976. */
  15977. export class RuntimeAnimation {
  15978. private _events;
  15979. /**
  15980. * The current frame of the runtime animation
  15981. */
  15982. private _currentFrame;
  15983. /**
  15984. * The animation used by the runtime animation
  15985. */
  15986. private _animation;
  15987. /**
  15988. * The target of the runtime animation
  15989. */
  15990. private _target;
  15991. /**
  15992. * The initiating animatable
  15993. */
  15994. private _host;
  15995. /**
  15996. * The original value of the runtime animation
  15997. */
  15998. private _originalValue;
  15999. /**
  16000. * The original blend value of the runtime animation
  16001. */
  16002. private _originalBlendValue;
  16003. /**
  16004. * The offsets cache of the runtime animation
  16005. */
  16006. private _offsetsCache;
  16007. /**
  16008. * The high limits cache of the runtime animation
  16009. */
  16010. private _highLimitsCache;
  16011. /**
  16012. * Specifies if the runtime animation has been stopped
  16013. */
  16014. private _stopped;
  16015. /**
  16016. * The blending factor of the runtime animation
  16017. */
  16018. private _blendingFactor;
  16019. /**
  16020. * The BabylonJS scene
  16021. */
  16022. private _scene;
  16023. /**
  16024. * The current value of the runtime animation
  16025. */
  16026. private _currentValue;
  16027. /** @hidden */
  16028. _animationState: _IAnimationState;
  16029. /**
  16030. * The active target of the runtime animation
  16031. */
  16032. private _activeTargets;
  16033. private _currentActiveTarget;
  16034. private _directTarget;
  16035. /**
  16036. * The target path of the runtime animation
  16037. */
  16038. private _targetPath;
  16039. /**
  16040. * The weight of the runtime animation
  16041. */
  16042. private _weight;
  16043. /**
  16044. * The ratio offset of the runtime animation
  16045. */
  16046. private _ratioOffset;
  16047. /**
  16048. * The previous delay of the runtime animation
  16049. */
  16050. private _previousDelay;
  16051. /**
  16052. * The previous ratio of the runtime animation
  16053. */
  16054. private _previousRatio;
  16055. private _enableBlending;
  16056. private _keys;
  16057. private _minFrame;
  16058. private _maxFrame;
  16059. private _minValue;
  16060. private _maxValue;
  16061. private _targetIsArray;
  16062. /**
  16063. * Gets the current frame of the runtime animation
  16064. */
  16065. get currentFrame(): number;
  16066. /**
  16067. * Gets the weight of the runtime animation
  16068. */
  16069. get weight(): number;
  16070. /**
  16071. * Gets the current value of the runtime animation
  16072. */
  16073. get currentValue(): any;
  16074. /**
  16075. * Gets the target path of the runtime animation
  16076. */
  16077. get targetPath(): string;
  16078. /**
  16079. * Gets the actual target of the runtime animation
  16080. */
  16081. get target(): any;
  16082. /**
  16083. * Gets the additive state of the runtime animation
  16084. */
  16085. get isAdditive(): boolean;
  16086. /** @hidden */
  16087. _onLoop: () => void;
  16088. /**
  16089. * Create a new RuntimeAnimation object
  16090. * @param target defines the target of the animation
  16091. * @param animation defines the source animation object
  16092. * @param scene defines the hosting scene
  16093. * @param host defines the initiating Animatable
  16094. */
  16095. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16096. private _preparePath;
  16097. /**
  16098. * Gets the animation from the runtime animation
  16099. */
  16100. get animation(): Animation;
  16101. /**
  16102. * Resets the runtime animation to the beginning
  16103. * @param restoreOriginal defines whether to restore the target property to the original value
  16104. */
  16105. reset(restoreOriginal?: boolean): void;
  16106. /**
  16107. * Specifies if the runtime animation is stopped
  16108. * @returns Boolean specifying if the runtime animation is stopped
  16109. */
  16110. isStopped(): boolean;
  16111. /**
  16112. * Disposes of the runtime animation
  16113. */
  16114. dispose(): void;
  16115. /**
  16116. * Apply the interpolated value to the target
  16117. * @param currentValue defines the value computed by the animation
  16118. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16119. */
  16120. setValue(currentValue: any, weight: number): void;
  16121. private _getOriginalValues;
  16122. private _setValue;
  16123. /**
  16124. * Gets the loop pmode of the runtime animation
  16125. * @returns Loop Mode
  16126. */
  16127. private _getCorrectLoopMode;
  16128. /**
  16129. * Move the current animation to a given frame
  16130. * @param frame defines the frame to move to
  16131. */
  16132. goToFrame(frame: number): void;
  16133. /**
  16134. * @hidden Internal use only
  16135. */
  16136. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16137. /**
  16138. * Execute the current animation
  16139. * @param delay defines the delay to add to the current frame
  16140. * @param from defines the lower bound of the animation range
  16141. * @param to defines the upper bound of the animation range
  16142. * @param loop defines if the current animation must loop
  16143. * @param speedRatio defines the current speed ratio
  16144. * @param weight defines the weight of the animation (default is -1 so no weight)
  16145. * @param onLoop optional callback called when animation loops
  16146. * @returns a boolean indicating if the animation is running
  16147. */
  16148. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16149. }
  16150. }
  16151. declare module "babylonjs/Animations/animatable" {
  16152. import { Animation } from "babylonjs/Animations/animation";
  16153. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16154. import { Nullable } from "babylonjs/types";
  16155. import { Observable } from "babylonjs/Misc/observable";
  16156. import { Scene } from "babylonjs/scene";
  16157. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16158. import { Node } from "babylonjs/node";
  16159. /**
  16160. * Class used to store an actual running animation
  16161. */
  16162. export class Animatable {
  16163. /** defines the target object */
  16164. target: any;
  16165. /** defines the starting frame number (default is 0) */
  16166. fromFrame: number;
  16167. /** defines the ending frame number (default is 100) */
  16168. toFrame: number;
  16169. /** defines if the animation must loop (default is false) */
  16170. loopAnimation: boolean;
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined;
  16173. /** defines a callback to call when animation loops */
  16174. onAnimationLoop?: (() => void) | null | undefined;
  16175. /** defines whether the animation should be evaluated additively */
  16176. isAdditive: boolean;
  16177. private _localDelayOffset;
  16178. private _pausedDelay;
  16179. private _runtimeAnimations;
  16180. private _paused;
  16181. private _scene;
  16182. private _speedRatio;
  16183. private _weight;
  16184. private _syncRoot;
  16185. /**
  16186. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16187. * This will only apply for non looping animation (default is true)
  16188. */
  16189. disposeOnEnd: boolean;
  16190. /**
  16191. * Gets a boolean indicating if the animation has started
  16192. */
  16193. animationStarted: boolean;
  16194. /**
  16195. * Observer raised when the animation ends
  16196. */
  16197. onAnimationEndObservable: Observable<Animatable>;
  16198. /**
  16199. * Observer raised when the animation loops
  16200. */
  16201. onAnimationLoopObservable: Observable<Animatable>;
  16202. /**
  16203. * Gets the root Animatable used to synchronize and normalize animations
  16204. */
  16205. get syncRoot(): Nullable<Animatable>;
  16206. /**
  16207. * Gets the current frame of the first RuntimeAnimation
  16208. * Used to synchronize Animatables
  16209. */
  16210. get masterFrame(): number;
  16211. /**
  16212. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16213. */
  16214. get weight(): number;
  16215. set weight(value: number);
  16216. /**
  16217. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16218. */
  16219. get speedRatio(): number;
  16220. set speedRatio(value: number);
  16221. /**
  16222. * Creates a new Animatable
  16223. * @param scene defines the hosting scene
  16224. * @param target defines the target object
  16225. * @param fromFrame defines the starting frame number (default is 0)
  16226. * @param toFrame defines the ending frame number (default is 100)
  16227. * @param loopAnimation defines if the animation must loop (default is false)
  16228. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16229. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16230. * @param animations defines a group of animation to add to the new Animatable
  16231. * @param onAnimationLoop defines a callback to call when animation loops
  16232. * @param isAdditive defines whether the animation should be evaluated additively
  16233. */
  16234. constructor(scene: Scene,
  16235. /** defines the target object */
  16236. target: any,
  16237. /** defines the starting frame number (default is 0) */
  16238. fromFrame?: number,
  16239. /** defines the ending frame number (default is 100) */
  16240. toFrame?: number,
  16241. /** defines if the animation must loop (default is false) */
  16242. loopAnimation?: boolean, speedRatio?: number,
  16243. /** defines a callback to call when animation ends if it is not looping */
  16244. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16245. /** defines a callback to call when animation loops */
  16246. onAnimationLoop?: (() => void) | null | undefined,
  16247. /** defines whether the animation should be evaluated additively */
  16248. isAdditive?: boolean);
  16249. /**
  16250. * Synchronize and normalize current Animatable with a source Animatable
  16251. * This is useful when using animation weights and when animations are not of the same length
  16252. * @param root defines the root Animatable to synchronize with
  16253. * @returns the current Animatable
  16254. */
  16255. syncWith(root: Animatable): Animatable;
  16256. /**
  16257. * Gets the list of runtime animations
  16258. * @returns an array of RuntimeAnimation
  16259. */
  16260. getAnimations(): RuntimeAnimation[];
  16261. /**
  16262. * Adds more animations to the current animatable
  16263. * @param target defines the target of the animations
  16264. * @param animations defines the new animations to add
  16265. */
  16266. appendAnimations(target: any, animations: Animation[]): void;
  16267. /**
  16268. * Gets the source animation for a specific property
  16269. * @param property defines the propertyu to look for
  16270. * @returns null or the source animation for the given property
  16271. */
  16272. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16273. /**
  16274. * Gets the runtime animation for a specific property
  16275. * @param property defines the propertyu to look for
  16276. * @returns null or the runtime animation for the given property
  16277. */
  16278. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16279. /**
  16280. * Resets the animatable to its original state
  16281. */
  16282. reset(): void;
  16283. /**
  16284. * Allows the animatable to blend with current running animations
  16285. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16286. * @param blendingSpeed defines the blending speed to use
  16287. */
  16288. enableBlending(blendingSpeed: number): void;
  16289. /**
  16290. * Disable animation blending
  16291. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16292. */
  16293. disableBlending(): void;
  16294. /**
  16295. * Jump directly to a given frame
  16296. * @param frame defines the frame to jump to
  16297. */
  16298. goToFrame(frame: number): void;
  16299. /**
  16300. * Pause the animation
  16301. */
  16302. pause(): void;
  16303. /**
  16304. * Restart the animation
  16305. */
  16306. restart(): void;
  16307. private _raiseOnAnimationEnd;
  16308. /**
  16309. * Stop and delete the current animation
  16310. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16311. * @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)
  16312. */
  16313. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16314. /**
  16315. * Wait asynchronously for the animation to end
  16316. * @returns a promise which will be fullfilled when the animation ends
  16317. */
  16318. waitAsync(): Promise<Animatable>;
  16319. /** @hidden */
  16320. _animate(delay: number): boolean;
  16321. }
  16322. module "babylonjs/scene" {
  16323. interface Scene {
  16324. /** @hidden */
  16325. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16326. /** @hidden */
  16327. _processLateAnimationBindingsForMatrices(holder: {
  16328. totalWeight: number;
  16329. totalAdditiveWeight: number;
  16330. animations: RuntimeAnimation[];
  16331. additiveAnimations: RuntimeAnimation[];
  16332. originalValue: Matrix;
  16333. }): any;
  16334. /** @hidden */
  16335. _processLateAnimationBindingsForQuaternions(holder: {
  16336. totalWeight: number;
  16337. totalAdditiveWeight: number;
  16338. animations: RuntimeAnimation[];
  16339. additiveAnimations: RuntimeAnimation[];
  16340. originalValue: Quaternion;
  16341. }, refQuaternion: Quaternion): Quaternion;
  16342. /** @hidden */
  16343. _processLateAnimationBindings(): void;
  16344. /**
  16345. * Will start the animation sequence of a given target
  16346. * @param target defines the target
  16347. * @param from defines from which frame should animation start
  16348. * @param to defines until which frame should animation run.
  16349. * @param weight defines the weight to apply to the animation (1.0 by default)
  16350. * @param loop defines if the animation loops
  16351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16352. * @param onAnimationEnd defines the function to be executed when the animation ends
  16353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16354. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16355. * @param onAnimationLoop defines the callback to call when an animation loops
  16356. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16357. * @returns the animatable object created for this animation
  16358. */
  16359. 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;
  16360. /**
  16361. * Will start the animation sequence of a given target
  16362. * @param target defines the target
  16363. * @param from defines from which frame should animation start
  16364. * @param to defines until which frame should animation run.
  16365. * @param loop defines if the animation loops
  16366. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16367. * @param onAnimationEnd defines the function to be executed when the animation ends
  16368. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16369. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16370. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16371. * @param onAnimationLoop defines the callback to call when an animation loops
  16372. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16373. * @returns the animatable object created for this animation
  16374. */
  16375. 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;
  16376. /**
  16377. * Will start the animation sequence of a given target and its hierarchy
  16378. * @param target defines the target
  16379. * @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.
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param loop defines if the animation loops
  16383. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16384. * @param onAnimationEnd defines the function to be executed when the animation ends
  16385. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16386. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16387. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16388. * @param onAnimationLoop defines the callback to call when an animation loops
  16389. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16390. * @returns the list of created animatables
  16391. */
  16392. 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[];
  16393. /**
  16394. * Begin a new animation on a given node
  16395. * @param target defines the target where the animation will take place
  16396. * @param animations defines the list of animations to start
  16397. * @param from defines the initial value
  16398. * @param to defines the final value
  16399. * @param loop defines if you want animation to loop (off by default)
  16400. * @param speedRatio defines the speed ratio to apply to all animations
  16401. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16402. * @param onAnimationLoop defines the callback to call when an animation loops
  16403. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16404. * @returns the list of created animatables
  16405. */
  16406. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16407. /**
  16408. * Begin a new animation on a given node and its hierarchy
  16409. * @param target defines the root node where the animation will take place
  16410. * @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.
  16411. * @param animations defines the list of animations to start
  16412. * @param from defines the initial value
  16413. * @param to defines the final value
  16414. * @param loop defines if you want animation to loop (off by default)
  16415. * @param speedRatio defines the speed ratio to apply to all animations
  16416. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16417. * @param onAnimationLoop defines the callback to call when an animation loops
  16418. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16419. * @returns the list of animatables created for all nodes
  16420. */
  16421. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16422. /**
  16423. * Gets the animatable associated with a specific target
  16424. * @param target defines the target of the animatable
  16425. * @returns the required animatable if found
  16426. */
  16427. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16428. /**
  16429. * Gets all animatables associated with a given target
  16430. * @param target defines the target to look animatables for
  16431. * @returns an array of Animatables
  16432. */
  16433. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16434. /**
  16435. * Stops and removes all animations that have been applied to the scene
  16436. */
  16437. stopAllAnimations(): void;
  16438. /**
  16439. * Gets the current delta time used by animation engine
  16440. */
  16441. deltaTime: number;
  16442. }
  16443. }
  16444. module "babylonjs/Bones/bone" {
  16445. interface Bone {
  16446. /**
  16447. * Copy an animation range from another bone
  16448. * @param source defines the source bone
  16449. * @param rangeName defines the range name to copy
  16450. * @param frameOffset defines the frame offset
  16451. * @param rescaleAsRequired defines if rescaling must be applied if required
  16452. * @param skelDimensionsRatio defines the scaling ratio
  16453. * @returns true if operation was successful
  16454. */
  16455. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16456. }
  16457. }
  16458. }
  16459. declare module "babylonjs/Bones/skeleton" {
  16460. import { Bone } from "babylonjs/Bones/bone";
  16461. import { Observable } from "babylonjs/Misc/observable";
  16462. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16463. import { Scene } from "babylonjs/scene";
  16464. import { Nullable } from "babylonjs/types";
  16465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16466. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16467. import { Animatable } from "babylonjs/Animations/animatable";
  16468. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16469. import { Animation } from "babylonjs/Animations/animation";
  16470. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16471. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16472. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16473. /**
  16474. * Class used to handle skinning animations
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16476. */
  16477. export class Skeleton implements IAnimatable {
  16478. /** defines the skeleton name */
  16479. name: string;
  16480. /** defines the skeleton Id */
  16481. id: string;
  16482. /**
  16483. * Defines the list of child bones
  16484. */
  16485. bones: Bone[];
  16486. /**
  16487. * Defines an estimate of the dimension of the skeleton at rest
  16488. */
  16489. dimensionsAtRest: Vector3;
  16490. /**
  16491. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16492. */
  16493. needInitialSkinMatrix: boolean;
  16494. /**
  16495. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16496. */
  16497. overrideMesh: Nullable<AbstractMesh>;
  16498. /**
  16499. * Gets the list of animations attached to this skeleton
  16500. */
  16501. animations: Array<Animation>;
  16502. private _scene;
  16503. private _isDirty;
  16504. private _transformMatrices;
  16505. private _transformMatrixTexture;
  16506. private _meshesWithPoseMatrix;
  16507. private _animatables;
  16508. private _identity;
  16509. private _synchronizedWithMesh;
  16510. private _ranges;
  16511. private _lastAbsoluteTransformsUpdateId;
  16512. private _canUseTextureForBones;
  16513. private _uniqueId;
  16514. /** @hidden */
  16515. _numBonesWithLinkedTransformNode: number;
  16516. /** @hidden */
  16517. _hasWaitingData: Nullable<boolean>;
  16518. /** @hidden */
  16519. _waitingOverrideMeshId: Nullable<string>;
  16520. /**
  16521. * Specifies if the skeleton should be serialized
  16522. */
  16523. doNotSerialize: boolean;
  16524. private _useTextureToStoreBoneMatrices;
  16525. /**
  16526. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16527. * Please note that this option is not available if the hardware does not support it
  16528. */
  16529. get useTextureToStoreBoneMatrices(): boolean;
  16530. set useTextureToStoreBoneMatrices(value: boolean);
  16531. private _animationPropertiesOverride;
  16532. /**
  16533. * Gets or sets the animation properties override
  16534. */
  16535. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16536. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16537. /**
  16538. * List of inspectable custom properties (used by the Inspector)
  16539. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16540. */
  16541. inspectableCustomProperties: IInspectable[];
  16542. /**
  16543. * An observable triggered before computing the skeleton's matrices
  16544. */
  16545. onBeforeComputeObservable: Observable<Skeleton>;
  16546. /**
  16547. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16548. */
  16549. get isUsingTextureForMatrices(): boolean;
  16550. /**
  16551. * Gets the unique ID of this skeleton
  16552. */
  16553. get uniqueId(): number;
  16554. /**
  16555. * Creates a new skeleton
  16556. * @param name defines the skeleton name
  16557. * @param id defines the skeleton Id
  16558. * @param scene defines the hosting scene
  16559. */
  16560. constructor(
  16561. /** defines the skeleton name */
  16562. name: string,
  16563. /** defines the skeleton Id */
  16564. id: string, scene: Scene);
  16565. /**
  16566. * Gets the current object class name.
  16567. * @return the class name
  16568. */
  16569. getClassName(): string;
  16570. /**
  16571. * Returns an array containing the root bones
  16572. * @returns an array containing the root bones
  16573. */
  16574. getChildren(): Array<Bone>;
  16575. /**
  16576. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16577. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16578. * @returns a Float32Array containing matrices data
  16579. */
  16580. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16581. /**
  16582. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16583. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16584. * @returns a raw texture containing the data
  16585. */
  16586. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16587. /**
  16588. * Gets the current hosting scene
  16589. * @returns a scene object
  16590. */
  16591. getScene(): Scene;
  16592. /**
  16593. * Gets a string representing the current skeleton data
  16594. * @param fullDetails defines a boolean indicating if we want a verbose version
  16595. * @returns a string representing the current skeleton data
  16596. */
  16597. toString(fullDetails?: boolean): string;
  16598. /**
  16599. * Get bone's index searching by name
  16600. * @param name defines bone's name to search for
  16601. * @return the indice of the bone. Returns -1 if not found
  16602. */
  16603. getBoneIndexByName(name: string): number;
  16604. /**
  16605. * Creater a new animation range
  16606. * @param name defines the name of the range
  16607. * @param from defines the start key
  16608. * @param to defines the end key
  16609. */
  16610. createAnimationRange(name: string, from: number, to: number): void;
  16611. /**
  16612. * Delete a specific animation range
  16613. * @param name defines the name of the range
  16614. * @param deleteFrames defines if frames must be removed as well
  16615. */
  16616. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16617. /**
  16618. * Gets a specific animation range
  16619. * @param name defines the name of the range to look for
  16620. * @returns the requested animation range or null if not found
  16621. */
  16622. getAnimationRange(name: string): Nullable<AnimationRange>;
  16623. /**
  16624. * Gets the list of all animation ranges defined on this skeleton
  16625. * @returns an array
  16626. */
  16627. getAnimationRanges(): Nullable<AnimationRange>[];
  16628. /**
  16629. * Copy animation range from a source skeleton.
  16630. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16631. * @param source defines the source skeleton
  16632. * @param name defines the name of the range to copy
  16633. * @param rescaleAsRequired defines if rescaling must be applied if required
  16634. * @returns true if operation was successful
  16635. */
  16636. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16637. /**
  16638. * Forces the skeleton to go to rest pose
  16639. */
  16640. returnToRest(): void;
  16641. private _getHighestAnimationFrame;
  16642. /**
  16643. * Begin a specific animation range
  16644. * @param name defines the name of the range to start
  16645. * @param loop defines if looping must be turned on (false by default)
  16646. * @param speedRatio defines the speed ratio to apply (1 by default)
  16647. * @param onAnimationEnd defines a callback which will be called when animation will end
  16648. * @returns a new animatable
  16649. */
  16650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16651. /**
  16652. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16653. * @param skeleton defines the Skeleton containing the animation range to convert
  16654. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16655. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16656. * @returns the original skeleton
  16657. */
  16658. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16659. /** @hidden */
  16660. _markAsDirty(): void;
  16661. /** @hidden */
  16662. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16663. /** @hidden */
  16664. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16665. private _computeTransformMatrices;
  16666. /**
  16667. * Build all resources required to render a skeleton
  16668. */
  16669. prepare(): void;
  16670. /**
  16671. * Gets the list of animatables currently running for this skeleton
  16672. * @returns an array of animatables
  16673. */
  16674. getAnimatables(): IAnimatable[];
  16675. /**
  16676. * Clone the current skeleton
  16677. * @param name defines the name of the new skeleton
  16678. * @param id defines the id of the new skeleton
  16679. * @returns the new skeleton
  16680. */
  16681. clone(name: string, id?: string): Skeleton;
  16682. /**
  16683. * Enable animation blending for this skeleton
  16684. * @param blendingSpeed defines the blending speed to apply
  16685. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16686. */
  16687. enableBlending(blendingSpeed?: number): void;
  16688. /**
  16689. * Releases all resources associated with the current skeleton
  16690. */
  16691. dispose(): void;
  16692. /**
  16693. * Serialize the skeleton in a JSON object
  16694. * @returns a JSON object
  16695. */
  16696. serialize(): any;
  16697. /**
  16698. * Creates a new skeleton from serialized data
  16699. * @param parsedSkeleton defines the serialized data
  16700. * @param scene defines the hosting scene
  16701. * @returns a new skeleton
  16702. */
  16703. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16704. /**
  16705. * Compute all node absolute transforms
  16706. * @param forceUpdate defines if computation must be done even if cache is up to date
  16707. */
  16708. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16709. /**
  16710. * Gets the root pose matrix
  16711. * @returns a matrix
  16712. */
  16713. getPoseMatrix(): Nullable<Matrix>;
  16714. /**
  16715. * Sorts bones per internal index
  16716. */
  16717. sortBones(): void;
  16718. private _sortBones;
  16719. /**
  16720. * Set the current local matrix as the restPose for all bones in the skeleton.
  16721. */
  16722. setCurrentPoseAsRest(): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Meshes/instancedMesh" {
  16726. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16728. import { Camera } from "babylonjs/Cameras/camera";
  16729. import { Node } from "babylonjs/node";
  16730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16731. import { Mesh } from "babylonjs/Meshes/mesh";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. import { Skeleton } from "babylonjs/Bones/skeleton";
  16734. import { Light } from "babylonjs/Lights/light";
  16735. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16736. /**
  16737. * Creates an instance based on a source mesh.
  16738. */
  16739. export class InstancedMesh extends AbstractMesh {
  16740. private _sourceMesh;
  16741. private _currentLOD;
  16742. /** @hidden */
  16743. _indexInSourceMeshInstanceArray: number;
  16744. constructor(name: string, source: Mesh);
  16745. /**
  16746. * Returns the string "InstancedMesh".
  16747. */
  16748. getClassName(): string;
  16749. /** Gets the list of lights affecting that mesh */
  16750. get lightSources(): Light[];
  16751. _resyncLightSources(): void;
  16752. _resyncLightSource(light: Light): void;
  16753. _removeLightSource(light: Light, dispose: boolean): void;
  16754. /**
  16755. * If the source mesh receives shadows
  16756. */
  16757. get receiveShadows(): boolean;
  16758. /**
  16759. * The material of the source mesh
  16760. */
  16761. get material(): Nullable<Material>;
  16762. /**
  16763. * Visibility of the source mesh
  16764. */
  16765. get visibility(): number;
  16766. /**
  16767. * Skeleton of the source mesh
  16768. */
  16769. get skeleton(): Nullable<Skeleton>;
  16770. /**
  16771. * Rendering ground id of the source mesh
  16772. */
  16773. get renderingGroupId(): number;
  16774. set renderingGroupId(value: number);
  16775. /**
  16776. * Returns the total number of vertices (integer).
  16777. */
  16778. getTotalVertices(): number;
  16779. /**
  16780. * Returns a positive integer : the total number of indices in this mesh geometry.
  16781. * @returns the numner of indices or zero if the mesh has no geometry.
  16782. */
  16783. getTotalIndices(): number;
  16784. /**
  16785. * The source mesh of the instance
  16786. */
  16787. get sourceMesh(): Mesh;
  16788. /**
  16789. * Creates a new InstancedMesh object from the mesh model.
  16790. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16791. * @param name defines the name of the new instance
  16792. * @returns a new InstancedMesh
  16793. */
  16794. createInstance(name: string): InstancedMesh;
  16795. /**
  16796. * Is this node ready to be used/rendered
  16797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16798. * @return {boolean} is it ready
  16799. */
  16800. isReady(completeCheck?: boolean): boolean;
  16801. /**
  16802. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16803. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16804. * @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.
  16805. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16806. */
  16807. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16808. /**
  16809. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16810. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16811. * The `data` are either a numeric array either a Float32Array.
  16812. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16813. * 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).
  16814. * Note that a new underlying VertexBuffer object is created each call.
  16815. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16816. *
  16817. * Possible `kind` values :
  16818. * - VertexBuffer.PositionKind
  16819. * - VertexBuffer.UVKind
  16820. * - VertexBuffer.UV2Kind
  16821. * - VertexBuffer.UV3Kind
  16822. * - VertexBuffer.UV4Kind
  16823. * - VertexBuffer.UV5Kind
  16824. * - VertexBuffer.UV6Kind
  16825. * - VertexBuffer.ColorKind
  16826. * - VertexBuffer.MatricesIndicesKind
  16827. * - VertexBuffer.MatricesIndicesExtraKind
  16828. * - VertexBuffer.MatricesWeightsKind
  16829. * - VertexBuffer.MatricesWeightsExtraKind
  16830. *
  16831. * Returns the Mesh.
  16832. */
  16833. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16834. /**
  16835. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16836. * If the mesh has no geometry, it is simply returned as it is.
  16837. * The `data` are either a numeric array either a Float32Array.
  16838. * No new underlying VertexBuffer object is created.
  16839. * 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.
  16840. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16841. *
  16842. * Possible `kind` values :
  16843. * - VertexBuffer.PositionKind
  16844. * - VertexBuffer.UVKind
  16845. * - VertexBuffer.UV2Kind
  16846. * - VertexBuffer.UV3Kind
  16847. * - VertexBuffer.UV4Kind
  16848. * - VertexBuffer.UV5Kind
  16849. * - VertexBuffer.UV6Kind
  16850. * - VertexBuffer.ColorKind
  16851. * - VertexBuffer.MatricesIndicesKind
  16852. * - VertexBuffer.MatricesIndicesExtraKind
  16853. * - VertexBuffer.MatricesWeightsKind
  16854. * - VertexBuffer.MatricesWeightsExtraKind
  16855. *
  16856. * Returns the Mesh.
  16857. */
  16858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16859. /**
  16860. * Sets the mesh indices.
  16861. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16862. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16863. * This method creates a new index buffer each call.
  16864. * Returns the Mesh.
  16865. */
  16866. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16867. /**
  16868. * Boolean : True if the mesh owns the requested kind of data.
  16869. */
  16870. isVerticesDataPresent(kind: string): boolean;
  16871. /**
  16872. * Returns an array of indices (IndicesArray).
  16873. */
  16874. getIndices(): Nullable<IndicesArray>;
  16875. get _positions(): Nullable<Vector3[]>;
  16876. /**
  16877. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16878. * This means the mesh underlying bounding box and sphere are recomputed.
  16879. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16880. * @returns the current mesh
  16881. */
  16882. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16883. /** @hidden */
  16884. _preActivate(): InstancedMesh;
  16885. /** @hidden */
  16886. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16887. /** @hidden */
  16888. _postActivate(): void;
  16889. getWorldMatrix(): Matrix;
  16890. get isAnInstance(): boolean;
  16891. /**
  16892. * Returns the current associated LOD AbstractMesh.
  16893. */
  16894. getLOD(camera: Camera): AbstractMesh;
  16895. /** @hidden */
  16896. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16897. /** @hidden */
  16898. _syncSubMeshes(): InstancedMesh;
  16899. /** @hidden */
  16900. _generatePointsArray(): boolean;
  16901. /** @hidden */
  16902. _updateBoundingInfo(): AbstractMesh;
  16903. /**
  16904. * Creates a new InstancedMesh from the current mesh.
  16905. * - name (string) : the cloned mesh name
  16906. * - newParent (optional Node) : the optional Node to parent the clone to.
  16907. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16908. *
  16909. * Returns the clone.
  16910. */
  16911. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16912. /**
  16913. * Disposes the InstancedMesh.
  16914. * Returns nothing.
  16915. */
  16916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16917. }
  16918. module "babylonjs/Meshes/mesh" {
  16919. interface Mesh {
  16920. /**
  16921. * Register a custom buffer that will be instanced
  16922. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16923. * @param kind defines the buffer kind
  16924. * @param stride defines the stride in floats
  16925. */
  16926. registerInstancedBuffer(kind: string, stride: number): void;
  16927. /**
  16928. * true to use the edge renderer for all instances of this mesh
  16929. */
  16930. edgesShareWithInstances: boolean;
  16931. /** @hidden */
  16932. _userInstancedBuffersStorage: {
  16933. data: {
  16934. [key: string]: Float32Array;
  16935. };
  16936. sizes: {
  16937. [key: string]: number;
  16938. };
  16939. vertexBuffers: {
  16940. [key: string]: Nullable<VertexBuffer>;
  16941. };
  16942. strides: {
  16943. [key: string]: number;
  16944. };
  16945. };
  16946. }
  16947. }
  16948. module "babylonjs/Meshes/abstractMesh" {
  16949. interface AbstractMesh {
  16950. /**
  16951. * Object used to store instanced buffers defined by user
  16952. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16953. */
  16954. instancedBuffers: {
  16955. [key: string]: any;
  16956. };
  16957. }
  16958. }
  16959. }
  16960. declare module "babylonjs/Materials/shaderMaterial" {
  16961. import { Nullable } from "babylonjs/types";
  16962. import { Scene } from "babylonjs/scene";
  16963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16965. import { Mesh } from "babylonjs/Meshes/mesh";
  16966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16968. import { Effect } from "babylonjs/Materials/effect";
  16969. import { Material } from "babylonjs/Materials/material";
  16970. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16971. /**
  16972. * Defines the options associated with the creation of a shader material.
  16973. */
  16974. export interface IShaderMaterialOptions {
  16975. /**
  16976. * Does the material work in alpha blend mode
  16977. */
  16978. needAlphaBlending: boolean;
  16979. /**
  16980. * Does the material work in alpha test mode
  16981. */
  16982. needAlphaTesting: boolean;
  16983. /**
  16984. * The list of attribute names used in the shader
  16985. */
  16986. attributes: string[];
  16987. /**
  16988. * The list of unifrom names used in the shader
  16989. */
  16990. uniforms: string[];
  16991. /**
  16992. * The list of UBO names used in the shader
  16993. */
  16994. uniformBuffers: string[];
  16995. /**
  16996. * The list of sampler names used in the shader
  16997. */
  16998. samplers: string[];
  16999. /**
  17000. * The list of defines used in the shader
  17001. */
  17002. defines: string[];
  17003. }
  17004. /**
  17005. * 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.
  17006. *
  17007. * This returned material effects how the mesh will look based on the code in the shaders.
  17008. *
  17009. * @see https://doc.babylonjs.com/how_to/shader_material
  17010. */
  17011. export class ShaderMaterial extends Material {
  17012. private _shaderPath;
  17013. private _options;
  17014. private _textures;
  17015. private _textureArrays;
  17016. private _floats;
  17017. private _ints;
  17018. private _floatsArrays;
  17019. private _colors3;
  17020. private _colors3Arrays;
  17021. private _colors4;
  17022. private _colors4Arrays;
  17023. private _vectors2;
  17024. private _vectors3;
  17025. private _vectors4;
  17026. private _matrices;
  17027. private _matrixArrays;
  17028. private _matrices3x3;
  17029. private _matrices2x2;
  17030. private _vectors2Arrays;
  17031. private _vectors3Arrays;
  17032. private _vectors4Arrays;
  17033. private _cachedWorldViewMatrix;
  17034. private _cachedWorldViewProjectionMatrix;
  17035. private _renderId;
  17036. private _multiview;
  17037. private _cachedDefines;
  17038. /** Define the Url to load snippets */
  17039. static SnippetUrl: string;
  17040. /** Snippet ID if the material was created from the snippet server */
  17041. snippetId: string;
  17042. /**
  17043. * Instantiate a new shader material.
  17044. * 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.
  17045. * This returned material effects how the mesh will look based on the code in the shaders.
  17046. * @see https://doc.babylonjs.com/how_to/shader_material
  17047. * @param name Define the name of the material in the scene
  17048. * @param scene Define the scene the material belongs to
  17049. * @param shaderPath Defines the route to the shader code in one of three ways:
  17050. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17051. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17052. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17053. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17054. * @param options Define the options used to create the shader
  17055. */
  17056. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17057. /**
  17058. * Gets the shader path used to define the shader code
  17059. * It can be modified to trigger a new compilation
  17060. */
  17061. get shaderPath(): any;
  17062. /**
  17063. * Sets the shader path used to define the shader code
  17064. * It can be modified to trigger a new compilation
  17065. */
  17066. set shaderPath(shaderPath: any);
  17067. /**
  17068. * Gets the options used to compile the shader.
  17069. * They can be modified to trigger a new compilation
  17070. */
  17071. get options(): IShaderMaterialOptions;
  17072. /**
  17073. * Gets the current class name of the material e.g. "ShaderMaterial"
  17074. * Mainly use in serialization.
  17075. * @returns the class name
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * Specifies if the material will require alpha blending
  17080. * @returns a boolean specifying if alpha blending is needed
  17081. */
  17082. needAlphaBlending(): boolean;
  17083. /**
  17084. * Specifies if this material should be rendered in alpha test mode
  17085. * @returns a boolean specifying if an alpha test is needed.
  17086. */
  17087. needAlphaTesting(): boolean;
  17088. private _checkUniform;
  17089. /**
  17090. * Set a texture in the shader.
  17091. * @param name Define the name of the uniform samplers as defined in the shader
  17092. * @param texture Define the texture to bind to this sampler
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17096. /**
  17097. * Set a texture array in the shader.
  17098. * @param name Define the name of the uniform sampler array as defined in the shader
  17099. * @param textures Define the list of textures to bind to this sampler
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17103. /**
  17104. * Set a float in the shader.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setFloat(name: string, value: number): ShaderMaterial;
  17110. /**
  17111. * Set a int in the shader.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setInt(name: string, value: number): ShaderMaterial;
  17117. /**
  17118. * Set an array of floats in the shader.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setFloats(name: string, value: number[]): ShaderMaterial;
  17124. /**
  17125. * Set a vec3 in the shader from a Color3.
  17126. * @param name Define the name of the uniform as defined in the shader
  17127. * @param value Define the value to give to the uniform
  17128. * @return the material itself allowing "fluent" like uniform updates
  17129. */
  17130. setColor3(name: string, value: Color3): ShaderMaterial;
  17131. /**
  17132. * Set a vec3 array in the shader from a Color3 array.
  17133. * @param name Define the name of the uniform as defined in the shader
  17134. * @param value Define the value to give to the uniform
  17135. * @return the material itself allowing "fluent" like uniform updates
  17136. */
  17137. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17138. /**
  17139. * Set a vec4 in the shader from a Color4.
  17140. * @param name Define the name of the uniform as defined in the shader
  17141. * @param value Define the value to give to the uniform
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setColor4(name: string, value: Color4): ShaderMaterial;
  17145. /**
  17146. * Set a vec4 array in the shader from a Color4 array.
  17147. * @param name Define the name of the uniform as defined in the shader
  17148. * @param value Define the value to give to the uniform
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17152. /**
  17153. * Set a vec2 in the shader from a Vector2.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setVector2(name: string, value: Vector2): ShaderMaterial;
  17159. /**
  17160. * Set a vec3 in the shader from a Vector3.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setVector3(name: string, value: Vector3): ShaderMaterial;
  17166. /**
  17167. * Set a vec4 in the shader from a Vector4.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setVector4(name: string, value: Vector4): ShaderMaterial;
  17173. /**
  17174. * Set a mat4 in the shader from a Matrix.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17180. /**
  17181. * Set a float32Array in the shader from a matrix array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17187. /**
  17188. * Set a mat3 in the shader from a Float32Array.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17194. /**
  17195. * Set a mat2 in the shader from a Float32Array.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 array in the shader from a number array.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setArray2(name: string, value: number[]): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 array in the shader from a number array.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setArray3(name: string, value: number[]): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 array in the shader from a number array.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setArray4(name: string, value: number[]): ShaderMaterial;
  17222. private _checkCache;
  17223. /**
  17224. * Specifies that the submesh is ready to be used
  17225. * @param mesh defines the mesh to check
  17226. * @param subMesh defines which submesh to check
  17227. * @param useInstances specifies that instances should be used
  17228. * @returns a boolean indicating that the submesh is ready or not
  17229. */
  17230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17231. /**
  17232. * Checks if the material is ready to render the requested mesh
  17233. * @param mesh Define the mesh to render
  17234. * @param useInstances Define whether or not the material is used with instances
  17235. * @returns true if ready, otherwise false
  17236. */
  17237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17238. /**
  17239. * Binds the world matrix to the material
  17240. * @param world defines the world transformation matrix
  17241. * @param effectOverride - If provided, use this effect instead of internal effect
  17242. */
  17243. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17244. /**
  17245. * Binds the submesh to this material by preparing the effect and shader to draw
  17246. * @param world defines the world transformation matrix
  17247. * @param mesh defines the mesh containing the submesh
  17248. * @param subMesh defines the submesh to bind the material to
  17249. */
  17250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17251. /**
  17252. * Binds the material to the mesh
  17253. * @param world defines the world transformation matrix
  17254. * @param mesh defines the mesh to bind the material to
  17255. * @param effectOverride - If provided, use this effect instead of internal effect
  17256. */
  17257. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17258. protected _afterBind(mesh?: Mesh): void;
  17259. /**
  17260. * Gets the active textures from the material
  17261. * @returns an array of textures
  17262. */
  17263. getActiveTextures(): BaseTexture[];
  17264. /**
  17265. * Specifies if the material uses a texture
  17266. * @param texture defines the texture to check against the material
  17267. * @returns a boolean specifying if the material uses the texture
  17268. */
  17269. hasTexture(texture: BaseTexture): boolean;
  17270. /**
  17271. * Makes a duplicate of the material, and gives it a new name
  17272. * @param name defines the new name for the duplicated material
  17273. * @returns the cloned material
  17274. */
  17275. clone(name: string): ShaderMaterial;
  17276. /**
  17277. * Disposes the material
  17278. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17279. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17280. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17281. */
  17282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17283. /**
  17284. * Serializes this material in a JSON representation
  17285. * @returns the serialized material object
  17286. */
  17287. serialize(): any;
  17288. /**
  17289. * Creates a shader material from parsed shader material data
  17290. * @param source defines the JSON represnetation of the material
  17291. * @param scene defines the hosting scene
  17292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17293. * @returns a new material
  17294. */
  17295. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17296. /**
  17297. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17298. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17299. * @param url defines the url to load from
  17300. * @param scene defines the hosting scene
  17301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17302. * @returns a promise that will resolve to the new ShaderMaterial
  17303. */
  17304. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17305. /**
  17306. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17307. * @param snippetId defines the snippet to load
  17308. * @param scene defines the hosting scene
  17309. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17310. * @returns a promise that will resolve to the new ShaderMaterial
  17311. */
  17312. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17313. }
  17314. }
  17315. declare module "babylonjs/Shaders/color.fragment" {
  17316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17318. /** @hidden */
  17319. export var colorPixelShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module "babylonjs/Shaders/color.vertex" {
  17325. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17331. /** @hidden */
  17332. export var colorVertexShader: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module "babylonjs/Meshes/linesMesh" {
  17338. import { Nullable } from "babylonjs/types";
  17339. import { Scene } from "babylonjs/scene";
  17340. import { Color3 } from "babylonjs/Maths/math.color";
  17341. import { Node } from "babylonjs/node";
  17342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17343. import { Mesh } from "babylonjs/Meshes/mesh";
  17344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17345. import { Effect } from "babylonjs/Materials/effect";
  17346. import { Material } from "babylonjs/Materials/material";
  17347. import "babylonjs/Shaders/color.fragment";
  17348. import "babylonjs/Shaders/color.vertex";
  17349. /**
  17350. * Line mesh
  17351. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17352. */
  17353. export class LinesMesh extends Mesh {
  17354. /**
  17355. * If vertex color should be applied to the mesh
  17356. */
  17357. readonly useVertexColor?: boolean | undefined;
  17358. /**
  17359. * If vertex alpha should be applied to the mesh
  17360. */
  17361. readonly useVertexAlpha?: boolean | undefined;
  17362. /**
  17363. * Color of the line (Default: White)
  17364. */
  17365. color: Color3;
  17366. /**
  17367. * Alpha of the line (Default: 1)
  17368. */
  17369. alpha: number;
  17370. /**
  17371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17372. * This margin is expressed in world space coordinates, so its value may vary.
  17373. * Default value is 0.1
  17374. */
  17375. intersectionThreshold: number;
  17376. private _colorShader;
  17377. private color4;
  17378. /**
  17379. * Creates a new LinesMesh
  17380. * @param name defines the name
  17381. * @param scene defines the hosting scene
  17382. * @param parent defines the parent mesh if any
  17383. * @param source defines the optional source LinesMesh used to clone data from
  17384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17385. * When false, achieved by calling a clone(), also passing False.
  17386. * This will make creation of children, recursive.
  17387. * @param useVertexColor defines if this LinesMesh supports vertex color
  17388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17389. */
  17390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17391. /**
  17392. * If vertex color should be applied to the mesh
  17393. */
  17394. useVertexColor?: boolean | undefined,
  17395. /**
  17396. * If vertex alpha should be applied to the mesh
  17397. */
  17398. useVertexAlpha?: boolean | undefined);
  17399. private _addClipPlaneDefine;
  17400. private _removeClipPlaneDefine;
  17401. isReady(): boolean;
  17402. /**
  17403. * Returns the string "LineMesh"
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * @hidden
  17408. */
  17409. get material(): Material;
  17410. /**
  17411. * @hidden
  17412. */
  17413. set material(value: Material);
  17414. /**
  17415. * @hidden
  17416. */
  17417. get checkCollisions(): boolean;
  17418. /** @hidden */
  17419. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17420. /** @hidden */
  17421. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17422. /**
  17423. * Disposes of the line mesh
  17424. * @param doNotRecurse If children should be disposed
  17425. */
  17426. dispose(doNotRecurse?: boolean): void;
  17427. /**
  17428. * Returns a new LineMesh object cloned from the current one.
  17429. */
  17430. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17431. /**
  17432. * Creates a new InstancedLinesMesh object from the mesh model.
  17433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17434. * @param name defines the name of the new instance
  17435. * @returns a new InstancedLinesMesh
  17436. */
  17437. createInstance(name: string): InstancedLinesMesh;
  17438. }
  17439. /**
  17440. * Creates an instance based on a source LinesMesh
  17441. */
  17442. export class InstancedLinesMesh extends InstancedMesh {
  17443. /**
  17444. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17445. * This margin is expressed in world space coordinates, so its value may vary.
  17446. * Initilized with the intersectionThreshold value of the source LinesMesh
  17447. */
  17448. intersectionThreshold: number;
  17449. constructor(name: string, source: LinesMesh);
  17450. /**
  17451. * Returns the string "InstancedLinesMesh".
  17452. */
  17453. getClassName(): string;
  17454. }
  17455. }
  17456. declare module "babylonjs/Shaders/line.fragment" {
  17457. /** @hidden */
  17458. export var linePixelShader: {
  17459. name: string;
  17460. shader: string;
  17461. };
  17462. }
  17463. declare module "babylonjs/Shaders/line.vertex" {
  17464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17466. /** @hidden */
  17467. export var lineVertexShader: {
  17468. name: string;
  17469. shader: string;
  17470. };
  17471. }
  17472. declare module "babylonjs/Rendering/edgesRenderer" {
  17473. import { Nullable } from "babylonjs/types";
  17474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17476. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17477. import { IDisposable } from "babylonjs/scene";
  17478. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17479. import "babylonjs/Shaders/line.fragment";
  17480. import "babylonjs/Shaders/line.vertex";
  17481. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17482. import { SmartArray } from "babylonjs/Misc/smartArray";
  17483. module "babylonjs/scene" {
  17484. interface Scene {
  17485. /** @hidden */
  17486. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17487. }
  17488. }
  17489. module "babylonjs/Meshes/abstractMesh" {
  17490. interface AbstractMesh {
  17491. /**
  17492. * Gets the edgesRenderer associated with the mesh
  17493. */
  17494. edgesRenderer: Nullable<EdgesRenderer>;
  17495. }
  17496. }
  17497. module "babylonjs/Meshes/linesMesh" {
  17498. interface LinesMesh {
  17499. /**
  17500. * Enables the edge rendering mode on the mesh.
  17501. * This mode makes the mesh edges visible
  17502. * @param epsilon defines the maximal distance between two angles to detect a face
  17503. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17504. * @returns the currentAbstractMesh
  17505. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17506. */
  17507. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17508. }
  17509. }
  17510. module "babylonjs/Meshes/linesMesh" {
  17511. interface InstancedLinesMesh {
  17512. /**
  17513. * Enables the edge rendering mode on the mesh.
  17514. * This mode makes the mesh edges visible
  17515. * @param epsilon defines the maximal distance between two angles to detect a face
  17516. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17517. * @returns the current InstancedLinesMesh
  17518. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17519. */
  17520. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17521. }
  17522. }
  17523. /**
  17524. * Defines the minimum contract an Edges renderer should follow.
  17525. */
  17526. export interface IEdgesRenderer extends IDisposable {
  17527. /**
  17528. * Gets or sets a boolean indicating if the edgesRenderer is active
  17529. */
  17530. isEnabled: boolean;
  17531. /**
  17532. * Renders the edges of the attached mesh,
  17533. */
  17534. render(): void;
  17535. /**
  17536. * Checks wether or not the edges renderer is ready to render.
  17537. * @return true if ready, otherwise false.
  17538. */
  17539. isReady(): boolean;
  17540. /**
  17541. * List of instances to render in case the source mesh has instances
  17542. */
  17543. customInstances: SmartArray<Matrix>;
  17544. }
  17545. /**
  17546. * Defines the additional options of the edges renderer
  17547. */
  17548. export interface IEdgesRendererOptions {
  17549. /**
  17550. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17551. * If not defined, the default value is true
  17552. */
  17553. useAlternateEdgeFinder?: boolean;
  17554. /**
  17555. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17556. * If not defined, the default value is true.
  17557. * 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)
  17558. * This option is used only if useAlternateEdgeFinder = true
  17559. */
  17560. useFastVertexMerger?: boolean;
  17561. /**
  17562. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17563. * The default value is 1e-6
  17564. * This option is used only if useAlternateEdgeFinder = true
  17565. */
  17566. epsilonVertexMerge?: number;
  17567. /**
  17568. * 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
  17569. * 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.
  17570. * This option is used only if useAlternateEdgeFinder = true
  17571. */
  17572. applyTessellation?: boolean;
  17573. /**
  17574. * 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
  17575. * The default value is 1e-6
  17576. * This option is used only if useAlternateEdgeFinder = true
  17577. */
  17578. epsilonVertexAligned?: number;
  17579. }
  17580. /**
  17581. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17582. */
  17583. export class EdgesRenderer implements IEdgesRenderer {
  17584. /**
  17585. * Define the size of the edges with an orthographic camera
  17586. */
  17587. edgesWidthScalerForOrthographic: number;
  17588. /**
  17589. * Define the size of the edges with a perspective camera
  17590. */
  17591. edgesWidthScalerForPerspective: number;
  17592. protected _source: AbstractMesh;
  17593. protected _linesPositions: number[];
  17594. protected _linesNormals: number[];
  17595. protected _linesIndices: number[];
  17596. protected _epsilon: number;
  17597. protected _indicesCount: number;
  17598. protected _lineShader: ShaderMaterial;
  17599. protected _ib: DataBuffer;
  17600. protected _buffers: {
  17601. [key: string]: Nullable<VertexBuffer>;
  17602. };
  17603. protected _buffersForInstances: {
  17604. [key: string]: Nullable<VertexBuffer>;
  17605. };
  17606. protected _checkVerticesInsteadOfIndices: boolean;
  17607. protected _options: Nullable<IEdgesRendererOptions>;
  17608. private _meshRebuildObserver;
  17609. private _meshDisposeObserver;
  17610. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17611. isEnabled: boolean;
  17612. /**
  17613. * List of instances to render in case the source mesh has instances
  17614. */
  17615. customInstances: SmartArray<Matrix>;
  17616. private static GetShader;
  17617. /**
  17618. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17619. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17620. * @param source Mesh used to create edges
  17621. * @param epsilon sum of angles in adjacency to check for edge
  17622. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17623. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17624. * @param options The options to apply when generating the edges
  17625. */
  17626. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17627. protected _prepareRessources(): void;
  17628. /** @hidden */
  17629. _rebuild(): void;
  17630. /**
  17631. * Releases the required resources for the edges renderer
  17632. */
  17633. dispose(): void;
  17634. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17635. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17636. /**
  17637. * Checks if the pair of p0 and p1 is en edge
  17638. * @param faceIndex
  17639. * @param edge
  17640. * @param faceNormals
  17641. * @param p0
  17642. * @param p1
  17643. * @private
  17644. */
  17645. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17646. /**
  17647. * push line into the position, normal and index buffer
  17648. * @protected
  17649. */
  17650. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17651. /**
  17652. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17653. */
  17654. private _tessellateTriangle;
  17655. private _generateEdgesLinesAlternate;
  17656. /**
  17657. * Generates lines edges from adjacencjes
  17658. * @private
  17659. */
  17660. _generateEdgesLines(): void;
  17661. /**
  17662. * Checks wether or not the edges renderer is ready to render.
  17663. * @return true if ready, otherwise false.
  17664. */
  17665. isReady(): boolean;
  17666. /**
  17667. * Renders the edges of the attached mesh,
  17668. */
  17669. render(): void;
  17670. }
  17671. /**
  17672. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17673. */
  17674. export class LineEdgesRenderer extends EdgesRenderer {
  17675. /**
  17676. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17677. * @param source LineMesh used to generate edges
  17678. * @param epsilon not important (specified angle for edge detection)
  17679. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17680. */
  17681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17682. /**
  17683. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17684. */
  17685. _generateEdgesLines(): void;
  17686. }
  17687. }
  17688. declare module "babylonjs/Rendering/renderingGroup" {
  17689. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17692. import { Nullable } from "babylonjs/types";
  17693. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17694. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17695. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17696. import { Material } from "babylonjs/Materials/material";
  17697. import { Scene } from "babylonjs/scene";
  17698. /**
  17699. * This represents the object necessary to create a rendering group.
  17700. * This is exclusively used and created by the rendering manager.
  17701. * To modify the behavior, you use the available helpers in your scene or meshes.
  17702. * @hidden
  17703. */
  17704. export class RenderingGroup {
  17705. index: number;
  17706. private static _zeroVector;
  17707. private _scene;
  17708. private _opaqueSubMeshes;
  17709. private _transparentSubMeshes;
  17710. private _alphaTestSubMeshes;
  17711. private _depthOnlySubMeshes;
  17712. private _particleSystems;
  17713. private _spriteManagers;
  17714. private _opaqueSortCompareFn;
  17715. private _alphaTestSortCompareFn;
  17716. private _transparentSortCompareFn;
  17717. private _renderOpaque;
  17718. private _renderAlphaTest;
  17719. private _renderTransparent;
  17720. /** @hidden */
  17721. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17722. onBeforeTransparentRendering: () => void;
  17723. /**
  17724. * Set the opaque sort comparison function.
  17725. * If null the sub meshes will be render in the order they were created
  17726. */
  17727. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17728. /**
  17729. * Set the alpha test sort comparison function.
  17730. * If null the sub meshes will be render in the order they were created
  17731. */
  17732. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17733. /**
  17734. * Set the transparent sort comparison function.
  17735. * If null the sub meshes will be render in the order they were created
  17736. */
  17737. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17738. /**
  17739. * Creates a new rendering group.
  17740. * @param index The rendering group index
  17741. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17742. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17743. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17744. */
  17745. 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>);
  17746. /**
  17747. * Render all the sub meshes contained in the group.
  17748. * @param customRenderFunction Used to override the default render behaviour of the group.
  17749. * @returns true if rendered some submeshes.
  17750. */
  17751. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17752. /**
  17753. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17754. * @param subMeshes The submeshes to render
  17755. */
  17756. private renderOpaqueSorted;
  17757. /**
  17758. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17759. * @param subMeshes The submeshes to render
  17760. */
  17761. private renderAlphaTestSorted;
  17762. /**
  17763. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17764. * @param subMeshes The submeshes to render
  17765. */
  17766. private renderTransparentSorted;
  17767. /**
  17768. * Renders the submeshes in a specified order.
  17769. * @param subMeshes The submeshes to sort before render
  17770. * @param sortCompareFn The comparison function use to sort
  17771. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17772. * @param transparent Specifies to activate blending if true
  17773. */
  17774. private static renderSorted;
  17775. /**
  17776. * Renders the submeshes in the order they were dispatched (no sort applied).
  17777. * @param subMeshes The submeshes to render
  17778. */
  17779. private static renderUnsorted;
  17780. /**
  17781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17782. * are rendered back to front if in the same alpha index.
  17783. *
  17784. * @param a The first submesh
  17785. * @param b The second submesh
  17786. * @returns The result of the comparison
  17787. */
  17788. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17789. /**
  17790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17791. * are rendered back to front.
  17792. *
  17793. * @param a The first submesh
  17794. * @param b The second submesh
  17795. * @returns The result of the comparison
  17796. */
  17797. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17798. /**
  17799. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17800. * are rendered front to back (prevent overdraw).
  17801. *
  17802. * @param a The first submesh
  17803. * @param b The second submesh
  17804. * @returns The result of the comparison
  17805. */
  17806. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17807. /**
  17808. * Resets the different lists of submeshes to prepare a new frame.
  17809. */
  17810. prepare(): void;
  17811. dispose(): void;
  17812. /**
  17813. * Inserts the submesh in its correct queue depending on its material.
  17814. * @param subMesh The submesh to dispatch
  17815. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17816. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17817. */
  17818. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17819. dispatchSprites(spriteManager: ISpriteManager): void;
  17820. dispatchParticles(particleSystem: IParticleSystem): void;
  17821. private _renderParticles;
  17822. private _renderSprites;
  17823. }
  17824. }
  17825. declare module "babylonjs/Rendering/renderingManager" {
  17826. import { Nullable } from "babylonjs/types";
  17827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17829. import { SmartArray } from "babylonjs/Misc/smartArray";
  17830. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17831. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17832. import { Material } from "babylonjs/Materials/material";
  17833. import { Scene } from "babylonjs/scene";
  17834. import { Camera } from "babylonjs/Cameras/camera";
  17835. /**
  17836. * Interface describing the different options available in the rendering manager
  17837. * regarding Auto Clear between groups.
  17838. */
  17839. export interface IRenderingManagerAutoClearSetup {
  17840. /**
  17841. * Defines whether or not autoclear is enable.
  17842. */
  17843. autoClear: boolean;
  17844. /**
  17845. * Defines whether or not to autoclear the depth buffer.
  17846. */
  17847. depth: boolean;
  17848. /**
  17849. * Defines whether or not to autoclear the stencil buffer.
  17850. */
  17851. stencil: boolean;
  17852. }
  17853. /**
  17854. * This class is used by the onRenderingGroupObservable
  17855. */
  17856. export class RenderingGroupInfo {
  17857. /**
  17858. * The Scene that being rendered
  17859. */
  17860. scene: Scene;
  17861. /**
  17862. * The camera currently used for the rendering pass
  17863. */
  17864. camera: Nullable<Camera>;
  17865. /**
  17866. * The ID of the renderingGroup being processed
  17867. */
  17868. renderingGroupId: number;
  17869. }
  17870. /**
  17871. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17872. * It is enable to manage the different groups as well as the different necessary sort functions.
  17873. * This should not be used directly aside of the few static configurations
  17874. */
  17875. export class RenderingManager {
  17876. /**
  17877. * The max id used for rendering groups (not included)
  17878. */
  17879. static MAX_RENDERINGGROUPS: number;
  17880. /**
  17881. * The min id used for rendering groups (included)
  17882. */
  17883. static MIN_RENDERINGGROUPS: number;
  17884. /**
  17885. * Used to globally prevent autoclearing scenes.
  17886. */
  17887. static AUTOCLEAR: boolean;
  17888. /**
  17889. * @hidden
  17890. */
  17891. _useSceneAutoClearSetup: boolean;
  17892. private _scene;
  17893. private _renderingGroups;
  17894. private _depthStencilBufferAlreadyCleaned;
  17895. private _autoClearDepthStencil;
  17896. private _customOpaqueSortCompareFn;
  17897. private _customAlphaTestSortCompareFn;
  17898. private _customTransparentSortCompareFn;
  17899. private _renderingGroupInfo;
  17900. /**
  17901. * Instantiates a new rendering group for a particular scene
  17902. * @param scene Defines the scene the groups belongs to
  17903. */
  17904. constructor(scene: Scene);
  17905. private _clearDepthStencilBuffer;
  17906. /**
  17907. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17908. * @hidden
  17909. */
  17910. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17911. /**
  17912. * Resets the different information of the group to prepare a new frame
  17913. * @hidden
  17914. */
  17915. reset(): void;
  17916. /**
  17917. * Dispose and release the group and its associated resources.
  17918. * @hidden
  17919. */
  17920. dispose(): void;
  17921. /**
  17922. * Clear the info related to rendering groups preventing retention points during dispose.
  17923. */
  17924. freeRenderingGroups(): void;
  17925. private _prepareRenderingGroup;
  17926. /**
  17927. * Add a sprite manager to the rendering manager in order to render it this frame.
  17928. * @param spriteManager Define the sprite manager to render
  17929. */
  17930. dispatchSprites(spriteManager: ISpriteManager): void;
  17931. /**
  17932. * Add a particle system to the rendering manager in order to render it this frame.
  17933. * @param particleSystem Define the particle system to render
  17934. */
  17935. dispatchParticles(particleSystem: IParticleSystem): void;
  17936. /**
  17937. * Add a submesh to the manager in order to render it this frame
  17938. * @param subMesh The submesh to dispatch
  17939. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17940. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17941. */
  17942. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17943. /**
  17944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17945. * This allowed control for front to back rendering or reversly depending of the special needs.
  17946. *
  17947. * @param renderingGroupId The rendering group id corresponding to its index
  17948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17951. */
  17952. 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;
  17953. /**
  17954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17955. *
  17956. * @param renderingGroupId The rendering group id corresponding to its index
  17957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17960. */
  17961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17962. /**
  17963. * Gets the current auto clear configuration for one rendering group of the rendering
  17964. * manager.
  17965. * @param index the rendering group index to get the information for
  17966. * @returns The auto clear setup for the requested rendering group
  17967. */
  17968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17969. }
  17970. }
  17971. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17972. import { SmartArray } from "babylonjs/Misc/smartArray";
  17973. import { Nullable } from "babylonjs/types";
  17974. import { Scene } from "babylonjs/scene";
  17975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17978. import { Mesh } from "babylonjs/Meshes/mesh";
  17979. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17980. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17981. import { Effect } from "babylonjs/Materials/effect";
  17982. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17984. import "babylonjs/Shaders/shadowMap.fragment";
  17985. import "babylonjs/Shaders/shadowMap.vertex";
  17986. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17987. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17988. import { Observable } from "babylonjs/Misc/observable";
  17989. /**
  17990. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17991. */
  17992. export interface ICustomShaderOptions {
  17993. /**
  17994. * Gets or sets the custom shader name to use
  17995. */
  17996. shaderName: string;
  17997. /**
  17998. * The list of attribute names used in the shader
  17999. */
  18000. attributes?: string[];
  18001. /**
  18002. * The list of unifrom names used in the shader
  18003. */
  18004. uniforms?: string[];
  18005. /**
  18006. * The list of sampler names used in the shader
  18007. */
  18008. samplers?: string[];
  18009. /**
  18010. * The list of defines used in the shader
  18011. */
  18012. defines?: string[];
  18013. }
  18014. /**
  18015. * Interface to implement to create a shadow generator compatible with BJS.
  18016. */
  18017. export interface IShadowGenerator {
  18018. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18019. id: string;
  18020. /**
  18021. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18022. * @returns The render target texture if present otherwise, null
  18023. */
  18024. getShadowMap(): Nullable<RenderTargetTexture>;
  18025. /**
  18026. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18027. * @param subMesh The submesh we want to render in the shadow map
  18028. * @param useInstances Defines wether will draw in the map using instances
  18029. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18030. * @returns true if ready otherwise, false
  18031. */
  18032. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18033. /**
  18034. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18035. * @param defines Defines of the material we want to update
  18036. * @param lightIndex Index of the light in the enabled light list of the material
  18037. */
  18038. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18039. /**
  18040. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18041. * defined in the generator but impacting the effect).
  18042. * It implies the unifroms available on the materials are the standard BJS ones.
  18043. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18044. * @param effect The effect we are binfing the information for
  18045. */
  18046. bindShadowLight(lightIndex: string, effect: Effect): void;
  18047. /**
  18048. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18049. * (eq to shadow prjection matrix * light transform matrix)
  18050. * @returns The transform matrix used to create the shadow map
  18051. */
  18052. getTransformMatrix(): Matrix;
  18053. /**
  18054. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18055. * Cube and 2D textures for instance.
  18056. */
  18057. recreateShadowMap(): void;
  18058. /**
  18059. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18060. * @param onCompiled Callback triggered at the and of the effects compilation
  18061. * @param options Sets of optional options forcing the compilation with different modes
  18062. */
  18063. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18064. useInstances: boolean;
  18065. }>): void;
  18066. /**
  18067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18068. * @param options Sets of optional options forcing the compilation with different modes
  18069. * @returns A promise that resolves when the compilation completes
  18070. */
  18071. forceCompilationAsync(options?: Partial<{
  18072. useInstances: boolean;
  18073. }>): Promise<void>;
  18074. /**
  18075. * Serializes the shadow generator setup to a json object.
  18076. * @returns The serialized JSON object
  18077. */
  18078. serialize(): any;
  18079. /**
  18080. * Disposes the Shadow map and related Textures and effects.
  18081. */
  18082. dispose(): void;
  18083. }
  18084. /**
  18085. * Default implementation IShadowGenerator.
  18086. * This is the main object responsible of generating shadows in the framework.
  18087. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18088. */
  18089. export class ShadowGenerator implements IShadowGenerator {
  18090. /**
  18091. * Name of the shadow generator class
  18092. */
  18093. static CLASSNAME: string;
  18094. /**
  18095. * Shadow generator mode None: no filtering applied.
  18096. */
  18097. static readonly FILTER_NONE: number;
  18098. /**
  18099. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18100. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18101. */
  18102. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18103. /**
  18104. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18105. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18106. */
  18107. static readonly FILTER_POISSONSAMPLING: number;
  18108. /**
  18109. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18110. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18111. */
  18112. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18113. /**
  18114. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18115. * edge artifacts on steep falloff.
  18116. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18117. */
  18118. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18119. /**
  18120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18121. * edge artifacts on steep falloff.
  18122. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18123. */
  18124. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18125. /**
  18126. * Shadow generator mode PCF: Percentage Closer Filtering
  18127. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18128. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18129. */
  18130. static readonly FILTER_PCF: number;
  18131. /**
  18132. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18133. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18134. * Contact Hardening
  18135. */
  18136. static readonly FILTER_PCSS: number;
  18137. /**
  18138. * Reserved for PCF and PCSS
  18139. * Highest Quality.
  18140. *
  18141. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18142. *
  18143. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18144. */
  18145. static readonly QUALITY_HIGH: number;
  18146. /**
  18147. * Reserved for PCF and PCSS
  18148. * Good tradeoff for quality/perf cross devices
  18149. *
  18150. * Execute PCF on a 3*3 kernel.
  18151. *
  18152. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18153. */
  18154. static readonly QUALITY_MEDIUM: number;
  18155. /**
  18156. * Reserved for PCF and PCSS
  18157. * The lowest quality but the fastest.
  18158. *
  18159. * Execute PCF on a 1*1 kernel.
  18160. *
  18161. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18162. */
  18163. static readonly QUALITY_LOW: number;
  18164. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18165. id: string;
  18166. /** Gets or sets the custom shader name to use */
  18167. customShaderOptions: ICustomShaderOptions;
  18168. /**
  18169. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18170. */
  18171. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18172. /**
  18173. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18174. */
  18175. onAfterShadowMapRenderObservable: Observable<Effect>;
  18176. /**
  18177. * Observable triggered before a mesh is rendered in the shadow map.
  18178. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18179. */
  18180. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18181. /**
  18182. * Observable triggered after a mesh is rendered in the shadow map.
  18183. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18184. */
  18185. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18186. protected _bias: number;
  18187. /**
  18188. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18189. */
  18190. get bias(): number;
  18191. /**
  18192. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18193. */
  18194. set bias(bias: number);
  18195. protected _normalBias: number;
  18196. /**
  18197. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18198. */
  18199. get normalBias(): number;
  18200. /**
  18201. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18202. */
  18203. set normalBias(normalBias: number);
  18204. protected _blurBoxOffset: number;
  18205. /**
  18206. * Gets the blur box offset: offset applied during the blur pass.
  18207. * Only useful if useKernelBlur = false
  18208. */
  18209. get blurBoxOffset(): number;
  18210. /**
  18211. * Sets the blur box offset: offset applied during the blur pass.
  18212. * Only useful if useKernelBlur = false
  18213. */
  18214. set blurBoxOffset(value: number);
  18215. protected _blurScale: number;
  18216. /**
  18217. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18218. * 2 means half of the size.
  18219. */
  18220. get blurScale(): number;
  18221. /**
  18222. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18223. * 2 means half of the size.
  18224. */
  18225. set blurScale(value: number);
  18226. protected _blurKernel: number;
  18227. /**
  18228. * Gets the blur kernel: kernel size of the blur pass.
  18229. * Only useful if useKernelBlur = true
  18230. */
  18231. get blurKernel(): number;
  18232. /**
  18233. * Sets the blur kernel: kernel size of the blur pass.
  18234. * Only useful if useKernelBlur = true
  18235. */
  18236. set blurKernel(value: number);
  18237. protected _useKernelBlur: boolean;
  18238. /**
  18239. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18240. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18241. */
  18242. get useKernelBlur(): boolean;
  18243. /**
  18244. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18245. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18246. */
  18247. set useKernelBlur(value: boolean);
  18248. protected _depthScale: number;
  18249. /**
  18250. * Gets the depth scale used in ESM mode.
  18251. */
  18252. get depthScale(): number;
  18253. /**
  18254. * Sets the depth scale used in ESM mode.
  18255. * This can override the scale stored on the light.
  18256. */
  18257. set depthScale(value: number);
  18258. protected _validateFilter(filter: number): number;
  18259. protected _filter: number;
  18260. /**
  18261. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18262. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18263. */
  18264. get filter(): number;
  18265. /**
  18266. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18267. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18268. */
  18269. set filter(value: number);
  18270. /**
  18271. * Gets if the current filter is set to Poisson Sampling.
  18272. */
  18273. get usePoissonSampling(): boolean;
  18274. /**
  18275. * Sets the current filter to Poisson Sampling.
  18276. */
  18277. set usePoissonSampling(value: boolean);
  18278. /**
  18279. * Gets if the current filter is set to ESM.
  18280. */
  18281. get useExponentialShadowMap(): boolean;
  18282. /**
  18283. * Sets the current filter is to ESM.
  18284. */
  18285. set useExponentialShadowMap(value: boolean);
  18286. /**
  18287. * Gets if the current filter is set to filtered ESM.
  18288. */
  18289. get useBlurExponentialShadowMap(): boolean;
  18290. /**
  18291. * Gets if the current filter is set to filtered ESM.
  18292. */
  18293. set useBlurExponentialShadowMap(value: boolean);
  18294. /**
  18295. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18296. * exponential to prevent steep falloff artifacts).
  18297. */
  18298. get useCloseExponentialShadowMap(): boolean;
  18299. /**
  18300. * Sets the current filter to "close ESM" (using the inverse of the
  18301. * exponential to prevent steep falloff artifacts).
  18302. */
  18303. set useCloseExponentialShadowMap(value: boolean);
  18304. /**
  18305. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18306. * exponential to prevent steep falloff artifacts).
  18307. */
  18308. get useBlurCloseExponentialShadowMap(): boolean;
  18309. /**
  18310. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18311. * exponential to prevent steep falloff artifacts).
  18312. */
  18313. set useBlurCloseExponentialShadowMap(value: boolean);
  18314. /**
  18315. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18316. */
  18317. get usePercentageCloserFiltering(): boolean;
  18318. /**
  18319. * Sets the current filter to "PCF" (percentage closer filtering).
  18320. */
  18321. set usePercentageCloserFiltering(value: boolean);
  18322. protected _filteringQuality: number;
  18323. /**
  18324. * Gets the PCF or PCSS Quality.
  18325. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18326. */
  18327. get filteringQuality(): number;
  18328. /**
  18329. * Sets the PCF or PCSS Quality.
  18330. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18331. */
  18332. set filteringQuality(filteringQuality: number);
  18333. /**
  18334. * Gets if the current filter is set to "PCSS" (contact hardening).
  18335. */
  18336. get useContactHardeningShadow(): boolean;
  18337. /**
  18338. * Sets the current filter to "PCSS" (contact hardening).
  18339. */
  18340. set useContactHardeningShadow(value: boolean);
  18341. protected _contactHardeningLightSizeUVRatio: number;
  18342. /**
  18343. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18344. * Using a ratio helps keeping shape stability independently of the map size.
  18345. *
  18346. * It does not account for the light projection as it was having too much
  18347. * instability during the light setup or during light position changes.
  18348. *
  18349. * Only valid if useContactHardeningShadow is true.
  18350. */
  18351. get contactHardeningLightSizeUVRatio(): number;
  18352. /**
  18353. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18354. * Using a ratio helps keeping shape stability independently of the map size.
  18355. *
  18356. * It does not account for the light projection as it was having too much
  18357. * instability during the light setup or during light position changes.
  18358. *
  18359. * Only valid if useContactHardeningShadow is true.
  18360. */
  18361. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18362. protected _darkness: number;
  18363. /** Gets or sets the actual darkness of a shadow */
  18364. get darkness(): number;
  18365. set darkness(value: number);
  18366. /**
  18367. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18368. * 0 means strongest and 1 would means no shadow.
  18369. * @returns the darkness.
  18370. */
  18371. getDarkness(): number;
  18372. /**
  18373. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18374. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18375. * @returns the shadow generator allowing fluent coding.
  18376. */
  18377. setDarkness(darkness: number): ShadowGenerator;
  18378. protected _transparencyShadow: boolean;
  18379. /** Gets or sets the ability to have transparent shadow */
  18380. get transparencyShadow(): boolean;
  18381. set transparencyShadow(value: boolean);
  18382. /**
  18383. * Sets the ability to have transparent shadow (boolean).
  18384. * @param transparent True if transparent else False
  18385. * @returns the shadow generator allowing fluent coding
  18386. */
  18387. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18388. /**
  18389. * Enables or disables shadows with varying strength based on the transparency
  18390. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18391. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18392. * mesh.visibility * alphaTexture.a
  18393. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18394. */
  18395. enableSoftTransparentShadow: boolean;
  18396. protected _shadowMap: Nullable<RenderTargetTexture>;
  18397. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18398. /**
  18399. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18400. * @returns The render target texture if present otherwise, null
  18401. */
  18402. getShadowMap(): Nullable<RenderTargetTexture>;
  18403. /**
  18404. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18405. * @returns The render target texture if the shadow map is present otherwise, null
  18406. */
  18407. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18408. /**
  18409. * Gets the class name of that object
  18410. * @returns "ShadowGenerator"
  18411. */
  18412. getClassName(): string;
  18413. /**
  18414. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18415. * @param mesh Mesh to add
  18416. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18417. * @returns the Shadow Generator itself
  18418. */
  18419. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18420. /**
  18421. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18422. * @param mesh Mesh to remove
  18423. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18424. * @returns the Shadow Generator itself
  18425. */
  18426. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18427. /**
  18428. * Controls the extent to which the shadows fade out at the edge of the frustum
  18429. */
  18430. frustumEdgeFalloff: number;
  18431. protected _light: IShadowLight;
  18432. /**
  18433. * Returns the associated light object.
  18434. * @returns the light generating the shadow
  18435. */
  18436. getLight(): IShadowLight;
  18437. /**
  18438. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18439. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18440. * It might on the other hand introduce peter panning.
  18441. */
  18442. forceBackFacesOnly: boolean;
  18443. protected _scene: Scene;
  18444. protected _lightDirection: Vector3;
  18445. protected _effect: Effect;
  18446. protected _viewMatrix: Matrix;
  18447. protected _projectionMatrix: Matrix;
  18448. protected _transformMatrix: Matrix;
  18449. protected _cachedPosition: Vector3;
  18450. protected _cachedDirection: Vector3;
  18451. protected _cachedDefines: string;
  18452. protected _currentRenderID: number;
  18453. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18454. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18455. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18456. protected _blurPostProcesses: PostProcess[];
  18457. protected _mapSize: number;
  18458. protected _currentFaceIndex: number;
  18459. protected _currentFaceIndexCache: number;
  18460. protected _textureType: number;
  18461. protected _defaultTextureMatrix: Matrix;
  18462. protected _storedUniqueId: Nullable<number>;
  18463. /** @hidden */
  18464. static _SceneComponentInitialization: (scene: Scene) => void;
  18465. /**
  18466. * Creates a ShadowGenerator object.
  18467. * A ShadowGenerator is the required tool to use the shadows.
  18468. * Each light casting shadows needs to use its own ShadowGenerator.
  18469. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18470. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18471. * @param light The light object generating the shadows.
  18472. * @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.
  18473. */
  18474. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18475. protected _initializeGenerator(): void;
  18476. protected _createTargetRenderTexture(): void;
  18477. protected _initializeShadowMap(): void;
  18478. protected _initializeBlurRTTAndPostProcesses(): void;
  18479. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18480. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18481. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18482. protected _applyFilterValues(): void;
  18483. /**
  18484. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18485. * @param onCompiled Callback triggered at the and of the effects compilation
  18486. * @param options Sets of optional options forcing the compilation with different modes
  18487. */
  18488. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18489. useInstances: boolean;
  18490. }>): void;
  18491. /**
  18492. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18493. * @param options Sets of optional options forcing the compilation with different modes
  18494. * @returns A promise that resolves when the compilation completes
  18495. */
  18496. forceCompilationAsync(options?: Partial<{
  18497. useInstances: boolean;
  18498. }>): Promise<void>;
  18499. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18500. private _prepareShadowDefines;
  18501. /**
  18502. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18503. * @param subMesh The submesh we want to render in the shadow map
  18504. * @param useInstances Defines wether will draw in the map using instances
  18505. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18506. * @returns true if ready otherwise, false
  18507. */
  18508. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18509. /**
  18510. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18511. * @param defines Defines of the material we want to update
  18512. * @param lightIndex Index of the light in the enabled light list of the material
  18513. */
  18514. prepareDefines(defines: any, lightIndex: number): void;
  18515. /**
  18516. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18517. * defined in the generator but impacting the effect).
  18518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18519. * @param effect The effect we are binfing the information for
  18520. */
  18521. bindShadowLight(lightIndex: string, effect: Effect): void;
  18522. /**
  18523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18524. * (eq to shadow prjection matrix * light transform matrix)
  18525. * @returns The transform matrix used to create the shadow map
  18526. */
  18527. getTransformMatrix(): Matrix;
  18528. /**
  18529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18530. * Cube and 2D textures for instance.
  18531. */
  18532. recreateShadowMap(): void;
  18533. protected _disposeBlurPostProcesses(): void;
  18534. protected _disposeRTTandPostProcesses(): void;
  18535. /**
  18536. * Disposes the ShadowGenerator.
  18537. * Returns nothing.
  18538. */
  18539. dispose(): void;
  18540. /**
  18541. * Serializes the shadow generator setup to a json object.
  18542. * @returns The serialized JSON object
  18543. */
  18544. serialize(): any;
  18545. /**
  18546. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18547. * @param parsedShadowGenerator The JSON object to parse
  18548. * @param scene The scene to create the shadow map for
  18549. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18550. * @returns The parsed shadow generator
  18551. */
  18552. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18553. }
  18554. }
  18555. declare module "babylonjs/Lights/light" {
  18556. import { Nullable } from "babylonjs/types";
  18557. import { Scene } from "babylonjs/scene";
  18558. import { Vector3 } from "babylonjs/Maths/math.vector";
  18559. import { Color3 } from "babylonjs/Maths/math.color";
  18560. import { Node } from "babylonjs/node";
  18561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18562. import { Effect } from "babylonjs/Materials/effect";
  18563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18564. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18565. /**
  18566. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18567. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18568. * 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.
  18569. */
  18570. export abstract class Light extends Node {
  18571. /**
  18572. * Falloff Default: light is falling off following the material specification:
  18573. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18574. */
  18575. static readonly FALLOFF_DEFAULT: number;
  18576. /**
  18577. * Falloff Physical: light is falling off following the inverse squared distance law.
  18578. */
  18579. static readonly FALLOFF_PHYSICAL: number;
  18580. /**
  18581. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18582. * to enhance interoperability with other engines.
  18583. */
  18584. static readonly FALLOFF_GLTF: number;
  18585. /**
  18586. * Falloff Standard: light is falling off like in the standard material
  18587. * to enhance interoperability with other materials.
  18588. */
  18589. static readonly FALLOFF_STANDARD: number;
  18590. /**
  18591. * If every light affecting the material is in this lightmapMode,
  18592. * material.lightmapTexture adds or multiplies
  18593. * (depends on material.useLightmapAsShadowmap)
  18594. * after every other light calculations.
  18595. */
  18596. static readonly LIGHTMAP_DEFAULT: number;
  18597. /**
  18598. * material.lightmapTexture as only diffuse lighting from this light
  18599. * adds only specular lighting from this light
  18600. * adds dynamic shadows
  18601. */
  18602. static readonly LIGHTMAP_SPECULAR: number;
  18603. /**
  18604. * material.lightmapTexture as only lighting
  18605. * no light calculation from this light
  18606. * only adds dynamic shadows from this light
  18607. */
  18608. static readonly LIGHTMAP_SHADOWSONLY: number;
  18609. /**
  18610. * Each light type uses the default quantity according to its type:
  18611. * point/spot lights use luminous intensity
  18612. * directional lights use illuminance
  18613. */
  18614. static readonly INTENSITYMODE_AUTOMATIC: number;
  18615. /**
  18616. * lumen (lm)
  18617. */
  18618. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18619. /**
  18620. * candela (lm/sr)
  18621. */
  18622. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18623. /**
  18624. * lux (lm/m^2)
  18625. */
  18626. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18627. /**
  18628. * nit (cd/m^2)
  18629. */
  18630. static readonly INTENSITYMODE_LUMINANCE: number;
  18631. /**
  18632. * Light type const id of the point light.
  18633. */
  18634. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18635. /**
  18636. * Light type const id of the directional light.
  18637. */
  18638. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18639. /**
  18640. * Light type const id of the spot light.
  18641. */
  18642. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18643. /**
  18644. * Light type const id of the hemispheric light.
  18645. */
  18646. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18647. /**
  18648. * Diffuse gives the basic color to an object.
  18649. */
  18650. diffuse: Color3;
  18651. /**
  18652. * Specular produces a highlight color on an object.
  18653. * Note: This is note affecting PBR materials.
  18654. */
  18655. specular: Color3;
  18656. /**
  18657. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18658. * falling off base on range or angle.
  18659. * This can be set to any values in Light.FALLOFF_x.
  18660. *
  18661. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18662. * other types of materials.
  18663. */
  18664. falloffType: number;
  18665. /**
  18666. * Strength of the light.
  18667. * Note: By default it is define in the framework own unit.
  18668. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18669. */
  18670. intensity: number;
  18671. private _range;
  18672. protected _inverseSquaredRange: number;
  18673. /**
  18674. * Defines how far from the source the light is impacting in scene units.
  18675. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18676. */
  18677. get range(): number;
  18678. /**
  18679. * Defines how far from the source the light is impacting in scene units.
  18680. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18681. */
  18682. set range(value: number);
  18683. /**
  18684. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18685. * of light.
  18686. */
  18687. private _photometricScale;
  18688. private _intensityMode;
  18689. /**
  18690. * Gets the photometric scale used to interpret the intensity.
  18691. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18692. */
  18693. get intensityMode(): number;
  18694. /**
  18695. * Sets the photometric scale used to interpret the intensity.
  18696. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18697. */
  18698. set intensityMode(value: number);
  18699. private _radius;
  18700. /**
  18701. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18702. */
  18703. get radius(): number;
  18704. /**
  18705. * sets the light radius used by PBR Materials to simulate soft area lights.
  18706. */
  18707. set radius(value: number);
  18708. private _renderPriority;
  18709. /**
  18710. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18711. * exceeding the number allowed of the materials.
  18712. */
  18713. renderPriority: number;
  18714. private _shadowEnabled;
  18715. /**
  18716. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18717. * the current shadow generator.
  18718. */
  18719. get shadowEnabled(): boolean;
  18720. /**
  18721. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18722. * the current shadow generator.
  18723. */
  18724. set shadowEnabled(value: boolean);
  18725. private _includedOnlyMeshes;
  18726. /**
  18727. * Gets the only meshes impacted by this light.
  18728. */
  18729. get includedOnlyMeshes(): AbstractMesh[];
  18730. /**
  18731. * Sets the only meshes impacted by this light.
  18732. */
  18733. set includedOnlyMeshes(value: AbstractMesh[]);
  18734. private _excludedMeshes;
  18735. /**
  18736. * Gets the meshes not impacted by this light.
  18737. */
  18738. get excludedMeshes(): AbstractMesh[];
  18739. /**
  18740. * Sets the meshes not impacted by this light.
  18741. */
  18742. set excludedMeshes(value: AbstractMesh[]);
  18743. private _excludeWithLayerMask;
  18744. /**
  18745. * Gets the layer id use to find what meshes are not impacted by the light.
  18746. * Inactive if 0
  18747. */
  18748. get excludeWithLayerMask(): number;
  18749. /**
  18750. * Sets the layer id use to find what meshes are not impacted by the light.
  18751. * Inactive if 0
  18752. */
  18753. set excludeWithLayerMask(value: number);
  18754. private _includeOnlyWithLayerMask;
  18755. /**
  18756. * Gets the layer id use to find what meshes are impacted by the light.
  18757. * Inactive if 0
  18758. */
  18759. get includeOnlyWithLayerMask(): number;
  18760. /**
  18761. * Sets the layer id use to find what meshes are impacted by the light.
  18762. * Inactive if 0
  18763. */
  18764. set includeOnlyWithLayerMask(value: number);
  18765. private _lightmapMode;
  18766. /**
  18767. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18768. */
  18769. get lightmapMode(): number;
  18770. /**
  18771. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18772. */
  18773. set lightmapMode(value: number);
  18774. /**
  18775. * Shadow generator associted to the light.
  18776. * @hidden Internal use only.
  18777. */
  18778. _shadowGenerator: Nullable<IShadowGenerator>;
  18779. /**
  18780. * @hidden Internal use only.
  18781. */
  18782. _excludedMeshesIds: string[];
  18783. /**
  18784. * @hidden Internal use only.
  18785. */
  18786. _includedOnlyMeshesIds: string[];
  18787. /**
  18788. * The current light unifom buffer.
  18789. * @hidden Internal use only.
  18790. */
  18791. _uniformBuffer: UniformBuffer;
  18792. /** @hidden */
  18793. _renderId: number;
  18794. /**
  18795. * Creates a Light object in the scene.
  18796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18797. * @param name The firendly name of the light
  18798. * @param scene The scene the light belongs too
  18799. */
  18800. constructor(name: string, scene: Scene);
  18801. protected abstract _buildUniformLayout(): void;
  18802. /**
  18803. * Sets the passed Effect "effect" with the Light information.
  18804. * @param effect The effect to update
  18805. * @param lightIndex The index of the light in the effect to update
  18806. * @returns The light
  18807. */
  18808. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18809. /**
  18810. * Sets the passed Effect "effect" with the Light textures.
  18811. * @param effect The effect to update
  18812. * @param lightIndex The index of the light in the effect to update
  18813. * @returns The light
  18814. */
  18815. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18816. /**
  18817. * Binds the lights information from the scene to the effect for the given mesh.
  18818. * @param lightIndex Light index
  18819. * @param scene The scene where the light belongs to
  18820. * @param effect The effect we are binding the data to
  18821. * @param useSpecular Defines if specular is supported
  18822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18823. */
  18824. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18825. /**
  18826. * Sets the passed Effect "effect" with the Light information.
  18827. * @param effect The effect to update
  18828. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18829. * @returns The light
  18830. */
  18831. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18832. /**
  18833. * Returns the string "Light".
  18834. * @returns the class name
  18835. */
  18836. getClassName(): string;
  18837. /** @hidden */
  18838. readonly _isLight: boolean;
  18839. /**
  18840. * Converts the light information to a readable string for debug purpose.
  18841. * @param fullDetails Supports for multiple levels of logging within scene loading
  18842. * @returns the human readable light info
  18843. */
  18844. toString(fullDetails?: boolean): string;
  18845. /** @hidden */
  18846. protected _syncParentEnabledState(): void;
  18847. /**
  18848. * Set the enabled state of this node.
  18849. * @param value - the new enabled state
  18850. */
  18851. setEnabled(value: boolean): void;
  18852. /**
  18853. * Returns the Light associated shadow generator if any.
  18854. * @return the associated shadow generator.
  18855. */
  18856. getShadowGenerator(): Nullable<IShadowGenerator>;
  18857. /**
  18858. * Returns a Vector3, the absolute light position in the World.
  18859. * @returns the world space position of the light
  18860. */
  18861. getAbsolutePosition(): Vector3;
  18862. /**
  18863. * Specifies if the light will affect the passed mesh.
  18864. * @param mesh The mesh to test against the light
  18865. * @return true the mesh is affected otherwise, false.
  18866. */
  18867. canAffectMesh(mesh: AbstractMesh): boolean;
  18868. /**
  18869. * Sort function to order lights for rendering.
  18870. * @param a First Light object to compare to second.
  18871. * @param b Second Light object to compare first.
  18872. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18873. */
  18874. static CompareLightsPriority(a: Light, b: Light): number;
  18875. /**
  18876. * Releases resources associated with this node.
  18877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18879. */
  18880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18881. /**
  18882. * Returns the light type ID (integer).
  18883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18884. */
  18885. getTypeID(): number;
  18886. /**
  18887. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18888. * @returns the scaled intensity in intensity mode unit
  18889. */
  18890. getScaledIntensity(): number;
  18891. /**
  18892. * Returns a new Light object, named "name", from the current one.
  18893. * @param name The name of the cloned light
  18894. * @param newParent The parent of this light, if it has one
  18895. * @returns the new created light
  18896. */
  18897. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18898. /**
  18899. * Serializes the current light into a Serialization object.
  18900. * @returns the serialized object.
  18901. */
  18902. serialize(): any;
  18903. /**
  18904. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18905. * This new light is named "name" and added to the passed scene.
  18906. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18907. * @param name The friendly name of the light
  18908. * @param scene The scene the new light will belong to
  18909. * @returns the constructor function
  18910. */
  18911. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18912. /**
  18913. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18914. * @param parsedLight The JSON representation of the light
  18915. * @param scene The scene to create the parsed light in
  18916. * @returns the created light after parsing
  18917. */
  18918. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18919. private _hookArrayForExcluded;
  18920. private _hookArrayForIncludedOnly;
  18921. private _resyncMeshes;
  18922. /**
  18923. * Forces the meshes to update their light related information in their rendering used effects
  18924. * @hidden Internal Use Only
  18925. */
  18926. _markMeshesAsLightDirty(): void;
  18927. /**
  18928. * Recomputes the cached photometric scale if needed.
  18929. */
  18930. private _computePhotometricScale;
  18931. /**
  18932. * Returns the Photometric Scale according to the light type and intensity mode.
  18933. */
  18934. private _getPhotometricScale;
  18935. /**
  18936. * Reorder the light in the scene according to their defined priority.
  18937. * @hidden Internal Use Only
  18938. */
  18939. _reorderLightsInScene(): void;
  18940. /**
  18941. * Prepares the list of defines specific to the light type.
  18942. * @param defines the list of defines
  18943. * @param lightIndex defines the index of the light for the effect
  18944. */
  18945. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18946. }
  18947. }
  18948. declare module "babylonjs/Cameras/targetCamera" {
  18949. import { Nullable } from "babylonjs/types";
  18950. import { Camera } from "babylonjs/Cameras/camera";
  18951. import { Scene } from "babylonjs/scene";
  18952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18953. /**
  18954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18955. * This is the base of the follow, arc rotate cameras and Free camera
  18956. * @see https://doc.babylonjs.com/features/cameras
  18957. */
  18958. export class TargetCamera extends Camera {
  18959. private static _RigCamTransformMatrix;
  18960. private static _TargetTransformMatrix;
  18961. private static _TargetFocalPoint;
  18962. private _tmpUpVector;
  18963. private _tmpTargetVector;
  18964. /**
  18965. * Define the current direction the camera is moving to
  18966. */
  18967. cameraDirection: Vector3;
  18968. /**
  18969. * Define the current rotation the camera is rotating to
  18970. */
  18971. cameraRotation: Vector2;
  18972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18973. ignoreParentScaling: boolean;
  18974. /**
  18975. * When set, the up vector of the camera will be updated by the rotation of the camera
  18976. */
  18977. updateUpVectorFromRotation: boolean;
  18978. private _tmpQuaternion;
  18979. /**
  18980. * Define the current rotation of the camera
  18981. */
  18982. rotation: Vector3;
  18983. /**
  18984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18985. */
  18986. rotationQuaternion: Quaternion;
  18987. /**
  18988. * Define the current speed of the camera
  18989. */
  18990. speed: number;
  18991. /**
  18992. * Add constraint to the camera to prevent it to move freely in all directions and
  18993. * around all axis.
  18994. */
  18995. noRotationConstraint: boolean;
  18996. /**
  18997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18998. * panning
  18999. */
  19000. invertRotation: boolean;
  19001. /**
  19002. * Speed multiplier for inverse camera panning
  19003. */
  19004. inverseRotationSpeed: number;
  19005. /**
  19006. * Define the current target of the camera as an object or a position.
  19007. */
  19008. lockedTarget: any;
  19009. /** @hidden */
  19010. _currentTarget: Vector3;
  19011. /** @hidden */
  19012. _initialFocalDistance: number;
  19013. /** @hidden */
  19014. _viewMatrix: Matrix;
  19015. /** @hidden */
  19016. _camMatrix: Matrix;
  19017. /** @hidden */
  19018. _cameraTransformMatrix: Matrix;
  19019. /** @hidden */
  19020. _cameraRotationMatrix: Matrix;
  19021. /** @hidden */
  19022. _referencePoint: Vector3;
  19023. /** @hidden */
  19024. _transformedReferencePoint: Vector3;
  19025. /** @hidden */
  19026. _reset: () => void;
  19027. private _defaultUp;
  19028. /**
  19029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19030. * This is the base of the follow, arc rotate cameras and Free camera
  19031. * @see https://doc.babylonjs.com/features/cameras
  19032. * @param name Defines the name of the camera in the scene
  19033. * @param position Defines the start position of the camera in the scene
  19034. * @param scene Defines the scene the camera belongs to
  19035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19036. */
  19037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19038. /**
  19039. * Gets the position in front of the camera at a given distance.
  19040. * @param distance The distance from the camera we want the position to be
  19041. * @returns the position
  19042. */
  19043. getFrontPosition(distance: number): Vector3;
  19044. /** @hidden */
  19045. _getLockedTargetPosition(): Nullable<Vector3>;
  19046. private _storedPosition;
  19047. private _storedRotation;
  19048. private _storedRotationQuaternion;
  19049. /**
  19050. * Store current camera state of the camera (fov, position, rotation, etc..)
  19051. * @returns the camera
  19052. */
  19053. storeState(): Camera;
  19054. /**
  19055. * Restored camera state. You must call storeState() first
  19056. * @returns whether it was successful or not
  19057. * @hidden
  19058. */
  19059. _restoreStateValues(): boolean;
  19060. /** @hidden */
  19061. _initCache(): void;
  19062. /** @hidden */
  19063. _updateCache(ignoreParentClass?: boolean): void;
  19064. /** @hidden */
  19065. _isSynchronizedViewMatrix(): boolean;
  19066. /** @hidden */
  19067. _computeLocalCameraSpeed(): number;
  19068. /**
  19069. * Defines the target the camera should look at.
  19070. * @param target Defines the new target as a Vector or a mesh
  19071. */
  19072. setTarget(target: Vector3): void;
  19073. /**
  19074. * Defines the target point of the camera.
  19075. * The camera looks towards it form the radius distance.
  19076. */
  19077. get target(): Vector3;
  19078. set target(value: Vector3);
  19079. /**
  19080. * Return the current target position of the camera. This value is expressed in local space.
  19081. * @returns the target position
  19082. */
  19083. getTarget(): Vector3;
  19084. /** @hidden */
  19085. _decideIfNeedsToMove(): boolean;
  19086. /** @hidden */
  19087. _updatePosition(): void;
  19088. /** @hidden */
  19089. _checkInputs(): void;
  19090. protected _updateCameraRotationMatrix(): void;
  19091. /**
  19092. * 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)
  19093. * @returns the current camera
  19094. */
  19095. private _rotateUpVectorWithCameraRotationMatrix;
  19096. private _cachedRotationZ;
  19097. private _cachedQuaternionRotationZ;
  19098. /** @hidden */
  19099. _getViewMatrix(): Matrix;
  19100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19101. /**
  19102. * @hidden
  19103. */
  19104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19105. /**
  19106. * @hidden
  19107. */
  19108. _updateRigCameras(): void;
  19109. private _getRigCamPositionAndTarget;
  19110. /**
  19111. * Gets the current object class name.
  19112. * @return the class name
  19113. */
  19114. getClassName(): string;
  19115. }
  19116. }
  19117. declare module "babylonjs/Events/keyboardEvents" {
  19118. /**
  19119. * Gather the list of keyboard event types as constants.
  19120. */
  19121. export class KeyboardEventTypes {
  19122. /**
  19123. * The keydown event is fired when a key becomes active (pressed).
  19124. */
  19125. static readonly KEYDOWN: number;
  19126. /**
  19127. * The keyup event is fired when a key has been released.
  19128. */
  19129. static readonly KEYUP: number;
  19130. }
  19131. /**
  19132. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19133. */
  19134. export class KeyboardInfo {
  19135. /**
  19136. * Defines the type of event (KeyboardEventTypes)
  19137. */
  19138. type: number;
  19139. /**
  19140. * Defines the related dom event
  19141. */
  19142. event: KeyboardEvent;
  19143. /**
  19144. * Instantiates a new keyboard info.
  19145. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19146. * @param type Defines the type of event (KeyboardEventTypes)
  19147. * @param event Defines the related dom event
  19148. */
  19149. constructor(
  19150. /**
  19151. * Defines the type of event (KeyboardEventTypes)
  19152. */
  19153. type: number,
  19154. /**
  19155. * Defines the related dom event
  19156. */
  19157. event: KeyboardEvent);
  19158. }
  19159. /**
  19160. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19161. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19162. */
  19163. export class KeyboardInfoPre extends KeyboardInfo {
  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. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19174. */
  19175. skipOnPointerObservable: boolean;
  19176. /**
  19177. * Instantiates a new keyboard pre info.
  19178. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19179. * @param type Defines the type of event (KeyboardEventTypes)
  19180. * @param event Defines the related dom event
  19181. */
  19182. constructor(
  19183. /**
  19184. * Defines the type of event (KeyboardEventTypes)
  19185. */
  19186. type: number,
  19187. /**
  19188. * Defines the related dom event
  19189. */
  19190. event: KeyboardEvent);
  19191. }
  19192. }
  19193. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19194. import { Nullable } from "babylonjs/types";
  19195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19197. /**
  19198. * Manage the keyboard inputs to control the movement of a free camera.
  19199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19200. */
  19201. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19202. /**
  19203. * Defines the camera the input is attached to.
  19204. */
  19205. camera: FreeCamera;
  19206. /**
  19207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19208. */
  19209. keysUp: number[];
  19210. /**
  19211. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19212. */
  19213. keysUpward: number[];
  19214. /**
  19215. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19216. */
  19217. keysDown: number[];
  19218. /**
  19219. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19220. */
  19221. keysDownward: number[];
  19222. /**
  19223. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19224. */
  19225. keysLeft: number[];
  19226. /**
  19227. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19228. */
  19229. keysRight: number[];
  19230. private _keys;
  19231. private _onCanvasBlurObserver;
  19232. private _onKeyboardObserver;
  19233. private _engine;
  19234. private _scene;
  19235. /**
  19236. * Attach the input controls to a specific dom element to get the input from.
  19237. * @param element Defines the element the controls should be listened from
  19238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19239. */
  19240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19241. /**
  19242. * Detach the current controls from the specified dom element.
  19243. * @param element Defines the element to stop listening the inputs from
  19244. */
  19245. detachControl(element: Nullable<HTMLElement>): void;
  19246. /**
  19247. * Update the current camera state depending on the inputs that have been used this frame.
  19248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19249. */
  19250. checkInputs(): void;
  19251. /**
  19252. * Gets the class name of the current intput.
  19253. * @returns the class name
  19254. */
  19255. getClassName(): string;
  19256. /** @hidden */
  19257. _onLostFocus(): void;
  19258. /**
  19259. * Get the friendly name associated with the input class.
  19260. * @returns the input friendly name
  19261. */
  19262. getSimpleName(): string;
  19263. }
  19264. }
  19265. declare module "babylonjs/Events/pointerEvents" {
  19266. import { Nullable } from "babylonjs/types";
  19267. import { Vector2 } from "babylonjs/Maths/math.vector";
  19268. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19269. import { Ray } from "babylonjs/Culling/ray";
  19270. /**
  19271. * Gather the list of pointer event types as constants.
  19272. */
  19273. export class PointerEventTypes {
  19274. /**
  19275. * 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.
  19276. */
  19277. static readonly POINTERDOWN: number;
  19278. /**
  19279. * The pointerup event is fired when a pointer is no longer active.
  19280. */
  19281. static readonly POINTERUP: number;
  19282. /**
  19283. * The pointermove event is fired when a pointer changes coordinates.
  19284. */
  19285. static readonly POINTERMOVE: number;
  19286. /**
  19287. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19288. */
  19289. static readonly POINTERWHEEL: number;
  19290. /**
  19291. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19292. */
  19293. static readonly POINTERPICK: number;
  19294. /**
  19295. * The pointertap event is fired when a the object has been touched and released without drag.
  19296. */
  19297. static readonly POINTERTAP: number;
  19298. /**
  19299. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19300. */
  19301. static readonly POINTERDOUBLETAP: number;
  19302. }
  19303. /**
  19304. * Base class of pointer info types.
  19305. */
  19306. export class PointerInfoBase {
  19307. /**
  19308. * Defines the type of event (PointerEventTypes)
  19309. */
  19310. type: number;
  19311. /**
  19312. * Defines the related dom event
  19313. */
  19314. event: PointerEvent | MouseWheelEvent;
  19315. /**
  19316. * Instantiates the base class of pointers info.
  19317. * @param type Defines the type of event (PointerEventTypes)
  19318. * @param event Defines the related dom event
  19319. */
  19320. constructor(
  19321. /**
  19322. * Defines the type of event (PointerEventTypes)
  19323. */
  19324. type: number,
  19325. /**
  19326. * Defines the related dom event
  19327. */
  19328. event: PointerEvent | MouseWheelEvent);
  19329. }
  19330. /**
  19331. * This class is used to store pointer related info for the onPrePointerObservable event.
  19332. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19333. */
  19334. export class PointerInfoPre extends PointerInfoBase {
  19335. /**
  19336. * Ray from a pointer if availible (eg. 6dof controller)
  19337. */
  19338. ray: Nullable<Ray>;
  19339. /**
  19340. * Defines the local position of the pointer on the canvas.
  19341. */
  19342. localPosition: Vector2;
  19343. /**
  19344. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19345. */
  19346. skipOnPointerObservable: boolean;
  19347. /**
  19348. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19349. * @param type Defines the type of event (PointerEventTypes)
  19350. * @param event Defines the related dom event
  19351. * @param localX Defines the local x coordinates of the pointer when the event occured
  19352. * @param localY Defines the local y coordinates of the pointer when the event occured
  19353. */
  19354. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19355. }
  19356. /**
  19357. * This type contains all the data related to a pointer event in Babylon.js.
  19358. * 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.
  19359. */
  19360. export class PointerInfo extends PointerInfoBase {
  19361. /**
  19362. * Defines the picking info associated to the info (if any)\
  19363. */
  19364. pickInfo: Nullable<PickingInfo>;
  19365. /**
  19366. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19367. * @param type Defines the type of event (PointerEventTypes)
  19368. * @param event Defines the related dom event
  19369. * @param pickInfo Defines the picking info associated to the info (if any)\
  19370. */
  19371. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19372. /**
  19373. * Defines the picking info associated to the info (if any)\
  19374. */
  19375. pickInfo: Nullable<PickingInfo>);
  19376. }
  19377. /**
  19378. * Data relating to a touch event on the screen.
  19379. */
  19380. export interface PointerTouch {
  19381. /**
  19382. * X coordinate of touch.
  19383. */
  19384. x: number;
  19385. /**
  19386. * Y coordinate of touch.
  19387. */
  19388. y: number;
  19389. /**
  19390. * Id of touch. Unique for each finger.
  19391. */
  19392. pointerId: number;
  19393. /**
  19394. * Event type passed from DOM.
  19395. */
  19396. type: any;
  19397. }
  19398. }
  19399. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19400. import { Observable } from "babylonjs/Misc/observable";
  19401. import { Nullable } from "babylonjs/types";
  19402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19404. /**
  19405. * Manage the mouse inputs to control the movement of a free camera.
  19406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19407. */
  19408. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19409. /**
  19410. * Define if touch is enabled in the mouse input
  19411. */
  19412. touchEnabled: boolean;
  19413. /**
  19414. * Defines the camera the input is attached to.
  19415. */
  19416. camera: FreeCamera;
  19417. /**
  19418. * Defines the buttons associated with the input to handle camera move.
  19419. */
  19420. buttons: number[];
  19421. /**
  19422. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19423. */
  19424. angularSensibility: number;
  19425. private _pointerInput;
  19426. private _onMouseMove;
  19427. private _observer;
  19428. private previousPosition;
  19429. /**
  19430. * Observable for when a pointer move event occurs containing the move offset
  19431. */
  19432. onPointerMovedObservable: Observable<{
  19433. offsetX: number;
  19434. offsetY: number;
  19435. }>;
  19436. /**
  19437. * @hidden
  19438. * If the camera should be rotated automatically based on pointer movement
  19439. */
  19440. _allowCameraRotation: boolean;
  19441. /**
  19442. * Manage the mouse inputs to control the movement of a free camera.
  19443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19444. * @param touchEnabled Defines if touch is enabled or not
  19445. */
  19446. constructor(
  19447. /**
  19448. * Define if touch is enabled in the mouse input
  19449. */
  19450. touchEnabled?: boolean);
  19451. /**
  19452. * Attach the input controls to a specific dom element to get the input from.
  19453. * @param element Defines the element the controls should be listened from
  19454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19455. */
  19456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19457. /**
  19458. * Called on JS contextmenu event.
  19459. * Override this method to provide functionality.
  19460. */
  19461. protected onContextMenu(evt: PointerEvent): void;
  19462. /**
  19463. * Detach the current controls from the specified dom element.
  19464. * @param element Defines the element to stop listening the inputs from
  19465. */
  19466. detachControl(element: Nullable<HTMLElement>): void;
  19467. /**
  19468. * Gets the class name of the current intput.
  19469. * @returns the class name
  19470. */
  19471. getClassName(): string;
  19472. /**
  19473. * Get the friendly name associated with the input class.
  19474. * @returns the input friendly name
  19475. */
  19476. getSimpleName(): string;
  19477. }
  19478. }
  19479. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19480. import { Nullable } from "babylonjs/types";
  19481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19483. /**
  19484. * Manage the touch inputs to control the movement of a free camera.
  19485. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19486. */
  19487. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19488. /**
  19489. * Define if mouse events can be treated as touch events
  19490. */
  19491. allowMouse: boolean;
  19492. /**
  19493. * Defines the camera the input is attached to.
  19494. */
  19495. camera: FreeCamera;
  19496. /**
  19497. * Defines the touch sensibility for rotation.
  19498. * The higher the faster.
  19499. */
  19500. touchAngularSensibility: number;
  19501. /**
  19502. * Defines the touch sensibility for move.
  19503. * The higher the faster.
  19504. */
  19505. touchMoveSensibility: number;
  19506. private _offsetX;
  19507. private _offsetY;
  19508. private _pointerPressed;
  19509. private _pointerInput;
  19510. private _observer;
  19511. private _onLostFocus;
  19512. /**
  19513. * Manage the touch inputs to control the movement of a free camera.
  19514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19515. * @param allowMouse Defines if mouse events can be treated as touch events
  19516. */
  19517. constructor(
  19518. /**
  19519. * Define if mouse events can be treated as touch events
  19520. */
  19521. allowMouse?: boolean);
  19522. /**
  19523. * Attach the input controls to a specific dom element to get the input from.
  19524. * @param element Defines the element the controls should be listened from
  19525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19526. */
  19527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19528. /**
  19529. * Detach the current controls from the specified dom element.
  19530. * @param element Defines the element to stop listening the inputs from
  19531. */
  19532. detachControl(element: Nullable<HTMLElement>): void;
  19533. /**
  19534. * Update the current camera state depending on the inputs that have been used this frame.
  19535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19536. */
  19537. checkInputs(): void;
  19538. /**
  19539. * Gets the class name of the current intput.
  19540. * @returns the class name
  19541. */
  19542. getClassName(): string;
  19543. /**
  19544. * Get the friendly name associated with the input class.
  19545. * @returns the input friendly name
  19546. */
  19547. getSimpleName(): string;
  19548. }
  19549. }
  19550. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19552. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19553. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19554. import { Nullable } from "babylonjs/types";
  19555. /**
  19556. * Default Inputs manager for the FreeCamera.
  19557. * It groups all the default supported inputs for ease of use.
  19558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19559. */
  19560. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19561. /**
  19562. * @hidden
  19563. */
  19564. _mouseInput: Nullable<FreeCameraMouseInput>;
  19565. /**
  19566. * Instantiates a new FreeCameraInputsManager.
  19567. * @param camera Defines the camera the inputs belong to
  19568. */
  19569. constructor(camera: FreeCamera);
  19570. /**
  19571. * Add keyboard input support to the input manager.
  19572. * @returns the current input manager
  19573. */
  19574. addKeyboard(): FreeCameraInputsManager;
  19575. /**
  19576. * Add mouse input support to the input manager.
  19577. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19578. * @returns the current input manager
  19579. */
  19580. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19581. /**
  19582. * Removes the mouse input support from the manager
  19583. * @returns the current input manager
  19584. */
  19585. removeMouse(): FreeCameraInputsManager;
  19586. /**
  19587. * Add touch input support to the input manager.
  19588. * @returns the current input manager
  19589. */
  19590. addTouch(): FreeCameraInputsManager;
  19591. /**
  19592. * Remove all attached input methods from a camera
  19593. */
  19594. clear(): void;
  19595. }
  19596. }
  19597. declare module "babylonjs/Cameras/freeCamera" {
  19598. import { Vector3 } from "babylonjs/Maths/math.vector";
  19599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19600. import { Scene } from "babylonjs/scene";
  19601. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19602. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19603. /**
  19604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19605. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19606. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19607. */
  19608. export class FreeCamera extends TargetCamera {
  19609. /**
  19610. * Define the collision ellipsoid of the camera.
  19611. * This is helpful to simulate a camera body like the player body around the camera
  19612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19613. */
  19614. ellipsoid: Vector3;
  19615. /**
  19616. * Define an offset for the position of the ellipsoid around the camera.
  19617. * This can be helpful to determine the center of the body near the gravity center of the body
  19618. * instead of its head.
  19619. */
  19620. ellipsoidOffset: Vector3;
  19621. /**
  19622. * Enable or disable collisions of the camera with the rest of the scene objects.
  19623. */
  19624. checkCollisions: boolean;
  19625. /**
  19626. * Enable or disable gravity on the camera.
  19627. */
  19628. applyGravity: boolean;
  19629. /**
  19630. * Define the input manager associated to the camera.
  19631. */
  19632. inputs: FreeCameraInputsManager;
  19633. /**
  19634. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19635. * Higher values reduce sensitivity.
  19636. */
  19637. get angularSensibility(): number;
  19638. /**
  19639. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19640. * Higher values reduce sensitivity.
  19641. */
  19642. set angularSensibility(value: number);
  19643. /**
  19644. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19645. */
  19646. get keysUp(): number[];
  19647. set keysUp(value: number[]);
  19648. /**
  19649. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19650. */
  19651. get keysUpward(): number[];
  19652. set keysUpward(value: number[]);
  19653. /**
  19654. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19655. */
  19656. get keysDown(): number[];
  19657. set keysDown(value: number[]);
  19658. /**
  19659. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19660. */
  19661. get keysDownward(): number[];
  19662. set keysDownward(value: number[]);
  19663. /**
  19664. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19665. */
  19666. get keysLeft(): number[];
  19667. set keysLeft(value: number[]);
  19668. /**
  19669. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19670. */
  19671. get keysRight(): number[];
  19672. set keysRight(value: number[]);
  19673. /**
  19674. * Event raised when the camera collide with a mesh in the scene.
  19675. */
  19676. onCollide: (collidedMesh: AbstractMesh) => void;
  19677. private _collider;
  19678. private _needMoveForGravity;
  19679. private _oldPosition;
  19680. private _diffPosition;
  19681. private _newPosition;
  19682. /** @hidden */
  19683. _localDirection: Vector3;
  19684. /** @hidden */
  19685. _transformedDirection: Vector3;
  19686. /**
  19687. * Instantiates a Free Camera.
  19688. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19689. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19690. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19691. * @param name Define the name of the camera in the scene
  19692. * @param position Define the start position of the camera in the scene
  19693. * @param scene Define the scene the camera belongs to
  19694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19695. */
  19696. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19697. /**
  19698. * Attached controls to the current camera.
  19699. * @param element Defines the element the controls should be listened from
  19700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19701. */
  19702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19703. /**
  19704. * Detach the current controls from the camera.
  19705. * The camera will stop reacting to inputs.
  19706. * @param element Defines the element to stop listening the inputs from
  19707. */
  19708. detachControl(element: HTMLElement): void;
  19709. private _collisionMask;
  19710. /**
  19711. * Define a collision mask to limit the list of object the camera can collide with
  19712. */
  19713. get collisionMask(): number;
  19714. set collisionMask(mask: number);
  19715. /** @hidden */
  19716. _collideWithWorld(displacement: Vector3): void;
  19717. private _onCollisionPositionChange;
  19718. /** @hidden */
  19719. _checkInputs(): void;
  19720. /** @hidden */
  19721. _decideIfNeedsToMove(): boolean;
  19722. /** @hidden */
  19723. _updatePosition(): void;
  19724. /**
  19725. * Destroy the camera and release the current resources hold by it.
  19726. */
  19727. dispose(): void;
  19728. /**
  19729. * Gets the current object class name.
  19730. * @return the class name
  19731. */
  19732. getClassName(): string;
  19733. }
  19734. }
  19735. declare module "babylonjs/Gamepads/gamepad" {
  19736. import { Observable } from "babylonjs/Misc/observable";
  19737. /**
  19738. * Represents a gamepad control stick position
  19739. */
  19740. export class StickValues {
  19741. /**
  19742. * The x component of the control stick
  19743. */
  19744. x: number;
  19745. /**
  19746. * The y component of the control stick
  19747. */
  19748. y: number;
  19749. /**
  19750. * Initializes the gamepad x and y control stick values
  19751. * @param x The x component of the gamepad control stick value
  19752. * @param y The y component of the gamepad control stick value
  19753. */
  19754. constructor(
  19755. /**
  19756. * The x component of the control stick
  19757. */
  19758. x: number,
  19759. /**
  19760. * The y component of the control stick
  19761. */
  19762. y: number);
  19763. }
  19764. /**
  19765. * An interface which manages callbacks for gamepad button changes
  19766. */
  19767. export interface GamepadButtonChanges {
  19768. /**
  19769. * Called when a gamepad has been changed
  19770. */
  19771. changed: boolean;
  19772. /**
  19773. * Called when a gamepad press event has been triggered
  19774. */
  19775. pressChanged: boolean;
  19776. /**
  19777. * Called when a touch event has been triggered
  19778. */
  19779. touchChanged: boolean;
  19780. /**
  19781. * Called when a value has changed
  19782. */
  19783. valueChanged: boolean;
  19784. }
  19785. /**
  19786. * Represents a gamepad
  19787. */
  19788. export class Gamepad {
  19789. /**
  19790. * The id of the gamepad
  19791. */
  19792. id: string;
  19793. /**
  19794. * The index of the gamepad
  19795. */
  19796. index: number;
  19797. /**
  19798. * The browser gamepad
  19799. */
  19800. browserGamepad: any;
  19801. /**
  19802. * Specifies what type of gamepad this represents
  19803. */
  19804. type: number;
  19805. private _leftStick;
  19806. private _rightStick;
  19807. /** @hidden */
  19808. _isConnected: boolean;
  19809. private _leftStickAxisX;
  19810. private _leftStickAxisY;
  19811. private _rightStickAxisX;
  19812. private _rightStickAxisY;
  19813. /**
  19814. * Triggered when the left control stick has been changed
  19815. */
  19816. private _onleftstickchanged;
  19817. /**
  19818. * Triggered when the right control stick has been changed
  19819. */
  19820. private _onrightstickchanged;
  19821. /**
  19822. * Represents a gamepad controller
  19823. */
  19824. static GAMEPAD: number;
  19825. /**
  19826. * Represents a generic controller
  19827. */
  19828. static GENERIC: number;
  19829. /**
  19830. * Represents an XBox controller
  19831. */
  19832. static XBOX: number;
  19833. /**
  19834. * Represents a pose-enabled controller
  19835. */
  19836. static POSE_ENABLED: number;
  19837. /**
  19838. * Represents an Dual Shock controller
  19839. */
  19840. static DUALSHOCK: number;
  19841. /**
  19842. * Specifies whether the left control stick should be Y-inverted
  19843. */
  19844. protected _invertLeftStickY: boolean;
  19845. /**
  19846. * Specifies if the gamepad has been connected
  19847. */
  19848. get isConnected(): boolean;
  19849. /**
  19850. * Initializes the gamepad
  19851. * @param id The id of the gamepad
  19852. * @param index The index of the gamepad
  19853. * @param browserGamepad The browser gamepad
  19854. * @param leftStickX The x component of the left joystick
  19855. * @param leftStickY The y component of the left joystick
  19856. * @param rightStickX The x component of the right joystick
  19857. * @param rightStickY The y component of the right joystick
  19858. */
  19859. constructor(
  19860. /**
  19861. * The id of the gamepad
  19862. */
  19863. id: string,
  19864. /**
  19865. * The index of the gamepad
  19866. */
  19867. index: number,
  19868. /**
  19869. * The browser gamepad
  19870. */
  19871. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19872. /**
  19873. * Callback triggered when the left joystick has changed
  19874. * @param callback
  19875. */
  19876. onleftstickchanged(callback: (values: StickValues) => void): void;
  19877. /**
  19878. * Callback triggered when the right joystick has changed
  19879. * @param callback
  19880. */
  19881. onrightstickchanged(callback: (values: StickValues) => void): void;
  19882. /**
  19883. * Gets the left joystick
  19884. */
  19885. get leftStick(): StickValues;
  19886. /**
  19887. * Sets the left joystick values
  19888. */
  19889. set leftStick(newValues: StickValues);
  19890. /**
  19891. * Gets the right joystick
  19892. */
  19893. get rightStick(): StickValues;
  19894. /**
  19895. * Sets the right joystick value
  19896. */
  19897. set rightStick(newValues: StickValues);
  19898. /**
  19899. * Updates the gamepad joystick positions
  19900. */
  19901. update(): void;
  19902. /**
  19903. * Disposes the gamepad
  19904. */
  19905. dispose(): void;
  19906. }
  19907. /**
  19908. * Represents a generic gamepad
  19909. */
  19910. export class GenericPad extends Gamepad {
  19911. private _buttons;
  19912. private _onbuttondown;
  19913. private _onbuttonup;
  19914. /**
  19915. * Observable triggered when a button has been pressed
  19916. */
  19917. onButtonDownObservable: Observable<number>;
  19918. /**
  19919. * Observable triggered when a button has been released
  19920. */
  19921. onButtonUpObservable: Observable<number>;
  19922. /**
  19923. * Callback triggered when a button has been pressed
  19924. * @param callback Called when a button has been pressed
  19925. */
  19926. onbuttondown(callback: (buttonPressed: number) => void): void;
  19927. /**
  19928. * Callback triggered when a button has been released
  19929. * @param callback Called when a button has been released
  19930. */
  19931. onbuttonup(callback: (buttonReleased: number) => void): void;
  19932. /**
  19933. * Initializes the generic gamepad
  19934. * @param id The id of the generic gamepad
  19935. * @param index The index of the generic gamepad
  19936. * @param browserGamepad The browser gamepad
  19937. */
  19938. constructor(id: string, index: number, browserGamepad: any);
  19939. private _setButtonValue;
  19940. /**
  19941. * Updates the generic gamepad
  19942. */
  19943. update(): void;
  19944. /**
  19945. * Disposes the generic gamepad
  19946. */
  19947. dispose(): void;
  19948. }
  19949. }
  19950. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19951. import { Observable } from "babylonjs/Misc/observable";
  19952. import { Nullable } from "babylonjs/types";
  19953. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19954. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19956. import { Ray } from "babylonjs/Culling/ray";
  19957. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19958. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19959. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19960. /**
  19961. * Defines the types of pose enabled controllers that are supported
  19962. */
  19963. export enum PoseEnabledControllerType {
  19964. /**
  19965. * HTC Vive
  19966. */
  19967. VIVE = 0,
  19968. /**
  19969. * Oculus Rift
  19970. */
  19971. OCULUS = 1,
  19972. /**
  19973. * Windows mixed reality
  19974. */
  19975. WINDOWS = 2,
  19976. /**
  19977. * Samsung gear VR
  19978. */
  19979. GEAR_VR = 3,
  19980. /**
  19981. * Google Daydream
  19982. */
  19983. DAYDREAM = 4,
  19984. /**
  19985. * Generic
  19986. */
  19987. GENERIC = 5
  19988. }
  19989. /**
  19990. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19991. */
  19992. export interface MutableGamepadButton {
  19993. /**
  19994. * Value of the button/trigger
  19995. */
  19996. value: number;
  19997. /**
  19998. * If the button/trigger is currently touched
  19999. */
  20000. touched: boolean;
  20001. /**
  20002. * If the button/trigger is currently pressed
  20003. */
  20004. pressed: boolean;
  20005. }
  20006. /**
  20007. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20008. * @hidden
  20009. */
  20010. export interface ExtendedGamepadButton extends GamepadButton {
  20011. /**
  20012. * If the button/trigger is currently pressed
  20013. */
  20014. readonly pressed: boolean;
  20015. /**
  20016. * If the button/trigger is currently touched
  20017. */
  20018. readonly touched: boolean;
  20019. /**
  20020. * Value of the button/trigger
  20021. */
  20022. readonly value: number;
  20023. }
  20024. /** @hidden */
  20025. export interface _GamePadFactory {
  20026. /**
  20027. * Returns whether or not the current gamepad can be created for this type of controller.
  20028. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20029. * @returns true if it can be created, otherwise false
  20030. */
  20031. canCreate(gamepadInfo: any): boolean;
  20032. /**
  20033. * Creates a new instance of the Gamepad.
  20034. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20035. * @returns the new gamepad instance
  20036. */
  20037. create(gamepadInfo: any): Gamepad;
  20038. }
  20039. /**
  20040. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20041. */
  20042. export class PoseEnabledControllerHelper {
  20043. /** @hidden */
  20044. static _ControllerFactories: _GamePadFactory[];
  20045. /** @hidden */
  20046. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20047. /**
  20048. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20049. * @param vrGamepad the gamepad to initialized
  20050. * @returns a vr controller of the type the gamepad identified as
  20051. */
  20052. static InitiateController(vrGamepad: any): Gamepad;
  20053. }
  20054. /**
  20055. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20056. */
  20057. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20058. /**
  20059. * If the controller is used in a webXR session
  20060. */
  20061. isXR: boolean;
  20062. private _deviceRoomPosition;
  20063. private _deviceRoomRotationQuaternion;
  20064. /**
  20065. * The device position in babylon space
  20066. */
  20067. devicePosition: Vector3;
  20068. /**
  20069. * The device rotation in babylon space
  20070. */
  20071. deviceRotationQuaternion: Quaternion;
  20072. /**
  20073. * The scale factor of the device in babylon space
  20074. */
  20075. deviceScaleFactor: number;
  20076. /**
  20077. * (Likely devicePosition should be used instead) The device position in its room space
  20078. */
  20079. position: Vector3;
  20080. /**
  20081. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20082. */
  20083. rotationQuaternion: Quaternion;
  20084. /**
  20085. * The type of controller (Eg. Windows mixed reality)
  20086. */
  20087. controllerType: PoseEnabledControllerType;
  20088. protected _calculatedPosition: Vector3;
  20089. private _calculatedRotation;
  20090. /**
  20091. * The raw pose from the device
  20092. */
  20093. rawPose: DevicePose;
  20094. private _trackPosition;
  20095. private _maxRotationDistFromHeadset;
  20096. private _draggedRoomRotation;
  20097. /**
  20098. * @hidden
  20099. */
  20100. _disableTrackPosition(fixedPosition: Vector3): void;
  20101. /**
  20102. * Internal, the mesh attached to the controller
  20103. * @hidden
  20104. */
  20105. _mesh: Nullable<AbstractMesh>;
  20106. private _poseControlledCamera;
  20107. private _leftHandSystemQuaternion;
  20108. /**
  20109. * Internal, matrix used to convert room space to babylon space
  20110. * @hidden
  20111. */
  20112. _deviceToWorld: Matrix;
  20113. /**
  20114. * Node to be used when casting a ray from the controller
  20115. * @hidden
  20116. */
  20117. _pointingPoseNode: Nullable<TransformNode>;
  20118. /**
  20119. * Name of the child mesh that can be used to cast a ray from the controller
  20120. */
  20121. static readonly POINTING_POSE: string;
  20122. /**
  20123. * Creates a new PoseEnabledController from a gamepad
  20124. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20125. */
  20126. constructor(browserGamepad: any);
  20127. private _workingMatrix;
  20128. /**
  20129. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20130. */
  20131. update(): void;
  20132. /**
  20133. * Updates only the pose device and mesh without doing any button event checking
  20134. */
  20135. protected _updatePoseAndMesh(): void;
  20136. /**
  20137. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20138. * @param poseData raw pose fromthe device
  20139. */
  20140. updateFromDevice(poseData: DevicePose): void;
  20141. /**
  20142. * @hidden
  20143. */
  20144. _meshAttachedObservable: Observable<AbstractMesh>;
  20145. /**
  20146. * Attaches a mesh to the controller
  20147. * @param mesh the mesh to be attached
  20148. */
  20149. attachToMesh(mesh: AbstractMesh): void;
  20150. /**
  20151. * Attaches the controllers mesh to a camera
  20152. * @param camera the camera the mesh should be attached to
  20153. */
  20154. attachToPoseControlledCamera(camera: TargetCamera): void;
  20155. /**
  20156. * Disposes of the controller
  20157. */
  20158. dispose(): void;
  20159. /**
  20160. * The mesh that is attached to the controller
  20161. */
  20162. get mesh(): Nullable<AbstractMesh>;
  20163. /**
  20164. * Gets the ray of the controller in the direction the controller is pointing
  20165. * @param length the length the resulting ray should be
  20166. * @returns a ray in the direction the controller is pointing
  20167. */
  20168. getForwardRay(length?: number): Ray;
  20169. }
  20170. }
  20171. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20172. import { Observable } from "babylonjs/Misc/observable";
  20173. import { Scene } from "babylonjs/scene";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20176. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20177. import { Nullable } from "babylonjs/types";
  20178. /**
  20179. * Defines the WebVRController object that represents controllers tracked in 3D space
  20180. */
  20181. export abstract class WebVRController extends PoseEnabledController {
  20182. /**
  20183. * Internal, the default controller model for the controller
  20184. */
  20185. protected _defaultModel: Nullable<AbstractMesh>;
  20186. /**
  20187. * Fired when the trigger state has changed
  20188. */
  20189. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20190. /**
  20191. * Fired when the main button state has changed
  20192. */
  20193. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20194. /**
  20195. * Fired when the secondary button state has changed
  20196. */
  20197. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20198. /**
  20199. * Fired when the pad state has changed
  20200. */
  20201. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20202. /**
  20203. * Fired when controllers stick values have changed
  20204. */
  20205. onPadValuesChangedObservable: Observable<StickValues>;
  20206. /**
  20207. * Array of button availible on the controller
  20208. */
  20209. protected _buttons: Array<MutableGamepadButton>;
  20210. private _onButtonStateChange;
  20211. /**
  20212. * Fired when a controller button's state has changed
  20213. * @param callback the callback containing the button that was modified
  20214. */
  20215. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20216. /**
  20217. * X and Y axis corresponding to the controllers joystick
  20218. */
  20219. pad: StickValues;
  20220. /**
  20221. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20222. */
  20223. hand: string;
  20224. /**
  20225. * The default controller model for the controller
  20226. */
  20227. get defaultModel(): Nullable<AbstractMesh>;
  20228. /**
  20229. * Creates a new WebVRController from a gamepad
  20230. * @param vrGamepad the gamepad that the WebVRController should be created from
  20231. */
  20232. constructor(vrGamepad: any);
  20233. /**
  20234. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20235. */
  20236. update(): void;
  20237. /**
  20238. * Function to be called when a button is modified
  20239. */
  20240. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20241. /**
  20242. * Loads a mesh and attaches it to the controller
  20243. * @param scene the scene the mesh should be added to
  20244. * @param meshLoaded callback for when the mesh has been loaded
  20245. */
  20246. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20247. private _setButtonValue;
  20248. private _changes;
  20249. private _checkChanges;
  20250. /**
  20251. * Disposes of th webVRCOntroller
  20252. */
  20253. dispose(): void;
  20254. }
  20255. }
  20256. declare module "babylonjs/Lights/hemisphericLight" {
  20257. import { Nullable } from "babylonjs/types";
  20258. import { Scene } from "babylonjs/scene";
  20259. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20260. import { Color3 } from "babylonjs/Maths/math.color";
  20261. import { Effect } from "babylonjs/Materials/effect";
  20262. import { Light } from "babylonjs/Lights/light";
  20263. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20264. /**
  20265. * The HemisphericLight simulates the ambient environment light,
  20266. * so the passed direction is the light reflection direction, not the incoming direction.
  20267. */
  20268. export class HemisphericLight extends Light {
  20269. /**
  20270. * The groundColor is the light in the opposite direction to the one specified during creation.
  20271. * 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.
  20272. */
  20273. groundColor: Color3;
  20274. /**
  20275. * The light reflection direction, not the incoming direction.
  20276. */
  20277. direction: Vector3;
  20278. /**
  20279. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20280. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20281. * The HemisphericLight can't cast shadows.
  20282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20283. * @param name The friendly name of the light
  20284. * @param direction The direction of the light reflection
  20285. * @param scene The scene the light belongs to
  20286. */
  20287. constructor(name: string, direction: Vector3, scene: Scene);
  20288. protected _buildUniformLayout(): void;
  20289. /**
  20290. * Returns the string "HemisphericLight".
  20291. * @return The class name
  20292. */
  20293. getClassName(): string;
  20294. /**
  20295. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20296. * Returns the updated direction.
  20297. * @param target The target the direction should point to
  20298. * @return The computed direction
  20299. */
  20300. setDirectionToTarget(target: Vector3): Vector3;
  20301. /**
  20302. * Returns the shadow generator associated to the light.
  20303. * @returns Always null for hemispheric lights because it does not support shadows.
  20304. */
  20305. getShadowGenerator(): Nullable<IShadowGenerator>;
  20306. /**
  20307. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20308. * @param effect The effect to update
  20309. * @param lightIndex The index of the light in the effect to update
  20310. * @returns The hemispheric light
  20311. */
  20312. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20314. /**
  20315. * Computes the world matrix of the node
  20316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20317. * @param useWasUpdatedFlag defines a reserved property
  20318. * @returns the world matrix
  20319. */
  20320. computeWorldMatrix(): Matrix;
  20321. /**
  20322. * Returns the integer 3.
  20323. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20324. */
  20325. getTypeID(): number;
  20326. /**
  20327. * Prepares the list of defines specific to the light type.
  20328. * @param defines the list of defines
  20329. * @param lightIndex defines the index of the light for the effect
  20330. */
  20331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20332. }
  20333. }
  20334. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20335. /** @hidden */
  20336. export var vrMultiviewToSingleviewPixelShader: {
  20337. name: string;
  20338. shader: string;
  20339. };
  20340. }
  20341. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20342. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20343. import { Scene } from "babylonjs/scene";
  20344. /**
  20345. * Renders to multiple views with a single draw call
  20346. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20347. */
  20348. export class MultiviewRenderTarget extends RenderTargetTexture {
  20349. /**
  20350. * Creates a multiview render target
  20351. * @param scene scene used with the render target
  20352. * @param size the size of the render target (used for each view)
  20353. */
  20354. constructor(scene: Scene, size?: number | {
  20355. width: number;
  20356. height: number;
  20357. } | {
  20358. ratio: number;
  20359. });
  20360. /**
  20361. * @hidden
  20362. * @param faceIndex the face index, if its a cube texture
  20363. */
  20364. _bindFrameBuffer(faceIndex?: number): void;
  20365. /**
  20366. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20367. * @returns the view count
  20368. */
  20369. getViewCount(): number;
  20370. }
  20371. }
  20372. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20373. import { Camera } from "babylonjs/Cameras/camera";
  20374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20375. import { Nullable } from "babylonjs/types";
  20376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20377. import { Matrix } from "babylonjs/Maths/math.vector";
  20378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20379. module "babylonjs/Engines/engine" {
  20380. interface Engine {
  20381. /**
  20382. * Creates a new multiview render target
  20383. * @param width defines the width of the texture
  20384. * @param height defines the height of the texture
  20385. * @returns the created multiview texture
  20386. */
  20387. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20388. /**
  20389. * Binds a multiview framebuffer to be drawn to
  20390. * @param multiviewTexture texture to bind
  20391. */
  20392. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20393. }
  20394. }
  20395. module "babylonjs/Cameras/camera" {
  20396. interface Camera {
  20397. /**
  20398. * @hidden
  20399. * 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)
  20400. */
  20401. _useMultiviewToSingleView: boolean;
  20402. /**
  20403. * @hidden
  20404. * 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)
  20405. */
  20406. _multiviewTexture: Nullable<RenderTargetTexture>;
  20407. /**
  20408. * @hidden
  20409. * ensures the multiview texture of the camera exists and has the specified width/height
  20410. * @param width height to set on the multiview texture
  20411. * @param height width to set on the multiview texture
  20412. */
  20413. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20414. }
  20415. }
  20416. module "babylonjs/scene" {
  20417. interface Scene {
  20418. /** @hidden */
  20419. _transformMatrixR: Matrix;
  20420. /** @hidden */
  20421. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20422. /** @hidden */
  20423. _createMultiviewUbo(): void;
  20424. /** @hidden */
  20425. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20426. /** @hidden */
  20427. _renderMultiviewToSingleView(camera: Camera): void;
  20428. }
  20429. }
  20430. }
  20431. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20432. import { Camera } from "babylonjs/Cameras/camera";
  20433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20434. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20435. import "babylonjs/Engines/Extensions/engine.multiview";
  20436. /**
  20437. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20438. * This will not be used for webXR as it supports displaying texture arrays directly
  20439. */
  20440. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20441. /**
  20442. * Gets a string identifying the name of the class
  20443. * @returns "VRMultiviewToSingleviewPostProcess" string
  20444. */
  20445. getClassName(): string;
  20446. /**
  20447. * Initializes a VRMultiviewToSingleview
  20448. * @param name name of the post process
  20449. * @param camera camera to be applied to
  20450. * @param scaleFactor scaling factor to the size of the output texture
  20451. */
  20452. constructor(name: string, camera: Camera, scaleFactor: number);
  20453. }
  20454. }
  20455. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20456. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20457. import { Nullable } from "babylonjs/types";
  20458. import { Size } from "babylonjs/Maths/math.size";
  20459. import { Observable } from "babylonjs/Misc/observable";
  20460. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20461. /**
  20462. * Interface used to define additional presentation attributes
  20463. */
  20464. export interface IVRPresentationAttributes {
  20465. /**
  20466. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20467. */
  20468. highRefreshRate: boolean;
  20469. /**
  20470. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20471. */
  20472. foveationLevel: number;
  20473. }
  20474. module "babylonjs/Engines/engine" {
  20475. interface Engine {
  20476. /** @hidden */
  20477. _vrDisplay: any;
  20478. /** @hidden */
  20479. _vrSupported: boolean;
  20480. /** @hidden */
  20481. _oldSize: Size;
  20482. /** @hidden */
  20483. _oldHardwareScaleFactor: number;
  20484. /** @hidden */
  20485. _vrExclusivePointerMode: boolean;
  20486. /** @hidden */
  20487. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20488. /** @hidden */
  20489. _onVRDisplayPointerRestricted: () => void;
  20490. /** @hidden */
  20491. _onVRDisplayPointerUnrestricted: () => void;
  20492. /** @hidden */
  20493. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20494. /** @hidden */
  20495. _onVrDisplayDisconnect: Nullable<() => void>;
  20496. /** @hidden */
  20497. _onVrDisplayPresentChange: Nullable<() => void>;
  20498. /**
  20499. * Observable signaled when VR display mode changes
  20500. */
  20501. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20502. /**
  20503. * Observable signaled when VR request present is complete
  20504. */
  20505. onVRRequestPresentComplete: Observable<boolean>;
  20506. /**
  20507. * Observable signaled when VR request present starts
  20508. */
  20509. onVRRequestPresentStart: Observable<Engine>;
  20510. /**
  20511. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20512. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20513. */
  20514. isInVRExclusivePointerMode: boolean;
  20515. /**
  20516. * Gets a boolean indicating if a webVR device was detected
  20517. * @returns true if a webVR device was detected
  20518. */
  20519. isVRDevicePresent(): boolean;
  20520. /**
  20521. * Gets the current webVR device
  20522. * @returns the current webVR device (or null)
  20523. */
  20524. getVRDevice(): any;
  20525. /**
  20526. * Initializes a webVR display and starts listening to display change events
  20527. * The onVRDisplayChangedObservable will be notified upon these changes
  20528. * @returns A promise containing a VRDisplay and if vr is supported
  20529. */
  20530. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20531. /** @hidden */
  20532. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20533. /**
  20534. * Gets or sets the presentation attributes used to configure VR rendering
  20535. */
  20536. vrPresentationAttributes?: IVRPresentationAttributes;
  20537. /**
  20538. * Call this function to switch to webVR mode
  20539. * Will do nothing if webVR is not supported or if there is no webVR device
  20540. * @param options the webvr options provided to the camera. mainly used for multiview
  20541. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20542. */
  20543. enableVR(options: WebVROptions): void;
  20544. /** @hidden */
  20545. _onVRFullScreenTriggered(): void;
  20546. }
  20547. }
  20548. }
  20549. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20550. import { Nullable } from "babylonjs/types";
  20551. import { Observable } from "babylonjs/Misc/observable";
  20552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20553. import { Scene } from "babylonjs/scene";
  20554. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20555. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20556. import { Node } from "babylonjs/node";
  20557. import { Ray } from "babylonjs/Culling/ray";
  20558. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20559. import "babylonjs/Engines/Extensions/engine.webVR";
  20560. /**
  20561. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20562. * IMPORTANT!! The data is right-hand data.
  20563. * @export
  20564. * @interface DevicePose
  20565. */
  20566. export interface DevicePose {
  20567. /**
  20568. * The position of the device, values in array are [x,y,z].
  20569. */
  20570. readonly position: Nullable<Float32Array>;
  20571. /**
  20572. * The linearVelocity of the device, values in array are [x,y,z].
  20573. */
  20574. readonly linearVelocity: Nullable<Float32Array>;
  20575. /**
  20576. * The linearAcceleration of the device, values in array are [x,y,z].
  20577. */
  20578. readonly linearAcceleration: Nullable<Float32Array>;
  20579. /**
  20580. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20581. */
  20582. readonly orientation: Nullable<Float32Array>;
  20583. /**
  20584. * The angularVelocity of the device, values in array are [x,y,z].
  20585. */
  20586. readonly angularVelocity: Nullable<Float32Array>;
  20587. /**
  20588. * The angularAcceleration of the device, values in array are [x,y,z].
  20589. */
  20590. readonly angularAcceleration: Nullable<Float32Array>;
  20591. }
  20592. /**
  20593. * Interface representing a pose controlled object in Babylon.
  20594. * A pose controlled object has both regular pose values as well as pose values
  20595. * from an external device such as a VR head mounted display
  20596. */
  20597. export interface PoseControlled {
  20598. /**
  20599. * The position of the object in babylon space.
  20600. */
  20601. position: Vector3;
  20602. /**
  20603. * The rotation quaternion of the object in babylon space.
  20604. */
  20605. rotationQuaternion: Quaternion;
  20606. /**
  20607. * The position of the device in babylon space.
  20608. */
  20609. devicePosition?: Vector3;
  20610. /**
  20611. * The rotation quaternion of the device in babylon space.
  20612. */
  20613. deviceRotationQuaternion: Quaternion;
  20614. /**
  20615. * The raw pose coming from the device.
  20616. */
  20617. rawPose: Nullable<DevicePose>;
  20618. /**
  20619. * The scale of the device to be used when translating from device space to babylon space.
  20620. */
  20621. deviceScaleFactor: number;
  20622. /**
  20623. * Updates the poseControlled values based on the input device pose.
  20624. * @param poseData the pose data to update the object with
  20625. */
  20626. updateFromDevice(poseData: DevicePose): void;
  20627. }
  20628. /**
  20629. * Set of options to customize the webVRCamera
  20630. */
  20631. export interface WebVROptions {
  20632. /**
  20633. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20634. */
  20635. trackPosition?: boolean;
  20636. /**
  20637. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20638. */
  20639. positionScale?: number;
  20640. /**
  20641. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20642. */
  20643. displayName?: string;
  20644. /**
  20645. * Should the native controller meshes be initialized. (default: true)
  20646. */
  20647. controllerMeshes?: boolean;
  20648. /**
  20649. * Creating a default HemiLight only on controllers. (default: true)
  20650. */
  20651. defaultLightingOnControllers?: boolean;
  20652. /**
  20653. * If you don't want to use the default VR button of the helper. (default: false)
  20654. */
  20655. useCustomVRButton?: boolean;
  20656. /**
  20657. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20658. */
  20659. customVRButton?: HTMLButtonElement;
  20660. /**
  20661. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20662. */
  20663. rayLength?: number;
  20664. /**
  20665. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20666. */
  20667. defaultHeight?: number;
  20668. /**
  20669. * If multiview should be used if availible (default: false)
  20670. */
  20671. useMultiview?: boolean;
  20672. }
  20673. /**
  20674. * This represents a WebVR camera.
  20675. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20676. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20677. */
  20678. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20679. private webVROptions;
  20680. /**
  20681. * @hidden
  20682. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20683. */
  20684. _vrDevice: any;
  20685. /**
  20686. * The rawPose of the vrDevice.
  20687. */
  20688. rawPose: Nullable<DevicePose>;
  20689. private _onVREnabled;
  20690. private _specsVersion;
  20691. private _attached;
  20692. private _frameData;
  20693. protected _descendants: Array<Node>;
  20694. private _deviceRoomPosition;
  20695. /** @hidden */
  20696. _deviceRoomRotationQuaternion: Quaternion;
  20697. private _standingMatrix;
  20698. /**
  20699. * Represents device position in babylon space.
  20700. */
  20701. devicePosition: Vector3;
  20702. /**
  20703. * Represents device rotation in babylon space.
  20704. */
  20705. deviceRotationQuaternion: Quaternion;
  20706. /**
  20707. * The scale of the device to be used when translating from device space to babylon space.
  20708. */
  20709. deviceScaleFactor: number;
  20710. private _deviceToWorld;
  20711. private _worldToDevice;
  20712. /**
  20713. * References to the webVR controllers for the vrDevice.
  20714. */
  20715. controllers: Array<WebVRController>;
  20716. /**
  20717. * Emits an event when a controller is attached.
  20718. */
  20719. onControllersAttachedObservable: Observable<WebVRController[]>;
  20720. /**
  20721. * Emits an event when a controller's mesh has been loaded;
  20722. */
  20723. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20724. /**
  20725. * Emits an event when the HMD's pose has been updated.
  20726. */
  20727. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20728. private _poseSet;
  20729. /**
  20730. * If the rig cameras be used as parent instead of this camera.
  20731. */
  20732. rigParenting: boolean;
  20733. private _lightOnControllers;
  20734. private _defaultHeight?;
  20735. /**
  20736. * Instantiates a WebVRFreeCamera.
  20737. * @param name The name of the WebVRFreeCamera
  20738. * @param position The starting anchor position for the camera
  20739. * @param scene The scene the camera belongs to
  20740. * @param webVROptions a set of customizable options for the webVRCamera
  20741. */
  20742. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20743. /**
  20744. * Gets the device distance from the ground in meters.
  20745. * @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.
  20746. */
  20747. deviceDistanceToRoomGround(): number;
  20748. /**
  20749. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20750. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20751. */
  20752. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20753. /**
  20754. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20755. * @returns A promise with a boolean set to if the standing matrix is supported.
  20756. */
  20757. useStandingMatrixAsync(): Promise<boolean>;
  20758. /**
  20759. * Disposes the camera
  20760. */
  20761. dispose(): void;
  20762. /**
  20763. * Gets a vrController by name.
  20764. * @param name The name of the controller to retreive
  20765. * @returns the controller matching the name specified or null if not found
  20766. */
  20767. getControllerByName(name: string): Nullable<WebVRController>;
  20768. private _leftController;
  20769. /**
  20770. * The controller corresponding to the users left hand.
  20771. */
  20772. get leftController(): Nullable<WebVRController>;
  20773. private _rightController;
  20774. /**
  20775. * The controller corresponding to the users right hand.
  20776. */
  20777. get rightController(): Nullable<WebVRController>;
  20778. /**
  20779. * Casts a ray forward from the vrCamera's gaze.
  20780. * @param length Length of the ray (default: 100)
  20781. * @returns the ray corresponding to the gaze
  20782. */
  20783. getForwardRay(length?: number): Ray;
  20784. /**
  20785. * @hidden
  20786. * Updates the camera based on device's frame data
  20787. */
  20788. _checkInputs(): void;
  20789. /**
  20790. * Updates the poseControlled values based on the input device pose.
  20791. * @param poseData Pose coming from the device
  20792. */
  20793. updateFromDevice(poseData: DevicePose): void;
  20794. private _htmlElementAttached;
  20795. private _detachIfAttached;
  20796. /**
  20797. * WebVR's attach control will start broadcasting frames to the device.
  20798. * Note that in certain browsers (chrome for example) this function must be called
  20799. * within a user-interaction callback. Example:
  20800. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20801. *
  20802. * @param element html element to attach the vrDevice to
  20803. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20804. */
  20805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20806. /**
  20807. * Detaches the camera from the html element and disables VR
  20808. *
  20809. * @param element html element to detach from
  20810. */
  20811. detachControl(element: HTMLElement): void;
  20812. /**
  20813. * @returns the name of this class
  20814. */
  20815. getClassName(): string;
  20816. /**
  20817. * Calls resetPose on the vrDisplay
  20818. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20819. */
  20820. resetToCurrentRotation(): void;
  20821. /**
  20822. * @hidden
  20823. * Updates the rig cameras (left and right eye)
  20824. */
  20825. _updateRigCameras(): void;
  20826. private _workingVector;
  20827. private _oneVector;
  20828. private _workingMatrix;
  20829. private updateCacheCalled;
  20830. private _correctPositionIfNotTrackPosition;
  20831. /**
  20832. * @hidden
  20833. * Updates the cached values of the camera
  20834. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20835. */
  20836. _updateCache(ignoreParentClass?: boolean): void;
  20837. /**
  20838. * @hidden
  20839. * Get current device position in babylon world
  20840. */
  20841. _computeDevicePosition(): void;
  20842. /**
  20843. * Updates the current device position and rotation in the babylon world
  20844. */
  20845. update(): void;
  20846. /**
  20847. * @hidden
  20848. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20849. * @returns an identity matrix
  20850. */
  20851. _getViewMatrix(): Matrix;
  20852. private _tmpMatrix;
  20853. /**
  20854. * This function is called by the two RIG cameras.
  20855. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20856. * @hidden
  20857. */
  20858. _getWebVRViewMatrix(): Matrix;
  20859. /** @hidden */
  20860. _getWebVRProjectionMatrix(): Matrix;
  20861. private _onGamepadConnectedObserver;
  20862. private _onGamepadDisconnectedObserver;
  20863. private _updateCacheWhenTrackingDisabledObserver;
  20864. /**
  20865. * Initializes the controllers and their meshes
  20866. */
  20867. initControllers(): void;
  20868. }
  20869. }
  20870. declare module "babylonjs/Materials/materialHelper" {
  20871. import { Nullable } from "babylonjs/types";
  20872. import { Scene } from "babylonjs/scene";
  20873. import { Engine } from "babylonjs/Engines/engine";
  20874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20875. import { Light } from "babylonjs/Lights/light";
  20876. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20877. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20879. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20880. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20881. /**
  20882. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20883. *
  20884. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20885. *
  20886. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20887. */
  20888. export class MaterialHelper {
  20889. /**
  20890. * Bind the current view position to an effect.
  20891. * @param effect The effect to be bound
  20892. * @param scene The scene the eyes position is used from
  20893. * @param variableName name of the shader variable that will hold the eye position
  20894. */
  20895. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20896. /**
  20897. * Helps preparing the defines values about the UVs in used in the effect.
  20898. * UVs are shared as much as we can accross channels in the shaders.
  20899. * @param texture The texture we are preparing the UVs for
  20900. * @param defines The defines to update
  20901. * @param key The channel key "diffuse", "specular"... used in the shader
  20902. */
  20903. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20904. /**
  20905. * Binds a texture matrix value to its corrsponding uniform
  20906. * @param texture The texture to bind the matrix for
  20907. * @param uniformBuffer The uniform buffer receivin the data
  20908. * @param key The channel key "diffuse", "specular"... used in the shader
  20909. */
  20910. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20911. /**
  20912. * Gets the current status of the fog (should it be enabled?)
  20913. * @param mesh defines the mesh to evaluate for fog support
  20914. * @param scene defines the hosting scene
  20915. * @returns true if fog must be enabled
  20916. */
  20917. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20918. /**
  20919. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20920. * @param mesh defines the current mesh
  20921. * @param scene defines the current scene
  20922. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20923. * @param pointsCloud defines if point cloud rendering has to be turned on
  20924. * @param fogEnabled defines if fog has to be turned on
  20925. * @param alphaTest defines if alpha testing has to be turned on
  20926. * @param defines defines the current list of defines
  20927. */
  20928. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20929. /**
  20930. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20931. * @param scene defines the current scene
  20932. * @param engine defines the current engine
  20933. * @param defines specifies the list of active defines
  20934. * @param useInstances defines if instances have to be turned on
  20935. * @param useClipPlane defines if clip plane have to be turned on
  20936. * @param useInstances defines if instances have to be turned on
  20937. * @param useThinInstances defines if thin instances have to be turned on
  20938. */
  20939. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20940. /**
  20941. * Prepares the defines for bones
  20942. * @param mesh The mesh containing the geometry data we will draw
  20943. * @param defines The defines to update
  20944. */
  20945. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20946. /**
  20947. * Prepares the defines for morph targets
  20948. * @param mesh The mesh containing the geometry data we will draw
  20949. * @param defines The defines to update
  20950. */
  20951. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20952. /**
  20953. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20954. * @param mesh The mesh containing the geometry data we will draw
  20955. * @param defines The defines to update
  20956. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20957. * @param useBones Precise whether bones should be used or not (override mesh info)
  20958. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20959. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20960. * @returns false if defines are considered not dirty and have not been checked
  20961. */
  20962. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20963. /**
  20964. * Prepares the defines related to multiview
  20965. * @param scene The scene we are intending to draw
  20966. * @param defines The defines to update
  20967. */
  20968. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20969. /**
  20970. * Prepares the defines related to the prepass
  20971. * @param scene The scene we are intending to draw
  20972. * @param defines The defines to update
  20973. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20974. */
  20975. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20976. /**
  20977. * Prepares the defines related to the light information passed in parameter
  20978. * @param scene The scene we are intending to draw
  20979. * @param mesh The mesh the effect is compiling for
  20980. * @param light The light the effect is compiling for
  20981. * @param lightIndex The index of the light
  20982. * @param defines The defines to update
  20983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20984. * @param state Defines the current state regarding what is needed (normals, etc...)
  20985. */
  20986. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20987. needNormals: boolean;
  20988. needRebuild: boolean;
  20989. shadowEnabled: boolean;
  20990. specularEnabled: boolean;
  20991. lightmapMode: boolean;
  20992. }): void;
  20993. /**
  20994. * Prepares the defines related to the light information passed in parameter
  20995. * @param scene The scene we are intending to draw
  20996. * @param mesh The mesh the effect is compiling for
  20997. * @param defines The defines to update
  20998. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20999. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21000. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21001. * @returns true if normals will be required for the rest of the effect
  21002. */
  21003. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21004. /**
  21005. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21006. * @param lightIndex defines the light index
  21007. * @param uniformsList The uniform list
  21008. * @param samplersList The sampler list
  21009. * @param projectedLightTexture defines if projected texture must be used
  21010. * @param uniformBuffersList defines an optional list of uniform buffers
  21011. */
  21012. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21013. /**
  21014. * Prepares the uniforms and samplers list to be used in the effect
  21015. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21016. * @param samplersList The sampler list
  21017. * @param defines The defines helping in the list generation
  21018. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21019. */
  21020. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21021. /**
  21022. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21023. * @param defines The defines to update while falling back
  21024. * @param fallbacks The authorized effect fallbacks
  21025. * @param maxSimultaneousLights The maximum number of lights allowed
  21026. * @param rank the current rank of the Effect
  21027. * @returns The newly affected rank
  21028. */
  21029. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21030. private static _TmpMorphInfluencers;
  21031. /**
  21032. * Prepares the list of attributes required for morph targets according to the effect defines.
  21033. * @param attribs The current list of supported attribs
  21034. * @param mesh The mesh to prepare the morph targets attributes for
  21035. * @param influencers The number of influencers
  21036. */
  21037. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21038. /**
  21039. * Prepares the list of attributes required for morph targets according to the effect defines.
  21040. * @param attribs The current list of supported attribs
  21041. * @param mesh The mesh to prepare the morph targets attributes for
  21042. * @param defines The current Defines of the effect
  21043. */
  21044. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21045. /**
  21046. * Prepares the list of attributes required for bones according to the effect defines.
  21047. * @param attribs The current list of supported attribs
  21048. * @param mesh The mesh to prepare the bones attributes for
  21049. * @param defines The current Defines of the effect
  21050. * @param fallbacks The current efffect fallback strategy
  21051. */
  21052. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21053. /**
  21054. * Check and prepare the list of attributes required for instances according to the effect defines.
  21055. * @param attribs The current list of supported attribs
  21056. * @param defines The current MaterialDefines of the effect
  21057. */
  21058. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21059. /**
  21060. * Add the list of attributes required for instances to the attribs array.
  21061. * @param attribs The current list of supported attribs
  21062. */
  21063. static PushAttributesForInstances(attribs: string[]): void;
  21064. /**
  21065. * Binds the light information to the effect.
  21066. * @param light The light containing the generator
  21067. * @param effect The effect we are binding the data to
  21068. * @param lightIndex The light index in the effect used to render
  21069. */
  21070. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21071. /**
  21072. * Binds the lights information from the scene to the effect for the given mesh.
  21073. * @param light Light to bind
  21074. * @param lightIndex Light index
  21075. * @param scene The scene where the light belongs to
  21076. * @param effect The effect we are binding the data to
  21077. * @param useSpecular Defines if specular is supported
  21078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21079. */
  21080. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21081. /**
  21082. * Binds the lights information from the scene to the effect for the given mesh.
  21083. * @param scene The scene the lights belongs to
  21084. * @param mesh The mesh we are binding the information to render
  21085. * @param effect The effect we are binding the data to
  21086. * @param defines The generated defines for the effect
  21087. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21088. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21089. */
  21090. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21091. private static _tempFogColor;
  21092. /**
  21093. * Binds the fog information from the scene to the effect for the given mesh.
  21094. * @param scene The scene the lights belongs to
  21095. * @param mesh The mesh we are binding the information to render
  21096. * @param effect The effect we are binding the data to
  21097. * @param linearSpace Defines if the fog effect is applied in linear space
  21098. */
  21099. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21100. /**
  21101. * Binds the bones information from the mesh to the effect.
  21102. * @param mesh The mesh we are binding the information to render
  21103. * @param effect The effect we are binding the data to
  21104. */
  21105. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21106. /**
  21107. * Binds the morph targets information from the mesh to the effect.
  21108. * @param abstractMesh The mesh we are binding the information to render
  21109. * @param effect The effect we are binding the data to
  21110. */
  21111. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21112. /**
  21113. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21114. * @param defines The generated defines used in the effect
  21115. * @param effect The effect we are binding the data to
  21116. * @param scene The scene we are willing to render with logarithmic scale for
  21117. */
  21118. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21119. /**
  21120. * Binds the clip plane information from the scene to the effect.
  21121. * @param scene The scene the clip plane information are extracted from
  21122. * @param effect The effect we are binding the data to
  21123. */
  21124. static BindClipPlane(effect: Effect, scene: Scene): void;
  21125. }
  21126. }
  21127. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21129. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21130. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21131. import { Nullable } from "babylonjs/types";
  21132. import { Effect } from "babylonjs/Materials/effect";
  21133. import { Matrix } from "babylonjs/Maths/math.vector";
  21134. import { Scene } from "babylonjs/scene";
  21135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21137. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21138. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21139. import { Observable } from "babylonjs/Misc/observable";
  21140. /**
  21141. * Block used to expose an input value
  21142. */
  21143. export class InputBlock extends NodeMaterialBlock {
  21144. private _mode;
  21145. private _associatedVariableName;
  21146. private _storedValue;
  21147. private _valueCallback;
  21148. private _type;
  21149. private _animationType;
  21150. /** Gets or set a value used to limit the range of float values */
  21151. min: number;
  21152. /** Gets or set a value used to limit the range of float values */
  21153. max: number;
  21154. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21155. isBoolean: boolean;
  21156. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21157. matrixMode: number;
  21158. /** @hidden */
  21159. _systemValue: Nullable<NodeMaterialSystemValues>;
  21160. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21161. isConstant: boolean;
  21162. /** Gets or sets the group to use to display this block in the Inspector */
  21163. groupInInspector: string;
  21164. /** Gets an observable raised when the value is changed */
  21165. onValueChangedObservable: Observable<InputBlock>;
  21166. /**
  21167. * Gets or sets the connection point type (default is float)
  21168. */
  21169. get type(): NodeMaterialBlockConnectionPointTypes;
  21170. /**
  21171. * Creates a new InputBlock
  21172. * @param name defines the block name
  21173. * @param target defines the target of that block (Vertex by default)
  21174. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21175. */
  21176. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21177. /**
  21178. * Validates if a name is a reserve word.
  21179. * @param newName the new name to be given to the node.
  21180. * @returns false if the name is a reserve word, else true.
  21181. */
  21182. validateBlockName(newName: string): boolean;
  21183. /**
  21184. * Gets the output component
  21185. */
  21186. get output(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Set the source of this connection point to a vertex attribute
  21189. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21190. * @returns the current connection point
  21191. */
  21192. setAsAttribute(attributeName?: string): InputBlock;
  21193. /**
  21194. * Set the source of this connection point to a system value
  21195. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21196. * @returns the current connection point
  21197. */
  21198. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21199. /**
  21200. * Gets or sets the value of that point.
  21201. * Please note that this value will be ignored if valueCallback is defined
  21202. */
  21203. get value(): any;
  21204. set value(value: any);
  21205. /**
  21206. * Gets or sets a callback used to get the value of that point.
  21207. * Please note that setting this value will force the connection point to ignore the value property
  21208. */
  21209. get valueCallback(): () => any;
  21210. set valueCallback(value: () => any);
  21211. /**
  21212. * Gets or sets the associated variable name in the shader
  21213. */
  21214. get associatedVariableName(): string;
  21215. set associatedVariableName(value: string);
  21216. /** Gets or sets the type of animation applied to the input */
  21217. get animationType(): AnimatedInputBlockTypes;
  21218. set animationType(value: AnimatedInputBlockTypes);
  21219. /**
  21220. * Gets a boolean indicating that this connection point not defined yet
  21221. */
  21222. get isUndefined(): boolean;
  21223. /**
  21224. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21225. * In this case the connection point name must be the name of the uniform to use.
  21226. * Can only be set on inputs
  21227. */
  21228. get isUniform(): boolean;
  21229. set isUniform(value: boolean);
  21230. /**
  21231. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21232. * In this case the connection point name must be the name of the attribute to use
  21233. * Can only be set on inputs
  21234. */
  21235. get isAttribute(): boolean;
  21236. set isAttribute(value: boolean);
  21237. /**
  21238. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21239. * Can only be set on exit points
  21240. */
  21241. get isVarying(): boolean;
  21242. set isVarying(value: boolean);
  21243. /**
  21244. * Gets a boolean indicating that the current connection point is a system value
  21245. */
  21246. get isSystemValue(): boolean;
  21247. /**
  21248. * Gets or sets the current well known value or null if not defined as a system value
  21249. */
  21250. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21251. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21252. /**
  21253. * Gets the current class name
  21254. * @returns the class name
  21255. */
  21256. getClassName(): string;
  21257. /**
  21258. * Animate the input if animationType !== None
  21259. * @param scene defines the rendering scene
  21260. */
  21261. animate(scene: Scene): void;
  21262. private _emitDefine;
  21263. initialize(state: NodeMaterialBuildState): void;
  21264. /**
  21265. * Set the input block to its default value (based on its type)
  21266. */
  21267. setDefaultValue(): void;
  21268. private _emitConstant;
  21269. /** @hidden */
  21270. get _noContextSwitch(): boolean;
  21271. private _emit;
  21272. /** @hidden */
  21273. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21274. /** @hidden */
  21275. _transmit(effect: Effect, scene: Scene): void;
  21276. protected _buildBlock(state: NodeMaterialBuildState): void;
  21277. protected _dumpPropertiesCode(): string;
  21278. dispose(): void;
  21279. serialize(): any;
  21280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21281. }
  21282. }
  21283. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21284. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21285. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21286. import { Nullable } from "babylonjs/types";
  21287. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21288. import { Observable } from "babylonjs/Misc/observable";
  21289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21290. /**
  21291. * Enum used to define the compatibility state between two connection points
  21292. */
  21293. export enum NodeMaterialConnectionPointCompatibilityStates {
  21294. /** Points are compatibles */
  21295. Compatible = 0,
  21296. /** Points are incompatible because of their types */
  21297. TypeIncompatible = 1,
  21298. /** Points are incompatible because of their targets (vertex vs fragment) */
  21299. TargetIncompatible = 2
  21300. }
  21301. /**
  21302. * Defines the direction of a connection point
  21303. */
  21304. export enum NodeMaterialConnectionPointDirection {
  21305. /** Input */
  21306. Input = 0,
  21307. /** Output */
  21308. Output = 1
  21309. }
  21310. /**
  21311. * Defines a connection point for a block
  21312. */
  21313. export class NodeMaterialConnectionPoint {
  21314. /** @hidden */
  21315. _ownerBlock: NodeMaterialBlock;
  21316. /** @hidden */
  21317. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21318. private _endpoints;
  21319. private _associatedVariableName;
  21320. private _direction;
  21321. /** @hidden */
  21322. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21323. /** @hidden */
  21324. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21325. private _type;
  21326. /** @hidden */
  21327. _enforceAssociatedVariableName: boolean;
  21328. /** Gets the direction of the point */
  21329. get direction(): NodeMaterialConnectionPointDirection;
  21330. /** Indicates that this connection point needs dual validation before being connected to another point */
  21331. needDualDirectionValidation: boolean;
  21332. /**
  21333. * Gets or sets the additional types supported by this connection point
  21334. */
  21335. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21336. /**
  21337. * Gets or sets the additional types excluded by this connection point
  21338. */
  21339. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21340. /**
  21341. * Observable triggered when this point is connected
  21342. */
  21343. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21344. /**
  21345. * Gets or sets the associated variable name in the shader
  21346. */
  21347. get associatedVariableName(): string;
  21348. set associatedVariableName(value: string);
  21349. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21350. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21351. /**
  21352. * Gets or sets the connection point type (default is float)
  21353. */
  21354. get type(): NodeMaterialBlockConnectionPointTypes;
  21355. set type(value: NodeMaterialBlockConnectionPointTypes);
  21356. /**
  21357. * Gets or sets the connection point name
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the connection point name
  21362. */
  21363. displayName: string;
  21364. /**
  21365. * Gets or sets a boolean indicating that this connection point can be omitted
  21366. */
  21367. isOptional: boolean;
  21368. /**
  21369. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21370. */
  21371. isExposedOnFrame: boolean;
  21372. /**
  21373. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21374. */
  21375. define: string;
  21376. /** @hidden */
  21377. _prioritizeVertex: boolean;
  21378. private _target;
  21379. /** Gets or sets the target of that connection point */
  21380. get target(): NodeMaterialBlockTargets;
  21381. set target(value: NodeMaterialBlockTargets);
  21382. /**
  21383. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21384. */
  21385. get isConnected(): boolean;
  21386. /**
  21387. * Gets a boolean indicating that the current point is connected to an input block
  21388. */
  21389. get isConnectedToInputBlock(): boolean;
  21390. /**
  21391. * Gets a the connected input block (if any)
  21392. */
  21393. get connectInputBlock(): Nullable<InputBlock>;
  21394. /** Get the other side of the connection (if any) */
  21395. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21396. /** Get the block that owns this connection point */
  21397. get ownerBlock(): NodeMaterialBlock;
  21398. /** Get the block connected on the other side of this connection (if any) */
  21399. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21400. /** Get the block connected on the endpoints of this connection (if any) */
  21401. get connectedBlocks(): Array<NodeMaterialBlock>;
  21402. /** Gets the list of connected endpoints */
  21403. get endpoints(): NodeMaterialConnectionPoint[];
  21404. /** Gets a boolean indicating if that output point is connected to at least one input */
  21405. get hasEndpoints(): boolean;
  21406. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21407. get isConnectedInVertexShader(): boolean;
  21408. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21409. get isConnectedInFragmentShader(): boolean;
  21410. /**
  21411. * Creates a block suitable to be used as an input for this input point.
  21412. * If null is returned, a block based on the point type will be created.
  21413. * @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
  21414. */
  21415. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21416. /**
  21417. * Creates a new connection point
  21418. * @param name defines the connection point name
  21419. * @param ownerBlock defines the block hosting this connection point
  21420. * @param direction defines the direction of the connection point
  21421. */
  21422. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21423. /**
  21424. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21425. * @returns the class name
  21426. */
  21427. getClassName(): string;
  21428. /**
  21429. * Gets a boolean indicating if the current point can be connected to another point
  21430. * @param connectionPoint defines the other connection point
  21431. * @returns a boolean
  21432. */
  21433. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21434. /**
  21435. * Gets a number indicating if the current point can be connected to another point
  21436. * @param connectionPoint defines the other connection point
  21437. * @returns a number defining the compatibility state
  21438. */
  21439. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21440. /**
  21441. * Connect this point to another connection point
  21442. * @param connectionPoint defines the other connection point
  21443. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21444. * @returns the current connection point
  21445. */
  21446. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21447. /**
  21448. * Disconnect this point from one of his endpoint
  21449. * @param endpoint defines the other connection point
  21450. * @returns the current connection point
  21451. */
  21452. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21453. /**
  21454. * Serializes this point in a JSON representation
  21455. * @param isInput defines if the connection point is an input (default is true)
  21456. * @returns the serialized point object
  21457. */
  21458. serialize(isInput?: boolean): any;
  21459. /**
  21460. * Release resources
  21461. */
  21462. dispose(): void;
  21463. }
  21464. }
  21465. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21466. /**
  21467. * Enum used to define the material modes
  21468. */
  21469. export enum NodeMaterialModes {
  21470. /** Regular material */
  21471. Material = 0,
  21472. /** For post process */
  21473. PostProcess = 1,
  21474. /** For particle system */
  21475. Particle = 2,
  21476. /** For procedural texture */
  21477. ProceduralTexture = 3
  21478. }
  21479. }
  21480. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21483. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21486. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21487. import { Effect } from "babylonjs/Materials/effect";
  21488. import { Mesh } from "babylonjs/Meshes/mesh";
  21489. import { Nullable } from "babylonjs/types";
  21490. import { Texture } from "babylonjs/Materials/Textures/texture";
  21491. import { Scene } from "babylonjs/scene";
  21492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21493. /**
  21494. * Block used to read a texture from a sampler
  21495. */
  21496. export class TextureBlock extends NodeMaterialBlock {
  21497. private _defineName;
  21498. private _linearDefineName;
  21499. private _gammaDefineName;
  21500. private _tempTextureRead;
  21501. private _samplerName;
  21502. private _transformedUVName;
  21503. private _textureTransformName;
  21504. private _textureInfoName;
  21505. private _mainUVName;
  21506. private _mainUVDefineName;
  21507. private _fragmentOnly;
  21508. /**
  21509. * Gets or sets the texture associated with the node
  21510. */
  21511. texture: Nullable<Texture>;
  21512. /**
  21513. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21514. */
  21515. convertToGammaSpace: boolean;
  21516. /**
  21517. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21518. */
  21519. convertToLinearSpace: boolean;
  21520. /**
  21521. * Create a new TextureBlock
  21522. * @param name defines the block name
  21523. */
  21524. constructor(name: string, fragmentOnly?: boolean);
  21525. /**
  21526. * Gets the current class name
  21527. * @returns the class name
  21528. */
  21529. getClassName(): string;
  21530. /**
  21531. * Gets the uv input component
  21532. */
  21533. get uv(): NodeMaterialConnectionPoint;
  21534. /**
  21535. * Gets the rgba output component
  21536. */
  21537. get rgba(): NodeMaterialConnectionPoint;
  21538. /**
  21539. * Gets the rgb output component
  21540. */
  21541. get rgb(): NodeMaterialConnectionPoint;
  21542. /**
  21543. * Gets the r output component
  21544. */
  21545. get r(): NodeMaterialConnectionPoint;
  21546. /**
  21547. * Gets the g output component
  21548. */
  21549. get g(): NodeMaterialConnectionPoint;
  21550. /**
  21551. * Gets the b output component
  21552. */
  21553. get b(): NodeMaterialConnectionPoint;
  21554. /**
  21555. * Gets the a output component
  21556. */
  21557. get a(): NodeMaterialConnectionPoint;
  21558. get target(): NodeMaterialBlockTargets;
  21559. autoConfigure(material: NodeMaterial): void;
  21560. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21562. isReady(): boolean;
  21563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21564. private get _isMixed();
  21565. private _injectVertexCode;
  21566. private _writeTextureRead;
  21567. private _writeOutput;
  21568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21569. protected _dumpPropertiesCode(): string;
  21570. serialize(): any;
  21571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21572. }
  21573. }
  21574. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21575. /** @hidden */
  21576. export var reflectionFunction: {
  21577. name: string;
  21578. shader: string;
  21579. };
  21580. }
  21581. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21587. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21588. import { Effect } from "babylonjs/Materials/effect";
  21589. import { Mesh } from "babylonjs/Meshes/mesh";
  21590. import { Nullable } from "babylonjs/types";
  21591. import { Scene } from "babylonjs/scene";
  21592. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21593. /**
  21594. * Base block used to read a reflection texture from a sampler
  21595. */
  21596. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21597. /** @hidden */
  21598. _define3DName: string;
  21599. /** @hidden */
  21600. _defineCubicName: string;
  21601. /** @hidden */
  21602. _defineExplicitName: string;
  21603. /** @hidden */
  21604. _defineProjectionName: string;
  21605. /** @hidden */
  21606. _defineLocalCubicName: string;
  21607. /** @hidden */
  21608. _defineSphericalName: string;
  21609. /** @hidden */
  21610. _definePlanarName: string;
  21611. /** @hidden */
  21612. _defineEquirectangularName: string;
  21613. /** @hidden */
  21614. _defineMirroredEquirectangularFixedName: string;
  21615. /** @hidden */
  21616. _defineEquirectangularFixedName: string;
  21617. /** @hidden */
  21618. _defineSkyboxName: string;
  21619. /** @hidden */
  21620. _defineOppositeZ: string;
  21621. /** @hidden */
  21622. _cubeSamplerName: string;
  21623. /** @hidden */
  21624. _2DSamplerName: string;
  21625. protected _positionUVWName: string;
  21626. protected _directionWName: string;
  21627. protected _reflectionVectorName: string;
  21628. /** @hidden */
  21629. _reflectionCoordsName: string;
  21630. /** @hidden */
  21631. _reflectionMatrixName: string;
  21632. protected _reflectionColorName: string;
  21633. /**
  21634. * Gets or sets the texture associated with the node
  21635. */
  21636. texture: Nullable<BaseTexture>;
  21637. /**
  21638. * Create a new ReflectionTextureBaseBlock
  21639. * @param name defines the block name
  21640. */
  21641. constructor(name: string);
  21642. /**
  21643. * Gets the current class name
  21644. * @returns the class name
  21645. */
  21646. getClassName(): string;
  21647. /**
  21648. * Gets the world position input component
  21649. */
  21650. abstract get position(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the world position input component
  21653. */
  21654. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the world normal input component
  21657. */
  21658. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the world input component
  21661. */
  21662. abstract get world(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the camera (or eye) position component
  21665. */
  21666. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21667. /**
  21668. * Gets the view input component
  21669. */
  21670. abstract get view(): NodeMaterialConnectionPoint;
  21671. protected _getTexture(): Nullable<BaseTexture>;
  21672. autoConfigure(material: NodeMaterial): void;
  21673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21674. isReady(): boolean;
  21675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21676. /**
  21677. * Gets the code to inject in the vertex shader
  21678. * @param state current state of the node material building
  21679. * @returns the shader code
  21680. */
  21681. handleVertexSide(state: NodeMaterialBuildState): string;
  21682. /**
  21683. * Handles the inits for the fragment code path
  21684. * @param state node material build state
  21685. */
  21686. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21687. /**
  21688. * Generates the reflection coords code for the fragment code path
  21689. * @param worldNormalVarName name of the world normal variable
  21690. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21691. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21692. * @returns the shader code
  21693. */
  21694. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21695. /**
  21696. * Generates the reflection color code for the fragment code path
  21697. * @param lodVarName name of the lod variable
  21698. * @param swizzleLookupTexture swizzle to use for the final color variable
  21699. * @returns the shader code
  21700. */
  21701. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21702. /**
  21703. * Generates the code corresponding to the connected output points
  21704. * @param state node material build state
  21705. * @param varName name of the variable to output
  21706. * @returns the shader code
  21707. */
  21708. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21709. protected _buildBlock(state: NodeMaterialBuildState): this;
  21710. protected _dumpPropertiesCode(): string;
  21711. serialize(): any;
  21712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21713. }
  21714. }
  21715. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21717. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21718. import { Nullable } from "babylonjs/types";
  21719. /**
  21720. * Defines a connection point to be used for points with a custom object type
  21721. */
  21722. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21723. private _blockType;
  21724. private _blockName;
  21725. private _nameForCheking?;
  21726. /**
  21727. * Creates a new connection point
  21728. * @param name defines the connection point name
  21729. * @param ownerBlock defines the block hosting this connection point
  21730. * @param direction defines the direction of the connection point
  21731. */
  21732. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21733. /**
  21734. * Gets a number indicating if the current point can be connected to another point
  21735. * @param connectionPoint defines the other connection point
  21736. * @returns a number defining the compatibility state
  21737. */
  21738. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21739. /**
  21740. * Creates a block suitable to be used as an input for this input point.
  21741. * If null is returned, a block based on the point type will be created.
  21742. * @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
  21743. */
  21744. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21745. }
  21746. }
  21747. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21748. /**
  21749. * Enum defining the type of properties that can be edited in the property pages in the NME
  21750. */
  21751. export enum PropertyTypeForEdition {
  21752. /** property is a boolean */
  21753. Boolean = 0,
  21754. /** property is a float */
  21755. Float = 1,
  21756. /** property is a Vector2 */
  21757. Vector2 = 2,
  21758. /** property is a list of values */
  21759. List = 3
  21760. }
  21761. /**
  21762. * Interface that defines an option in a variable of type list
  21763. */
  21764. export interface IEditablePropertyListOption {
  21765. /** label of the option */
  21766. "label": string;
  21767. /** value of the option */
  21768. "value": number;
  21769. }
  21770. /**
  21771. * Interface that defines the options available for an editable property
  21772. */
  21773. export interface IEditablePropertyOption {
  21774. /** min value */
  21775. "min"?: number;
  21776. /** max value */
  21777. "max"?: number;
  21778. /** notifiers: indicates which actions to take when the property is changed */
  21779. "notifiers"?: {
  21780. /** the material should be rebuilt */
  21781. "rebuild"?: boolean;
  21782. /** the preview should be updated */
  21783. "update"?: boolean;
  21784. };
  21785. /** list of the options for a variable of type list */
  21786. "options"?: IEditablePropertyListOption[];
  21787. }
  21788. /**
  21789. * Interface that describes an editable property
  21790. */
  21791. export interface IPropertyDescriptionForEdition {
  21792. /** name of the property */
  21793. "propertyName": string;
  21794. /** display name of the property */
  21795. "displayName": string;
  21796. /** type of the property */
  21797. "type": PropertyTypeForEdition;
  21798. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21799. "groupName": string;
  21800. /** options for the property */
  21801. "options": IEditablePropertyOption;
  21802. }
  21803. /**
  21804. * Decorator that flags a property in a node material block as being editable
  21805. */
  21806. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21807. }
  21808. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21811. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21813. import { Nullable } from "babylonjs/types";
  21814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21817. import { Effect } from "babylonjs/Materials/effect";
  21818. import { Scene } from "babylonjs/scene";
  21819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21820. /**
  21821. * Block used to implement the refraction part of the sub surface module of the PBR material
  21822. */
  21823. export class RefractionBlock extends NodeMaterialBlock {
  21824. /** @hidden */
  21825. _define3DName: string;
  21826. /** @hidden */
  21827. _refractionMatrixName: string;
  21828. /** @hidden */
  21829. _defineLODRefractionAlpha: string;
  21830. /** @hidden */
  21831. _defineLinearSpecularRefraction: string;
  21832. /** @hidden */
  21833. _defineOppositeZ: string;
  21834. /** @hidden */
  21835. _cubeSamplerName: string;
  21836. /** @hidden */
  21837. _2DSamplerName: string;
  21838. /** @hidden */
  21839. _vRefractionMicrosurfaceInfosName: string;
  21840. /** @hidden */
  21841. _vRefractionInfosName: string;
  21842. private _scene;
  21843. /**
  21844. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21845. * Materials half opaque for instance using refraction could benefit from this control.
  21846. */
  21847. linkRefractionWithTransparency: boolean;
  21848. /**
  21849. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21850. */
  21851. invertRefractionY: boolean;
  21852. /**
  21853. * Gets or sets the texture associated with the node
  21854. */
  21855. texture: Nullable<BaseTexture>;
  21856. /**
  21857. * Create a new RefractionBlock
  21858. * @param name defines the block name
  21859. */
  21860. constructor(name: string);
  21861. /**
  21862. * Gets the current class name
  21863. * @returns the class name
  21864. */
  21865. getClassName(): string;
  21866. /**
  21867. * Gets the intensity input component
  21868. */
  21869. get intensity(): NodeMaterialConnectionPoint;
  21870. /**
  21871. * Gets the index of refraction input component
  21872. */
  21873. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the tint at distance input component
  21876. */
  21877. get tintAtDistance(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the view input component
  21880. */
  21881. get view(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the refraction object output component
  21884. */
  21885. get refraction(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Returns true if the block has a texture
  21888. */
  21889. get hasTexture(): boolean;
  21890. protected _getTexture(): Nullable<BaseTexture>;
  21891. autoConfigure(material: NodeMaterial): void;
  21892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21893. isReady(): boolean;
  21894. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21895. /**
  21896. * Gets the main code of the block (fragment side)
  21897. * @param state current state of the node material building
  21898. * @returns the shader code
  21899. */
  21900. getCode(state: NodeMaterialBuildState): string;
  21901. protected _buildBlock(state: NodeMaterialBuildState): this;
  21902. protected _dumpPropertiesCode(): string;
  21903. serialize(): any;
  21904. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21905. }
  21906. }
  21907. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21910. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21913. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21915. import { Nullable } from "babylonjs/types";
  21916. import { Scene } from "babylonjs/scene";
  21917. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21918. /**
  21919. * Base block used as input for post process
  21920. */
  21921. export class CurrentScreenBlock extends NodeMaterialBlock {
  21922. private _samplerName;
  21923. private _linearDefineName;
  21924. private _gammaDefineName;
  21925. private _mainUVName;
  21926. private _tempTextureRead;
  21927. /**
  21928. * Gets or sets the texture associated with the node
  21929. */
  21930. texture: Nullable<BaseTexture>;
  21931. /**
  21932. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21933. */
  21934. convertToGammaSpace: boolean;
  21935. /**
  21936. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21937. */
  21938. convertToLinearSpace: boolean;
  21939. /**
  21940. * Create a new CurrentScreenBlock
  21941. * @param name defines the block name
  21942. */
  21943. constructor(name: string);
  21944. /**
  21945. * Gets the current class name
  21946. * @returns the class name
  21947. */
  21948. getClassName(): string;
  21949. /**
  21950. * Gets the uv input component
  21951. */
  21952. get uv(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the rgba output component
  21955. */
  21956. get rgba(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the rgb output component
  21959. */
  21960. get rgb(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the r output component
  21963. */
  21964. get r(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the g output component
  21967. */
  21968. get g(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Gets the b output component
  21971. */
  21972. get b(): NodeMaterialConnectionPoint;
  21973. /**
  21974. * Gets the a output component
  21975. */
  21976. get a(): NodeMaterialConnectionPoint;
  21977. /**
  21978. * Initialize the block and prepare the context for build
  21979. * @param state defines the state that will be used for the build
  21980. */
  21981. initialize(state: NodeMaterialBuildState): void;
  21982. get target(): NodeMaterialBlockTargets;
  21983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21984. isReady(): boolean;
  21985. private _injectVertexCode;
  21986. private _writeTextureRead;
  21987. private _writeOutput;
  21988. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21989. serialize(): any;
  21990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21991. }
  21992. }
  21993. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21998. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22000. import { Nullable } from "babylonjs/types";
  22001. import { Scene } from "babylonjs/scene";
  22002. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22003. /**
  22004. * Base block used for the particle texture
  22005. */
  22006. export class ParticleTextureBlock extends NodeMaterialBlock {
  22007. private _samplerName;
  22008. private _linearDefineName;
  22009. private _gammaDefineName;
  22010. private _tempTextureRead;
  22011. /**
  22012. * Gets or sets the texture associated with the node
  22013. */
  22014. texture: Nullable<BaseTexture>;
  22015. /**
  22016. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22017. */
  22018. convertToGammaSpace: boolean;
  22019. /**
  22020. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22021. */
  22022. convertToLinearSpace: boolean;
  22023. /**
  22024. * Create a new ParticleTextureBlock
  22025. * @param name defines the block name
  22026. */
  22027. constructor(name: string);
  22028. /**
  22029. * Gets the current class name
  22030. * @returns the class name
  22031. */
  22032. getClassName(): string;
  22033. /**
  22034. * Gets the uv input component
  22035. */
  22036. get uv(): NodeMaterialConnectionPoint;
  22037. /**
  22038. * Gets the rgba output component
  22039. */
  22040. get rgba(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the rgb output component
  22043. */
  22044. get rgb(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the r output component
  22047. */
  22048. get r(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the g output component
  22051. */
  22052. get g(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the b output component
  22055. */
  22056. get b(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the a output component
  22059. */
  22060. get a(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Initialize the block and prepare the context for build
  22063. * @param state defines the state that will be used for the build
  22064. */
  22065. initialize(state: NodeMaterialBuildState): void;
  22066. autoConfigure(material: NodeMaterial): void;
  22067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22068. isReady(): boolean;
  22069. private _writeOutput;
  22070. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22071. serialize(): any;
  22072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22073. }
  22074. }
  22075. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22078. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22079. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22080. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22081. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22082. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22083. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22084. import { Scene } from "babylonjs/scene";
  22085. /**
  22086. * Class used to store shared data between 2 NodeMaterialBuildState
  22087. */
  22088. export class NodeMaterialBuildStateSharedData {
  22089. /**
  22090. * Gets the list of emitted varyings
  22091. */
  22092. temps: string[];
  22093. /**
  22094. * Gets the list of emitted varyings
  22095. */
  22096. varyings: string[];
  22097. /**
  22098. * Gets the varying declaration string
  22099. */
  22100. varyingDeclaration: string;
  22101. /**
  22102. * Input blocks
  22103. */
  22104. inputBlocks: InputBlock[];
  22105. /**
  22106. * Input blocks
  22107. */
  22108. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22109. /**
  22110. * Bindable blocks (Blocks that need to set data to the effect)
  22111. */
  22112. bindableBlocks: NodeMaterialBlock[];
  22113. /**
  22114. * List of blocks that can provide a compilation fallback
  22115. */
  22116. blocksWithFallbacks: NodeMaterialBlock[];
  22117. /**
  22118. * List of blocks that can provide a define update
  22119. */
  22120. blocksWithDefines: NodeMaterialBlock[];
  22121. /**
  22122. * List of blocks that can provide a repeatable content
  22123. */
  22124. repeatableContentBlocks: NodeMaterialBlock[];
  22125. /**
  22126. * List of blocks that can provide a dynamic list of uniforms
  22127. */
  22128. dynamicUniformBlocks: NodeMaterialBlock[];
  22129. /**
  22130. * List of blocks that can block the isReady function for the material
  22131. */
  22132. blockingBlocks: NodeMaterialBlock[];
  22133. /**
  22134. * Gets the list of animated inputs
  22135. */
  22136. animatedInputs: InputBlock[];
  22137. /**
  22138. * Build Id used to avoid multiple recompilations
  22139. */
  22140. buildId: number;
  22141. /** List of emitted variables */
  22142. variableNames: {
  22143. [key: string]: number;
  22144. };
  22145. /** List of emitted defines */
  22146. defineNames: {
  22147. [key: string]: number;
  22148. };
  22149. /** Should emit comments? */
  22150. emitComments: boolean;
  22151. /** Emit build activity */
  22152. verbose: boolean;
  22153. /** Gets or sets the hosting scene */
  22154. scene: Scene;
  22155. /**
  22156. * Gets the compilation hints emitted at compilation time
  22157. */
  22158. hints: {
  22159. needWorldViewMatrix: boolean;
  22160. needWorldViewProjectionMatrix: boolean;
  22161. needAlphaBlending: boolean;
  22162. needAlphaTesting: boolean;
  22163. };
  22164. /**
  22165. * List of compilation checks
  22166. */
  22167. checks: {
  22168. emitVertex: boolean;
  22169. emitFragment: boolean;
  22170. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22171. };
  22172. /**
  22173. * Is vertex program allowed to be empty?
  22174. */
  22175. allowEmptyVertexProgram: boolean;
  22176. /** Creates a new shared data */
  22177. constructor();
  22178. /**
  22179. * Emits console errors and exceptions if there is a failing check
  22180. */
  22181. emitErrors(): void;
  22182. }
  22183. }
  22184. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22185. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22186. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22187. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22188. /**
  22189. * Class used to store node based material build state
  22190. */
  22191. export class NodeMaterialBuildState {
  22192. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22193. supportUniformBuffers: boolean;
  22194. /**
  22195. * Gets the list of emitted attributes
  22196. */
  22197. attributes: string[];
  22198. /**
  22199. * Gets the list of emitted uniforms
  22200. */
  22201. uniforms: string[];
  22202. /**
  22203. * Gets the list of emitted constants
  22204. */
  22205. constants: string[];
  22206. /**
  22207. * Gets the list of emitted samplers
  22208. */
  22209. samplers: string[];
  22210. /**
  22211. * Gets the list of emitted functions
  22212. */
  22213. functions: {
  22214. [key: string]: string;
  22215. };
  22216. /**
  22217. * Gets the list of emitted extensions
  22218. */
  22219. extensions: {
  22220. [key: string]: string;
  22221. };
  22222. /**
  22223. * Gets the target of the compilation state
  22224. */
  22225. target: NodeMaterialBlockTargets;
  22226. /**
  22227. * Gets the list of emitted counters
  22228. */
  22229. counters: {
  22230. [key: string]: number;
  22231. };
  22232. /**
  22233. * Shared data between multiple NodeMaterialBuildState instances
  22234. */
  22235. sharedData: NodeMaterialBuildStateSharedData;
  22236. /** @hidden */
  22237. _vertexState: NodeMaterialBuildState;
  22238. /** @hidden */
  22239. _attributeDeclaration: string;
  22240. /** @hidden */
  22241. _uniformDeclaration: string;
  22242. /** @hidden */
  22243. _constantDeclaration: string;
  22244. /** @hidden */
  22245. _samplerDeclaration: string;
  22246. /** @hidden */
  22247. _varyingTransfer: string;
  22248. /** @hidden */
  22249. _injectAtEnd: string;
  22250. private _repeatableContentAnchorIndex;
  22251. /** @hidden */
  22252. _builtCompilationString: string;
  22253. /**
  22254. * Gets the emitted compilation strings
  22255. */
  22256. compilationString: string;
  22257. /**
  22258. * Finalize the compilation strings
  22259. * @param state defines the current compilation state
  22260. */
  22261. finalize(state: NodeMaterialBuildState): void;
  22262. /** @hidden */
  22263. get _repeatableContentAnchor(): string;
  22264. /** @hidden */
  22265. _getFreeVariableName(prefix: string): string;
  22266. /** @hidden */
  22267. _getFreeDefineName(prefix: string): string;
  22268. /** @hidden */
  22269. _excludeVariableName(name: string): void;
  22270. /** @hidden */
  22271. _emit2DSampler(name: string): void;
  22272. /** @hidden */
  22273. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22274. /** @hidden */
  22275. _emitExtension(name: string, extension: string, define?: string): void;
  22276. /** @hidden */
  22277. _emitFunction(name: string, code: string, comments: string): void;
  22278. /** @hidden */
  22279. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22280. replaceStrings?: {
  22281. search: RegExp;
  22282. replace: string;
  22283. }[];
  22284. repeatKey?: string;
  22285. }): string;
  22286. /** @hidden */
  22287. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22288. repeatKey?: string;
  22289. removeAttributes?: boolean;
  22290. removeUniforms?: boolean;
  22291. removeVaryings?: boolean;
  22292. removeIfDef?: boolean;
  22293. replaceStrings?: {
  22294. search: RegExp;
  22295. replace: string;
  22296. }[];
  22297. }, storeKey?: string): void;
  22298. /** @hidden */
  22299. _registerTempVariable(name: string): boolean;
  22300. /** @hidden */
  22301. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22302. /** @hidden */
  22303. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22304. /** @hidden */
  22305. _emitFloat(value: number): string;
  22306. }
  22307. }
  22308. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22309. /**
  22310. * Helper class used to generate session unique ID
  22311. */
  22312. export class UniqueIdGenerator {
  22313. private static _UniqueIdCounter;
  22314. /**
  22315. * Gets an unique (relatively to the current scene) Id
  22316. */
  22317. static get UniqueId(): number;
  22318. }
  22319. }
  22320. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22321. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22323. import { Nullable } from "babylonjs/types";
  22324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22325. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22326. import { Effect } from "babylonjs/Materials/effect";
  22327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22328. import { Mesh } from "babylonjs/Meshes/mesh";
  22329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22330. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22331. import { Scene } from "babylonjs/scene";
  22332. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22333. /**
  22334. * Defines a block that can be used inside a node based material
  22335. */
  22336. export class NodeMaterialBlock {
  22337. private _buildId;
  22338. private _buildTarget;
  22339. private _target;
  22340. private _isFinalMerger;
  22341. private _isInput;
  22342. private _name;
  22343. protected _isUnique: boolean;
  22344. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22345. inputsAreExclusive: boolean;
  22346. /** @hidden */
  22347. _codeVariableName: string;
  22348. /** @hidden */
  22349. _inputs: NodeMaterialConnectionPoint[];
  22350. /** @hidden */
  22351. _outputs: NodeMaterialConnectionPoint[];
  22352. /** @hidden */
  22353. _preparationId: number;
  22354. /**
  22355. * Gets the name of the block
  22356. */
  22357. get name(): string;
  22358. /**
  22359. * Sets the name of the block. Will check if the name is valid.
  22360. */
  22361. set name(newName: string);
  22362. /**
  22363. * Gets or sets the unique id of the node
  22364. */
  22365. uniqueId: number;
  22366. /**
  22367. * Gets or sets the comments associated with this block
  22368. */
  22369. comments: string;
  22370. /**
  22371. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22372. */
  22373. get isUnique(): boolean;
  22374. /**
  22375. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22376. */
  22377. get isFinalMerger(): boolean;
  22378. /**
  22379. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22380. */
  22381. get isInput(): boolean;
  22382. /**
  22383. * Gets or sets the build Id
  22384. */
  22385. get buildId(): number;
  22386. set buildId(value: number);
  22387. /**
  22388. * Gets or sets the target of the block
  22389. */
  22390. get target(): NodeMaterialBlockTargets;
  22391. set target(value: NodeMaterialBlockTargets);
  22392. /**
  22393. * Gets the list of input points
  22394. */
  22395. get inputs(): NodeMaterialConnectionPoint[];
  22396. /** Gets the list of output points */
  22397. get outputs(): NodeMaterialConnectionPoint[];
  22398. /**
  22399. * Find an input by its name
  22400. * @param name defines the name of the input to look for
  22401. * @returns the input or null if not found
  22402. */
  22403. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22404. /**
  22405. * Find an output by its name
  22406. * @param name defines the name of the outputto look for
  22407. * @returns the output or null if not found
  22408. */
  22409. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22410. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22411. visibleInInspector: boolean;
  22412. /**
  22413. * Creates a new NodeMaterialBlock
  22414. * @param name defines the block name
  22415. * @param target defines the target of that block (Vertex by default)
  22416. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22417. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22418. */
  22419. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22420. /**
  22421. * Initialize the block and prepare the context for build
  22422. * @param state defines the state that will be used for the build
  22423. */
  22424. initialize(state: NodeMaterialBuildState): void;
  22425. /**
  22426. * Bind data to effect. Will only be called for blocks with isBindable === true
  22427. * @param effect defines the effect to bind data to
  22428. * @param nodeMaterial defines the hosting NodeMaterial
  22429. * @param mesh defines the mesh that will be rendered
  22430. * @param subMesh defines the submesh that will be rendered
  22431. */
  22432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22433. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22434. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22435. protected _writeFloat(value: number): string;
  22436. /**
  22437. * Gets the current class name e.g. "NodeMaterialBlock"
  22438. * @returns the class name
  22439. */
  22440. getClassName(): string;
  22441. /**
  22442. * Register a new input. Must be called inside a block constructor
  22443. * @param name defines the connection point name
  22444. * @param type defines the connection point type
  22445. * @param isOptional defines a boolean indicating that this input can be omitted
  22446. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22447. * @param point an already created connection point. If not provided, create a new one
  22448. * @returns the current block
  22449. */
  22450. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22451. /**
  22452. * Register a new output. Must be called inside a block constructor
  22453. * @param name defines the connection point name
  22454. * @param type defines the connection point type
  22455. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22456. * @param point an already created connection point. If not provided, create a new one
  22457. * @returns the current block
  22458. */
  22459. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22460. /**
  22461. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22462. * @param forOutput defines an optional connection point to check compatibility with
  22463. * @returns the first available input or null
  22464. */
  22465. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22466. /**
  22467. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22468. * @param forBlock defines an optional block to check compatibility with
  22469. * @returns the first available input or null
  22470. */
  22471. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22472. /**
  22473. * Gets the sibling of the given output
  22474. * @param current defines the current output
  22475. * @returns the next output in the list or null
  22476. */
  22477. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22478. /**
  22479. * Connect current block with another block
  22480. * @param other defines the block to connect with
  22481. * @param options define the various options to help pick the right connections
  22482. * @returns the current block
  22483. */
  22484. connectTo(other: NodeMaterialBlock, options?: {
  22485. input?: string;
  22486. output?: string;
  22487. outputSwizzle?: string;
  22488. }): this | undefined;
  22489. protected _buildBlock(state: NodeMaterialBuildState): void;
  22490. /**
  22491. * Add uniforms, samplers and uniform buffers at compilation time
  22492. * @param state defines the state to update
  22493. * @param nodeMaterial defines the node material requesting the update
  22494. * @param defines defines the material defines to update
  22495. * @param uniformBuffers defines the list of uniform buffer names
  22496. */
  22497. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22498. /**
  22499. * Add potential fallbacks if shader compilation fails
  22500. * @param mesh defines the mesh to be rendered
  22501. * @param fallbacks defines the current prioritized list of fallbacks
  22502. */
  22503. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22504. /**
  22505. * Initialize defines for shader compilation
  22506. * @param mesh defines the mesh to be rendered
  22507. * @param nodeMaterial defines the node material requesting the update
  22508. * @param defines defines the material defines to update
  22509. * @param useInstances specifies that instances should be used
  22510. */
  22511. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22512. /**
  22513. * Update defines for shader compilation
  22514. * @param mesh defines the mesh to be rendered
  22515. * @param nodeMaterial defines the node material requesting the update
  22516. * @param defines defines the material defines to update
  22517. * @param useInstances specifies that instances should be used
  22518. * @param subMesh defines which submesh to render
  22519. */
  22520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22521. /**
  22522. * Lets the block try to connect some inputs automatically
  22523. * @param material defines the hosting NodeMaterial
  22524. */
  22525. autoConfigure(material: NodeMaterial): void;
  22526. /**
  22527. * Function called when a block is declared as repeatable content generator
  22528. * @param vertexShaderState defines the current compilation state for the vertex shader
  22529. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22530. * @param mesh defines the mesh to be rendered
  22531. * @param defines defines the material defines to update
  22532. */
  22533. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22534. /**
  22535. * Checks if the block is ready
  22536. * @param mesh defines the mesh to be rendered
  22537. * @param nodeMaterial defines the node material requesting the update
  22538. * @param defines defines the material defines to update
  22539. * @param useInstances specifies that instances should be used
  22540. * @returns true if the block is ready
  22541. */
  22542. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22543. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22544. private _processBuild;
  22545. /**
  22546. * Validates the new name for the block node.
  22547. * @param newName the new name to be given to the node.
  22548. * @returns false if the name is a reserve word, else true.
  22549. */
  22550. validateBlockName(newName: string): boolean;
  22551. /**
  22552. * Compile the current node and generate the shader code
  22553. * @param state defines the current compilation state (uniforms, samplers, current string)
  22554. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22555. * @returns true if already built
  22556. */
  22557. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22558. protected _inputRename(name: string): string;
  22559. protected _outputRename(name: string): string;
  22560. protected _dumpPropertiesCode(): string;
  22561. /** @hidden */
  22562. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22563. /** @hidden */
  22564. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22565. /**
  22566. * Clone the current block to a new identical block
  22567. * @param scene defines the hosting scene
  22568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22569. * @returns a copy of the current block
  22570. */
  22571. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22572. /**
  22573. * Serializes this block in a JSON representation
  22574. * @returns the serialized block object
  22575. */
  22576. serialize(): any;
  22577. /** @hidden */
  22578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22579. private _deserializePortDisplayNamesAndExposedOnFrame;
  22580. /**
  22581. * Release resources
  22582. */
  22583. dispose(): void;
  22584. }
  22585. }
  22586. declare module "babylonjs/Materials/pushMaterial" {
  22587. import { Nullable } from "babylonjs/types";
  22588. import { Scene } from "babylonjs/scene";
  22589. import { Matrix } from "babylonjs/Maths/math.vector";
  22590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22591. import { Mesh } from "babylonjs/Meshes/mesh";
  22592. import { Material } from "babylonjs/Materials/material";
  22593. import { Effect } from "babylonjs/Materials/effect";
  22594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22595. /**
  22596. * Base class of materials working in push mode in babylon JS
  22597. * @hidden
  22598. */
  22599. export class PushMaterial extends Material {
  22600. protected _activeEffect: Effect;
  22601. protected _normalMatrix: Matrix;
  22602. constructor(name: string, scene: Scene);
  22603. getEffect(): Effect;
  22604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22605. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22606. /**
  22607. * Binds the given world matrix to the active effect
  22608. *
  22609. * @param world the matrix to bind
  22610. */
  22611. bindOnlyWorldMatrix(world: Matrix): void;
  22612. /**
  22613. * Binds the given normal matrix to the active effect
  22614. *
  22615. * @param normalMatrix the matrix to bind
  22616. */
  22617. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22618. bind(world: Matrix, mesh?: Mesh): void;
  22619. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22620. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22621. }
  22622. }
  22623. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22625. /**
  22626. * Root class for all node material optimizers
  22627. */
  22628. export class NodeMaterialOptimizer {
  22629. /**
  22630. * Function used to optimize a NodeMaterial graph
  22631. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22632. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22633. */
  22634. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22635. }
  22636. }
  22637. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22641. import { Scene } from "babylonjs/scene";
  22642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22643. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22644. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22645. /**
  22646. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22647. */
  22648. export class TransformBlock extends NodeMaterialBlock {
  22649. /**
  22650. * Defines the value to use to complement W value to transform it to a Vector4
  22651. */
  22652. complementW: number;
  22653. /**
  22654. * Defines the value to use to complement z value to transform it to a Vector4
  22655. */
  22656. complementZ: number;
  22657. /**
  22658. * Creates a new TransformBlock
  22659. * @param name defines the block name
  22660. */
  22661. constructor(name: string);
  22662. /**
  22663. * Gets the current class name
  22664. * @returns the class name
  22665. */
  22666. getClassName(): string;
  22667. /**
  22668. * Gets the vector input
  22669. */
  22670. get vector(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the output component
  22673. */
  22674. get output(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the xyz output component
  22677. */
  22678. get xyz(): NodeMaterialConnectionPoint;
  22679. /**
  22680. * Gets the matrix transform input
  22681. */
  22682. get transform(): NodeMaterialConnectionPoint;
  22683. protected _buildBlock(state: NodeMaterialBuildState): this;
  22684. /**
  22685. * Update defines for shader compilation
  22686. * @param mesh defines the mesh to be rendered
  22687. * @param nodeMaterial defines the node material requesting the update
  22688. * @param defines defines the material defines to update
  22689. * @param useInstances specifies that instances should be used
  22690. * @param subMesh defines which submesh to render
  22691. */
  22692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22693. serialize(): any;
  22694. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22695. protected _dumpPropertiesCode(): string;
  22696. }
  22697. }
  22698. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22702. /**
  22703. * Block used to output the vertex position
  22704. */
  22705. export class VertexOutputBlock extends NodeMaterialBlock {
  22706. /**
  22707. * Creates a new VertexOutputBlock
  22708. * @param name defines the block name
  22709. */
  22710. constructor(name: string);
  22711. /**
  22712. * Gets the current class name
  22713. * @returns the class name
  22714. */
  22715. getClassName(): string;
  22716. /**
  22717. * Gets the vector input component
  22718. */
  22719. get vector(): NodeMaterialConnectionPoint;
  22720. protected _buildBlock(state: NodeMaterialBuildState): this;
  22721. }
  22722. }
  22723. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22727. /**
  22728. * Block used to output the final color
  22729. */
  22730. export class FragmentOutputBlock extends NodeMaterialBlock {
  22731. /**
  22732. * Create a new FragmentOutputBlock
  22733. * @param name defines the block name
  22734. */
  22735. constructor(name: string);
  22736. /**
  22737. * Gets the current class name
  22738. * @returns the class name
  22739. */
  22740. getClassName(): string;
  22741. /**
  22742. * Gets the rgba input component
  22743. */
  22744. get rgba(): NodeMaterialConnectionPoint;
  22745. /**
  22746. * Gets the rgb input component
  22747. */
  22748. get rgb(): NodeMaterialConnectionPoint;
  22749. /**
  22750. * Gets the a input component
  22751. */
  22752. get a(): NodeMaterialConnectionPoint;
  22753. protected _buildBlock(state: NodeMaterialBuildState): this;
  22754. }
  22755. }
  22756. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22760. /**
  22761. * Block used for the particle ramp gradient section
  22762. */
  22763. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22764. /**
  22765. * Create a new ParticleRampGradientBlock
  22766. * @param name defines the block name
  22767. */
  22768. constructor(name: string);
  22769. /**
  22770. * Gets the current class name
  22771. * @returns the class name
  22772. */
  22773. getClassName(): string;
  22774. /**
  22775. * Gets the color input component
  22776. */
  22777. get color(): NodeMaterialConnectionPoint;
  22778. /**
  22779. * Gets the rampColor output component
  22780. */
  22781. get rampColor(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Initialize the block and prepare the context for build
  22784. * @param state defines the state that will be used for the build
  22785. */
  22786. initialize(state: NodeMaterialBuildState): void;
  22787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22788. }
  22789. }
  22790. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22794. /**
  22795. * Block used for the particle blend multiply section
  22796. */
  22797. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22798. /**
  22799. * Create a new ParticleBlendMultiplyBlock
  22800. * @param name defines the block name
  22801. */
  22802. constructor(name: string);
  22803. /**
  22804. * Gets the current class name
  22805. * @returns the class name
  22806. */
  22807. getClassName(): string;
  22808. /**
  22809. * Gets the color input component
  22810. */
  22811. get color(): NodeMaterialConnectionPoint;
  22812. /**
  22813. * Gets the alphaTexture input component
  22814. */
  22815. get alphaTexture(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the alphaColor input component
  22818. */
  22819. get alphaColor(): NodeMaterialConnectionPoint;
  22820. /**
  22821. * Gets the blendColor output component
  22822. */
  22823. get blendColor(): NodeMaterialConnectionPoint;
  22824. /**
  22825. * Initialize the block and prepare the context for build
  22826. * @param state defines the state that will be used for the build
  22827. */
  22828. initialize(state: NodeMaterialBuildState): void;
  22829. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22830. }
  22831. }
  22832. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22836. /**
  22837. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22838. */
  22839. export class VectorMergerBlock extends NodeMaterialBlock {
  22840. /**
  22841. * Create a new VectorMergerBlock
  22842. * @param name defines the block name
  22843. */
  22844. constructor(name: string);
  22845. /**
  22846. * Gets the current class name
  22847. * @returns the class name
  22848. */
  22849. getClassName(): string;
  22850. /**
  22851. * Gets the xyz component (input)
  22852. */
  22853. get xyzIn(): NodeMaterialConnectionPoint;
  22854. /**
  22855. * Gets the xy component (input)
  22856. */
  22857. get xyIn(): NodeMaterialConnectionPoint;
  22858. /**
  22859. * Gets the x component (input)
  22860. */
  22861. get x(): NodeMaterialConnectionPoint;
  22862. /**
  22863. * Gets the y component (input)
  22864. */
  22865. get y(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the z component (input)
  22868. */
  22869. get z(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Gets the w component (input)
  22872. */
  22873. get w(): NodeMaterialConnectionPoint;
  22874. /**
  22875. * Gets the xyzw component (output)
  22876. */
  22877. get xyzw(): NodeMaterialConnectionPoint;
  22878. /**
  22879. * Gets the xyz component (output)
  22880. */
  22881. get xyzOut(): NodeMaterialConnectionPoint;
  22882. /**
  22883. * Gets the xy component (output)
  22884. */
  22885. get xyOut(): NodeMaterialConnectionPoint;
  22886. /**
  22887. * Gets the xy component (output)
  22888. * @deprecated Please use xyOut instead.
  22889. */
  22890. get xy(): NodeMaterialConnectionPoint;
  22891. /**
  22892. * Gets the xyz component (output)
  22893. * @deprecated Please use xyzOut instead.
  22894. */
  22895. get xyz(): NodeMaterialConnectionPoint;
  22896. protected _buildBlock(state: NodeMaterialBuildState): this;
  22897. }
  22898. }
  22899. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22903. import { Vector2 } from "babylonjs/Maths/math.vector";
  22904. import { Scene } from "babylonjs/scene";
  22905. /**
  22906. * Block used to remap a float from a range to a new one
  22907. */
  22908. export class RemapBlock extends NodeMaterialBlock {
  22909. /**
  22910. * Gets or sets the source range
  22911. */
  22912. sourceRange: Vector2;
  22913. /**
  22914. * Gets or sets the target range
  22915. */
  22916. targetRange: Vector2;
  22917. /**
  22918. * Creates a new RemapBlock
  22919. * @param name defines the block name
  22920. */
  22921. constructor(name: string);
  22922. /**
  22923. * Gets the current class name
  22924. * @returns the class name
  22925. */
  22926. getClassName(): string;
  22927. /**
  22928. * Gets the input component
  22929. */
  22930. get input(): NodeMaterialConnectionPoint;
  22931. /**
  22932. * Gets the source min input component
  22933. */
  22934. get sourceMin(): NodeMaterialConnectionPoint;
  22935. /**
  22936. * Gets the source max input component
  22937. */
  22938. get sourceMax(): NodeMaterialConnectionPoint;
  22939. /**
  22940. * Gets the target min input component
  22941. */
  22942. get targetMin(): NodeMaterialConnectionPoint;
  22943. /**
  22944. * Gets the target max input component
  22945. */
  22946. get targetMax(): NodeMaterialConnectionPoint;
  22947. /**
  22948. * Gets the output component
  22949. */
  22950. get output(): NodeMaterialConnectionPoint;
  22951. protected _buildBlock(state: NodeMaterialBuildState): this;
  22952. protected _dumpPropertiesCode(): string;
  22953. serialize(): any;
  22954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22955. }
  22956. }
  22957. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22961. /**
  22962. * Block used to multiply 2 values
  22963. */
  22964. export class MultiplyBlock extends NodeMaterialBlock {
  22965. /**
  22966. * Creates a new MultiplyBlock
  22967. * @param name defines the block name
  22968. */
  22969. constructor(name: string);
  22970. /**
  22971. * Gets the current class name
  22972. * @returns the class name
  22973. */
  22974. getClassName(): string;
  22975. /**
  22976. * Gets the left operand input component
  22977. */
  22978. get left(): NodeMaterialConnectionPoint;
  22979. /**
  22980. * Gets the right operand input component
  22981. */
  22982. get right(): NodeMaterialConnectionPoint;
  22983. /**
  22984. * Gets the output component
  22985. */
  22986. get output(): NodeMaterialConnectionPoint;
  22987. protected _buildBlock(state: NodeMaterialBuildState): this;
  22988. }
  22989. }
  22990. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22994. /**
  22995. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22996. */
  22997. export class ColorSplitterBlock extends NodeMaterialBlock {
  22998. /**
  22999. * Create a new ColorSplitterBlock
  23000. * @param name defines the block name
  23001. */
  23002. constructor(name: string);
  23003. /**
  23004. * Gets the current class name
  23005. * @returns the class name
  23006. */
  23007. getClassName(): string;
  23008. /**
  23009. * Gets the rgba component (input)
  23010. */
  23011. get rgba(): NodeMaterialConnectionPoint;
  23012. /**
  23013. * Gets the rgb component (input)
  23014. */
  23015. get rgbIn(): NodeMaterialConnectionPoint;
  23016. /**
  23017. * Gets the rgb component (output)
  23018. */
  23019. get rgbOut(): NodeMaterialConnectionPoint;
  23020. /**
  23021. * Gets the r component (output)
  23022. */
  23023. get r(): NodeMaterialConnectionPoint;
  23024. /**
  23025. * Gets the g component (output)
  23026. */
  23027. get g(): NodeMaterialConnectionPoint;
  23028. /**
  23029. * Gets the b component (output)
  23030. */
  23031. get b(): NodeMaterialConnectionPoint;
  23032. /**
  23033. * Gets the a component (output)
  23034. */
  23035. get a(): NodeMaterialConnectionPoint;
  23036. protected _inputRename(name: string): string;
  23037. protected _outputRename(name: string): string;
  23038. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23039. }
  23040. }
  23041. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23045. import { Scene } from "babylonjs/scene";
  23046. /**
  23047. * Operations supported by the Trigonometry block
  23048. */
  23049. export enum TrigonometryBlockOperations {
  23050. /** Cos */
  23051. Cos = 0,
  23052. /** Sin */
  23053. Sin = 1,
  23054. /** Abs */
  23055. Abs = 2,
  23056. /** Exp */
  23057. Exp = 3,
  23058. /** Exp2 */
  23059. Exp2 = 4,
  23060. /** Round */
  23061. Round = 5,
  23062. /** Floor */
  23063. Floor = 6,
  23064. /** Ceiling */
  23065. Ceiling = 7,
  23066. /** Square root */
  23067. Sqrt = 8,
  23068. /** Log */
  23069. Log = 9,
  23070. /** Tangent */
  23071. Tan = 10,
  23072. /** Arc tangent */
  23073. ArcTan = 11,
  23074. /** Arc cosinus */
  23075. ArcCos = 12,
  23076. /** Arc sinus */
  23077. ArcSin = 13,
  23078. /** Fraction */
  23079. Fract = 14,
  23080. /** Sign */
  23081. Sign = 15,
  23082. /** To radians (from degrees) */
  23083. Radians = 16,
  23084. /** To degrees (from radians) */
  23085. Degrees = 17
  23086. }
  23087. /**
  23088. * Block used to apply trigonometry operation to floats
  23089. */
  23090. export class TrigonometryBlock extends NodeMaterialBlock {
  23091. /**
  23092. * Gets or sets the operation applied by the block
  23093. */
  23094. operation: TrigonometryBlockOperations;
  23095. /**
  23096. * Creates a new TrigonometryBlock
  23097. * @param name defines the block name
  23098. */
  23099. constructor(name: string);
  23100. /**
  23101. * Gets the current class name
  23102. * @returns the class name
  23103. */
  23104. getClassName(): string;
  23105. /**
  23106. * Gets the input component
  23107. */
  23108. get input(): NodeMaterialConnectionPoint;
  23109. /**
  23110. * Gets the output component
  23111. */
  23112. get output(): NodeMaterialConnectionPoint;
  23113. protected _buildBlock(state: NodeMaterialBuildState): this;
  23114. serialize(): any;
  23115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23116. protected _dumpPropertiesCode(): string;
  23117. }
  23118. }
  23119. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23121. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23122. import { Scene } from "babylonjs/scene";
  23123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23124. import { Matrix } from "babylonjs/Maths/math.vector";
  23125. import { Mesh } from "babylonjs/Meshes/mesh";
  23126. import { Engine } from "babylonjs/Engines/engine";
  23127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23128. import { Observable } from "babylonjs/Misc/observable";
  23129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23130. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23131. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23132. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23133. import { Nullable } from "babylonjs/types";
  23134. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23135. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23136. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23137. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23138. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23139. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23140. import { Effect } from "babylonjs/Materials/effect";
  23141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23142. import { Camera } from "babylonjs/Cameras/camera";
  23143. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23144. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23145. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23146. /**
  23147. * Interface used to configure the node material editor
  23148. */
  23149. export interface INodeMaterialEditorOptions {
  23150. /** Define the URl to load node editor script */
  23151. editorURL?: string;
  23152. }
  23153. /** @hidden */
  23154. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23155. NORMAL: boolean;
  23156. TANGENT: boolean;
  23157. UV1: boolean;
  23158. /** BONES */
  23159. NUM_BONE_INFLUENCERS: number;
  23160. BonesPerMesh: number;
  23161. BONETEXTURE: boolean;
  23162. /** MORPH TARGETS */
  23163. MORPHTARGETS: boolean;
  23164. MORPHTARGETS_NORMAL: boolean;
  23165. MORPHTARGETS_TANGENT: boolean;
  23166. MORPHTARGETS_UV: boolean;
  23167. NUM_MORPH_INFLUENCERS: number;
  23168. /** IMAGE PROCESSING */
  23169. IMAGEPROCESSING: boolean;
  23170. VIGNETTE: boolean;
  23171. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23172. VIGNETTEBLENDMODEOPAQUE: boolean;
  23173. TONEMAPPING: boolean;
  23174. TONEMAPPING_ACES: boolean;
  23175. CONTRAST: boolean;
  23176. EXPOSURE: boolean;
  23177. COLORCURVES: boolean;
  23178. COLORGRADING: boolean;
  23179. COLORGRADING3D: boolean;
  23180. SAMPLER3DGREENDEPTH: boolean;
  23181. SAMPLER3DBGRMAP: boolean;
  23182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23183. /** MISC. */
  23184. BUMPDIRECTUV: number;
  23185. constructor();
  23186. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23187. }
  23188. /**
  23189. * Class used to configure NodeMaterial
  23190. */
  23191. export interface INodeMaterialOptions {
  23192. /**
  23193. * Defines if blocks should emit comments
  23194. */
  23195. emitComments: boolean;
  23196. }
  23197. /**
  23198. * Class used to create a node based material built by assembling shader blocks
  23199. */
  23200. export class NodeMaterial extends PushMaterial {
  23201. private static _BuildIdGenerator;
  23202. private _options;
  23203. private _vertexCompilationState;
  23204. private _fragmentCompilationState;
  23205. private _sharedData;
  23206. private _buildId;
  23207. private _buildWasSuccessful;
  23208. private _cachedWorldViewMatrix;
  23209. private _cachedWorldViewProjectionMatrix;
  23210. private _optimizers;
  23211. private _animationFrame;
  23212. /** Define the Url to load node editor script */
  23213. static EditorURL: string;
  23214. /** Define the Url to load snippets */
  23215. static SnippetUrl: string;
  23216. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23217. static IgnoreTexturesAtLoadTime: boolean;
  23218. private BJSNODEMATERIALEDITOR;
  23219. /** Get the inspector from bundle or global */
  23220. private _getGlobalNodeMaterialEditor;
  23221. /**
  23222. * Snippet ID if the material was created from the snippet server
  23223. */
  23224. snippetId: string;
  23225. /**
  23226. * Gets or sets data used by visual editor
  23227. * @see https://nme.babylonjs.com
  23228. */
  23229. editorData: any;
  23230. /**
  23231. * 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)
  23232. */
  23233. ignoreAlpha: boolean;
  23234. /**
  23235. * Defines the maximum number of lights that can be used in the material
  23236. */
  23237. maxSimultaneousLights: number;
  23238. /**
  23239. * Observable raised when the material is built
  23240. */
  23241. onBuildObservable: Observable<NodeMaterial>;
  23242. /**
  23243. * Gets or sets the root nodes of the material vertex shader
  23244. */
  23245. _vertexOutputNodes: NodeMaterialBlock[];
  23246. /**
  23247. * Gets or sets the root nodes of the material fragment (pixel) shader
  23248. */
  23249. _fragmentOutputNodes: NodeMaterialBlock[];
  23250. /** Gets or sets options to control the node material overall behavior */
  23251. get options(): INodeMaterialOptions;
  23252. set options(options: INodeMaterialOptions);
  23253. /**
  23254. * Default configuration related to image processing available in the standard Material.
  23255. */
  23256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23257. /**
  23258. * Gets the image processing configuration used either in this material.
  23259. */
  23260. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23261. /**
  23262. * Sets the Default image processing configuration used either in the this material.
  23263. *
  23264. * If sets to null, the scene one is in use.
  23265. */
  23266. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23267. /**
  23268. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23269. */
  23270. attachedBlocks: NodeMaterialBlock[];
  23271. /**
  23272. * Specifies the mode of the node material
  23273. * @hidden
  23274. */
  23275. _mode: NodeMaterialModes;
  23276. /**
  23277. * Gets the mode property
  23278. */
  23279. get mode(): NodeMaterialModes;
  23280. /**
  23281. * Create a new node based material
  23282. * @param name defines the material name
  23283. * @param scene defines the hosting scene
  23284. * @param options defines creation option
  23285. */
  23286. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23287. /**
  23288. * Gets the current class name of the material e.g. "NodeMaterial"
  23289. * @returns the class name
  23290. */
  23291. getClassName(): string;
  23292. /**
  23293. * Keep track of the image processing observer to allow dispose and replace.
  23294. */
  23295. private _imageProcessingObserver;
  23296. /**
  23297. * Attaches a new image processing configuration to the Standard Material.
  23298. * @param configuration
  23299. */
  23300. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23301. /**
  23302. * Get a block by its name
  23303. * @param name defines the name of the block to retrieve
  23304. * @returns the required block or null if not found
  23305. */
  23306. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23307. /**
  23308. * Get a block by its name
  23309. * @param predicate defines the predicate used to find the good candidate
  23310. * @returns the required block or null if not found
  23311. */
  23312. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23313. /**
  23314. * Get an input block by its name
  23315. * @param predicate defines the predicate used to find the good candidate
  23316. * @returns the required input block or null if not found
  23317. */
  23318. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23319. /**
  23320. * Gets the list of input blocks attached to this material
  23321. * @returns an array of InputBlocks
  23322. */
  23323. getInputBlocks(): InputBlock[];
  23324. /**
  23325. * Adds a new optimizer to the list of optimizers
  23326. * @param optimizer defines the optimizers to add
  23327. * @returns the current material
  23328. */
  23329. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23330. /**
  23331. * Remove an optimizer from the list of optimizers
  23332. * @param optimizer defines the optimizers to remove
  23333. * @returns the current material
  23334. */
  23335. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23336. /**
  23337. * Add a new block to the list of output nodes
  23338. * @param node defines the node to add
  23339. * @returns the current material
  23340. */
  23341. addOutputNode(node: NodeMaterialBlock): this;
  23342. /**
  23343. * Remove a block from the list of root nodes
  23344. * @param node defines the node to remove
  23345. * @returns the current material
  23346. */
  23347. removeOutputNode(node: NodeMaterialBlock): this;
  23348. private _addVertexOutputNode;
  23349. private _removeVertexOutputNode;
  23350. private _addFragmentOutputNode;
  23351. private _removeFragmentOutputNode;
  23352. /**
  23353. * Specifies if the material will require alpha blending
  23354. * @returns a boolean specifying if alpha blending is needed
  23355. */
  23356. needAlphaBlending(): boolean;
  23357. /**
  23358. * Specifies if this material should be rendered in alpha test mode
  23359. * @returns a boolean specifying if an alpha test is needed.
  23360. */
  23361. needAlphaTesting(): boolean;
  23362. private _initializeBlock;
  23363. private _resetDualBlocks;
  23364. /**
  23365. * Remove a block from the current node material
  23366. * @param block defines the block to remove
  23367. */
  23368. removeBlock(block: NodeMaterialBlock): void;
  23369. /**
  23370. * Build the material and generates the inner effect
  23371. * @param verbose defines if the build should log activity
  23372. */
  23373. build(verbose?: boolean): void;
  23374. /**
  23375. * Runs an otpimization phase to try to improve the shader code
  23376. */
  23377. optimize(): void;
  23378. private _prepareDefinesForAttributes;
  23379. /**
  23380. * Create a post process from the material
  23381. * @param camera The camera to apply the render pass to.
  23382. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23384. * @param engine The engine which the post process will be applied. (default: current engine)
  23385. * @param reusable If the post process can be reused on the same frame. (default: false)
  23386. * @param textureType Type of textures used when performing the post process. (default: 0)
  23387. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23388. * @returns the post process created
  23389. */
  23390. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23391. /**
  23392. * Create the post process effect from the material
  23393. * @param postProcess The post process to create the effect for
  23394. */
  23395. createEffectForPostProcess(postProcess: PostProcess): void;
  23396. private _createEffectForPostProcess;
  23397. /**
  23398. * Create a new procedural texture based on this node material
  23399. * @param size defines the size of the texture
  23400. * @param scene defines the hosting scene
  23401. * @returns the new procedural texture attached to this node material
  23402. */
  23403. createProceduralTexture(size: number | {
  23404. width: number;
  23405. height: number;
  23406. layers?: number;
  23407. }, scene: Scene): Nullable<ProceduralTexture>;
  23408. private _createEffectForParticles;
  23409. private _checkInternals;
  23410. /**
  23411. * Create the effect to be used as the custom effect for a particle system
  23412. * @param particleSystem Particle system to create the effect for
  23413. * @param onCompiled defines a function to call when the effect creation is successful
  23414. * @param onError defines a function to call when the effect creation has failed
  23415. */
  23416. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23417. private _processDefines;
  23418. /**
  23419. * Get if the submesh is ready to be used and all its information available.
  23420. * Child classes can use it to update shaders
  23421. * @param mesh defines the mesh to check
  23422. * @param subMesh defines which submesh to check
  23423. * @param useInstances specifies that instances should be used
  23424. * @returns a boolean indicating that the submesh is ready or not
  23425. */
  23426. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23427. /**
  23428. * Get a string representing the shaders built by the current node graph
  23429. */
  23430. get compiledShaders(): string;
  23431. /**
  23432. * Binds the world matrix to the material
  23433. * @param world defines the world transformation matrix
  23434. */
  23435. bindOnlyWorldMatrix(world: Matrix): void;
  23436. /**
  23437. * Binds the submesh to this material by preparing the effect and shader to draw
  23438. * @param world defines the world transformation matrix
  23439. * @param mesh defines the mesh containing the submesh
  23440. * @param subMesh defines the submesh to bind the material to
  23441. */
  23442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23443. /**
  23444. * Gets the active textures from the material
  23445. * @returns an array of textures
  23446. */
  23447. getActiveTextures(): BaseTexture[];
  23448. /**
  23449. * Gets the list of texture blocks
  23450. * @returns an array of texture blocks
  23451. */
  23452. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23453. /**
  23454. * Specifies if the material uses a texture
  23455. * @param texture defines the texture to check against the material
  23456. * @returns a boolean specifying if the material uses the texture
  23457. */
  23458. hasTexture(texture: BaseTexture): boolean;
  23459. /**
  23460. * Disposes the material
  23461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23464. */
  23465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23466. /** Creates the node editor window. */
  23467. private _createNodeEditor;
  23468. /**
  23469. * Launch the node material editor
  23470. * @param config Define the configuration of the editor
  23471. * @return a promise fulfilled when the node editor is visible
  23472. */
  23473. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23474. /**
  23475. * Clear the current material
  23476. */
  23477. clear(): void;
  23478. /**
  23479. * Clear the current material and set it to a default state
  23480. */
  23481. setToDefault(): void;
  23482. /**
  23483. * Clear the current material and set it to a default state for post process
  23484. */
  23485. setToDefaultPostProcess(): void;
  23486. /**
  23487. * Clear the current material and set it to a default state for procedural texture
  23488. */
  23489. setToDefaultProceduralTexture(): void;
  23490. /**
  23491. * Clear the current material and set it to a default state for particle
  23492. */
  23493. setToDefaultParticle(): void;
  23494. /**
  23495. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23496. * @param url defines the url to load from
  23497. * @returns a promise that will fullfil when the material is fully loaded
  23498. */
  23499. loadAsync(url: string): Promise<void>;
  23500. private _gatherBlocks;
  23501. /**
  23502. * Generate a string containing the code declaration required to create an equivalent of this material
  23503. * @returns a string
  23504. */
  23505. generateCode(): string;
  23506. /**
  23507. * Serializes this material in a JSON representation
  23508. * @returns the serialized material object
  23509. */
  23510. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23511. private _restoreConnections;
  23512. /**
  23513. * Clear the current graph and load a new one from a serialization object
  23514. * @param source defines the JSON representation of the material
  23515. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23516. * @param merge defines whether or not the source must be merged or replace the current content
  23517. */
  23518. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23519. /**
  23520. * Makes a duplicate of the current material.
  23521. * @param name - name to use for the new material.
  23522. */
  23523. clone(name: string): NodeMaterial;
  23524. /**
  23525. * Creates a node material from parsed material data
  23526. * @param source defines the JSON representation of the material
  23527. * @param scene defines the hosting scene
  23528. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23529. * @returns a new node material
  23530. */
  23531. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23532. /**
  23533. * Creates a node material from a snippet saved in a remote file
  23534. * @param name defines the name of the material to create
  23535. * @param url defines the url to load from
  23536. * @param scene defines the hosting scene
  23537. * @returns a promise that will resolve to the new node material
  23538. */
  23539. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23540. /**
  23541. * Creates a node material from a snippet saved by the node material editor
  23542. * @param snippetId defines the snippet to load
  23543. * @param scene defines the hosting scene
  23544. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23545. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23546. * @returns a promise that will resolve to the new node material
  23547. */
  23548. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23549. /**
  23550. * Creates a new node material set to default basic configuration
  23551. * @param name defines the name of the material
  23552. * @param scene defines the hosting scene
  23553. * @returns a new NodeMaterial
  23554. */
  23555. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23556. }
  23557. }
  23558. declare module "babylonjs/PostProcesses/postProcess" {
  23559. import { Nullable } from "babylonjs/types";
  23560. import { SmartArray } from "babylonjs/Misc/smartArray";
  23561. import { Observable } from "babylonjs/Misc/observable";
  23562. import { Vector2 } from "babylonjs/Maths/math.vector";
  23563. import { Camera } from "babylonjs/Cameras/camera";
  23564. import { Effect } from "babylonjs/Materials/effect";
  23565. import "babylonjs/Shaders/postprocess.vertex";
  23566. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23567. import { Engine } from "babylonjs/Engines/engine";
  23568. import { Color4 } from "babylonjs/Maths/math.color";
  23569. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23570. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23571. import { Scene } from "babylonjs/scene";
  23572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23573. /**
  23574. * Size options for a post process
  23575. */
  23576. export type PostProcessOptions = {
  23577. width: number;
  23578. height: number;
  23579. };
  23580. /**
  23581. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23582. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23583. */
  23584. export class PostProcess {
  23585. /**
  23586. * Gets or sets the unique id of the post process
  23587. */
  23588. uniqueId: number;
  23589. /** Name of the PostProcess. */
  23590. name: string;
  23591. /**
  23592. * Width of the texture to apply the post process on
  23593. */
  23594. width: number;
  23595. /**
  23596. * Height of the texture to apply the post process on
  23597. */
  23598. height: number;
  23599. /**
  23600. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23601. */
  23602. nodeMaterialSource: Nullable<NodeMaterial>;
  23603. /**
  23604. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23605. * @hidden
  23606. */
  23607. _outputTexture: Nullable<InternalTexture>;
  23608. /**
  23609. * Sampling mode used by the shader
  23610. * See https://doc.babylonjs.com/classes/3.1/texture
  23611. */
  23612. renderTargetSamplingMode: number;
  23613. /**
  23614. * Clear color to use when screen clearing
  23615. */
  23616. clearColor: Color4;
  23617. /**
  23618. * If the buffer needs to be cleared before applying the post process. (default: true)
  23619. * Should be set to false if shader will overwrite all previous pixels.
  23620. */
  23621. autoClear: boolean;
  23622. /**
  23623. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23624. */
  23625. alphaMode: number;
  23626. /**
  23627. * Sets the setAlphaBlendConstants of the babylon engine
  23628. */
  23629. alphaConstants: Color4;
  23630. /**
  23631. * Animations to be used for the post processing
  23632. */
  23633. animations: import("babylonjs/Animations/animation").Animation[];
  23634. /**
  23635. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23636. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23637. */
  23638. enablePixelPerfectMode: boolean;
  23639. /**
  23640. * Force the postprocess to be applied without taking in account viewport
  23641. */
  23642. forceFullscreenViewport: boolean;
  23643. /**
  23644. * List of inspectable custom properties (used by the Inspector)
  23645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23646. */
  23647. inspectableCustomProperties: IInspectable[];
  23648. /**
  23649. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23650. *
  23651. * | Value | Type | Description |
  23652. * | ----- | ----------------------------------- | ----------- |
  23653. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23654. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23655. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23656. *
  23657. */
  23658. scaleMode: number;
  23659. /**
  23660. * Force textures to be a power of two (default: false)
  23661. */
  23662. alwaysForcePOT: boolean;
  23663. private _samples;
  23664. /**
  23665. * Number of sample textures (default: 1)
  23666. */
  23667. get samples(): number;
  23668. set samples(n: number);
  23669. /**
  23670. * Modify the scale of the post process to be the same as the viewport (default: false)
  23671. */
  23672. adaptScaleToCurrentViewport: boolean;
  23673. private _camera;
  23674. protected _scene: Scene;
  23675. private _engine;
  23676. private _options;
  23677. private _reusable;
  23678. private _textureType;
  23679. private _textureFormat;
  23680. /**
  23681. * Smart array of input and output textures for the post process.
  23682. * @hidden
  23683. */
  23684. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23685. /**
  23686. * The index in _textures that corresponds to the output texture.
  23687. * @hidden
  23688. */
  23689. _currentRenderTextureInd: number;
  23690. private _effect;
  23691. private _samplers;
  23692. private _fragmentUrl;
  23693. private _vertexUrl;
  23694. private _parameters;
  23695. private _scaleRatio;
  23696. protected _indexParameters: any;
  23697. private _shareOutputWithPostProcess;
  23698. private _texelSize;
  23699. private _forcedOutputTexture;
  23700. /**
  23701. * Returns the fragment url or shader name used in the post process.
  23702. * @returns the fragment url or name in the shader store.
  23703. */
  23704. getEffectName(): string;
  23705. /**
  23706. * An event triggered when the postprocess is activated.
  23707. */
  23708. onActivateObservable: Observable<Camera>;
  23709. private _onActivateObserver;
  23710. /**
  23711. * A function that is added to the onActivateObservable
  23712. */
  23713. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23714. /**
  23715. * An event triggered when the postprocess changes its size.
  23716. */
  23717. onSizeChangedObservable: Observable<PostProcess>;
  23718. private _onSizeChangedObserver;
  23719. /**
  23720. * A function that is added to the onSizeChangedObservable
  23721. */
  23722. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23723. /**
  23724. * An event triggered when the postprocess applies its effect.
  23725. */
  23726. onApplyObservable: Observable<Effect>;
  23727. private _onApplyObserver;
  23728. /**
  23729. * A function that is added to the onApplyObservable
  23730. */
  23731. set onApply(callback: (effect: Effect) => void);
  23732. /**
  23733. * An event triggered before rendering the postprocess
  23734. */
  23735. onBeforeRenderObservable: Observable<Effect>;
  23736. private _onBeforeRenderObserver;
  23737. /**
  23738. * A function that is added to the onBeforeRenderObservable
  23739. */
  23740. set onBeforeRender(callback: (effect: Effect) => void);
  23741. /**
  23742. * An event triggered after rendering the postprocess
  23743. */
  23744. onAfterRenderObservable: Observable<Effect>;
  23745. private _onAfterRenderObserver;
  23746. /**
  23747. * A function that is added to the onAfterRenderObservable
  23748. */
  23749. set onAfterRender(callback: (efect: Effect) => void);
  23750. /**
  23751. * 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
  23752. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23753. */
  23754. get inputTexture(): InternalTexture;
  23755. set inputTexture(value: InternalTexture);
  23756. /**
  23757. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23758. * the only way to unset it is to use this function to restore its internal state
  23759. */
  23760. restoreDefaultInputTexture(): void;
  23761. /**
  23762. * Gets the camera which post process is applied to.
  23763. * @returns The camera the post process is applied to.
  23764. */
  23765. getCamera(): Camera;
  23766. /**
  23767. * Gets the texel size of the postprocess.
  23768. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23769. */
  23770. get texelSize(): Vector2;
  23771. /**
  23772. * Creates a new instance PostProcess
  23773. * @param name The name of the PostProcess.
  23774. * @param fragmentUrl The url of the fragment shader to be used.
  23775. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23776. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23777. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23778. * @param camera The camera to apply the render pass to.
  23779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23780. * @param engine The engine which the post process will be applied. (default: current engine)
  23781. * @param reusable If the post process can be reused on the same frame. (default: false)
  23782. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23783. * @param textureType Type of textures used when performing the post process. (default: 0)
  23784. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23785. * @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
  23786. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23787. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23788. */
  23789. 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);
  23790. /**
  23791. * Gets a string identifying the name of the class
  23792. * @returns "PostProcess" string
  23793. */
  23794. getClassName(): string;
  23795. /**
  23796. * Gets the engine which this post process belongs to.
  23797. * @returns The engine the post process was enabled with.
  23798. */
  23799. getEngine(): Engine;
  23800. /**
  23801. * The effect that is created when initializing the post process.
  23802. * @returns The created effect corresponding the the postprocess.
  23803. */
  23804. getEffect(): Effect;
  23805. /**
  23806. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23807. * @param postProcess The post process to share the output with.
  23808. * @returns This post process.
  23809. */
  23810. shareOutputWith(postProcess: PostProcess): PostProcess;
  23811. /**
  23812. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23813. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23814. */
  23815. useOwnOutput(): void;
  23816. /**
  23817. * Updates the effect with the current post process compile time values and recompiles the shader.
  23818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23821. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23822. * @param onCompiled Called when the shader has been compiled.
  23823. * @param onError Called if there is an error when compiling a shader.
  23824. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23825. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23826. */
  23827. 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;
  23828. /**
  23829. * The post process is reusable if it can be used multiple times within one frame.
  23830. * @returns If the post process is reusable
  23831. */
  23832. isReusable(): boolean;
  23833. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23834. markTextureDirty(): void;
  23835. /**
  23836. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23837. * 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.
  23838. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23839. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23840. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23841. * @returns The target texture that was bound to be written to.
  23842. */
  23843. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23844. /**
  23845. * If the post process is supported.
  23846. */
  23847. get isSupported(): boolean;
  23848. /**
  23849. * The aspect ratio of the output texture.
  23850. */
  23851. get aspectRatio(): number;
  23852. /**
  23853. * Get a value indicating if the post-process is ready to be used
  23854. * @returns true if the post-process is ready (shader is compiled)
  23855. */
  23856. isReady(): boolean;
  23857. /**
  23858. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23859. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23860. */
  23861. apply(): Nullable<Effect>;
  23862. private _disposeTextures;
  23863. /**
  23864. * Disposes the post process.
  23865. * @param camera The camera to dispose the post process on.
  23866. */
  23867. dispose(camera?: Camera): void;
  23868. /**
  23869. * Serializes the particle system to a JSON object
  23870. * @returns the JSON object
  23871. */
  23872. serialize(): any;
  23873. /**
  23874. * Creates a material from parsed material data
  23875. * @param parsedPostProcess defines parsed post process data
  23876. * @param scene defines the hosting scene
  23877. * @param rootUrl defines the root URL to use to load textures
  23878. * @returns a new post process
  23879. */
  23880. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23881. }
  23882. }
  23883. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23884. /** @hidden */
  23885. export var kernelBlurVaryingDeclaration: {
  23886. name: string;
  23887. shader: string;
  23888. };
  23889. }
  23890. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23891. /** @hidden */
  23892. export var kernelBlurFragment: {
  23893. name: string;
  23894. shader: string;
  23895. };
  23896. }
  23897. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23898. /** @hidden */
  23899. export var kernelBlurFragment2: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23905. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23906. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23907. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23908. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23909. /** @hidden */
  23910. export var kernelBlurPixelShader: {
  23911. name: string;
  23912. shader: string;
  23913. };
  23914. }
  23915. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23916. /** @hidden */
  23917. export var kernelBlurVertex: {
  23918. name: string;
  23919. shader: string;
  23920. };
  23921. }
  23922. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23923. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23924. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23925. /** @hidden */
  23926. export var kernelBlurVertexShader: {
  23927. name: string;
  23928. shader: string;
  23929. };
  23930. }
  23931. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23932. import { Vector2 } from "babylonjs/Maths/math.vector";
  23933. import { Nullable } from "babylonjs/types";
  23934. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23935. import { Camera } from "babylonjs/Cameras/camera";
  23936. import { Effect } from "babylonjs/Materials/effect";
  23937. import { Engine } from "babylonjs/Engines/engine";
  23938. import "babylonjs/Shaders/kernelBlur.fragment";
  23939. import "babylonjs/Shaders/kernelBlur.vertex";
  23940. import { Scene } from "babylonjs/scene";
  23941. /**
  23942. * The Blur Post Process which blurs an image based on a kernel and direction.
  23943. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23944. */
  23945. export class BlurPostProcess extends PostProcess {
  23946. private blockCompilation;
  23947. protected _kernel: number;
  23948. protected _idealKernel: number;
  23949. protected _packedFloat: boolean;
  23950. private _staticDefines;
  23951. /** The direction in which to blur the image. */
  23952. direction: Vector2;
  23953. /**
  23954. * Sets the length in pixels of the blur sample region
  23955. */
  23956. set kernel(v: number);
  23957. /**
  23958. * Gets the length in pixels of the blur sample region
  23959. */
  23960. get kernel(): number;
  23961. /**
  23962. * Sets wether or not the blur needs to unpack/repack floats
  23963. */
  23964. set packedFloat(v: boolean);
  23965. /**
  23966. * Gets wether or not the blur is unpacking/repacking floats
  23967. */
  23968. get packedFloat(): boolean;
  23969. /**
  23970. * Gets a string identifying the name of the class
  23971. * @returns "BlurPostProcess" string
  23972. */
  23973. getClassName(): string;
  23974. /**
  23975. * Creates a new instance BlurPostProcess
  23976. * @param name The name of the effect.
  23977. * @param direction The direction in which to blur the image.
  23978. * @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.
  23979. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23980. * @param camera The camera to apply the render pass to.
  23981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23982. * @param engine The engine which the post process will be applied. (default: current engine)
  23983. * @param reusable If the post process can be reused on the same frame. (default: false)
  23984. * @param textureType Type of textures used when performing the post process. (default: 0)
  23985. * @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)
  23986. */
  23987. 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);
  23988. /**
  23989. * Updates the effect with the current post process compile time values and recompiles the shader.
  23990. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23991. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23992. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23993. * @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
  23994. * @param onCompiled Called when the shader has been compiled.
  23995. * @param onError Called if there is an error when compiling a shader.
  23996. */
  23997. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23998. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23999. /**
  24000. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24001. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24002. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24003. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24004. * The gaps between physical kernels are compensated for in the weighting of the samples
  24005. * @param idealKernel Ideal blur kernel.
  24006. * @return Nearest best kernel.
  24007. */
  24008. protected _nearestBestKernel(idealKernel: number): number;
  24009. /**
  24010. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24011. * @param x The point on the Gaussian distribution to sample.
  24012. * @return the value of the Gaussian function at x.
  24013. */
  24014. protected _gaussianWeight(x: number): number;
  24015. /**
  24016. * Generates a string that can be used as a floating point number in GLSL.
  24017. * @param x Value to print.
  24018. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24019. * @return GLSL float string.
  24020. */
  24021. protected _glslFloat(x: number, decimalFigures?: number): string;
  24022. /** @hidden */
  24023. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24024. }
  24025. }
  24026. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24027. import { Scene } from "babylonjs/scene";
  24028. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24029. import { Plane } from "babylonjs/Maths/math.plane";
  24030. /**
  24031. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24032. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24033. * You can then easily use it as a reflectionTexture on a flat surface.
  24034. * In case the surface is not a plane, please consider relying on reflection probes.
  24035. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24036. */
  24037. export class MirrorTexture extends RenderTargetTexture {
  24038. private scene;
  24039. /**
  24040. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24041. * 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.
  24042. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24043. */
  24044. mirrorPlane: Plane;
  24045. /**
  24046. * Define the blur ratio used to blur the reflection if needed.
  24047. */
  24048. set blurRatio(value: number);
  24049. get blurRatio(): number;
  24050. /**
  24051. * Define the adaptive blur kernel used to blur the reflection if needed.
  24052. * This will autocompute the closest best match for the `blurKernel`
  24053. */
  24054. set adaptiveBlurKernel(value: number);
  24055. /**
  24056. * Define the blur kernel used to blur the reflection if needed.
  24057. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24058. */
  24059. set blurKernel(value: number);
  24060. /**
  24061. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24062. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24063. */
  24064. set blurKernelX(value: number);
  24065. get blurKernelX(): number;
  24066. /**
  24067. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24069. */
  24070. set blurKernelY(value: number);
  24071. get blurKernelY(): number;
  24072. private _autoComputeBlurKernel;
  24073. protected _onRatioRescale(): void;
  24074. private _updateGammaSpace;
  24075. private _imageProcessingConfigChangeObserver;
  24076. private _transformMatrix;
  24077. private _mirrorMatrix;
  24078. private _savedViewMatrix;
  24079. private _blurX;
  24080. private _blurY;
  24081. private _adaptiveBlurKernel;
  24082. private _blurKernelX;
  24083. private _blurKernelY;
  24084. private _blurRatio;
  24085. /**
  24086. * Instantiates a Mirror Texture.
  24087. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24088. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24089. * You can then easily use it as a reflectionTexture on a flat surface.
  24090. * In case the surface is not a plane, please consider relying on reflection probes.
  24091. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24092. * @param name
  24093. * @param size
  24094. * @param scene
  24095. * @param generateMipMaps
  24096. * @param type
  24097. * @param samplingMode
  24098. * @param generateDepthBuffer
  24099. */
  24100. constructor(name: string, size: number | {
  24101. width: number;
  24102. height: number;
  24103. } | {
  24104. ratio: number;
  24105. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24106. private _preparePostProcesses;
  24107. /**
  24108. * Clone the mirror texture.
  24109. * @returns the cloned texture
  24110. */
  24111. clone(): MirrorTexture;
  24112. /**
  24113. * Serialize the texture to a JSON representation you could use in Parse later on
  24114. * @returns the serialized JSON representation
  24115. */
  24116. serialize(): any;
  24117. /**
  24118. * Dispose the texture and release its associated resources.
  24119. */
  24120. dispose(): void;
  24121. }
  24122. }
  24123. declare module "babylonjs/Materials/Textures/texture" {
  24124. import { Observable } from "babylonjs/Misc/observable";
  24125. import { Nullable } from "babylonjs/types";
  24126. import { Matrix } from "babylonjs/Maths/math.vector";
  24127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24128. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24129. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24130. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24131. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24133. import { Scene } from "babylonjs/scene";
  24134. /**
  24135. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24136. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24137. */
  24138. export class Texture extends BaseTexture {
  24139. /**
  24140. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24141. */
  24142. static SerializeBuffers: boolean;
  24143. /** @hidden */
  24144. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24145. /** @hidden */
  24146. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24147. /** @hidden */
  24148. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24149. /** nearest is mag = nearest and min = nearest and mip = linear */
  24150. static readonly NEAREST_SAMPLINGMODE: number;
  24151. /** nearest is mag = nearest and min = nearest and mip = linear */
  24152. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24153. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24154. static readonly BILINEAR_SAMPLINGMODE: number;
  24155. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24156. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24157. /** Trilinear is mag = linear and min = linear and mip = linear */
  24158. static readonly TRILINEAR_SAMPLINGMODE: number;
  24159. /** Trilinear is mag = linear and min = linear and mip = linear */
  24160. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24161. /** mag = nearest and min = nearest and mip = nearest */
  24162. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24163. /** mag = nearest and min = linear and mip = nearest */
  24164. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24165. /** mag = nearest and min = linear and mip = linear */
  24166. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24167. /** mag = nearest and min = linear and mip = none */
  24168. static readonly NEAREST_LINEAR: number;
  24169. /** mag = nearest and min = nearest and mip = none */
  24170. static readonly NEAREST_NEAREST: number;
  24171. /** mag = linear and min = nearest and mip = nearest */
  24172. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24173. /** mag = linear and min = nearest and mip = linear */
  24174. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24175. /** mag = linear and min = linear and mip = none */
  24176. static readonly LINEAR_LINEAR: number;
  24177. /** mag = linear and min = nearest and mip = none */
  24178. static readonly LINEAR_NEAREST: number;
  24179. /** Explicit coordinates mode */
  24180. static readonly EXPLICIT_MODE: number;
  24181. /** Spherical coordinates mode */
  24182. static readonly SPHERICAL_MODE: number;
  24183. /** Planar coordinates mode */
  24184. static readonly PLANAR_MODE: number;
  24185. /** Cubic coordinates mode */
  24186. static readonly CUBIC_MODE: number;
  24187. /** Projection coordinates mode */
  24188. static readonly PROJECTION_MODE: number;
  24189. /** Inverse Cubic coordinates mode */
  24190. static readonly SKYBOX_MODE: number;
  24191. /** Inverse Cubic coordinates mode */
  24192. static readonly INVCUBIC_MODE: number;
  24193. /** Equirectangular coordinates mode */
  24194. static readonly EQUIRECTANGULAR_MODE: number;
  24195. /** Equirectangular Fixed coordinates mode */
  24196. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24197. /** Equirectangular Fixed Mirrored coordinates mode */
  24198. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24199. /** Texture is not repeating outside of 0..1 UVs */
  24200. static readonly CLAMP_ADDRESSMODE: number;
  24201. /** Texture is repeating outside of 0..1 UVs */
  24202. static readonly WRAP_ADDRESSMODE: number;
  24203. /** Texture is repeating and mirrored */
  24204. static readonly MIRROR_ADDRESSMODE: number;
  24205. /**
  24206. * 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
  24207. */
  24208. static UseSerializedUrlIfAny: boolean;
  24209. /**
  24210. * Define the url of the texture.
  24211. */
  24212. url: Nullable<string>;
  24213. /**
  24214. * Define an offset on the texture to offset the u coordinates of the UVs
  24215. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24216. */
  24217. uOffset: number;
  24218. /**
  24219. * Define an offset on the texture to offset the v coordinates of the UVs
  24220. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24221. */
  24222. vOffset: number;
  24223. /**
  24224. * Define an offset on the texture to scale the u coordinates of the UVs
  24225. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24226. */
  24227. uScale: number;
  24228. /**
  24229. * Define an offset on the texture to scale the v coordinates of the UVs
  24230. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24231. */
  24232. vScale: number;
  24233. /**
  24234. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24235. * @see https://doc.babylonjs.com/how_to/more_materials
  24236. */
  24237. uAng: number;
  24238. /**
  24239. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24240. * @see https://doc.babylonjs.com/how_to/more_materials
  24241. */
  24242. vAng: number;
  24243. /**
  24244. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24245. * @see https://doc.babylonjs.com/how_to/more_materials
  24246. */
  24247. wAng: number;
  24248. /**
  24249. * Defines the center of rotation (U)
  24250. */
  24251. uRotationCenter: number;
  24252. /**
  24253. * Defines the center of rotation (V)
  24254. */
  24255. vRotationCenter: number;
  24256. /**
  24257. * Defines the center of rotation (W)
  24258. */
  24259. wRotationCenter: number;
  24260. /**
  24261. * Are mip maps generated for this texture or not.
  24262. */
  24263. get noMipmap(): boolean;
  24264. /**
  24265. * List of inspectable custom properties (used by the Inspector)
  24266. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24267. */
  24268. inspectableCustomProperties: Nullable<IInspectable[]>;
  24269. private _noMipmap;
  24270. /** @hidden */
  24271. _invertY: boolean;
  24272. private _rowGenerationMatrix;
  24273. private _cachedTextureMatrix;
  24274. private _projectionModeMatrix;
  24275. private _t0;
  24276. private _t1;
  24277. private _t2;
  24278. private _cachedUOffset;
  24279. private _cachedVOffset;
  24280. private _cachedUScale;
  24281. private _cachedVScale;
  24282. private _cachedUAng;
  24283. private _cachedVAng;
  24284. private _cachedWAng;
  24285. private _cachedProjectionMatrixId;
  24286. private _cachedCoordinatesMode;
  24287. /** @hidden */
  24288. protected _initialSamplingMode: number;
  24289. /** @hidden */
  24290. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24291. private _deleteBuffer;
  24292. protected _format: Nullable<number>;
  24293. private _delayedOnLoad;
  24294. private _delayedOnError;
  24295. private _mimeType?;
  24296. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24297. get mimeType(): string | undefined;
  24298. /**
  24299. * Observable triggered once the texture has been loaded.
  24300. */
  24301. onLoadObservable: Observable<Texture>;
  24302. protected _isBlocking: boolean;
  24303. /**
  24304. * Is the texture preventing material to render while loading.
  24305. * If false, a default texture will be used instead of the loading one during the preparation step.
  24306. */
  24307. set isBlocking(value: boolean);
  24308. get isBlocking(): boolean;
  24309. /**
  24310. * Get the current sampling mode associated with the texture.
  24311. */
  24312. get samplingMode(): number;
  24313. /**
  24314. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24315. */
  24316. get invertY(): boolean;
  24317. /**
  24318. * Instantiates a new texture.
  24319. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24320. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24321. * @param url defines the url of the picture to load as a texture
  24322. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24323. * @param noMipmap defines if the texture will require mip maps or not
  24324. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24325. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24326. * @param onLoad defines a callback triggered when the texture has been loaded
  24327. * @param onError defines a callback triggered when an error occurred during the loading session
  24328. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24329. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24330. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24331. * @param mimeType defines an optional mime type information
  24332. */
  24333. 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);
  24334. /**
  24335. * Update the url (and optional buffer) of this texture if url was null during construction.
  24336. * @param url the url of the texture
  24337. * @param buffer the buffer of the texture (defaults to null)
  24338. * @param onLoad callback called when the texture is loaded (defaults to null)
  24339. */
  24340. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24341. /**
  24342. * Finish the loading sequence of a texture flagged as delayed load.
  24343. * @hidden
  24344. */
  24345. delayLoad(): void;
  24346. private _prepareRowForTextureGeneration;
  24347. /**
  24348. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24349. * @returns the transform matrix of the texture.
  24350. */
  24351. getTextureMatrix(uBase?: number): Matrix;
  24352. /**
  24353. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24354. * @returns The reflection texture transform
  24355. */
  24356. getReflectionTextureMatrix(): Matrix;
  24357. /**
  24358. * Clones the texture.
  24359. * @returns the cloned texture
  24360. */
  24361. clone(): Texture;
  24362. /**
  24363. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24364. * @returns The JSON representation of the texture
  24365. */
  24366. serialize(): any;
  24367. /**
  24368. * Get the current class name of the texture useful for serialization or dynamic coding.
  24369. * @returns "Texture"
  24370. */
  24371. getClassName(): string;
  24372. /**
  24373. * Dispose the texture and release its associated resources.
  24374. */
  24375. dispose(): void;
  24376. /**
  24377. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24378. * @param parsedTexture Define the JSON representation of the texture
  24379. * @param scene Define the scene the parsed texture should be instantiated in
  24380. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24381. * @returns The parsed texture if successful
  24382. */
  24383. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24384. /**
  24385. * Creates a texture from its base 64 representation.
  24386. * @param data Define the base64 payload without the data: prefix
  24387. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24388. * @param scene Define the scene the texture should belong to
  24389. * @param noMipmap Forces the texture to not create mip map information if true
  24390. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24391. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24392. * @param onLoad define a callback triggered when the texture has been loaded
  24393. * @param onError define a callback triggered when an error occurred during the loading session
  24394. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24395. * @returns the created texture
  24396. */
  24397. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24398. /**
  24399. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24400. * @param data Define the base64 payload without the data: prefix
  24401. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24402. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24403. * @param scene Define the scene the texture should belong to
  24404. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24405. * @param noMipmap Forces the texture to not create mip map information if true
  24406. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24407. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24408. * @param onLoad define a callback triggered when the texture has been loaded
  24409. * @param onError define a callback triggered when an error occurred during the loading session
  24410. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24411. * @returns the created texture
  24412. */
  24413. 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;
  24414. }
  24415. }
  24416. declare module "babylonjs/PostProcesses/postProcessManager" {
  24417. import { Nullable } from "babylonjs/types";
  24418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24420. import { Scene } from "babylonjs/scene";
  24421. /**
  24422. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24423. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24424. */
  24425. export class PostProcessManager {
  24426. private _scene;
  24427. private _indexBuffer;
  24428. private _vertexBuffers;
  24429. /**
  24430. * Creates a new instance PostProcess
  24431. * @param scene The scene that the post process is associated with.
  24432. */
  24433. constructor(scene: Scene);
  24434. private _prepareBuffers;
  24435. private _buildIndexBuffer;
  24436. /**
  24437. * Rebuilds the vertex buffers of the manager.
  24438. * @hidden
  24439. */
  24440. _rebuild(): void;
  24441. /**
  24442. * Prepares a frame to be run through a post process.
  24443. * @param sourceTexture The input texture to the post procesess. (default: null)
  24444. * @param postProcesses An array of post processes to be run. (default: null)
  24445. * @returns True if the post processes were able to be run.
  24446. * @hidden
  24447. */
  24448. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24449. /**
  24450. * Manually render a set of post processes to a texture.
  24451. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24452. * @param postProcesses An array of post processes to be run.
  24453. * @param targetTexture The target texture to render to.
  24454. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24455. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24456. * @param lodLevel defines which lod of the texture to render to
  24457. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24458. */
  24459. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24460. /**
  24461. * Finalize the result of the output of the postprocesses.
  24462. * @param doNotPresent If true the result will not be displayed to the screen.
  24463. * @param targetTexture The target texture to render to.
  24464. * @param faceIndex The index of the face to bind the target texture to.
  24465. * @param postProcesses The array of post processes to render.
  24466. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24467. * @hidden
  24468. */
  24469. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24470. /**
  24471. * Disposes of the post process manager.
  24472. */
  24473. dispose(): void;
  24474. }
  24475. }
  24476. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24477. import { Observable } from "babylonjs/Misc/observable";
  24478. import { SmartArray } from "babylonjs/Misc/smartArray";
  24479. import { Nullable, Immutable } from "babylonjs/types";
  24480. import { Camera } from "babylonjs/Cameras/camera";
  24481. import { Scene } from "babylonjs/scene";
  24482. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24483. import { Color4 } from "babylonjs/Maths/math.color";
  24484. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24486. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24488. import { Texture } from "babylonjs/Materials/Textures/texture";
  24489. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24490. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24491. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24492. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24493. import { Engine } from "babylonjs/Engines/engine";
  24494. /**
  24495. * This Helps creating a texture that will be created from a camera in your scene.
  24496. * It is basically a dynamic texture that could be used to create special effects for instance.
  24497. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24498. */
  24499. export class RenderTargetTexture extends Texture {
  24500. /**
  24501. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24502. */
  24503. static readonly REFRESHRATE_RENDER_ONCE: number;
  24504. /**
  24505. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24506. */
  24507. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24508. /**
  24509. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24510. * the central point of your effect and can save a lot of performances.
  24511. */
  24512. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24513. /**
  24514. * Use this predicate to dynamically define the list of mesh you want to render.
  24515. * If set, the renderList property will be overwritten.
  24516. */
  24517. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24518. private _renderList;
  24519. /**
  24520. * Use this list to define the list of mesh you want to render.
  24521. */
  24522. get renderList(): Nullable<Array<AbstractMesh>>;
  24523. set renderList(value: Nullable<Array<AbstractMesh>>);
  24524. /**
  24525. * Use this function to overload the renderList array at rendering time.
  24526. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24527. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24528. * the cube (if the RTT is a cube, else layerOrFace=0).
  24529. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24530. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24531. * hold dummy elements!
  24532. */
  24533. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24534. private _hookArray;
  24535. /**
  24536. * Define if particles should be rendered in your texture.
  24537. */
  24538. renderParticles: boolean;
  24539. /**
  24540. * Define if sprites should be rendered in your texture.
  24541. */
  24542. renderSprites: boolean;
  24543. /**
  24544. * Define the camera used to render the texture.
  24545. */
  24546. activeCamera: Nullable<Camera>;
  24547. /**
  24548. * Override the mesh isReady function with your own one.
  24549. */
  24550. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24551. /**
  24552. * Override the render function of the texture with your own one.
  24553. */
  24554. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24555. /**
  24556. * Define if camera post processes should be use while rendering the texture.
  24557. */
  24558. useCameraPostProcesses: boolean;
  24559. /**
  24560. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24561. */
  24562. ignoreCameraViewport: boolean;
  24563. private _postProcessManager;
  24564. private _postProcesses;
  24565. private _resizeObserver;
  24566. /**
  24567. * An event triggered when the texture is unbind.
  24568. */
  24569. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24570. /**
  24571. * An event triggered when the texture is unbind.
  24572. */
  24573. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24574. private _onAfterUnbindObserver;
  24575. /**
  24576. * Set a after unbind callback in the texture.
  24577. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24578. */
  24579. set onAfterUnbind(callback: () => void);
  24580. /**
  24581. * An event triggered before rendering the texture
  24582. */
  24583. onBeforeRenderObservable: Observable<number>;
  24584. private _onBeforeRenderObserver;
  24585. /**
  24586. * Set a before render callback in the texture.
  24587. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24588. */
  24589. set onBeforeRender(callback: (faceIndex: number) => void);
  24590. /**
  24591. * An event triggered after rendering the texture
  24592. */
  24593. onAfterRenderObservable: Observable<number>;
  24594. private _onAfterRenderObserver;
  24595. /**
  24596. * Set a after render callback in the texture.
  24597. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24598. */
  24599. set onAfterRender(callback: (faceIndex: number) => void);
  24600. /**
  24601. * An event triggered after the texture clear
  24602. */
  24603. onClearObservable: Observable<Engine>;
  24604. private _onClearObserver;
  24605. /**
  24606. * Set a clear callback in the texture.
  24607. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24608. */
  24609. set onClear(callback: (Engine: Engine) => void);
  24610. /**
  24611. * An event triggered when the texture is resized.
  24612. */
  24613. onResizeObservable: Observable<RenderTargetTexture>;
  24614. /**
  24615. * Define the clear color of the Render Target if it should be different from the scene.
  24616. */
  24617. clearColor: Color4;
  24618. protected _size: number | {
  24619. width: number;
  24620. height: number;
  24621. layers?: number;
  24622. };
  24623. protected _initialSizeParameter: number | {
  24624. width: number;
  24625. height: number;
  24626. } | {
  24627. ratio: number;
  24628. };
  24629. protected _sizeRatio: Nullable<number>;
  24630. /** @hidden */
  24631. _generateMipMaps: boolean;
  24632. protected _renderingManager: RenderingManager;
  24633. /** @hidden */
  24634. _waitingRenderList?: string[];
  24635. protected _doNotChangeAspectRatio: boolean;
  24636. protected _currentRefreshId: number;
  24637. protected _refreshRate: number;
  24638. protected _textureMatrix: Matrix;
  24639. protected _samples: number;
  24640. protected _renderTargetOptions: RenderTargetCreationOptions;
  24641. /**
  24642. * Gets render target creation options that were used.
  24643. */
  24644. get renderTargetOptions(): RenderTargetCreationOptions;
  24645. protected _onRatioRescale(): void;
  24646. /**
  24647. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24648. * It must define where the camera used to render the texture is set
  24649. */
  24650. boundingBoxPosition: Vector3;
  24651. private _boundingBoxSize;
  24652. /**
  24653. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24654. * When defined, the cubemap will switch to local mode
  24655. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24656. * @example https://www.babylonjs-playground.com/#RNASML
  24657. */
  24658. set boundingBoxSize(value: Vector3);
  24659. get boundingBoxSize(): Vector3;
  24660. /**
  24661. * In case the RTT has been created with a depth texture, get the associated
  24662. * depth texture.
  24663. * Otherwise, return null.
  24664. */
  24665. get depthStencilTexture(): Nullable<InternalTexture>;
  24666. /**
  24667. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24668. * or used a shadow, depth texture...
  24669. * @param name The friendly name of the texture
  24670. * @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)
  24671. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24672. * @param generateMipMaps True if mip maps need to be generated after render.
  24673. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24674. * @param type The type of the buffer in the RTT (int, half float, float...)
  24675. * @param isCube True if a cube texture needs to be created
  24676. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24677. * @param generateDepthBuffer True to generate a depth buffer
  24678. * @param generateStencilBuffer True to generate a stencil buffer
  24679. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24680. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24681. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24682. */
  24683. constructor(name: string, size: number | {
  24684. width: number;
  24685. height: number;
  24686. layers?: number;
  24687. } | {
  24688. ratio: number;
  24689. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24690. /**
  24691. * Creates a depth stencil texture.
  24692. * This is only available in WebGL 2 or with the depth texture extension available.
  24693. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24694. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24695. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24696. */
  24697. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24698. private _processSizeParameter;
  24699. /**
  24700. * Define the number of samples to use in case of MSAA.
  24701. * It defaults to one meaning no MSAA has been enabled.
  24702. */
  24703. get samples(): number;
  24704. set samples(value: number);
  24705. /**
  24706. * Resets the refresh counter of the texture and start bak from scratch.
  24707. * Could be useful to regenerate the texture if it is setup to render only once.
  24708. */
  24709. resetRefreshCounter(): void;
  24710. /**
  24711. * Define the refresh rate of the texture or the rendering frequency.
  24712. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24713. */
  24714. get refreshRate(): number;
  24715. set refreshRate(value: number);
  24716. /**
  24717. * Adds a post process to the render target rendering passes.
  24718. * @param postProcess define the post process to add
  24719. */
  24720. addPostProcess(postProcess: PostProcess): void;
  24721. /**
  24722. * Clear all the post processes attached to the render target
  24723. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24724. */
  24725. clearPostProcesses(dispose?: boolean): void;
  24726. /**
  24727. * Remove one of the post process from the list of attached post processes to the texture
  24728. * @param postProcess define the post process to remove from the list
  24729. */
  24730. removePostProcess(postProcess: PostProcess): void;
  24731. /** @hidden */
  24732. _shouldRender(): boolean;
  24733. /**
  24734. * Gets the actual render size of the texture.
  24735. * @returns the width of the render size
  24736. */
  24737. getRenderSize(): number;
  24738. /**
  24739. * Gets the actual render width of the texture.
  24740. * @returns the width of the render size
  24741. */
  24742. getRenderWidth(): number;
  24743. /**
  24744. * Gets the actual render height of the texture.
  24745. * @returns the height of the render size
  24746. */
  24747. getRenderHeight(): number;
  24748. /**
  24749. * Gets the actual number of layers of the texture.
  24750. * @returns the number of layers
  24751. */
  24752. getRenderLayers(): number;
  24753. /**
  24754. * Get if the texture can be rescaled or not.
  24755. */
  24756. get canRescale(): boolean;
  24757. /**
  24758. * Resize the texture using a ratio.
  24759. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24760. */
  24761. scale(ratio: number): void;
  24762. /**
  24763. * Get the texture reflection matrix used to rotate/transform the reflection.
  24764. * @returns the reflection matrix
  24765. */
  24766. getReflectionTextureMatrix(): Matrix;
  24767. /**
  24768. * Resize the texture to a new desired size.
  24769. * Be carrefull as it will recreate all the data in the new texture.
  24770. * @param size Define the new size. It can be:
  24771. * - a number for squared texture,
  24772. * - an object containing { width: number, height: number }
  24773. * - or an object containing a ratio { ratio: number }
  24774. */
  24775. resize(size: number | {
  24776. width: number;
  24777. height: number;
  24778. } | {
  24779. ratio: number;
  24780. }): void;
  24781. private _defaultRenderListPrepared;
  24782. /**
  24783. * Renders all the objects from the render list into the texture.
  24784. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24785. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24786. */
  24787. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24788. private _bestReflectionRenderTargetDimension;
  24789. private _prepareRenderingManager;
  24790. /**
  24791. * @hidden
  24792. * @param faceIndex face index to bind to if this is a cubetexture
  24793. * @param layer defines the index of the texture to bind in the array
  24794. */
  24795. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24796. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24797. private renderToTarget;
  24798. /**
  24799. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24800. * This allowed control for front to back rendering or reversly depending of the special needs.
  24801. *
  24802. * @param renderingGroupId The rendering group id corresponding to its index
  24803. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24804. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24805. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24806. */
  24807. 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;
  24808. /**
  24809. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24810. *
  24811. * @param renderingGroupId The rendering group id corresponding to its index
  24812. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24813. */
  24814. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24815. /**
  24816. * Clones the texture.
  24817. * @returns the cloned texture
  24818. */
  24819. clone(): RenderTargetTexture;
  24820. /**
  24821. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24822. * @returns The JSON representation of the texture
  24823. */
  24824. serialize(): any;
  24825. /**
  24826. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24827. */
  24828. disposeFramebufferObjects(): void;
  24829. /**
  24830. * Dispose the texture and release its associated resources.
  24831. */
  24832. dispose(): void;
  24833. /** @hidden */
  24834. _rebuild(): void;
  24835. /**
  24836. * Clear the info related to rendering groups preventing retention point in material dispose.
  24837. */
  24838. freeRenderingGroups(): void;
  24839. /**
  24840. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24841. * @returns the view count
  24842. */
  24843. getViewCount(): number;
  24844. }
  24845. }
  24846. declare module "babylonjs/Misc/guid" {
  24847. /**
  24848. * Class used to manipulate GUIDs
  24849. */
  24850. export class GUID {
  24851. /**
  24852. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24853. * Be aware Math.random() could cause collisions, but:
  24854. * "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"
  24855. * @returns a pseudo random id
  24856. */
  24857. static RandomId(): string;
  24858. }
  24859. }
  24860. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24861. import { Nullable } from "babylonjs/types";
  24862. import { Scene } from "babylonjs/scene";
  24863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24864. import { Material } from "babylonjs/Materials/material";
  24865. import { Effect } from "babylonjs/Materials/effect";
  24866. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24867. /**
  24868. * Options to be used when creating a shadow depth material
  24869. */
  24870. export interface IIOptionShadowDepthMaterial {
  24871. /** Variables in the vertex shader code that need to have their names remapped.
  24872. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24873. * "var_name" should be either: worldPos or vNormalW
  24874. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24875. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24876. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24877. */
  24878. remappedVariables?: string[];
  24879. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24880. standalone?: boolean;
  24881. }
  24882. /**
  24883. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24884. */
  24885. export class ShadowDepthWrapper {
  24886. private _scene;
  24887. private _options?;
  24888. private _baseMaterial;
  24889. private _onEffectCreatedObserver;
  24890. private _subMeshToEffect;
  24891. private _subMeshToDepthEffect;
  24892. private _meshes;
  24893. /** @hidden */
  24894. _matriceNames: any;
  24895. /** Gets the standalone status of the wrapper */
  24896. get standalone(): boolean;
  24897. /** Gets the base material the wrapper is built upon */
  24898. get baseMaterial(): Material;
  24899. /**
  24900. * Instantiate a new shadow depth wrapper.
  24901. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24902. * generate the shadow depth map. For more information, please refer to the documentation:
  24903. * https://doc.babylonjs.com/babylon101/shadows
  24904. * @param baseMaterial Material to wrap
  24905. * @param scene Define the scene the material belongs to
  24906. * @param options Options used to create the wrapper
  24907. */
  24908. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24909. /**
  24910. * Gets the effect to use to generate the depth map
  24911. * @param subMesh subMesh to get the effect for
  24912. * @param shadowGenerator shadow generator to get the effect for
  24913. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24914. */
  24915. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24916. /**
  24917. * Specifies that the submesh is ready to be used for depth rendering
  24918. * @param subMesh submesh to check
  24919. * @param defines the list of defines to take into account when checking the effect
  24920. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24921. * @param useInstances specifies that instances should be used
  24922. * @returns a boolean indicating that the submesh is ready or not
  24923. */
  24924. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24925. /**
  24926. * Disposes the resources
  24927. */
  24928. dispose(): void;
  24929. private _makeEffect;
  24930. }
  24931. }
  24932. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24934. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24935. import { Nullable } from "babylonjs/types";
  24936. module "babylonjs/Engines/thinEngine" {
  24937. interface ThinEngine {
  24938. /**
  24939. * Unbind a list of render target textures from the webGL context
  24940. * This is used only when drawBuffer extension or webGL2 are active
  24941. * @param textures defines the render target textures to unbind
  24942. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24943. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24944. */
  24945. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24946. /**
  24947. * Create a multi render target texture
  24948. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24949. * @param size defines the size of the texture
  24950. * @param options defines the creation options
  24951. * @returns the cube texture as an InternalTexture
  24952. */
  24953. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24954. /**
  24955. * Update the sample count for a given multiple render target texture
  24956. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24957. * @param textures defines the textures to update
  24958. * @param samples defines the sample count to set
  24959. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24960. */
  24961. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24962. /**
  24963. * Select a subsets of attachments to draw to.
  24964. * @param attachments gl attachments
  24965. */
  24966. bindAttachments(attachments: number[]): void;
  24967. }
  24968. }
  24969. }
  24970. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24971. import { Scene } from "babylonjs/scene";
  24972. import { Engine } from "babylonjs/Engines/engine";
  24973. import { Texture } from "babylonjs/Materials/Textures/texture";
  24974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24975. import "babylonjs/Engines/Extensions/engine.multiRender";
  24976. /**
  24977. * Creation options of the multi render target texture.
  24978. */
  24979. export interface IMultiRenderTargetOptions {
  24980. /**
  24981. * Define if the texture needs to create mip maps after render.
  24982. */
  24983. generateMipMaps?: boolean;
  24984. /**
  24985. * Define the types of all the draw buffers we want to create
  24986. */
  24987. types?: number[];
  24988. /**
  24989. * Define the sampling modes of all the draw buffers we want to create
  24990. */
  24991. samplingModes?: number[];
  24992. /**
  24993. * Define if a depth buffer is required
  24994. */
  24995. generateDepthBuffer?: boolean;
  24996. /**
  24997. * Define if a stencil buffer is required
  24998. */
  24999. generateStencilBuffer?: boolean;
  25000. /**
  25001. * Define if a depth texture is required instead of a depth buffer
  25002. */
  25003. generateDepthTexture?: boolean;
  25004. /**
  25005. * Define the number of desired draw buffers
  25006. */
  25007. textureCount?: number;
  25008. /**
  25009. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25010. */
  25011. doNotChangeAspectRatio?: boolean;
  25012. /**
  25013. * Define the default type of the buffers we are creating
  25014. */
  25015. defaultType?: number;
  25016. }
  25017. /**
  25018. * A multi render target, like a render target provides the ability to render to a texture.
  25019. * Unlike the render target, it can render to several draw buffers in one draw.
  25020. * This is specially interesting in deferred rendering or for any effects requiring more than
  25021. * just one color from a single pass.
  25022. */
  25023. export class MultiRenderTarget extends RenderTargetTexture {
  25024. private _internalTextures;
  25025. private _textures;
  25026. private _multiRenderTargetOptions;
  25027. private _count;
  25028. /**
  25029. * Get if draw buffers are currently supported by the used hardware and browser.
  25030. */
  25031. get isSupported(): boolean;
  25032. /**
  25033. * Get the list of textures generated by the multi render target.
  25034. */
  25035. get textures(): Texture[];
  25036. /**
  25037. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25038. */
  25039. get count(): number;
  25040. /**
  25041. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25042. */
  25043. get depthTexture(): Texture;
  25044. /**
  25045. * Set the wrapping mode on U of all the textures we are rendering to.
  25046. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25047. */
  25048. set wrapU(wrap: number);
  25049. /**
  25050. * Set the wrapping mode on V of all the textures we are rendering to.
  25051. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25052. */
  25053. set wrapV(wrap: number);
  25054. /**
  25055. * Instantiate a new multi render target texture.
  25056. * A multi render target, like a render target provides the ability to render to a texture.
  25057. * Unlike the render target, it can render to several draw buffers in one draw.
  25058. * This is specially interesting in deferred rendering or for any effects requiring more than
  25059. * just one color from a single pass.
  25060. * @param name Define the name of the texture
  25061. * @param size Define the size of the buffers to render to
  25062. * @param count Define the number of target we are rendering into
  25063. * @param scene Define the scene the texture belongs to
  25064. * @param options Define the options used to create the multi render target
  25065. */
  25066. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25067. private _initTypes;
  25068. /** @hidden */
  25069. _rebuild(forceFullRebuild?: boolean): void;
  25070. private _createInternalTextures;
  25071. private _createTextures;
  25072. /**
  25073. * Define the number of samples used if MSAA is enabled.
  25074. */
  25075. get samples(): number;
  25076. set samples(value: number);
  25077. /**
  25078. * Resize all the textures in the multi render target.
  25079. * Be careful as it will recreate all the data in the new texture.
  25080. * @param size Define the new size
  25081. */
  25082. resize(size: any): void;
  25083. /**
  25084. * Changes the number of render targets in this MRT
  25085. * Be careful as it will recreate all the data in the new texture.
  25086. * @param count new texture count
  25087. * @param options Specifies texture types and sampling modes for new textures
  25088. */
  25089. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  25090. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25091. /**
  25092. * Dispose the render targets and their associated resources
  25093. */
  25094. dispose(): void;
  25095. /**
  25096. * Release all the underlying texture used as draw buffers.
  25097. */
  25098. releaseInternalTextures(): void;
  25099. }
  25100. }
  25101. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25102. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25103. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25104. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25105. /** @hidden */
  25106. export var imageProcessingPixelShader: {
  25107. name: string;
  25108. shader: string;
  25109. };
  25110. }
  25111. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25112. import { Nullable } from "babylonjs/types";
  25113. import { Color4 } from "babylonjs/Maths/math.color";
  25114. import { Camera } from "babylonjs/Cameras/camera";
  25115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25116. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25117. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25119. import { Engine } from "babylonjs/Engines/engine";
  25120. import "babylonjs/Shaders/imageProcessing.fragment";
  25121. import "babylonjs/Shaders/postprocess.vertex";
  25122. /**
  25123. * ImageProcessingPostProcess
  25124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25125. */
  25126. export class ImageProcessingPostProcess extends PostProcess {
  25127. /**
  25128. * Default configuration related to image processing available in the PBR Material.
  25129. */
  25130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25131. /**
  25132. * Gets the image processing configuration used either in this material.
  25133. */
  25134. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25135. /**
  25136. * Sets the Default image processing configuration used either in the this material.
  25137. *
  25138. * If sets to null, the scene one is in use.
  25139. */
  25140. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25141. /**
  25142. * Keep track of the image processing observer to allow dispose and replace.
  25143. */
  25144. private _imageProcessingObserver;
  25145. /**
  25146. * Attaches a new image processing configuration to the PBR Material.
  25147. * @param configuration
  25148. */
  25149. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25150. /**
  25151. * If the post process is supported.
  25152. */
  25153. get isSupported(): boolean;
  25154. /**
  25155. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25156. */
  25157. get colorCurves(): Nullable<ColorCurves>;
  25158. /**
  25159. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25160. */
  25161. set colorCurves(value: Nullable<ColorCurves>);
  25162. /**
  25163. * Gets wether the color curves effect is enabled.
  25164. */
  25165. get colorCurvesEnabled(): boolean;
  25166. /**
  25167. * Sets wether the color curves effect is enabled.
  25168. */
  25169. set colorCurvesEnabled(value: boolean);
  25170. /**
  25171. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25172. */
  25173. get colorGradingTexture(): Nullable<BaseTexture>;
  25174. /**
  25175. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25176. */
  25177. set colorGradingTexture(value: Nullable<BaseTexture>);
  25178. /**
  25179. * Gets wether the color grading effect is enabled.
  25180. */
  25181. get colorGradingEnabled(): boolean;
  25182. /**
  25183. * Gets wether the color grading effect is enabled.
  25184. */
  25185. set colorGradingEnabled(value: boolean);
  25186. /**
  25187. * Gets exposure used in the effect.
  25188. */
  25189. get exposure(): number;
  25190. /**
  25191. * Sets exposure used in the effect.
  25192. */
  25193. set exposure(value: number);
  25194. /**
  25195. * Gets wether tonemapping is enabled or not.
  25196. */
  25197. get toneMappingEnabled(): boolean;
  25198. /**
  25199. * Sets wether tonemapping is enabled or not
  25200. */
  25201. set toneMappingEnabled(value: boolean);
  25202. /**
  25203. * Gets the type of tone mapping effect.
  25204. */
  25205. get toneMappingType(): number;
  25206. /**
  25207. * Sets the type of tone mapping effect.
  25208. */
  25209. set toneMappingType(value: number);
  25210. /**
  25211. * Gets contrast used in the effect.
  25212. */
  25213. get contrast(): number;
  25214. /**
  25215. * Sets contrast used in the effect.
  25216. */
  25217. set contrast(value: number);
  25218. /**
  25219. * Gets Vignette stretch size.
  25220. */
  25221. get vignetteStretch(): number;
  25222. /**
  25223. * Sets Vignette stretch size.
  25224. */
  25225. set vignetteStretch(value: number);
  25226. /**
  25227. * Gets Vignette centre X Offset.
  25228. */
  25229. get vignetteCentreX(): number;
  25230. /**
  25231. * Sets Vignette centre X Offset.
  25232. */
  25233. set vignetteCentreX(value: number);
  25234. /**
  25235. * Gets Vignette centre Y Offset.
  25236. */
  25237. get vignetteCentreY(): number;
  25238. /**
  25239. * Sets Vignette centre Y Offset.
  25240. */
  25241. set vignetteCentreY(value: number);
  25242. /**
  25243. * Gets Vignette weight or intensity of the vignette effect.
  25244. */
  25245. get vignetteWeight(): number;
  25246. /**
  25247. * Sets Vignette weight or intensity of the vignette effect.
  25248. */
  25249. set vignetteWeight(value: number);
  25250. /**
  25251. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25252. * if vignetteEnabled is set to true.
  25253. */
  25254. get vignetteColor(): Color4;
  25255. /**
  25256. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25257. * if vignetteEnabled is set to true.
  25258. */
  25259. set vignetteColor(value: Color4);
  25260. /**
  25261. * Gets Camera field of view used by the Vignette effect.
  25262. */
  25263. get vignetteCameraFov(): number;
  25264. /**
  25265. * Sets Camera field of view used by the Vignette effect.
  25266. */
  25267. set vignetteCameraFov(value: number);
  25268. /**
  25269. * Gets the vignette blend mode allowing different kind of effect.
  25270. */
  25271. get vignetteBlendMode(): number;
  25272. /**
  25273. * Sets the vignette blend mode allowing different kind of effect.
  25274. */
  25275. set vignetteBlendMode(value: number);
  25276. /**
  25277. * Gets wether the vignette effect is enabled.
  25278. */
  25279. get vignetteEnabled(): boolean;
  25280. /**
  25281. * Sets wether the vignette effect is enabled.
  25282. */
  25283. set vignetteEnabled(value: boolean);
  25284. private _fromLinearSpace;
  25285. /**
  25286. * Gets wether the input of the processing is in Gamma or Linear Space.
  25287. */
  25288. get fromLinearSpace(): boolean;
  25289. /**
  25290. * Sets wether the input of the processing is in Gamma or Linear Space.
  25291. */
  25292. set fromLinearSpace(value: boolean);
  25293. /**
  25294. * Defines cache preventing GC.
  25295. */
  25296. private _defines;
  25297. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25298. /**
  25299. * "ImageProcessingPostProcess"
  25300. * @returns "ImageProcessingPostProcess"
  25301. */
  25302. getClassName(): string;
  25303. /**
  25304. * @hidden
  25305. */
  25306. _updateParameters(): void;
  25307. dispose(camera?: Camera): void;
  25308. }
  25309. }
  25310. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25311. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25312. /**
  25313. * Interface for defining prepass effects in the prepass post-process pipeline
  25314. */
  25315. export interface PrePassEffectConfiguration {
  25316. /**
  25317. * Name of the effect
  25318. */
  25319. name: string;
  25320. /**
  25321. * Post process to attach for this effect
  25322. */
  25323. postProcess?: PostProcess;
  25324. /**
  25325. * Textures required in the MRT
  25326. */
  25327. texturesRequired: number[];
  25328. /**
  25329. * Is the effect enabled
  25330. */
  25331. enabled: boolean;
  25332. /**
  25333. * Disposes the effect configuration
  25334. */
  25335. dispose(): void;
  25336. /**
  25337. * Creates the associated post process
  25338. */
  25339. createPostProcess?: () => PostProcess;
  25340. }
  25341. }
  25342. declare module "babylonjs/Rendering/prePassRenderer" {
  25343. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25344. import { Scene } from "babylonjs/scene";
  25345. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25346. import { Effect } from "babylonjs/Materials/effect";
  25347. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25348. /**
  25349. * Renders a pre pass of the scene
  25350. * This means every mesh in the scene will be rendered to a render target texture
  25351. * And then this texture will be composited to the rendering canvas with post processes
  25352. * It is necessary for effects like subsurface scattering or deferred shading
  25353. */
  25354. export class PrePassRenderer {
  25355. /** @hidden */
  25356. static _SceneComponentInitialization: (scene: Scene) => void;
  25357. private _textureFormats;
  25358. private _textureIndices;
  25359. private _scene;
  25360. private _engine;
  25361. private _isDirty;
  25362. /**
  25363. * Number of textures in the multi render target texture where the scene is directly rendered
  25364. */
  25365. mrtCount: number;
  25366. /**
  25367. * The render target where the scene is directly rendered
  25368. */
  25369. prePassRT: MultiRenderTarget;
  25370. private _multiRenderAttachments;
  25371. private _defaultAttachments;
  25372. private _clearAttachments;
  25373. private _postProcesses;
  25374. private readonly _clearColor;
  25375. /**
  25376. * Image processing post process for composition
  25377. */
  25378. imageProcessingPostProcess: ImageProcessingPostProcess;
  25379. /**
  25380. * Configuration for prepass effects
  25381. */
  25382. private _effectConfigurations;
  25383. /**
  25384. * Should materials render their geometry on the MRT
  25385. */
  25386. materialsShouldRenderGeometry: boolean;
  25387. /**
  25388. * Should materials render the irradiance information on the MRT
  25389. */
  25390. materialsShouldRenderIrradiance: boolean;
  25391. private _mrtFormats;
  25392. private _mrtLayout;
  25393. private _enabled;
  25394. /**
  25395. * Indicates if the prepass is enabled
  25396. */
  25397. get enabled(): boolean;
  25398. /**
  25399. * How many samples are used for MSAA of the scene render target
  25400. */
  25401. get samples(): number;
  25402. set samples(n: number);
  25403. /**
  25404. * Instanciates a prepass renderer
  25405. * @param scene The scene
  25406. */
  25407. constructor(scene: Scene);
  25408. private _initializeAttachments;
  25409. private _createCompositionEffect;
  25410. /**
  25411. * Indicates if rendering a prepass is supported
  25412. */
  25413. get isSupported(): boolean;
  25414. /**
  25415. * Sets the proper output textures to draw in the engine.
  25416. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25417. */
  25418. bindAttachmentsForEffect(effect: Effect): void;
  25419. /**
  25420. * @hidden
  25421. */
  25422. _beforeCameraDraw(): void;
  25423. /**
  25424. * @hidden
  25425. */
  25426. _afterCameraDraw(): void;
  25427. private _checkRTSize;
  25428. private _bindFrameBuffer;
  25429. /**
  25430. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25431. */
  25432. clear(): void;
  25433. private _setState;
  25434. private _checkTextureType;
  25435. /**
  25436. * Adds an effect configuration to the prepass.
  25437. * If an effect has already been added, it won't add it twice and will return the configuration
  25438. * already present.
  25439. * @param cfg the effect configuration
  25440. * @return the effect configuration now used by the prepass
  25441. */
  25442. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  25443. /**
  25444. * Returns the index of a texture in the multi render target texture array.
  25445. * @param type Texture type
  25446. * @return The index
  25447. */
  25448. getIndex(type: number): number;
  25449. private _enable;
  25450. private _disable;
  25451. private _resetLayout;
  25452. private _resetPostProcessChain;
  25453. private _bindPostProcessChain;
  25454. /**
  25455. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25456. */
  25457. markAsDirty(): void;
  25458. /**
  25459. * Enables a texture on the MultiRenderTarget for prepass
  25460. */
  25461. private _enableTextures;
  25462. private _update;
  25463. /**
  25464. * Disposes the prepass renderer.
  25465. */
  25466. dispose(): void;
  25467. }
  25468. }
  25469. declare module "babylonjs/Materials/material" {
  25470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25471. import { SmartArray } from "babylonjs/Misc/smartArray";
  25472. import { Observable } from "babylonjs/Misc/observable";
  25473. import { Nullable } from "babylonjs/types";
  25474. import { Scene } from "babylonjs/scene";
  25475. import { Matrix } from "babylonjs/Maths/math.vector";
  25476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25478. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25479. import { Effect } from "babylonjs/Materials/effect";
  25480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25482. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25483. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25484. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25485. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25486. import { Mesh } from "babylonjs/Meshes/mesh";
  25487. import { Animation } from "babylonjs/Animations/animation";
  25488. /**
  25489. * Options for compiling materials.
  25490. */
  25491. export interface IMaterialCompilationOptions {
  25492. /**
  25493. * Defines whether clip planes are enabled.
  25494. */
  25495. clipPlane: boolean;
  25496. /**
  25497. * Defines whether instances are enabled.
  25498. */
  25499. useInstances: boolean;
  25500. }
  25501. /**
  25502. * Options passed when calling customShaderNameResolve
  25503. */
  25504. export interface ICustomShaderNameResolveOptions {
  25505. /**
  25506. * 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
  25507. */
  25508. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25509. }
  25510. /**
  25511. * Base class for the main features of a material in Babylon.js
  25512. */
  25513. export class Material implements IAnimatable {
  25514. /**
  25515. * Returns the triangle fill mode
  25516. */
  25517. static readonly TriangleFillMode: number;
  25518. /**
  25519. * Returns the wireframe mode
  25520. */
  25521. static readonly WireFrameFillMode: number;
  25522. /**
  25523. * Returns the point fill mode
  25524. */
  25525. static readonly PointFillMode: number;
  25526. /**
  25527. * Returns the point list draw mode
  25528. */
  25529. static readonly PointListDrawMode: number;
  25530. /**
  25531. * Returns the line list draw mode
  25532. */
  25533. static readonly LineListDrawMode: number;
  25534. /**
  25535. * Returns the line loop draw mode
  25536. */
  25537. static readonly LineLoopDrawMode: number;
  25538. /**
  25539. * Returns the line strip draw mode
  25540. */
  25541. static readonly LineStripDrawMode: number;
  25542. /**
  25543. * Returns the triangle strip draw mode
  25544. */
  25545. static readonly TriangleStripDrawMode: number;
  25546. /**
  25547. * Returns the triangle fan draw mode
  25548. */
  25549. static readonly TriangleFanDrawMode: number;
  25550. /**
  25551. * Stores the clock-wise side orientation
  25552. */
  25553. static readonly ClockWiseSideOrientation: number;
  25554. /**
  25555. * Stores the counter clock-wise side orientation
  25556. */
  25557. static readonly CounterClockWiseSideOrientation: number;
  25558. /**
  25559. * The dirty texture flag value
  25560. */
  25561. static readonly TextureDirtyFlag: number;
  25562. /**
  25563. * The dirty light flag value
  25564. */
  25565. static readonly LightDirtyFlag: number;
  25566. /**
  25567. * The dirty fresnel flag value
  25568. */
  25569. static readonly FresnelDirtyFlag: number;
  25570. /**
  25571. * The dirty attribute flag value
  25572. */
  25573. static readonly AttributesDirtyFlag: number;
  25574. /**
  25575. * The dirty misc flag value
  25576. */
  25577. static readonly MiscDirtyFlag: number;
  25578. /**
  25579. * The all dirty flag value
  25580. */
  25581. static readonly AllDirtyFlag: number;
  25582. /**
  25583. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25584. */
  25585. static readonly MATERIAL_OPAQUE: number;
  25586. /**
  25587. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25588. */
  25589. static readonly MATERIAL_ALPHATEST: number;
  25590. /**
  25591. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25592. */
  25593. static readonly MATERIAL_ALPHABLEND: number;
  25594. /**
  25595. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25596. * They are also discarded below the alpha cutoff threshold to improve performances.
  25597. */
  25598. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25599. /**
  25600. * The Whiteout method is used to blend normals.
  25601. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25602. */
  25603. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25604. /**
  25605. * The Reoriented Normal Mapping method is used to blend normals.
  25606. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25607. */
  25608. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25609. /**
  25610. * Custom callback helping to override the default shader used in the material.
  25611. */
  25612. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25613. /**
  25614. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25615. */
  25616. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25617. /**
  25618. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25619. * This means that the material can keep using a previous shader while a new one is being compiled.
  25620. * This is mostly used when shader parallel compilation is supported (true by default)
  25621. */
  25622. allowShaderHotSwapping: boolean;
  25623. /**
  25624. * The ID of the material
  25625. */
  25626. id: string;
  25627. /**
  25628. * Gets or sets the unique id of the material
  25629. */
  25630. uniqueId: number;
  25631. /**
  25632. * The name of the material
  25633. */
  25634. name: string;
  25635. /**
  25636. * Gets or sets user defined metadata
  25637. */
  25638. metadata: any;
  25639. /**
  25640. * For internal use only. Please do not use.
  25641. */
  25642. reservedDataStore: any;
  25643. /**
  25644. * Specifies if the ready state should be checked on each call
  25645. */
  25646. checkReadyOnEveryCall: boolean;
  25647. /**
  25648. * Specifies if the ready state should be checked once
  25649. */
  25650. checkReadyOnlyOnce: boolean;
  25651. /**
  25652. * The state of the material
  25653. */
  25654. state: string;
  25655. /**
  25656. * If the material can be rendered to several textures with MRT extension
  25657. */
  25658. get canRenderToMRT(): boolean;
  25659. /**
  25660. * The alpha value of the material
  25661. */
  25662. protected _alpha: number;
  25663. /**
  25664. * List of inspectable custom properties (used by the Inspector)
  25665. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25666. */
  25667. inspectableCustomProperties: IInspectable[];
  25668. /**
  25669. * Sets the alpha value of the material
  25670. */
  25671. set alpha(value: number);
  25672. /**
  25673. * Gets the alpha value of the material
  25674. */
  25675. get alpha(): number;
  25676. /**
  25677. * Specifies if back face culling is enabled
  25678. */
  25679. protected _backFaceCulling: boolean;
  25680. /**
  25681. * Sets the back-face culling state
  25682. */
  25683. set backFaceCulling(value: boolean);
  25684. /**
  25685. * Gets the back-face culling state
  25686. */
  25687. get backFaceCulling(): boolean;
  25688. /**
  25689. * Stores the value for side orientation
  25690. */
  25691. sideOrientation: number;
  25692. /**
  25693. * Callback triggered when the material is compiled
  25694. */
  25695. onCompiled: Nullable<(effect: Effect) => void>;
  25696. /**
  25697. * Callback triggered when an error occurs
  25698. */
  25699. onError: Nullable<(effect: Effect, errors: string) => void>;
  25700. /**
  25701. * Callback triggered to get the render target textures
  25702. */
  25703. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25704. /**
  25705. * Gets a boolean indicating that current material needs to register RTT
  25706. */
  25707. get hasRenderTargetTextures(): boolean;
  25708. /**
  25709. * Specifies if the material should be serialized
  25710. */
  25711. doNotSerialize: boolean;
  25712. /**
  25713. * @hidden
  25714. */
  25715. _storeEffectOnSubMeshes: boolean;
  25716. /**
  25717. * Stores the animations for the material
  25718. */
  25719. animations: Nullable<Array<Animation>>;
  25720. /**
  25721. * An event triggered when the material is disposed
  25722. */
  25723. onDisposeObservable: Observable<Material>;
  25724. /**
  25725. * An observer which watches for dispose events
  25726. */
  25727. private _onDisposeObserver;
  25728. private _onUnBindObservable;
  25729. /**
  25730. * Called during a dispose event
  25731. */
  25732. set onDispose(callback: () => void);
  25733. private _onBindObservable;
  25734. /**
  25735. * An event triggered when the material is bound
  25736. */
  25737. get onBindObservable(): Observable<AbstractMesh>;
  25738. /**
  25739. * An observer which watches for bind events
  25740. */
  25741. private _onBindObserver;
  25742. /**
  25743. * Called during a bind event
  25744. */
  25745. set onBind(callback: (Mesh: AbstractMesh) => void);
  25746. /**
  25747. * An event triggered when the material is unbound
  25748. */
  25749. get onUnBindObservable(): Observable<Material>;
  25750. protected _onEffectCreatedObservable: Nullable<Observable<{
  25751. effect: Effect;
  25752. subMesh: Nullable<SubMesh>;
  25753. }>>;
  25754. /**
  25755. * An event triggered when the effect is (re)created
  25756. */
  25757. get onEffectCreatedObservable(): Observable<{
  25758. effect: Effect;
  25759. subMesh: Nullable<SubMesh>;
  25760. }>;
  25761. /**
  25762. * Stores the value of the alpha mode
  25763. */
  25764. private _alphaMode;
  25765. /**
  25766. * Sets the value of the alpha mode.
  25767. *
  25768. * | Value | Type | Description |
  25769. * | --- | --- | --- |
  25770. * | 0 | ALPHA_DISABLE | |
  25771. * | 1 | ALPHA_ADD | |
  25772. * | 2 | ALPHA_COMBINE | |
  25773. * | 3 | ALPHA_SUBTRACT | |
  25774. * | 4 | ALPHA_MULTIPLY | |
  25775. * | 5 | ALPHA_MAXIMIZED | |
  25776. * | 6 | ALPHA_ONEONE | |
  25777. * | 7 | ALPHA_PREMULTIPLIED | |
  25778. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25779. * | 9 | ALPHA_INTERPOLATE | |
  25780. * | 10 | ALPHA_SCREENMODE | |
  25781. *
  25782. */
  25783. set alphaMode(value: number);
  25784. /**
  25785. * Gets the value of the alpha mode
  25786. */
  25787. get alphaMode(): number;
  25788. /**
  25789. * Stores the state of the need depth pre-pass value
  25790. */
  25791. private _needDepthPrePass;
  25792. /**
  25793. * Sets the need depth pre-pass value
  25794. */
  25795. set needDepthPrePass(value: boolean);
  25796. /**
  25797. * Gets the depth pre-pass value
  25798. */
  25799. get needDepthPrePass(): boolean;
  25800. /**
  25801. * Specifies if depth writing should be disabled
  25802. */
  25803. disableDepthWrite: boolean;
  25804. /**
  25805. * Specifies if color writing should be disabled
  25806. */
  25807. disableColorWrite: boolean;
  25808. /**
  25809. * Specifies if depth writing should be forced
  25810. */
  25811. forceDepthWrite: boolean;
  25812. /**
  25813. * Specifies the depth function that should be used. 0 means the default engine function
  25814. */
  25815. depthFunction: number;
  25816. /**
  25817. * Specifies if there should be a separate pass for culling
  25818. */
  25819. separateCullingPass: boolean;
  25820. /**
  25821. * Stores the state specifing if fog should be enabled
  25822. */
  25823. private _fogEnabled;
  25824. /**
  25825. * Sets the state for enabling fog
  25826. */
  25827. set fogEnabled(value: boolean);
  25828. /**
  25829. * Gets the value of the fog enabled state
  25830. */
  25831. get fogEnabled(): boolean;
  25832. /**
  25833. * Stores the size of points
  25834. */
  25835. pointSize: number;
  25836. /**
  25837. * Stores the z offset value
  25838. */
  25839. zOffset: number;
  25840. get wireframe(): boolean;
  25841. /**
  25842. * Sets the state of wireframe mode
  25843. */
  25844. set wireframe(value: boolean);
  25845. /**
  25846. * Gets the value specifying if point clouds are enabled
  25847. */
  25848. get pointsCloud(): boolean;
  25849. /**
  25850. * Sets the state of point cloud mode
  25851. */
  25852. set pointsCloud(value: boolean);
  25853. /**
  25854. * Gets the material fill mode
  25855. */
  25856. get fillMode(): number;
  25857. /**
  25858. * Sets the material fill mode
  25859. */
  25860. set fillMode(value: number);
  25861. /**
  25862. * @hidden
  25863. * Stores the effects for the material
  25864. */
  25865. _effect: Nullable<Effect>;
  25866. /**
  25867. * Specifies if uniform buffers should be used
  25868. */
  25869. private _useUBO;
  25870. /**
  25871. * Stores a reference to the scene
  25872. */
  25873. private _scene;
  25874. /**
  25875. * Stores the fill mode state
  25876. */
  25877. private _fillMode;
  25878. /**
  25879. * Specifies if the depth write state should be cached
  25880. */
  25881. private _cachedDepthWriteState;
  25882. /**
  25883. * Specifies if the color write state should be cached
  25884. */
  25885. private _cachedColorWriteState;
  25886. /**
  25887. * Specifies if the depth function state should be cached
  25888. */
  25889. private _cachedDepthFunctionState;
  25890. /**
  25891. * Stores the uniform buffer
  25892. */
  25893. protected _uniformBuffer: UniformBuffer;
  25894. /** @hidden */
  25895. _indexInSceneMaterialArray: number;
  25896. /** @hidden */
  25897. meshMap: Nullable<{
  25898. [id: string]: AbstractMesh | undefined;
  25899. }>;
  25900. /**
  25901. * Creates a material instance
  25902. * @param name defines the name of the material
  25903. * @param scene defines the scene to reference
  25904. * @param doNotAdd specifies if the material should be added to the scene
  25905. */
  25906. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25907. /**
  25908. * Returns a string representation of the current material
  25909. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25910. * @returns a string with material information
  25911. */
  25912. toString(fullDetails?: boolean): string;
  25913. /**
  25914. * Gets the class name of the material
  25915. * @returns a string with the class name of the material
  25916. */
  25917. getClassName(): string;
  25918. /**
  25919. * Specifies if updates for the material been locked
  25920. */
  25921. get isFrozen(): boolean;
  25922. /**
  25923. * Locks updates for the material
  25924. */
  25925. freeze(): void;
  25926. /**
  25927. * Unlocks updates for the material
  25928. */
  25929. unfreeze(): void;
  25930. /**
  25931. * Specifies if the material is ready to be used
  25932. * @param mesh defines the mesh to check
  25933. * @param useInstances specifies if instances should be used
  25934. * @returns a boolean indicating if the material is ready to be used
  25935. */
  25936. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25937. /**
  25938. * Specifies that the submesh is ready to be used
  25939. * @param mesh defines the mesh to check
  25940. * @param subMesh defines which submesh to check
  25941. * @param useInstances specifies that instances should be used
  25942. * @returns a boolean indicating that the submesh is ready or not
  25943. */
  25944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25945. /**
  25946. * Returns the material effect
  25947. * @returns the effect associated with the material
  25948. */
  25949. getEffect(): Nullable<Effect>;
  25950. /**
  25951. * Returns the current scene
  25952. * @returns a Scene
  25953. */
  25954. getScene(): Scene;
  25955. /**
  25956. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25957. */
  25958. protected _forceAlphaTest: boolean;
  25959. /**
  25960. * The transparency mode of the material.
  25961. */
  25962. protected _transparencyMode: Nullable<number>;
  25963. /**
  25964. * Gets the current transparency mode.
  25965. */
  25966. get transparencyMode(): Nullable<number>;
  25967. /**
  25968. * Sets the transparency mode of the material.
  25969. *
  25970. * | Value | Type | Description |
  25971. * | ----- | ----------------------------------- | ----------- |
  25972. * | 0 | OPAQUE | |
  25973. * | 1 | ALPHATEST | |
  25974. * | 2 | ALPHABLEND | |
  25975. * | 3 | ALPHATESTANDBLEND | |
  25976. *
  25977. */
  25978. set transparencyMode(value: Nullable<number>);
  25979. /**
  25980. * Returns true if alpha blending should be disabled.
  25981. */
  25982. protected get _disableAlphaBlending(): boolean;
  25983. /**
  25984. * Specifies whether or not this material should be rendered in alpha blend mode.
  25985. * @returns a boolean specifying if alpha blending is needed
  25986. */
  25987. needAlphaBlending(): boolean;
  25988. /**
  25989. * Specifies if the mesh will require alpha blending
  25990. * @param mesh defines the mesh to check
  25991. * @returns a boolean specifying if alpha blending is needed for the mesh
  25992. */
  25993. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25994. /**
  25995. * Specifies whether or not this material should be rendered in alpha test mode.
  25996. * @returns a boolean specifying if an alpha test is needed.
  25997. */
  25998. needAlphaTesting(): boolean;
  25999. /**
  26000. * Specifies if material alpha testing should be turned on for the mesh
  26001. * @param mesh defines the mesh to check
  26002. */
  26003. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26004. /**
  26005. * Gets the texture used for the alpha test
  26006. * @returns the texture to use for alpha testing
  26007. */
  26008. getAlphaTestTexture(): Nullable<BaseTexture>;
  26009. /**
  26010. * Marks the material to indicate that it needs to be re-calculated
  26011. */
  26012. markDirty(): void;
  26013. /** @hidden */
  26014. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26015. /**
  26016. * Binds the material to the mesh
  26017. * @param world defines the world transformation matrix
  26018. * @param mesh defines the mesh to bind the material to
  26019. */
  26020. bind(world: Matrix, mesh?: Mesh): void;
  26021. /**
  26022. * Binds the submesh to the material
  26023. * @param world defines the world transformation matrix
  26024. * @param mesh defines the mesh containing the submesh
  26025. * @param subMesh defines the submesh to bind the material to
  26026. */
  26027. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26028. /**
  26029. * Binds the world matrix to the material
  26030. * @param world defines the world transformation matrix
  26031. */
  26032. bindOnlyWorldMatrix(world: Matrix): void;
  26033. /**
  26034. * Binds the scene's uniform buffer to the effect.
  26035. * @param effect defines the effect to bind to the scene uniform buffer
  26036. * @param sceneUbo defines the uniform buffer storing scene data
  26037. */
  26038. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26039. /**
  26040. * Binds the view matrix to the effect
  26041. * @param effect defines the effect to bind the view matrix to
  26042. */
  26043. bindView(effect: Effect): void;
  26044. /**
  26045. * Binds the view projection matrix to the effect
  26046. * @param effect defines the effect to bind the view projection matrix to
  26047. */
  26048. bindViewProjection(effect: Effect): void;
  26049. /**
  26050. * Processes to execute after binding the material to a mesh
  26051. * @param mesh defines the rendered mesh
  26052. */
  26053. protected _afterBind(mesh?: Mesh): void;
  26054. /**
  26055. * Unbinds the material from the mesh
  26056. */
  26057. unbind(): void;
  26058. /**
  26059. * Gets the active textures from the material
  26060. * @returns an array of textures
  26061. */
  26062. getActiveTextures(): BaseTexture[];
  26063. /**
  26064. * Specifies if the material uses a texture
  26065. * @param texture defines the texture to check against the material
  26066. * @returns a boolean specifying if the material uses the texture
  26067. */
  26068. hasTexture(texture: BaseTexture): boolean;
  26069. /**
  26070. * Makes a duplicate of the material, and gives it a new name
  26071. * @param name defines the new name for the duplicated material
  26072. * @returns the cloned material
  26073. */
  26074. clone(name: string): Nullable<Material>;
  26075. /**
  26076. * Gets the meshes bound to the material
  26077. * @returns an array of meshes bound to the material
  26078. */
  26079. getBindedMeshes(): AbstractMesh[];
  26080. /**
  26081. * Force shader compilation
  26082. * @param mesh defines the mesh associated with this material
  26083. * @param onCompiled defines a function to execute once the material is compiled
  26084. * @param options defines the options to configure the compilation
  26085. * @param onError defines a function to execute if the material fails compiling
  26086. */
  26087. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26088. /**
  26089. * Force shader compilation
  26090. * @param mesh defines the mesh that will use this material
  26091. * @param options defines additional options for compiling the shaders
  26092. * @returns a promise that resolves when the compilation completes
  26093. */
  26094. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26095. private static readonly _AllDirtyCallBack;
  26096. private static readonly _ImageProcessingDirtyCallBack;
  26097. private static readonly _TextureDirtyCallBack;
  26098. private static readonly _FresnelDirtyCallBack;
  26099. private static readonly _MiscDirtyCallBack;
  26100. private static readonly _LightsDirtyCallBack;
  26101. private static readonly _AttributeDirtyCallBack;
  26102. private static _FresnelAndMiscDirtyCallBack;
  26103. private static _TextureAndMiscDirtyCallBack;
  26104. private static readonly _DirtyCallbackArray;
  26105. private static readonly _RunDirtyCallBacks;
  26106. /**
  26107. * Marks a define in the material to indicate that it needs to be re-computed
  26108. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26109. */
  26110. markAsDirty(flag: number): void;
  26111. /**
  26112. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26113. * @param func defines a function which checks material defines against the submeshes
  26114. */
  26115. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26116. /**
  26117. * Indicates that the scene should check if the rendering now needs a prepass
  26118. */
  26119. protected _markScenePrePassDirty(): void;
  26120. /**
  26121. * Indicates that we need to re-calculated for all submeshes
  26122. */
  26123. protected _markAllSubMeshesAsAllDirty(): void;
  26124. /**
  26125. * Indicates that image processing needs to be re-calculated for all submeshes
  26126. */
  26127. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26128. /**
  26129. * Indicates that textures need to be re-calculated for all submeshes
  26130. */
  26131. protected _markAllSubMeshesAsTexturesDirty(): void;
  26132. /**
  26133. * Indicates that fresnel needs to be re-calculated for all submeshes
  26134. */
  26135. protected _markAllSubMeshesAsFresnelDirty(): void;
  26136. /**
  26137. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26138. */
  26139. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26140. /**
  26141. * Indicates that lights need to be re-calculated for all submeshes
  26142. */
  26143. protected _markAllSubMeshesAsLightsDirty(): void;
  26144. /**
  26145. * Indicates that attributes need to be re-calculated for all submeshes
  26146. */
  26147. protected _markAllSubMeshesAsAttributesDirty(): void;
  26148. /**
  26149. * Indicates that misc needs to be re-calculated for all submeshes
  26150. */
  26151. protected _markAllSubMeshesAsMiscDirty(): void;
  26152. /**
  26153. * Indicates that textures and misc need to be re-calculated for all submeshes
  26154. */
  26155. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26156. /**
  26157. * Sets the required values to the prepass renderer.
  26158. * @param prePassRenderer defines the prepass renderer to setup.
  26159. * @returns true if the pre pass is needed.
  26160. */
  26161. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26162. /**
  26163. * Disposes the material
  26164. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26165. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26166. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26167. */
  26168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26169. /** @hidden */
  26170. private releaseVertexArrayObject;
  26171. /**
  26172. * Serializes this material
  26173. * @returns the serialized material object
  26174. */
  26175. serialize(): any;
  26176. /**
  26177. * Creates a material from parsed material data
  26178. * @param parsedMaterial defines parsed material data
  26179. * @param scene defines the hosting scene
  26180. * @param rootUrl defines the root URL to use to load textures
  26181. * @returns a new material
  26182. */
  26183. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26184. }
  26185. }
  26186. declare module "babylonjs/Materials/multiMaterial" {
  26187. import { Nullable } from "babylonjs/types";
  26188. import { Scene } from "babylonjs/scene";
  26189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26192. import { Material } from "babylonjs/Materials/material";
  26193. /**
  26194. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26195. * separate meshes. This can be use to improve performances.
  26196. * @see https://doc.babylonjs.com/how_to/multi_materials
  26197. */
  26198. export class MultiMaterial extends Material {
  26199. private _subMaterials;
  26200. /**
  26201. * Gets or Sets the list of Materials used within the multi material.
  26202. * They need to be ordered according to the submeshes order in the associated mesh
  26203. */
  26204. get subMaterials(): Nullable<Material>[];
  26205. set subMaterials(value: Nullable<Material>[]);
  26206. /**
  26207. * Function used to align with Node.getChildren()
  26208. * @returns the list of Materials used within the multi material
  26209. */
  26210. getChildren(): Nullable<Material>[];
  26211. /**
  26212. * Instantiates a new Multi Material
  26213. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26214. * separate meshes. This can be use to improve performances.
  26215. * @see https://doc.babylonjs.com/how_to/multi_materials
  26216. * @param name Define the name in the scene
  26217. * @param scene Define the scene the material belongs to
  26218. */
  26219. constructor(name: string, scene: Scene);
  26220. private _hookArray;
  26221. /**
  26222. * Get one of the submaterial by its index in the submaterials array
  26223. * @param index The index to look the sub material at
  26224. * @returns The Material if the index has been defined
  26225. */
  26226. getSubMaterial(index: number): Nullable<Material>;
  26227. /**
  26228. * Get the list of active textures for the whole sub materials list.
  26229. * @returns All the textures that will be used during the rendering
  26230. */
  26231. getActiveTextures(): BaseTexture[];
  26232. /**
  26233. * Gets the current class name of the material e.g. "MultiMaterial"
  26234. * Mainly use in serialization.
  26235. * @returns the class name
  26236. */
  26237. getClassName(): string;
  26238. /**
  26239. * Checks if the material is ready to render the requested sub mesh
  26240. * @param mesh Define the mesh the submesh belongs to
  26241. * @param subMesh Define the sub mesh to look readyness for
  26242. * @param useInstances Define whether or not the material is used with instances
  26243. * @returns true if ready, otherwise false
  26244. */
  26245. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26246. /**
  26247. * Clones the current material and its related sub materials
  26248. * @param name Define the name of the newly cloned material
  26249. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26250. * @returns the cloned material
  26251. */
  26252. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26253. /**
  26254. * Serializes the materials into a JSON representation.
  26255. * @returns the JSON representation
  26256. */
  26257. serialize(): any;
  26258. /**
  26259. * Dispose the material and release its associated resources
  26260. * @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)
  26261. * @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)
  26262. * @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)
  26263. */
  26264. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26265. /**
  26266. * Creates a MultiMaterial from parsed MultiMaterial data.
  26267. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26268. * @param scene defines the hosting scene
  26269. * @returns a new MultiMaterial
  26270. */
  26271. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26272. }
  26273. }
  26274. declare module "babylonjs/Meshes/subMesh" {
  26275. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26276. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26277. import { Engine } from "babylonjs/Engines/engine";
  26278. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26279. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26280. import { Effect } from "babylonjs/Materials/effect";
  26281. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26282. import { Plane } from "babylonjs/Maths/math.plane";
  26283. import { Collider } from "babylonjs/Collisions/collider";
  26284. import { Material } from "babylonjs/Materials/material";
  26285. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26287. import { Mesh } from "babylonjs/Meshes/mesh";
  26288. import { Ray } from "babylonjs/Culling/ray";
  26289. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26290. /**
  26291. * Defines a subdivision inside a mesh
  26292. */
  26293. export class SubMesh implements ICullable {
  26294. /** the material index to use */
  26295. materialIndex: number;
  26296. /** vertex index start */
  26297. verticesStart: number;
  26298. /** vertices count */
  26299. verticesCount: number;
  26300. /** index start */
  26301. indexStart: number;
  26302. /** indices count */
  26303. indexCount: number;
  26304. /** @hidden */
  26305. _materialDefines: Nullable<MaterialDefines>;
  26306. /** @hidden */
  26307. _materialEffect: Nullable<Effect>;
  26308. /** @hidden */
  26309. _effectOverride: Nullable<Effect>;
  26310. /**
  26311. * Gets material defines used by the effect associated to the sub mesh
  26312. */
  26313. get materialDefines(): Nullable<MaterialDefines>;
  26314. /**
  26315. * Sets material defines used by the effect associated to the sub mesh
  26316. */
  26317. set materialDefines(defines: Nullable<MaterialDefines>);
  26318. /**
  26319. * Gets associated effect
  26320. */
  26321. get effect(): Nullable<Effect>;
  26322. /**
  26323. * Sets associated effect (effect used to render this submesh)
  26324. * @param effect defines the effect to associate with
  26325. * @param defines defines the set of defines used to compile this effect
  26326. */
  26327. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26328. /** @hidden */
  26329. _linesIndexCount: number;
  26330. private _mesh;
  26331. private _renderingMesh;
  26332. private _boundingInfo;
  26333. private _linesIndexBuffer;
  26334. /** @hidden */
  26335. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26336. /** @hidden */
  26337. _trianglePlanes: Plane[];
  26338. /** @hidden */
  26339. _lastColliderTransformMatrix: Nullable<Matrix>;
  26340. /** @hidden */
  26341. _renderId: number;
  26342. /** @hidden */
  26343. _alphaIndex: number;
  26344. /** @hidden */
  26345. _distanceToCamera: number;
  26346. /** @hidden */
  26347. _id: number;
  26348. private _currentMaterial;
  26349. /**
  26350. * Add a new submesh to a mesh
  26351. * @param materialIndex defines the material index to use
  26352. * @param verticesStart defines vertex index start
  26353. * @param verticesCount defines vertices count
  26354. * @param indexStart defines index start
  26355. * @param indexCount defines indices count
  26356. * @param mesh defines the parent mesh
  26357. * @param renderingMesh defines an optional rendering mesh
  26358. * @param createBoundingBox defines if bounding box should be created for this submesh
  26359. * @returns the new submesh
  26360. */
  26361. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26362. /**
  26363. * Creates a new submesh
  26364. * @param materialIndex defines the material index to use
  26365. * @param verticesStart defines vertex index start
  26366. * @param verticesCount defines vertices count
  26367. * @param indexStart defines index start
  26368. * @param indexCount defines indices count
  26369. * @param mesh defines the parent mesh
  26370. * @param renderingMesh defines an optional rendering mesh
  26371. * @param createBoundingBox defines if bounding box should be created for this submesh
  26372. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26373. */
  26374. constructor(
  26375. /** the material index to use */
  26376. materialIndex: number,
  26377. /** vertex index start */
  26378. verticesStart: number,
  26379. /** vertices count */
  26380. verticesCount: number,
  26381. /** index start */
  26382. indexStart: number,
  26383. /** indices count */
  26384. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26385. /**
  26386. * Returns true if this submesh covers the entire parent mesh
  26387. * @ignorenaming
  26388. */
  26389. get IsGlobal(): boolean;
  26390. /**
  26391. * Returns the submesh BoudingInfo object
  26392. * @returns current bounding info (or mesh's one if the submesh is global)
  26393. */
  26394. getBoundingInfo(): BoundingInfo;
  26395. /**
  26396. * Sets the submesh BoundingInfo
  26397. * @param boundingInfo defines the new bounding info to use
  26398. * @returns the SubMesh
  26399. */
  26400. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26401. /**
  26402. * Returns the mesh of the current submesh
  26403. * @return the parent mesh
  26404. */
  26405. getMesh(): AbstractMesh;
  26406. /**
  26407. * Returns the rendering mesh of the submesh
  26408. * @returns the rendering mesh (could be different from parent mesh)
  26409. */
  26410. getRenderingMesh(): Mesh;
  26411. /**
  26412. * Returns the replacement mesh of the submesh
  26413. * @returns the replacement mesh (could be different from parent mesh)
  26414. */
  26415. getReplacementMesh(): Nullable<AbstractMesh>;
  26416. /**
  26417. * Returns the effective mesh of the submesh
  26418. * @returns the effective mesh (could be different from parent mesh)
  26419. */
  26420. getEffectiveMesh(): AbstractMesh;
  26421. /**
  26422. * Returns the submesh material
  26423. * @returns null or the current material
  26424. */
  26425. getMaterial(): Nullable<Material>;
  26426. private _IsMultiMaterial;
  26427. /**
  26428. * Sets a new updated BoundingInfo object to the submesh
  26429. * @param data defines an optional position array to use to determine the bounding info
  26430. * @returns the SubMesh
  26431. */
  26432. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26433. /** @hidden */
  26434. _checkCollision(collider: Collider): boolean;
  26435. /**
  26436. * Updates the submesh BoundingInfo
  26437. * @param world defines the world matrix to use to update the bounding info
  26438. * @returns the submesh
  26439. */
  26440. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26441. /**
  26442. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26443. * @param frustumPlanes defines the frustum planes
  26444. * @returns true if the submesh is intersecting with the frustum
  26445. */
  26446. isInFrustum(frustumPlanes: Plane[]): boolean;
  26447. /**
  26448. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26449. * @param frustumPlanes defines the frustum planes
  26450. * @returns true if the submesh is inside the frustum
  26451. */
  26452. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26453. /**
  26454. * Renders the submesh
  26455. * @param enableAlphaMode defines if alpha needs to be used
  26456. * @returns the submesh
  26457. */
  26458. render(enableAlphaMode: boolean): SubMesh;
  26459. /**
  26460. * @hidden
  26461. */
  26462. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26463. /**
  26464. * Checks if the submesh intersects with a ray
  26465. * @param ray defines the ray to test
  26466. * @returns true is the passed ray intersects the submesh bounding box
  26467. */
  26468. canIntersects(ray: Ray): boolean;
  26469. /**
  26470. * Intersects current submesh with a ray
  26471. * @param ray defines the ray to test
  26472. * @param positions defines mesh's positions array
  26473. * @param indices defines mesh's indices array
  26474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26476. * @returns intersection info or null if no intersection
  26477. */
  26478. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26479. /** @hidden */
  26480. private _intersectLines;
  26481. /** @hidden */
  26482. private _intersectUnIndexedLines;
  26483. /** @hidden */
  26484. private _intersectTriangles;
  26485. /** @hidden */
  26486. private _intersectUnIndexedTriangles;
  26487. /** @hidden */
  26488. _rebuild(): void;
  26489. /**
  26490. * Creates a new submesh from the passed mesh
  26491. * @param newMesh defines the new hosting mesh
  26492. * @param newRenderingMesh defines an optional rendering mesh
  26493. * @returns the new submesh
  26494. */
  26495. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26496. /**
  26497. * Release associated resources
  26498. */
  26499. dispose(): void;
  26500. /**
  26501. * Gets the class name
  26502. * @returns the string "SubMesh".
  26503. */
  26504. getClassName(): string;
  26505. /**
  26506. * Creates a new submesh from indices data
  26507. * @param materialIndex the index of the main mesh material
  26508. * @param startIndex the index where to start the copy in the mesh indices array
  26509. * @param indexCount the number of indices to copy then from the startIndex
  26510. * @param mesh the main mesh to create the submesh from
  26511. * @param renderingMesh the optional rendering mesh
  26512. * @returns a new submesh
  26513. */
  26514. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26515. }
  26516. }
  26517. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26518. /**
  26519. * Class used to represent data loading progression
  26520. */
  26521. export class SceneLoaderFlags {
  26522. private static _ForceFullSceneLoadingForIncremental;
  26523. private static _ShowLoadingScreen;
  26524. private static _CleanBoneMatrixWeights;
  26525. private static _loggingLevel;
  26526. /**
  26527. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26528. */
  26529. static get ForceFullSceneLoadingForIncremental(): boolean;
  26530. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26531. /**
  26532. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26533. */
  26534. static get ShowLoadingScreen(): boolean;
  26535. static set ShowLoadingScreen(value: boolean);
  26536. /**
  26537. * Defines the current logging level (while loading the scene)
  26538. * @ignorenaming
  26539. */
  26540. static get loggingLevel(): number;
  26541. static set loggingLevel(value: number);
  26542. /**
  26543. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26544. */
  26545. static get CleanBoneMatrixWeights(): boolean;
  26546. static set CleanBoneMatrixWeights(value: boolean);
  26547. }
  26548. }
  26549. declare module "babylonjs/Meshes/geometry" {
  26550. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26551. import { Scene } from "babylonjs/scene";
  26552. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26553. import { Engine } from "babylonjs/Engines/engine";
  26554. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26555. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26556. import { Effect } from "babylonjs/Materials/effect";
  26557. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26559. import { Mesh } from "babylonjs/Meshes/mesh";
  26560. /**
  26561. * Class used to store geometry data (vertex buffers + index buffer)
  26562. */
  26563. export class Geometry implements IGetSetVerticesData {
  26564. /**
  26565. * Gets or sets the ID of the geometry
  26566. */
  26567. id: string;
  26568. /**
  26569. * Gets or sets the unique ID of the geometry
  26570. */
  26571. uniqueId: number;
  26572. /**
  26573. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26574. */
  26575. delayLoadState: number;
  26576. /**
  26577. * Gets the file containing the data to load when running in delay load state
  26578. */
  26579. delayLoadingFile: Nullable<string>;
  26580. /**
  26581. * Callback called when the geometry is updated
  26582. */
  26583. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26584. private _scene;
  26585. private _engine;
  26586. private _meshes;
  26587. private _totalVertices;
  26588. /** @hidden */
  26589. _indices: IndicesArray;
  26590. /** @hidden */
  26591. _vertexBuffers: {
  26592. [key: string]: VertexBuffer;
  26593. };
  26594. private _isDisposed;
  26595. private _extend;
  26596. private _boundingBias;
  26597. /** @hidden */
  26598. _delayInfo: Array<string>;
  26599. private _indexBuffer;
  26600. private _indexBufferIsUpdatable;
  26601. /** @hidden */
  26602. _boundingInfo: Nullable<BoundingInfo>;
  26603. /** @hidden */
  26604. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26605. /** @hidden */
  26606. _softwareSkinningFrameId: number;
  26607. private _vertexArrayObjects;
  26608. private _updatable;
  26609. /** @hidden */
  26610. _positions: Nullable<Vector3[]>;
  26611. /**
  26612. * 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
  26613. */
  26614. get boundingBias(): Vector2;
  26615. /**
  26616. * 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
  26617. */
  26618. set boundingBias(value: Vector2);
  26619. /**
  26620. * Static function used to attach a new empty geometry to a mesh
  26621. * @param mesh defines the mesh to attach the geometry to
  26622. * @returns the new Geometry
  26623. */
  26624. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26625. /** Get the list of meshes using this geometry */
  26626. get meshes(): Mesh[];
  26627. /**
  26628. * 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
  26629. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26630. */
  26631. useBoundingInfoFromGeometry: boolean;
  26632. /**
  26633. * Creates a new geometry
  26634. * @param id defines the unique ID
  26635. * @param scene defines the hosting scene
  26636. * @param vertexData defines the VertexData used to get geometry data
  26637. * @param updatable defines if geometry must be updatable (false by default)
  26638. * @param mesh defines the mesh that will be associated with the geometry
  26639. */
  26640. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26641. /**
  26642. * Gets the current extend of the geometry
  26643. */
  26644. get extend(): {
  26645. minimum: Vector3;
  26646. maximum: Vector3;
  26647. };
  26648. /**
  26649. * Gets the hosting scene
  26650. * @returns the hosting Scene
  26651. */
  26652. getScene(): Scene;
  26653. /**
  26654. * Gets the hosting engine
  26655. * @returns the hosting Engine
  26656. */
  26657. getEngine(): Engine;
  26658. /**
  26659. * Defines if the geometry is ready to use
  26660. * @returns true if the geometry is ready to be used
  26661. */
  26662. isReady(): boolean;
  26663. /**
  26664. * Gets a value indicating that the geometry should not be serialized
  26665. */
  26666. get doNotSerialize(): boolean;
  26667. /** @hidden */
  26668. _rebuild(): void;
  26669. /**
  26670. * Affects all geometry data in one call
  26671. * @param vertexData defines the geometry data
  26672. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26673. */
  26674. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26675. /**
  26676. * Set specific vertex data
  26677. * @param kind defines the data kind (Position, normal, etc...)
  26678. * @param data defines the vertex data to use
  26679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26681. */
  26682. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26683. /**
  26684. * Removes a specific vertex data
  26685. * @param kind defines the data kind (Position, normal, etc...)
  26686. */
  26687. removeVerticesData(kind: string): void;
  26688. /**
  26689. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26690. * @param buffer defines the vertex buffer to use
  26691. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26692. */
  26693. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26694. /**
  26695. * Update a specific vertex buffer
  26696. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26697. * It will do nothing if the buffer is not updatable
  26698. * @param kind defines the data kind (Position, normal, etc...)
  26699. * @param data defines the data to use
  26700. * @param offset defines the offset in the target buffer where to store the data
  26701. * @param useBytes set to true if the offset is in bytes
  26702. */
  26703. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26704. /**
  26705. * Update a specific vertex buffer
  26706. * This function will create a new buffer if the current one is not updatable
  26707. * @param kind defines the data kind (Position, normal, etc...)
  26708. * @param data defines the data to use
  26709. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26710. */
  26711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26712. private _updateBoundingInfo;
  26713. /** @hidden */
  26714. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26715. /**
  26716. * Gets total number of vertices
  26717. * @returns the total number of vertices
  26718. */
  26719. getTotalVertices(): number;
  26720. /**
  26721. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26722. * @param kind defines the data kind (Position, normal, etc...)
  26723. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26724. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26725. * @returns a float array containing vertex data
  26726. */
  26727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26728. /**
  26729. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26730. * @param kind defines the data kind (Position, normal, etc...)
  26731. * @returns true if the vertex buffer with the specified kind is updatable
  26732. */
  26733. isVertexBufferUpdatable(kind: string): boolean;
  26734. /**
  26735. * Gets a specific vertex buffer
  26736. * @param kind defines the data kind (Position, normal, etc...)
  26737. * @returns a VertexBuffer
  26738. */
  26739. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26740. /**
  26741. * Returns all vertex buffers
  26742. * @return an object holding all vertex buffers indexed by kind
  26743. */
  26744. getVertexBuffers(): Nullable<{
  26745. [key: string]: VertexBuffer;
  26746. }>;
  26747. /**
  26748. * Gets a boolean indicating if specific vertex buffer is present
  26749. * @param kind defines the data kind (Position, normal, etc...)
  26750. * @returns true if data is present
  26751. */
  26752. isVerticesDataPresent(kind: string): boolean;
  26753. /**
  26754. * Gets a list of all attached data kinds (Position, normal, etc...)
  26755. * @returns a list of string containing all kinds
  26756. */
  26757. getVerticesDataKinds(): string[];
  26758. /**
  26759. * Update index buffer
  26760. * @param indices defines the indices to store in the index buffer
  26761. * @param offset defines the offset in the target buffer where to store the data
  26762. * @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)
  26763. */
  26764. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26765. /**
  26766. * Creates a new index buffer
  26767. * @param indices defines the indices to store in the index buffer
  26768. * @param totalVertices defines the total number of vertices (could be null)
  26769. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26770. */
  26771. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26772. /**
  26773. * Return the total number of indices
  26774. * @returns the total number of indices
  26775. */
  26776. getTotalIndices(): number;
  26777. /**
  26778. * Gets the index buffer array
  26779. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26780. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26781. * @returns the index buffer array
  26782. */
  26783. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26784. /**
  26785. * Gets the index buffer
  26786. * @return the index buffer
  26787. */
  26788. getIndexBuffer(): Nullable<DataBuffer>;
  26789. /** @hidden */
  26790. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26791. /**
  26792. * Release the associated resources for a specific mesh
  26793. * @param mesh defines the source mesh
  26794. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26795. */
  26796. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26797. /**
  26798. * Apply current geometry to a given mesh
  26799. * @param mesh defines the mesh to apply geometry to
  26800. */
  26801. applyToMesh(mesh: Mesh): void;
  26802. private _updateExtend;
  26803. private _applyToMesh;
  26804. private notifyUpdate;
  26805. /**
  26806. * Load the geometry if it was flagged as delay loaded
  26807. * @param scene defines the hosting scene
  26808. * @param onLoaded defines a callback called when the geometry is loaded
  26809. */
  26810. load(scene: Scene, onLoaded?: () => void): void;
  26811. private _queueLoad;
  26812. /**
  26813. * Invert the geometry to move from a right handed system to a left handed one.
  26814. */
  26815. toLeftHanded(): void;
  26816. /** @hidden */
  26817. _resetPointsArrayCache(): void;
  26818. /** @hidden */
  26819. _generatePointsArray(): boolean;
  26820. /**
  26821. * Gets a value indicating if the geometry is disposed
  26822. * @returns true if the geometry was disposed
  26823. */
  26824. isDisposed(): boolean;
  26825. private _disposeVertexArrayObjects;
  26826. /**
  26827. * Free all associated resources
  26828. */
  26829. dispose(): void;
  26830. /**
  26831. * Clone the current geometry into a new geometry
  26832. * @param id defines the unique ID of the new geometry
  26833. * @returns a new geometry object
  26834. */
  26835. copy(id: string): Geometry;
  26836. /**
  26837. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26838. * @return a JSON representation of the current geometry data (without the vertices data)
  26839. */
  26840. serialize(): any;
  26841. private toNumberArray;
  26842. /**
  26843. * Serialize all vertices data into a JSON oject
  26844. * @returns a JSON representation of the current geometry data
  26845. */
  26846. serializeVerticeData(): any;
  26847. /**
  26848. * Extracts a clone of a mesh geometry
  26849. * @param mesh defines the source mesh
  26850. * @param id defines the unique ID of the new geometry object
  26851. * @returns the new geometry object
  26852. */
  26853. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26854. /**
  26855. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26856. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26857. * Be aware Math.random() could cause collisions, but:
  26858. * "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"
  26859. * @returns a string containing a new GUID
  26860. */
  26861. static RandomId(): string;
  26862. /** @hidden */
  26863. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26864. private static _CleanMatricesWeights;
  26865. /**
  26866. * Create a new geometry from persisted data (Using .babylon file format)
  26867. * @param parsedVertexData defines the persisted data
  26868. * @param scene defines the hosting scene
  26869. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26870. * @returns the new geometry object
  26871. */
  26872. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26873. }
  26874. }
  26875. declare module "babylonjs/Meshes/mesh.vertexData" {
  26876. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26877. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26878. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26879. import { Geometry } from "babylonjs/Meshes/geometry";
  26880. import { Mesh } from "babylonjs/Meshes/mesh";
  26881. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26882. /**
  26883. * Define an interface for all classes that will get and set the data on vertices
  26884. */
  26885. export interface IGetSetVerticesData {
  26886. /**
  26887. * Gets a boolean indicating if specific vertex data is present
  26888. * @param kind defines the vertex data kind to use
  26889. * @returns true is data kind is present
  26890. */
  26891. isVerticesDataPresent(kind: string): boolean;
  26892. /**
  26893. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26894. * @param kind defines the data kind (Position, normal, etc...)
  26895. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26897. * @returns a float array containing vertex data
  26898. */
  26899. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26900. /**
  26901. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26902. * @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.
  26903. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26904. * @returns the indices array or an empty array if the mesh has no geometry
  26905. */
  26906. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26907. /**
  26908. * Set specific vertex data
  26909. * @param kind defines the data kind (Position, normal, etc...)
  26910. * @param data defines the vertex data to use
  26911. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26912. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26913. */
  26914. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26915. /**
  26916. * Update a specific associated vertex buffer
  26917. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26918. * - VertexBuffer.PositionKind
  26919. * - VertexBuffer.UVKind
  26920. * - VertexBuffer.UV2Kind
  26921. * - VertexBuffer.UV3Kind
  26922. * - VertexBuffer.UV4Kind
  26923. * - VertexBuffer.UV5Kind
  26924. * - VertexBuffer.UV6Kind
  26925. * - VertexBuffer.ColorKind
  26926. * - VertexBuffer.MatricesIndicesKind
  26927. * - VertexBuffer.MatricesIndicesExtraKind
  26928. * - VertexBuffer.MatricesWeightsKind
  26929. * - VertexBuffer.MatricesWeightsExtraKind
  26930. * @param data defines the data source
  26931. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26932. * @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)
  26933. */
  26934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26935. /**
  26936. * Creates a new index buffer
  26937. * @param indices defines the indices to store in the index buffer
  26938. * @param totalVertices defines the total number of vertices (could be null)
  26939. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26940. */
  26941. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26942. }
  26943. /**
  26944. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26945. */
  26946. export class VertexData {
  26947. /**
  26948. * Mesh side orientation : usually the external or front surface
  26949. */
  26950. static readonly FRONTSIDE: number;
  26951. /**
  26952. * Mesh side orientation : usually the internal or back surface
  26953. */
  26954. static readonly BACKSIDE: number;
  26955. /**
  26956. * Mesh side orientation : both internal and external or front and back surfaces
  26957. */
  26958. static readonly DOUBLESIDE: number;
  26959. /**
  26960. * Mesh side orientation : by default, `FRONTSIDE`
  26961. */
  26962. static readonly DEFAULTSIDE: number;
  26963. /**
  26964. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26965. */
  26966. positions: Nullable<FloatArray>;
  26967. /**
  26968. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26969. */
  26970. normals: Nullable<FloatArray>;
  26971. /**
  26972. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26973. */
  26974. tangents: Nullable<FloatArray>;
  26975. /**
  26976. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26977. */
  26978. uvs: Nullable<FloatArray>;
  26979. /**
  26980. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26981. */
  26982. uvs2: Nullable<FloatArray>;
  26983. /**
  26984. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26985. */
  26986. uvs3: Nullable<FloatArray>;
  26987. /**
  26988. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26989. */
  26990. uvs4: Nullable<FloatArray>;
  26991. /**
  26992. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26993. */
  26994. uvs5: Nullable<FloatArray>;
  26995. /**
  26996. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26997. */
  26998. uvs6: Nullable<FloatArray>;
  26999. /**
  27000. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27001. */
  27002. colors: Nullable<FloatArray>;
  27003. /**
  27004. * 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).
  27005. */
  27006. matricesIndices: Nullable<FloatArray>;
  27007. /**
  27008. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27009. */
  27010. matricesWeights: Nullable<FloatArray>;
  27011. /**
  27012. * An array extending the number of possible indices
  27013. */
  27014. matricesIndicesExtra: Nullable<FloatArray>;
  27015. /**
  27016. * An array extending the number of possible weights when the number of indices is extended
  27017. */
  27018. matricesWeightsExtra: Nullable<FloatArray>;
  27019. /**
  27020. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27021. */
  27022. indices: Nullable<IndicesArray>;
  27023. /**
  27024. * Uses the passed data array to set the set the values for the specified kind of data
  27025. * @param data a linear array of floating numbers
  27026. * @param kind the type of data that is being set, eg positions, colors etc
  27027. */
  27028. set(data: FloatArray, kind: string): void;
  27029. /**
  27030. * Associates the vertexData to the passed Mesh.
  27031. * Sets it as updatable or not (default `false`)
  27032. * @param mesh the mesh the vertexData is applied to
  27033. * @param updatable when used and having the value true allows new data to update the vertexData
  27034. * @returns the VertexData
  27035. */
  27036. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27037. /**
  27038. * Associates the vertexData to the passed Geometry.
  27039. * Sets it as updatable or not (default `false`)
  27040. * @param geometry the geometry the vertexData is applied to
  27041. * @param updatable when used and having the value true allows new data to update the vertexData
  27042. * @returns VertexData
  27043. */
  27044. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27045. /**
  27046. * Updates the associated mesh
  27047. * @param mesh the mesh to be updated
  27048. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27049. * @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
  27050. * @returns VertexData
  27051. */
  27052. updateMesh(mesh: Mesh): VertexData;
  27053. /**
  27054. * Updates the associated geometry
  27055. * @param geometry the geometry to be updated
  27056. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27057. * @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
  27058. * @returns VertexData.
  27059. */
  27060. updateGeometry(geometry: Geometry): VertexData;
  27061. private _applyTo;
  27062. private _update;
  27063. /**
  27064. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27065. * @param matrix the transforming matrix
  27066. * @returns the VertexData
  27067. */
  27068. transform(matrix: Matrix): VertexData;
  27069. /**
  27070. * Merges the passed VertexData into the current one
  27071. * @param other the VertexData to be merged into the current one
  27072. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27073. * @returns the modified VertexData
  27074. */
  27075. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27076. private _mergeElement;
  27077. private _validate;
  27078. /**
  27079. * Serializes the VertexData
  27080. * @returns a serialized object
  27081. */
  27082. serialize(): any;
  27083. /**
  27084. * Extracts the vertexData from a mesh
  27085. * @param mesh the mesh from which to extract the VertexData
  27086. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27088. * @returns the object VertexData associated to the passed mesh
  27089. */
  27090. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27091. /**
  27092. * Extracts the vertexData from the geometry
  27093. * @param geometry the geometry from which to extract the VertexData
  27094. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27095. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27096. * @returns the object VertexData associated to the passed mesh
  27097. */
  27098. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27099. private static _ExtractFrom;
  27100. /**
  27101. * Creates the VertexData for a Ribbon
  27102. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27103. * * pathArray array of paths, each of which an array of successive Vector3
  27104. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27105. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27106. * * 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
  27107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27108. * * 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)
  27109. * * 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)
  27110. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27111. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27112. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27113. * @returns the VertexData of the ribbon
  27114. */
  27115. static CreateRibbon(options: {
  27116. pathArray: Vector3[][];
  27117. closeArray?: boolean;
  27118. closePath?: boolean;
  27119. offset?: number;
  27120. sideOrientation?: number;
  27121. frontUVs?: Vector4;
  27122. backUVs?: Vector4;
  27123. invertUV?: boolean;
  27124. uvs?: Vector2[];
  27125. colors?: Color4[];
  27126. }): VertexData;
  27127. /**
  27128. * Creates the VertexData for a box
  27129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27130. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27131. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27132. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27133. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27134. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27135. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27137. * * 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)
  27138. * * 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)
  27139. * @returns the VertexData of the box
  27140. */
  27141. static CreateBox(options: {
  27142. size?: number;
  27143. width?: number;
  27144. height?: number;
  27145. depth?: number;
  27146. faceUV?: Vector4[];
  27147. faceColors?: Color4[];
  27148. sideOrientation?: number;
  27149. frontUVs?: Vector4;
  27150. backUVs?: Vector4;
  27151. }): VertexData;
  27152. /**
  27153. * Creates the VertexData for a tiled box
  27154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27155. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27156. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27157. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27159. * @returns the VertexData of the box
  27160. */
  27161. static CreateTiledBox(options: {
  27162. pattern?: number;
  27163. width?: number;
  27164. height?: number;
  27165. depth?: number;
  27166. tileSize?: number;
  27167. tileWidth?: number;
  27168. tileHeight?: number;
  27169. alignHorizontal?: number;
  27170. alignVertical?: number;
  27171. faceUV?: Vector4[];
  27172. faceColors?: Color4[];
  27173. sideOrientation?: number;
  27174. }): VertexData;
  27175. /**
  27176. * Creates the VertexData for a tiled plane
  27177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27178. * * pattern a limited pattern arrangement depending on the number
  27179. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27180. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27181. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27183. * * 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)
  27184. * * 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)
  27185. * @returns the VertexData of the tiled plane
  27186. */
  27187. static CreateTiledPlane(options: {
  27188. pattern?: number;
  27189. tileSize?: number;
  27190. tileWidth?: number;
  27191. tileHeight?: number;
  27192. size?: number;
  27193. width?: number;
  27194. height?: number;
  27195. alignHorizontal?: number;
  27196. alignVertical?: number;
  27197. sideOrientation?: number;
  27198. frontUVs?: Vector4;
  27199. backUVs?: Vector4;
  27200. }): VertexData;
  27201. /**
  27202. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27204. * * segments sets the number of horizontal strips optional, default 32
  27205. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27206. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27207. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27208. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27209. * * 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
  27210. * * 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
  27211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27212. * * 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)
  27213. * * 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)
  27214. * @returns the VertexData of the ellipsoid
  27215. */
  27216. static CreateSphere(options: {
  27217. segments?: number;
  27218. diameter?: number;
  27219. diameterX?: number;
  27220. diameterY?: number;
  27221. diameterZ?: number;
  27222. arc?: number;
  27223. slice?: number;
  27224. sideOrientation?: number;
  27225. frontUVs?: Vector4;
  27226. backUVs?: Vector4;
  27227. }): VertexData;
  27228. /**
  27229. * Creates the VertexData for a cylinder, cone or prism
  27230. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27231. * * height sets the height (y direction) of the cylinder, optional, default 2
  27232. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27233. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27234. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27235. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27236. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27237. * * 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
  27238. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27239. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27240. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27241. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27243. * * 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)
  27244. * * 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)
  27245. * @returns the VertexData of the cylinder, cone or prism
  27246. */
  27247. static CreateCylinder(options: {
  27248. height?: number;
  27249. diameterTop?: number;
  27250. diameterBottom?: number;
  27251. diameter?: number;
  27252. tessellation?: number;
  27253. subdivisions?: number;
  27254. arc?: number;
  27255. faceColors?: Color4[];
  27256. faceUV?: Vector4[];
  27257. hasRings?: boolean;
  27258. enclose?: boolean;
  27259. sideOrientation?: number;
  27260. frontUVs?: Vector4;
  27261. backUVs?: Vector4;
  27262. }): VertexData;
  27263. /**
  27264. * Creates the VertexData for a torus
  27265. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27266. * * diameter the diameter of the torus, optional default 1
  27267. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27268. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27270. * * 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)
  27271. * * 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)
  27272. * @returns the VertexData of the torus
  27273. */
  27274. static CreateTorus(options: {
  27275. diameter?: number;
  27276. thickness?: number;
  27277. tessellation?: number;
  27278. sideOrientation?: number;
  27279. frontUVs?: Vector4;
  27280. backUVs?: Vector4;
  27281. }): VertexData;
  27282. /**
  27283. * Creates the VertexData of the LineSystem
  27284. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27285. * - lines an array of lines, each line being an array of successive Vector3
  27286. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27287. * @returns the VertexData of the LineSystem
  27288. */
  27289. static CreateLineSystem(options: {
  27290. lines: Vector3[][];
  27291. colors?: Nullable<Color4[][]>;
  27292. }): VertexData;
  27293. /**
  27294. * Create the VertexData for a DashedLines
  27295. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27296. * - points an array successive Vector3
  27297. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27298. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27299. * - dashNb the intended total number of dashes, optional, default 200
  27300. * @returns the VertexData for the DashedLines
  27301. */
  27302. static CreateDashedLines(options: {
  27303. points: Vector3[];
  27304. dashSize?: number;
  27305. gapSize?: number;
  27306. dashNb?: number;
  27307. }): VertexData;
  27308. /**
  27309. * Creates the VertexData for a Ground
  27310. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27311. * - width the width (x direction) of the ground, optional, default 1
  27312. * - height the height (z direction) of the ground, optional, default 1
  27313. * - subdivisions the number of subdivisions per side, optional, default 1
  27314. * @returns the VertexData of the Ground
  27315. */
  27316. static CreateGround(options: {
  27317. width?: number;
  27318. height?: number;
  27319. subdivisions?: number;
  27320. subdivisionsX?: number;
  27321. subdivisionsY?: number;
  27322. }): VertexData;
  27323. /**
  27324. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27325. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27326. * * xmin the ground minimum X coordinate, optional, default -1
  27327. * * zmin the ground minimum Z coordinate, optional, default -1
  27328. * * xmax the ground maximum X coordinate, optional, default 1
  27329. * * zmax the ground maximum Z coordinate, optional, default 1
  27330. * * 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}
  27331. * * 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}
  27332. * @returns the VertexData of the TiledGround
  27333. */
  27334. static CreateTiledGround(options: {
  27335. xmin: number;
  27336. zmin: number;
  27337. xmax: number;
  27338. zmax: number;
  27339. subdivisions?: {
  27340. w: number;
  27341. h: number;
  27342. };
  27343. precision?: {
  27344. w: number;
  27345. h: number;
  27346. };
  27347. }): VertexData;
  27348. /**
  27349. * Creates the VertexData of the Ground designed from a heightmap
  27350. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27351. * * width the width (x direction) of the ground
  27352. * * height the height (z direction) of the ground
  27353. * * subdivisions the number of subdivisions per side
  27354. * * minHeight the minimum altitude on the ground, optional, default 0
  27355. * * maxHeight the maximum altitude on the ground, optional default 1
  27356. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27357. * * buffer the array holding the image color data
  27358. * * bufferWidth the width of image
  27359. * * bufferHeight the height of image
  27360. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27361. * @returns the VertexData of the Ground designed from a heightmap
  27362. */
  27363. static CreateGroundFromHeightMap(options: {
  27364. width: number;
  27365. height: number;
  27366. subdivisions: number;
  27367. minHeight: number;
  27368. maxHeight: number;
  27369. colorFilter: Color3;
  27370. buffer: Uint8Array;
  27371. bufferWidth: number;
  27372. bufferHeight: number;
  27373. alphaFilter: number;
  27374. }): VertexData;
  27375. /**
  27376. * Creates the VertexData for a Plane
  27377. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27378. * * size sets the width and height of the plane to the value of size, optional default 1
  27379. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27380. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27382. * * 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)
  27383. * * 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)
  27384. * @returns the VertexData of the box
  27385. */
  27386. static CreatePlane(options: {
  27387. size?: number;
  27388. width?: number;
  27389. height?: number;
  27390. sideOrientation?: number;
  27391. frontUVs?: Vector4;
  27392. backUVs?: Vector4;
  27393. }): VertexData;
  27394. /**
  27395. * Creates the VertexData of the Disc or regular Polygon
  27396. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27397. * * radius the radius of the disc, optional default 0.5
  27398. * * tessellation the number of polygon sides, optional, default 64
  27399. * * 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
  27400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27401. * * 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)
  27402. * * 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)
  27403. * @returns the VertexData of the box
  27404. */
  27405. static CreateDisc(options: {
  27406. radius?: number;
  27407. tessellation?: number;
  27408. arc?: number;
  27409. sideOrientation?: number;
  27410. frontUVs?: Vector4;
  27411. backUVs?: Vector4;
  27412. }): VertexData;
  27413. /**
  27414. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27415. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27416. * @param polygon a mesh built from polygonTriangulation.build()
  27417. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27418. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27419. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27420. * @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)
  27421. * @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)
  27422. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27423. * @returns the VertexData of the Polygon
  27424. */
  27425. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27426. /**
  27427. * Creates the VertexData of the IcoSphere
  27428. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27429. * * radius the radius of the IcoSphere, optional default 1
  27430. * * radiusX allows stretching in the x direction, optional, default radius
  27431. * * radiusY allows stretching in the y direction, optional, default radius
  27432. * * radiusZ allows stretching in the z direction, optional, default radius
  27433. * * flat when true creates a flat shaded mesh, optional, default true
  27434. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27436. * * 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)
  27437. * * 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)
  27438. * @returns the VertexData of the IcoSphere
  27439. */
  27440. static CreateIcoSphere(options: {
  27441. radius?: number;
  27442. radiusX?: number;
  27443. radiusY?: number;
  27444. radiusZ?: number;
  27445. flat?: boolean;
  27446. subdivisions?: number;
  27447. sideOrientation?: number;
  27448. frontUVs?: Vector4;
  27449. backUVs?: Vector4;
  27450. }): VertexData;
  27451. /**
  27452. * Creates the VertexData for a Polyhedron
  27453. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27454. * * type provided types are:
  27455. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27456. * * 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)
  27457. * * size the size of the IcoSphere, optional default 1
  27458. * * sizeX allows stretching in the x direction, optional, default size
  27459. * * sizeY allows stretching in the y direction, optional, default size
  27460. * * sizeZ allows stretching in the z direction, optional, default size
  27461. * * 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
  27462. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27463. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27464. * * flat when true creates a flat shaded mesh, optional, default true
  27465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27467. * * 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)
  27468. * * 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)
  27469. * @returns the VertexData of the Polyhedron
  27470. */
  27471. static CreatePolyhedron(options: {
  27472. type?: number;
  27473. size?: number;
  27474. sizeX?: number;
  27475. sizeY?: number;
  27476. sizeZ?: number;
  27477. custom?: any;
  27478. faceUV?: Vector4[];
  27479. faceColors?: Color4[];
  27480. flat?: boolean;
  27481. sideOrientation?: number;
  27482. frontUVs?: Vector4;
  27483. backUVs?: Vector4;
  27484. }): VertexData;
  27485. /**
  27486. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27487. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27488. * @returns the VertexData of the Capsule
  27489. */
  27490. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27491. /**
  27492. * Creates the VertexData for a TorusKnot
  27493. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27494. * * radius the radius of the torus knot, optional, default 2
  27495. * * tube the thickness of the tube, optional, default 0.5
  27496. * * radialSegments the number of sides on each tube segments, optional, default 32
  27497. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27498. * * p the number of windings around the z axis, optional, default 2
  27499. * * q the number of windings around the x axis, optional, default 3
  27500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27501. * * 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)
  27502. * * 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)
  27503. * @returns the VertexData of the Torus Knot
  27504. */
  27505. static CreateTorusKnot(options: {
  27506. radius?: number;
  27507. tube?: number;
  27508. radialSegments?: number;
  27509. tubularSegments?: number;
  27510. p?: number;
  27511. q?: number;
  27512. sideOrientation?: number;
  27513. frontUVs?: Vector4;
  27514. backUVs?: Vector4;
  27515. }): VertexData;
  27516. /**
  27517. * Compute normals for given positions and indices
  27518. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27519. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27520. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27521. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27522. * * facetNormals : optional array of facet normals (vector3)
  27523. * * facetPositions : optional array of facet positions (vector3)
  27524. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27525. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27526. * * bInfo : optional bounding info, required for facetPartitioning computation
  27527. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27528. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27529. * * useRightHandedSystem: optional boolean to for right handed system computation
  27530. * * depthSort : optional boolean to enable the facet depth sort computation
  27531. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27532. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27533. */
  27534. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27535. facetNormals?: any;
  27536. facetPositions?: any;
  27537. facetPartitioning?: any;
  27538. ratio?: number;
  27539. bInfo?: any;
  27540. bbSize?: Vector3;
  27541. subDiv?: any;
  27542. useRightHandedSystem?: boolean;
  27543. depthSort?: boolean;
  27544. distanceTo?: Vector3;
  27545. depthSortedFacets?: any;
  27546. }): void;
  27547. /** @hidden */
  27548. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27549. /**
  27550. * Applies VertexData created from the imported parameters to the geometry
  27551. * @param parsedVertexData the parsed data from an imported file
  27552. * @param geometry the geometry to apply the VertexData to
  27553. */
  27554. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27555. }
  27556. }
  27557. declare module "babylonjs/Morph/morphTarget" {
  27558. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27559. import { Observable } from "babylonjs/Misc/observable";
  27560. import { Nullable, FloatArray } from "babylonjs/types";
  27561. import { Scene } from "babylonjs/scene";
  27562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27563. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27564. /**
  27565. * Defines a target to use with MorphTargetManager
  27566. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27567. */
  27568. export class MorphTarget implements IAnimatable {
  27569. /** defines the name of the target */
  27570. name: string;
  27571. /**
  27572. * Gets or sets the list of animations
  27573. */
  27574. animations: import("babylonjs/Animations/animation").Animation[];
  27575. private _scene;
  27576. private _positions;
  27577. private _normals;
  27578. private _tangents;
  27579. private _uvs;
  27580. private _influence;
  27581. private _uniqueId;
  27582. /**
  27583. * Observable raised when the influence changes
  27584. */
  27585. onInfluenceChanged: Observable<boolean>;
  27586. /** @hidden */
  27587. _onDataLayoutChanged: Observable<void>;
  27588. /**
  27589. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27590. */
  27591. get influence(): number;
  27592. set influence(influence: number);
  27593. /**
  27594. * Gets or sets the id of the morph Target
  27595. */
  27596. id: string;
  27597. private _animationPropertiesOverride;
  27598. /**
  27599. * Gets or sets the animation properties override
  27600. */
  27601. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27602. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27603. /**
  27604. * Creates a new MorphTarget
  27605. * @param name defines the name of the target
  27606. * @param influence defines the influence to use
  27607. * @param scene defines the scene the morphtarget belongs to
  27608. */
  27609. constructor(
  27610. /** defines the name of the target */
  27611. name: string, influence?: number, scene?: Nullable<Scene>);
  27612. /**
  27613. * Gets the unique ID of this manager
  27614. */
  27615. get uniqueId(): number;
  27616. /**
  27617. * Gets a boolean defining if the target contains position data
  27618. */
  27619. get hasPositions(): boolean;
  27620. /**
  27621. * Gets a boolean defining if the target contains normal data
  27622. */
  27623. get hasNormals(): boolean;
  27624. /**
  27625. * Gets a boolean defining if the target contains tangent data
  27626. */
  27627. get hasTangents(): boolean;
  27628. /**
  27629. * Gets a boolean defining if the target contains texture coordinates data
  27630. */
  27631. get hasUVs(): boolean;
  27632. /**
  27633. * Affects position data to this target
  27634. * @param data defines the position data to use
  27635. */
  27636. setPositions(data: Nullable<FloatArray>): void;
  27637. /**
  27638. * Gets the position data stored in this target
  27639. * @returns a FloatArray containing the position data (or null if not present)
  27640. */
  27641. getPositions(): Nullable<FloatArray>;
  27642. /**
  27643. * Affects normal data to this target
  27644. * @param data defines the normal data to use
  27645. */
  27646. setNormals(data: Nullable<FloatArray>): void;
  27647. /**
  27648. * Gets the normal data stored in this target
  27649. * @returns a FloatArray containing the normal data (or null if not present)
  27650. */
  27651. getNormals(): Nullable<FloatArray>;
  27652. /**
  27653. * Affects tangent data to this target
  27654. * @param data defines the tangent data to use
  27655. */
  27656. setTangents(data: Nullable<FloatArray>): void;
  27657. /**
  27658. * Gets the tangent data stored in this target
  27659. * @returns a FloatArray containing the tangent data (or null if not present)
  27660. */
  27661. getTangents(): Nullable<FloatArray>;
  27662. /**
  27663. * Affects texture coordinates data to this target
  27664. * @param data defines the texture coordinates data to use
  27665. */
  27666. setUVs(data: Nullable<FloatArray>): void;
  27667. /**
  27668. * Gets the texture coordinates data stored in this target
  27669. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27670. */
  27671. getUVs(): Nullable<FloatArray>;
  27672. /**
  27673. * Clone the current target
  27674. * @returns a new MorphTarget
  27675. */
  27676. clone(): MorphTarget;
  27677. /**
  27678. * Serializes the current target into a Serialization object
  27679. * @returns the serialized object
  27680. */
  27681. serialize(): any;
  27682. /**
  27683. * Returns the string "MorphTarget"
  27684. * @returns "MorphTarget"
  27685. */
  27686. getClassName(): string;
  27687. /**
  27688. * Creates a new target from serialized data
  27689. * @param serializationObject defines the serialized data to use
  27690. * @returns a new MorphTarget
  27691. */
  27692. static Parse(serializationObject: any): MorphTarget;
  27693. /**
  27694. * Creates a MorphTarget from mesh data
  27695. * @param mesh defines the source mesh
  27696. * @param name defines the name to use for the new target
  27697. * @param influence defines the influence to attach to the target
  27698. * @returns a new MorphTarget
  27699. */
  27700. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27701. }
  27702. }
  27703. declare module "babylonjs/Morph/morphTargetManager" {
  27704. import { Nullable } from "babylonjs/types";
  27705. import { Scene } from "babylonjs/scene";
  27706. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27707. /**
  27708. * This class is used to deform meshes using morphing between different targets
  27709. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27710. */
  27711. export class MorphTargetManager {
  27712. private _targets;
  27713. private _targetInfluenceChangedObservers;
  27714. private _targetDataLayoutChangedObservers;
  27715. private _activeTargets;
  27716. private _scene;
  27717. private _influences;
  27718. private _supportsNormals;
  27719. private _supportsTangents;
  27720. private _supportsUVs;
  27721. private _vertexCount;
  27722. private _uniqueId;
  27723. private _tempInfluences;
  27724. /**
  27725. * Gets or sets a boolean indicating if normals must be morphed
  27726. */
  27727. enableNormalMorphing: boolean;
  27728. /**
  27729. * Gets or sets a boolean indicating if tangents must be morphed
  27730. */
  27731. enableTangentMorphing: boolean;
  27732. /**
  27733. * Gets or sets a boolean indicating if UV must be morphed
  27734. */
  27735. enableUVMorphing: boolean;
  27736. /**
  27737. * Creates a new MorphTargetManager
  27738. * @param scene defines the current scene
  27739. */
  27740. constructor(scene?: Nullable<Scene>);
  27741. /**
  27742. * Gets the unique ID of this manager
  27743. */
  27744. get uniqueId(): number;
  27745. /**
  27746. * Gets the number of vertices handled by this manager
  27747. */
  27748. get vertexCount(): number;
  27749. /**
  27750. * Gets a boolean indicating if this manager supports morphing of normals
  27751. */
  27752. get supportsNormals(): boolean;
  27753. /**
  27754. * Gets a boolean indicating if this manager supports morphing of tangents
  27755. */
  27756. get supportsTangents(): boolean;
  27757. /**
  27758. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27759. */
  27760. get supportsUVs(): boolean;
  27761. /**
  27762. * Gets the number of targets stored in this manager
  27763. */
  27764. get numTargets(): number;
  27765. /**
  27766. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27767. */
  27768. get numInfluencers(): number;
  27769. /**
  27770. * Gets the list of influences (one per target)
  27771. */
  27772. get influences(): Float32Array;
  27773. /**
  27774. * Gets the active target at specified index. An active target is a target with an influence > 0
  27775. * @param index defines the index to check
  27776. * @returns the requested target
  27777. */
  27778. getActiveTarget(index: number): MorphTarget;
  27779. /**
  27780. * Gets the target at specified index
  27781. * @param index defines the index to check
  27782. * @returns the requested target
  27783. */
  27784. getTarget(index: number): MorphTarget;
  27785. /**
  27786. * Add a new target to this manager
  27787. * @param target defines the target to add
  27788. */
  27789. addTarget(target: MorphTarget): void;
  27790. /**
  27791. * Removes a target from the manager
  27792. * @param target defines the target to remove
  27793. */
  27794. removeTarget(target: MorphTarget): void;
  27795. /**
  27796. * Clone the current manager
  27797. * @returns a new MorphTargetManager
  27798. */
  27799. clone(): MorphTargetManager;
  27800. /**
  27801. * Serializes the current manager into a Serialization object
  27802. * @returns the serialized object
  27803. */
  27804. serialize(): any;
  27805. private _syncActiveTargets;
  27806. /**
  27807. * Syncrhonize the targets with all the meshes using this morph target manager
  27808. */
  27809. synchronize(): void;
  27810. /**
  27811. * Creates a new MorphTargetManager from serialized data
  27812. * @param serializationObject defines the serialized data
  27813. * @param scene defines the hosting scene
  27814. * @returns the new MorphTargetManager
  27815. */
  27816. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27817. }
  27818. }
  27819. declare module "babylonjs/Meshes/meshLODLevel" {
  27820. import { Mesh } from "babylonjs/Meshes/mesh";
  27821. import { Nullable } from "babylonjs/types";
  27822. /**
  27823. * Class used to represent a specific level of detail of a mesh
  27824. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27825. */
  27826. export class MeshLODLevel {
  27827. /** Defines the distance where this level should start being displayed */
  27828. distance: number;
  27829. /** Defines the mesh to use to render this level */
  27830. mesh: Nullable<Mesh>;
  27831. /**
  27832. * Creates a new LOD level
  27833. * @param distance defines the distance where this level should star being displayed
  27834. * @param mesh defines the mesh to use to render this level
  27835. */
  27836. constructor(
  27837. /** Defines the distance where this level should start being displayed */
  27838. distance: number,
  27839. /** Defines the mesh to use to render this level */
  27840. mesh: Nullable<Mesh>);
  27841. }
  27842. }
  27843. declare module "babylonjs/Misc/canvasGenerator" {
  27844. /**
  27845. * Helper class used to generate a canvas to manipulate images
  27846. */
  27847. export class CanvasGenerator {
  27848. /**
  27849. * Create a new canvas (or offscreen canvas depending on the context)
  27850. * @param width defines the expected width
  27851. * @param height defines the expected height
  27852. * @return a new canvas or offscreen canvas
  27853. */
  27854. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27855. }
  27856. }
  27857. declare module "babylonjs/Meshes/groundMesh" {
  27858. import { Scene } from "babylonjs/scene";
  27859. import { Vector3 } from "babylonjs/Maths/math.vector";
  27860. import { Mesh } from "babylonjs/Meshes/mesh";
  27861. /**
  27862. * Mesh representing the gorund
  27863. */
  27864. export class GroundMesh extends Mesh {
  27865. /** If octree should be generated */
  27866. generateOctree: boolean;
  27867. private _heightQuads;
  27868. /** @hidden */
  27869. _subdivisionsX: number;
  27870. /** @hidden */
  27871. _subdivisionsY: number;
  27872. /** @hidden */
  27873. _width: number;
  27874. /** @hidden */
  27875. _height: number;
  27876. /** @hidden */
  27877. _minX: number;
  27878. /** @hidden */
  27879. _maxX: number;
  27880. /** @hidden */
  27881. _minZ: number;
  27882. /** @hidden */
  27883. _maxZ: number;
  27884. constructor(name: string, scene: Scene);
  27885. /**
  27886. * "GroundMesh"
  27887. * @returns "GroundMesh"
  27888. */
  27889. getClassName(): string;
  27890. /**
  27891. * The minimum of x and y subdivisions
  27892. */
  27893. get subdivisions(): number;
  27894. /**
  27895. * X subdivisions
  27896. */
  27897. get subdivisionsX(): number;
  27898. /**
  27899. * Y subdivisions
  27900. */
  27901. get subdivisionsY(): number;
  27902. /**
  27903. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27904. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27905. * @param chunksCount the number of subdivisions for x and y
  27906. * @param octreeBlocksSize (Default: 32)
  27907. */
  27908. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27909. /**
  27910. * Returns a height (y) value in the Worl system :
  27911. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27912. * @param x x coordinate
  27913. * @param z z coordinate
  27914. * @returns the ground y position if (x, z) are outside the ground surface.
  27915. */
  27916. getHeightAtCoordinates(x: number, z: number): number;
  27917. /**
  27918. * Returns a normalized vector (Vector3) orthogonal to the ground
  27919. * at the ground coordinates (x, z) expressed in the World system.
  27920. * @param x x coordinate
  27921. * @param z z coordinate
  27922. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27923. */
  27924. getNormalAtCoordinates(x: number, z: number): Vector3;
  27925. /**
  27926. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27927. * at the ground coordinates (x, z) expressed in the World system.
  27928. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27929. * @param x x coordinate
  27930. * @param z z coordinate
  27931. * @param ref vector to store the result
  27932. * @returns the GroundMesh.
  27933. */
  27934. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27935. /**
  27936. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27937. * if the ground has been updated.
  27938. * This can be used in the render loop.
  27939. * @returns the GroundMesh.
  27940. */
  27941. updateCoordinateHeights(): GroundMesh;
  27942. private _getFacetAt;
  27943. private _initHeightQuads;
  27944. private _computeHeightQuads;
  27945. /**
  27946. * Serializes this ground mesh
  27947. * @param serializationObject object to write serialization to
  27948. */
  27949. serialize(serializationObject: any): void;
  27950. /**
  27951. * Parses a serialized ground mesh
  27952. * @param parsedMesh the serialized mesh
  27953. * @param scene the scene to create the ground mesh in
  27954. * @returns the created ground mesh
  27955. */
  27956. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27957. }
  27958. }
  27959. declare module "babylonjs/Physics/physicsJoint" {
  27960. import { Vector3 } from "babylonjs/Maths/math.vector";
  27961. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27962. /**
  27963. * Interface for Physics-Joint data
  27964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27965. */
  27966. export interface PhysicsJointData {
  27967. /**
  27968. * The main pivot of the joint
  27969. */
  27970. mainPivot?: Vector3;
  27971. /**
  27972. * The connected pivot of the joint
  27973. */
  27974. connectedPivot?: Vector3;
  27975. /**
  27976. * The main axis of the joint
  27977. */
  27978. mainAxis?: Vector3;
  27979. /**
  27980. * The connected axis of the joint
  27981. */
  27982. connectedAxis?: Vector3;
  27983. /**
  27984. * The collision of the joint
  27985. */
  27986. collision?: boolean;
  27987. /**
  27988. * Native Oimo/Cannon/Energy data
  27989. */
  27990. nativeParams?: any;
  27991. }
  27992. /**
  27993. * This is a holder class for the physics joint created by the physics plugin
  27994. * It holds a set of functions to control the underlying joint
  27995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27996. */
  27997. export class PhysicsJoint {
  27998. /**
  27999. * The type of the physics joint
  28000. */
  28001. type: number;
  28002. /**
  28003. * The data for the physics joint
  28004. */
  28005. jointData: PhysicsJointData;
  28006. private _physicsJoint;
  28007. protected _physicsPlugin: IPhysicsEnginePlugin;
  28008. /**
  28009. * Initializes the physics joint
  28010. * @param type The type of the physics joint
  28011. * @param jointData The data for the physics joint
  28012. */
  28013. constructor(
  28014. /**
  28015. * The type of the physics joint
  28016. */
  28017. type: number,
  28018. /**
  28019. * The data for the physics joint
  28020. */
  28021. jointData: PhysicsJointData);
  28022. /**
  28023. * Gets the physics joint
  28024. */
  28025. get physicsJoint(): any;
  28026. /**
  28027. * Sets the physics joint
  28028. */
  28029. set physicsJoint(newJoint: any);
  28030. /**
  28031. * Sets the physics plugin
  28032. */
  28033. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28034. /**
  28035. * Execute a function that is physics-plugin specific.
  28036. * @param {Function} func the function that will be executed.
  28037. * It accepts two parameters: the physics world and the physics joint
  28038. */
  28039. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28040. /**
  28041. * Distance-Joint type
  28042. */
  28043. static DistanceJoint: number;
  28044. /**
  28045. * Hinge-Joint type
  28046. */
  28047. static HingeJoint: number;
  28048. /**
  28049. * Ball-and-Socket joint type
  28050. */
  28051. static BallAndSocketJoint: number;
  28052. /**
  28053. * Wheel-Joint type
  28054. */
  28055. static WheelJoint: number;
  28056. /**
  28057. * Slider-Joint type
  28058. */
  28059. static SliderJoint: number;
  28060. /**
  28061. * Prismatic-Joint type
  28062. */
  28063. static PrismaticJoint: number;
  28064. /**
  28065. * Universal-Joint type
  28066. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28067. */
  28068. static UniversalJoint: number;
  28069. /**
  28070. * Hinge-Joint 2 type
  28071. */
  28072. static Hinge2Joint: number;
  28073. /**
  28074. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28075. */
  28076. static PointToPointJoint: number;
  28077. /**
  28078. * Spring-Joint type
  28079. */
  28080. static SpringJoint: number;
  28081. /**
  28082. * Lock-Joint type
  28083. */
  28084. static LockJoint: number;
  28085. }
  28086. /**
  28087. * A class representing a physics distance joint
  28088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28089. */
  28090. export class DistanceJoint extends PhysicsJoint {
  28091. /**
  28092. *
  28093. * @param jointData The data for the Distance-Joint
  28094. */
  28095. constructor(jointData: DistanceJointData);
  28096. /**
  28097. * Update the predefined distance.
  28098. * @param maxDistance The maximum preferred distance
  28099. * @param minDistance The minimum preferred distance
  28100. */
  28101. updateDistance(maxDistance: number, minDistance?: number): void;
  28102. }
  28103. /**
  28104. * Represents a Motor-Enabled Joint
  28105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28106. */
  28107. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28108. /**
  28109. * Initializes the Motor-Enabled Joint
  28110. * @param type The type of the joint
  28111. * @param jointData The physica joint data for the joint
  28112. */
  28113. constructor(type: number, jointData: PhysicsJointData);
  28114. /**
  28115. * Set the motor values.
  28116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28117. * @param force the force to apply
  28118. * @param maxForce max force for this motor.
  28119. */
  28120. setMotor(force?: number, maxForce?: number): void;
  28121. /**
  28122. * Set the motor's limits.
  28123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28124. * @param upperLimit The upper limit of the motor
  28125. * @param lowerLimit The lower limit of the motor
  28126. */
  28127. setLimit(upperLimit: number, lowerLimit?: number): void;
  28128. }
  28129. /**
  28130. * This class represents a single physics Hinge-Joint
  28131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28132. */
  28133. export class HingeJoint extends MotorEnabledJoint {
  28134. /**
  28135. * Initializes the Hinge-Joint
  28136. * @param jointData The joint data for the Hinge-Joint
  28137. */
  28138. constructor(jointData: PhysicsJointData);
  28139. /**
  28140. * Set the motor values.
  28141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28142. * @param {number} force the force to apply
  28143. * @param {number} maxForce max force for this motor.
  28144. */
  28145. setMotor(force?: number, maxForce?: number): void;
  28146. /**
  28147. * Set the motor's limits.
  28148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28149. * @param upperLimit The upper limit of the motor
  28150. * @param lowerLimit The lower limit of the motor
  28151. */
  28152. setLimit(upperLimit: number, lowerLimit?: number): void;
  28153. }
  28154. /**
  28155. * This class represents a dual hinge physics joint (same as wheel joint)
  28156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28157. */
  28158. export class Hinge2Joint extends MotorEnabledJoint {
  28159. /**
  28160. * Initializes the Hinge2-Joint
  28161. * @param jointData The joint data for the Hinge2-Joint
  28162. */
  28163. constructor(jointData: PhysicsJointData);
  28164. /**
  28165. * Set the motor values.
  28166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28167. * @param {number} targetSpeed the speed the motor is to reach
  28168. * @param {number} maxForce max force for this motor.
  28169. * @param {motorIndex} the motor's index, 0 or 1.
  28170. */
  28171. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28172. /**
  28173. * Set the motor limits.
  28174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28175. * @param {number} upperLimit the upper limit
  28176. * @param {number} lowerLimit lower limit
  28177. * @param {motorIndex} the motor's index, 0 or 1.
  28178. */
  28179. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28180. }
  28181. /**
  28182. * Interface for a motor enabled joint
  28183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28184. */
  28185. export interface IMotorEnabledJoint {
  28186. /**
  28187. * Physics joint
  28188. */
  28189. physicsJoint: any;
  28190. /**
  28191. * Sets the motor of the motor-enabled joint
  28192. * @param force The force of the motor
  28193. * @param maxForce The maximum force of the motor
  28194. * @param motorIndex The index of the motor
  28195. */
  28196. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28197. /**
  28198. * Sets the limit of the motor
  28199. * @param upperLimit The upper limit of the motor
  28200. * @param lowerLimit The lower limit of the motor
  28201. * @param motorIndex The index of the motor
  28202. */
  28203. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28204. }
  28205. /**
  28206. * Joint data for a Distance-Joint
  28207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28208. */
  28209. export interface DistanceJointData extends PhysicsJointData {
  28210. /**
  28211. * Max distance the 2 joint objects can be apart
  28212. */
  28213. maxDistance: number;
  28214. }
  28215. /**
  28216. * Joint data from a spring joint
  28217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28218. */
  28219. export interface SpringJointData extends PhysicsJointData {
  28220. /**
  28221. * Length of the spring
  28222. */
  28223. length: number;
  28224. /**
  28225. * Stiffness of the spring
  28226. */
  28227. stiffness: number;
  28228. /**
  28229. * Damping of the spring
  28230. */
  28231. damping: number;
  28232. /** this callback will be called when applying the force to the impostors. */
  28233. forceApplicationCallback: () => void;
  28234. }
  28235. }
  28236. declare module "babylonjs/Physics/physicsRaycastResult" {
  28237. import { Vector3 } from "babylonjs/Maths/math.vector";
  28238. /**
  28239. * Holds the data for the raycast result
  28240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28241. */
  28242. export class PhysicsRaycastResult {
  28243. private _hasHit;
  28244. private _hitDistance;
  28245. private _hitNormalWorld;
  28246. private _hitPointWorld;
  28247. private _rayFromWorld;
  28248. private _rayToWorld;
  28249. /**
  28250. * Gets if there was a hit
  28251. */
  28252. get hasHit(): boolean;
  28253. /**
  28254. * Gets the distance from the hit
  28255. */
  28256. get hitDistance(): number;
  28257. /**
  28258. * Gets the hit normal/direction in the world
  28259. */
  28260. get hitNormalWorld(): Vector3;
  28261. /**
  28262. * Gets the hit point in the world
  28263. */
  28264. get hitPointWorld(): Vector3;
  28265. /**
  28266. * Gets the ray "start point" of the ray in the world
  28267. */
  28268. get rayFromWorld(): Vector3;
  28269. /**
  28270. * Gets the ray "end point" of the ray in the world
  28271. */
  28272. get rayToWorld(): Vector3;
  28273. /**
  28274. * Sets the hit data (normal & point in world space)
  28275. * @param hitNormalWorld defines the normal in world space
  28276. * @param hitPointWorld defines the point in world space
  28277. */
  28278. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28279. /**
  28280. * Sets the distance from the start point to the hit point
  28281. * @param distance
  28282. */
  28283. setHitDistance(distance: number): void;
  28284. /**
  28285. * Calculates the distance manually
  28286. */
  28287. calculateHitDistance(): void;
  28288. /**
  28289. * Resets all the values to default
  28290. * @param from The from point on world space
  28291. * @param to The to point on world space
  28292. */
  28293. reset(from?: Vector3, to?: Vector3): void;
  28294. }
  28295. /**
  28296. * Interface for the size containing width and height
  28297. */
  28298. interface IXYZ {
  28299. /**
  28300. * X
  28301. */
  28302. x: number;
  28303. /**
  28304. * Y
  28305. */
  28306. y: number;
  28307. /**
  28308. * Z
  28309. */
  28310. z: number;
  28311. }
  28312. }
  28313. declare module "babylonjs/Physics/IPhysicsEngine" {
  28314. import { Nullable } from "babylonjs/types";
  28315. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28317. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28318. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28319. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28320. /**
  28321. * Interface used to describe a physics joint
  28322. */
  28323. export interface PhysicsImpostorJoint {
  28324. /** Defines the main impostor to which the joint is linked */
  28325. mainImpostor: PhysicsImpostor;
  28326. /** Defines the impostor that is connected to the main impostor using this joint */
  28327. connectedImpostor: PhysicsImpostor;
  28328. /** Defines the joint itself */
  28329. joint: PhysicsJoint;
  28330. }
  28331. /** @hidden */
  28332. export interface IPhysicsEnginePlugin {
  28333. world: any;
  28334. name: string;
  28335. setGravity(gravity: Vector3): void;
  28336. setTimeStep(timeStep: number): void;
  28337. getTimeStep(): number;
  28338. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28342. removePhysicsBody(impostor: PhysicsImpostor): void;
  28343. generateJoint(joint: PhysicsImpostorJoint): void;
  28344. removeJoint(joint: PhysicsImpostorJoint): void;
  28345. isSupported(): boolean;
  28346. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28347. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28348. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28349. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28350. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28351. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28352. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28353. getBodyMass(impostor: PhysicsImpostor): number;
  28354. getBodyFriction(impostor: PhysicsImpostor): number;
  28355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28356. getBodyRestitution(impostor: PhysicsImpostor): number;
  28357. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28358. getBodyPressure?(impostor: PhysicsImpostor): number;
  28359. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28360. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28361. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28362. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28363. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28364. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28365. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28366. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28367. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28368. sleepBody(impostor: PhysicsImpostor): void;
  28369. wakeUpBody(impostor: PhysicsImpostor): void;
  28370. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28372. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28373. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28374. getRadius(impostor: PhysicsImpostor): number;
  28375. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28377. dispose(): void;
  28378. }
  28379. /**
  28380. * Interface used to define a physics engine
  28381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28382. */
  28383. export interface IPhysicsEngine {
  28384. /**
  28385. * Gets the gravity vector used by the simulation
  28386. */
  28387. gravity: Vector3;
  28388. /**
  28389. * Sets the gravity vector used by the simulation
  28390. * @param gravity defines the gravity vector to use
  28391. */
  28392. setGravity(gravity: Vector3): void;
  28393. /**
  28394. * Set the time step of the physics engine.
  28395. * Default is 1/60.
  28396. * To slow it down, enter 1/600 for example.
  28397. * To speed it up, 1/30
  28398. * @param newTimeStep the new timestep to apply to this world.
  28399. */
  28400. setTimeStep(newTimeStep: number): void;
  28401. /**
  28402. * Get the time step of the physics engine.
  28403. * @returns the current time step
  28404. */
  28405. getTimeStep(): number;
  28406. /**
  28407. * Set the sub time step of the physics engine.
  28408. * Default is 0 meaning there is no sub steps
  28409. * To increase physics resolution precision, set a small value (like 1 ms)
  28410. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28411. */
  28412. setSubTimeStep(subTimeStep: number): void;
  28413. /**
  28414. * Get the sub time step of the physics engine.
  28415. * @returns the current sub time step
  28416. */
  28417. getSubTimeStep(): number;
  28418. /**
  28419. * Release all resources
  28420. */
  28421. dispose(): void;
  28422. /**
  28423. * Gets the name of the current physics plugin
  28424. * @returns the name of the plugin
  28425. */
  28426. getPhysicsPluginName(): string;
  28427. /**
  28428. * Adding a new impostor for the impostor tracking.
  28429. * This will be done by the impostor itself.
  28430. * @param impostor the impostor to add
  28431. */
  28432. addImpostor(impostor: PhysicsImpostor): void;
  28433. /**
  28434. * Remove an impostor from the engine.
  28435. * This impostor and its mesh will not longer be updated by the physics engine.
  28436. * @param impostor the impostor to remove
  28437. */
  28438. removeImpostor(impostor: PhysicsImpostor): void;
  28439. /**
  28440. * Add a joint to the physics engine
  28441. * @param mainImpostor defines the main impostor to which the joint is added.
  28442. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28443. * @param joint defines the joint that will connect both impostors.
  28444. */
  28445. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28446. /**
  28447. * Removes a joint from the simulation
  28448. * @param mainImpostor defines the impostor used with the joint
  28449. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28450. * @param joint defines the joint to remove
  28451. */
  28452. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28453. /**
  28454. * Gets the current plugin used to run the simulation
  28455. * @returns current plugin
  28456. */
  28457. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28458. /**
  28459. * Gets the list of physic impostors
  28460. * @returns an array of PhysicsImpostor
  28461. */
  28462. getImpostors(): Array<PhysicsImpostor>;
  28463. /**
  28464. * Gets the impostor for a physics enabled object
  28465. * @param object defines the object impersonated by the impostor
  28466. * @returns the PhysicsImpostor or null if not found
  28467. */
  28468. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28469. /**
  28470. * Gets the impostor for a physics body object
  28471. * @param body defines physics body used by the impostor
  28472. * @returns the PhysicsImpostor or null if not found
  28473. */
  28474. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28475. /**
  28476. * Does a raycast in the physics world
  28477. * @param from when should the ray start?
  28478. * @param to when should the ray end?
  28479. * @returns PhysicsRaycastResult
  28480. */
  28481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28482. /**
  28483. * Called by the scene. No need to call it.
  28484. * @param delta defines the timespam between frames
  28485. */
  28486. _step(delta: number): void;
  28487. }
  28488. }
  28489. declare module "babylonjs/Physics/physicsImpostor" {
  28490. import { Nullable, IndicesArray } from "babylonjs/types";
  28491. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28494. import { Scene } from "babylonjs/scene";
  28495. import { Bone } from "babylonjs/Bones/bone";
  28496. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28497. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28498. import { Space } from "babylonjs/Maths/math.axis";
  28499. /**
  28500. * The interface for the physics imposter parameters
  28501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28502. */
  28503. export interface PhysicsImpostorParameters {
  28504. /**
  28505. * The mass of the physics imposter
  28506. */
  28507. mass: number;
  28508. /**
  28509. * The friction of the physics imposter
  28510. */
  28511. friction?: number;
  28512. /**
  28513. * The coefficient of restitution of the physics imposter
  28514. */
  28515. restitution?: number;
  28516. /**
  28517. * The native options of the physics imposter
  28518. */
  28519. nativeOptions?: any;
  28520. /**
  28521. * Specifies if the parent should be ignored
  28522. */
  28523. ignoreParent?: boolean;
  28524. /**
  28525. * Specifies if bi-directional transformations should be disabled
  28526. */
  28527. disableBidirectionalTransformation?: boolean;
  28528. /**
  28529. * The pressure inside the physics imposter, soft object only
  28530. */
  28531. pressure?: number;
  28532. /**
  28533. * The stiffness the physics imposter, soft object only
  28534. */
  28535. stiffness?: number;
  28536. /**
  28537. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28538. */
  28539. velocityIterations?: number;
  28540. /**
  28541. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28542. */
  28543. positionIterations?: number;
  28544. /**
  28545. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28546. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28547. * Add to fix multiple points
  28548. */
  28549. fixedPoints?: number;
  28550. /**
  28551. * The collision margin around a soft object
  28552. */
  28553. margin?: number;
  28554. /**
  28555. * The collision margin around a soft object
  28556. */
  28557. damping?: number;
  28558. /**
  28559. * The path for a rope based on an extrusion
  28560. */
  28561. path?: any;
  28562. /**
  28563. * The shape of an extrusion used for a rope based on an extrusion
  28564. */
  28565. shape?: any;
  28566. }
  28567. /**
  28568. * Interface for a physics-enabled object
  28569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28570. */
  28571. export interface IPhysicsEnabledObject {
  28572. /**
  28573. * The position of the physics-enabled object
  28574. */
  28575. position: Vector3;
  28576. /**
  28577. * The rotation of the physics-enabled object
  28578. */
  28579. rotationQuaternion: Nullable<Quaternion>;
  28580. /**
  28581. * The scale of the physics-enabled object
  28582. */
  28583. scaling: Vector3;
  28584. /**
  28585. * The rotation of the physics-enabled object
  28586. */
  28587. rotation?: Vector3;
  28588. /**
  28589. * The parent of the physics-enabled object
  28590. */
  28591. parent?: any;
  28592. /**
  28593. * The bounding info of the physics-enabled object
  28594. * @returns The bounding info of the physics-enabled object
  28595. */
  28596. getBoundingInfo(): BoundingInfo;
  28597. /**
  28598. * Computes the world matrix
  28599. * @param force Specifies if the world matrix should be computed by force
  28600. * @returns A world matrix
  28601. */
  28602. computeWorldMatrix(force: boolean): Matrix;
  28603. /**
  28604. * Gets the world matrix
  28605. * @returns A world matrix
  28606. */
  28607. getWorldMatrix?(): Matrix;
  28608. /**
  28609. * Gets the child meshes
  28610. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28611. * @returns An array of abstract meshes
  28612. */
  28613. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28614. /**
  28615. * Gets the vertex data
  28616. * @param kind The type of vertex data
  28617. * @returns A nullable array of numbers, or a float32 array
  28618. */
  28619. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28620. /**
  28621. * Gets the indices from the mesh
  28622. * @returns A nullable array of index arrays
  28623. */
  28624. getIndices?(): Nullable<IndicesArray>;
  28625. /**
  28626. * Gets the scene from the mesh
  28627. * @returns the indices array or null
  28628. */
  28629. getScene?(): Scene;
  28630. /**
  28631. * Gets the absolute position from the mesh
  28632. * @returns the absolute position
  28633. */
  28634. getAbsolutePosition(): Vector3;
  28635. /**
  28636. * Gets the absolute pivot point from the mesh
  28637. * @returns the absolute pivot point
  28638. */
  28639. getAbsolutePivotPoint(): Vector3;
  28640. /**
  28641. * Rotates the mesh
  28642. * @param axis The axis of rotation
  28643. * @param amount The amount of rotation
  28644. * @param space The space of the rotation
  28645. * @returns The rotation transform node
  28646. */
  28647. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28648. /**
  28649. * Translates the mesh
  28650. * @param axis The axis of translation
  28651. * @param distance The distance of translation
  28652. * @param space The space of the translation
  28653. * @returns The transform node
  28654. */
  28655. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28656. /**
  28657. * Sets the absolute position of the mesh
  28658. * @param absolutePosition The absolute position of the mesh
  28659. * @returns The transform node
  28660. */
  28661. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28662. /**
  28663. * Gets the class name of the mesh
  28664. * @returns The class name
  28665. */
  28666. getClassName(): string;
  28667. }
  28668. /**
  28669. * Represents a physics imposter
  28670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28671. */
  28672. export class PhysicsImpostor {
  28673. /**
  28674. * The physics-enabled object used as the physics imposter
  28675. */
  28676. object: IPhysicsEnabledObject;
  28677. /**
  28678. * The type of the physics imposter
  28679. */
  28680. type: number;
  28681. private _options;
  28682. private _scene?;
  28683. /**
  28684. * The default object size of the imposter
  28685. */
  28686. static DEFAULT_OBJECT_SIZE: Vector3;
  28687. /**
  28688. * The identity quaternion of the imposter
  28689. */
  28690. static IDENTITY_QUATERNION: Quaternion;
  28691. /** @hidden */
  28692. _pluginData: any;
  28693. private _physicsEngine;
  28694. private _physicsBody;
  28695. private _bodyUpdateRequired;
  28696. private _onBeforePhysicsStepCallbacks;
  28697. private _onAfterPhysicsStepCallbacks;
  28698. /** @hidden */
  28699. _onPhysicsCollideCallbacks: Array<{
  28700. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28701. otherImpostors: Array<PhysicsImpostor>;
  28702. }>;
  28703. private _deltaPosition;
  28704. private _deltaRotation;
  28705. private _deltaRotationConjugated;
  28706. /** @hidden */
  28707. _isFromLine: boolean;
  28708. private _parent;
  28709. private _isDisposed;
  28710. private static _tmpVecs;
  28711. private static _tmpQuat;
  28712. /**
  28713. * Specifies if the physics imposter is disposed
  28714. */
  28715. get isDisposed(): boolean;
  28716. /**
  28717. * Gets the mass of the physics imposter
  28718. */
  28719. get mass(): number;
  28720. set mass(value: number);
  28721. /**
  28722. * Gets the coefficient of friction
  28723. */
  28724. get friction(): number;
  28725. /**
  28726. * Sets the coefficient of friction
  28727. */
  28728. set friction(value: number);
  28729. /**
  28730. * Gets the coefficient of restitution
  28731. */
  28732. get restitution(): number;
  28733. /**
  28734. * Sets the coefficient of restitution
  28735. */
  28736. set restitution(value: number);
  28737. /**
  28738. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28739. */
  28740. get pressure(): number;
  28741. /**
  28742. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28743. */
  28744. set pressure(value: number);
  28745. /**
  28746. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28747. */
  28748. get stiffness(): number;
  28749. /**
  28750. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28751. */
  28752. set stiffness(value: number);
  28753. /**
  28754. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28755. */
  28756. get velocityIterations(): number;
  28757. /**
  28758. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28759. */
  28760. set velocityIterations(value: number);
  28761. /**
  28762. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28763. */
  28764. get positionIterations(): number;
  28765. /**
  28766. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28767. */
  28768. set positionIterations(value: number);
  28769. /**
  28770. * The unique id of the physics imposter
  28771. * set by the physics engine when adding this impostor to the array
  28772. */
  28773. uniqueId: number;
  28774. /**
  28775. * @hidden
  28776. */
  28777. soft: boolean;
  28778. /**
  28779. * @hidden
  28780. */
  28781. segments: number;
  28782. private _joints;
  28783. /**
  28784. * Initializes the physics imposter
  28785. * @param object The physics-enabled object used as the physics imposter
  28786. * @param type The type of the physics imposter
  28787. * @param _options The options for the physics imposter
  28788. * @param _scene The Babylon scene
  28789. */
  28790. constructor(
  28791. /**
  28792. * The physics-enabled object used as the physics imposter
  28793. */
  28794. object: IPhysicsEnabledObject,
  28795. /**
  28796. * The type of the physics imposter
  28797. */
  28798. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28799. /**
  28800. * This function will completly initialize this impostor.
  28801. * It will create a new body - but only if this mesh has no parent.
  28802. * If it has, this impostor will not be used other than to define the impostor
  28803. * of the child mesh.
  28804. * @hidden
  28805. */
  28806. _init(): void;
  28807. private _getPhysicsParent;
  28808. /**
  28809. * Should a new body be generated.
  28810. * @returns boolean specifying if body initialization is required
  28811. */
  28812. isBodyInitRequired(): boolean;
  28813. /**
  28814. * Sets the updated scaling
  28815. * @param updated Specifies if the scaling is updated
  28816. */
  28817. setScalingUpdated(): void;
  28818. /**
  28819. * Force a regeneration of this or the parent's impostor's body.
  28820. * Use under cautious - This will remove all joints already implemented.
  28821. */
  28822. forceUpdate(): void;
  28823. /**
  28824. * Gets the body that holds this impostor. Either its own, or its parent.
  28825. */
  28826. get physicsBody(): any;
  28827. /**
  28828. * Get the parent of the physics imposter
  28829. * @returns Physics imposter or null
  28830. */
  28831. get parent(): Nullable<PhysicsImpostor>;
  28832. /**
  28833. * Sets the parent of the physics imposter
  28834. */
  28835. set parent(value: Nullable<PhysicsImpostor>);
  28836. /**
  28837. * Set the physics body. Used mainly by the physics engine/plugin
  28838. */
  28839. set physicsBody(physicsBody: any);
  28840. /**
  28841. * Resets the update flags
  28842. */
  28843. resetUpdateFlags(): void;
  28844. /**
  28845. * Gets the object extend size
  28846. * @returns the object extend size
  28847. */
  28848. getObjectExtendSize(): Vector3;
  28849. /**
  28850. * Gets the object center
  28851. * @returns The object center
  28852. */
  28853. getObjectCenter(): Vector3;
  28854. /**
  28855. * Get a specific parameter from the options parameters
  28856. * @param paramName The object parameter name
  28857. * @returns The object parameter
  28858. */
  28859. getParam(paramName: string): any;
  28860. /**
  28861. * Sets a specific parameter in the options given to the physics plugin
  28862. * @param paramName The parameter name
  28863. * @param value The value of the parameter
  28864. */
  28865. setParam(paramName: string, value: number): void;
  28866. /**
  28867. * Specifically change the body's mass option. Won't recreate the physics body object
  28868. * @param mass The mass of the physics imposter
  28869. */
  28870. setMass(mass: number): void;
  28871. /**
  28872. * Gets the linear velocity
  28873. * @returns linear velocity or null
  28874. */
  28875. getLinearVelocity(): Nullable<Vector3>;
  28876. /**
  28877. * Sets the linear velocity
  28878. * @param velocity linear velocity or null
  28879. */
  28880. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28881. /**
  28882. * Gets the angular velocity
  28883. * @returns angular velocity or null
  28884. */
  28885. getAngularVelocity(): Nullable<Vector3>;
  28886. /**
  28887. * Sets the angular velocity
  28888. * @param velocity The velocity or null
  28889. */
  28890. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28891. /**
  28892. * Execute a function with the physics plugin native code
  28893. * Provide a function the will have two variables - the world object and the physics body object
  28894. * @param func The function to execute with the physics plugin native code
  28895. */
  28896. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28897. /**
  28898. * Register a function that will be executed before the physics world is stepping forward
  28899. * @param func The function to execute before the physics world is stepped forward
  28900. */
  28901. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28902. /**
  28903. * Unregister a function that will be executed before the physics world is stepping forward
  28904. * @param func The function to execute before the physics world is stepped forward
  28905. */
  28906. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28907. /**
  28908. * Register a function that will be executed after the physics step
  28909. * @param func The function to execute after physics step
  28910. */
  28911. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28912. /**
  28913. * Unregisters a function that will be executed after the physics step
  28914. * @param func The function to execute after physics step
  28915. */
  28916. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28917. /**
  28918. * register a function that will be executed when this impostor collides against a different body
  28919. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28920. * @param func Callback that is executed on collision
  28921. */
  28922. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28923. /**
  28924. * Unregisters the physics imposter on contact
  28925. * @param collideAgainst The physics object to collide against
  28926. * @param func Callback to execute on collision
  28927. */
  28928. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28929. private _tmpQuat;
  28930. private _tmpQuat2;
  28931. /**
  28932. * Get the parent rotation
  28933. * @returns The parent rotation
  28934. */
  28935. getParentsRotation(): Quaternion;
  28936. /**
  28937. * this function is executed by the physics engine.
  28938. */
  28939. beforeStep: () => void;
  28940. /**
  28941. * this function is executed by the physics engine
  28942. */
  28943. afterStep: () => void;
  28944. /**
  28945. * Legacy collision detection event support
  28946. */
  28947. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28948. /**
  28949. * event and body object due to cannon's event-based architecture.
  28950. */
  28951. onCollide: (e: {
  28952. body: any;
  28953. }) => void;
  28954. /**
  28955. * Apply a force
  28956. * @param force The force to apply
  28957. * @param contactPoint The contact point for the force
  28958. * @returns The physics imposter
  28959. */
  28960. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28961. /**
  28962. * Apply an impulse
  28963. * @param force The impulse force
  28964. * @param contactPoint The contact point for the impulse force
  28965. * @returns The physics imposter
  28966. */
  28967. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28968. /**
  28969. * A help function to create a joint
  28970. * @param otherImpostor A physics imposter used to create a joint
  28971. * @param jointType The type of joint
  28972. * @param jointData The data for the joint
  28973. * @returns The physics imposter
  28974. */
  28975. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28976. /**
  28977. * Add a joint to this impostor with a different impostor
  28978. * @param otherImpostor A physics imposter used to add a joint
  28979. * @param joint The joint to add
  28980. * @returns The physics imposter
  28981. */
  28982. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28983. /**
  28984. * Add an anchor to a cloth impostor
  28985. * @param otherImpostor rigid impostor to anchor to
  28986. * @param width ratio across width from 0 to 1
  28987. * @param height ratio up height from 0 to 1
  28988. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28989. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28990. * @returns impostor the soft imposter
  28991. */
  28992. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28993. /**
  28994. * Add a hook to a rope impostor
  28995. * @param otherImpostor rigid impostor to anchor to
  28996. * @param length ratio across rope from 0 to 1
  28997. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28998. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28999. * @returns impostor the rope imposter
  29000. */
  29001. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29002. /**
  29003. * Will keep this body still, in a sleep mode.
  29004. * @returns the physics imposter
  29005. */
  29006. sleep(): PhysicsImpostor;
  29007. /**
  29008. * Wake the body up.
  29009. * @returns The physics imposter
  29010. */
  29011. wakeUp(): PhysicsImpostor;
  29012. /**
  29013. * Clones the physics imposter
  29014. * @param newObject The physics imposter clones to this physics-enabled object
  29015. * @returns A nullable physics imposter
  29016. */
  29017. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29018. /**
  29019. * Disposes the physics imposter
  29020. */
  29021. dispose(): void;
  29022. /**
  29023. * Sets the delta position
  29024. * @param position The delta position amount
  29025. */
  29026. setDeltaPosition(position: Vector3): void;
  29027. /**
  29028. * Sets the delta rotation
  29029. * @param rotation The delta rotation amount
  29030. */
  29031. setDeltaRotation(rotation: Quaternion): void;
  29032. /**
  29033. * Gets the box size of the physics imposter and stores the result in the input parameter
  29034. * @param result Stores the box size
  29035. * @returns The physics imposter
  29036. */
  29037. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29038. /**
  29039. * Gets the radius of the physics imposter
  29040. * @returns Radius of the physics imposter
  29041. */
  29042. getRadius(): number;
  29043. /**
  29044. * Sync a bone with this impostor
  29045. * @param bone The bone to sync to the impostor.
  29046. * @param boneMesh The mesh that the bone is influencing.
  29047. * @param jointPivot The pivot of the joint / bone in local space.
  29048. * @param distToJoint Optional distance from the impostor to the joint.
  29049. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29050. */
  29051. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29052. /**
  29053. * Sync impostor to a bone
  29054. * @param bone The bone that the impostor will be synced to.
  29055. * @param boneMesh The mesh that the bone is influencing.
  29056. * @param jointPivot The pivot of the joint / bone in local space.
  29057. * @param distToJoint Optional distance from the impostor to the joint.
  29058. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29059. * @param boneAxis Optional vector3 axis the bone is aligned with
  29060. */
  29061. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29062. /**
  29063. * No-Imposter type
  29064. */
  29065. static NoImpostor: number;
  29066. /**
  29067. * Sphere-Imposter type
  29068. */
  29069. static SphereImpostor: number;
  29070. /**
  29071. * Box-Imposter type
  29072. */
  29073. static BoxImpostor: number;
  29074. /**
  29075. * Plane-Imposter type
  29076. */
  29077. static PlaneImpostor: number;
  29078. /**
  29079. * Mesh-imposter type
  29080. */
  29081. static MeshImpostor: number;
  29082. /**
  29083. * Capsule-Impostor type (Ammo.js plugin only)
  29084. */
  29085. static CapsuleImpostor: number;
  29086. /**
  29087. * Cylinder-Imposter type
  29088. */
  29089. static CylinderImpostor: number;
  29090. /**
  29091. * Particle-Imposter type
  29092. */
  29093. static ParticleImpostor: number;
  29094. /**
  29095. * Heightmap-Imposter type
  29096. */
  29097. static HeightmapImpostor: number;
  29098. /**
  29099. * ConvexHull-Impostor type (Ammo.js plugin only)
  29100. */
  29101. static ConvexHullImpostor: number;
  29102. /**
  29103. * Custom-Imposter type (Ammo.js plugin only)
  29104. */
  29105. static CustomImpostor: number;
  29106. /**
  29107. * Rope-Imposter type
  29108. */
  29109. static RopeImpostor: number;
  29110. /**
  29111. * Cloth-Imposter type
  29112. */
  29113. static ClothImpostor: number;
  29114. /**
  29115. * Softbody-Imposter type
  29116. */
  29117. static SoftbodyImpostor: number;
  29118. }
  29119. }
  29120. declare module "babylonjs/Meshes/mesh" {
  29121. import { Observable } from "babylonjs/Misc/observable";
  29122. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29123. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29124. import { Camera } from "babylonjs/Cameras/camera";
  29125. import { Scene } from "babylonjs/scene";
  29126. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29127. import { Color4 } from "babylonjs/Maths/math.color";
  29128. import { Engine } from "babylonjs/Engines/engine";
  29129. import { Node } from "babylonjs/node";
  29130. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29131. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29132. import { Buffer } from "babylonjs/Meshes/buffer";
  29133. import { Geometry } from "babylonjs/Meshes/geometry";
  29134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29136. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29137. import { Effect } from "babylonjs/Materials/effect";
  29138. import { Material } from "babylonjs/Materials/material";
  29139. import { Skeleton } from "babylonjs/Bones/skeleton";
  29140. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29141. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29142. import { Path3D } from "babylonjs/Maths/math.path";
  29143. import { Plane } from "babylonjs/Maths/math.plane";
  29144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29145. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29146. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29147. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29148. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29149. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29150. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29151. /**
  29152. * @hidden
  29153. **/
  29154. export class _CreationDataStorage {
  29155. closePath?: boolean;
  29156. closeArray?: boolean;
  29157. idx: number[];
  29158. dashSize: number;
  29159. gapSize: number;
  29160. path3D: Path3D;
  29161. pathArray: Vector3[][];
  29162. arc: number;
  29163. radius: number;
  29164. cap: number;
  29165. tessellation: number;
  29166. }
  29167. /**
  29168. * @hidden
  29169. **/
  29170. class _InstanceDataStorage {
  29171. visibleInstances: any;
  29172. batchCache: _InstancesBatch;
  29173. instancesBufferSize: number;
  29174. instancesBuffer: Nullable<Buffer>;
  29175. instancesData: Float32Array;
  29176. overridenInstanceCount: number;
  29177. isFrozen: boolean;
  29178. previousBatch: Nullable<_InstancesBatch>;
  29179. hardwareInstancedRendering: boolean;
  29180. sideOrientation: number;
  29181. manualUpdate: boolean;
  29182. previousRenderId: number;
  29183. }
  29184. /**
  29185. * @hidden
  29186. **/
  29187. export class _InstancesBatch {
  29188. mustReturn: boolean;
  29189. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29190. renderSelf: boolean[];
  29191. hardwareInstancedRendering: boolean[];
  29192. }
  29193. /**
  29194. * @hidden
  29195. **/
  29196. class _ThinInstanceDataStorage {
  29197. instancesCount: number;
  29198. matrixBuffer: Nullable<Buffer>;
  29199. matrixBufferSize: number;
  29200. matrixData: Nullable<Float32Array>;
  29201. boundingVectors: Array<Vector3>;
  29202. worldMatrices: Nullable<Matrix[]>;
  29203. }
  29204. /**
  29205. * Class used to represent renderable models
  29206. */
  29207. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29208. /**
  29209. * Mesh side orientation : usually the external or front surface
  29210. */
  29211. static readonly FRONTSIDE: number;
  29212. /**
  29213. * Mesh side orientation : usually the internal or back surface
  29214. */
  29215. static readonly BACKSIDE: number;
  29216. /**
  29217. * Mesh side orientation : both internal and external or front and back surfaces
  29218. */
  29219. static readonly DOUBLESIDE: number;
  29220. /**
  29221. * Mesh side orientation : by default, `FRONTSIDE`
  29222. */
  29223. static readonly DEFAULTSIDE: number;
  29224. /**
  29225. * Mesh cap setting : no cap
  29226. */
  29227. static readonly NO_CAP: number;
  29228. /**
  29229. * Mesh cap setting : one cap at the beginning of the mesh
  29230. */
  29231. static readonly CAP_START: number;
  29232. /**
  29233. * Mesh cap setting : one cap at the end of the mesh
  29234. */
  29235. static readonly CAP_END: number;
  29236. /**
  29237. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29238. */
  29239. static readonly CAP_ALL: number;
  29240. /**
  29241. * Mesh pattern setting : no flip or rotate
  29242. */
  29243. static readonly NO_FLIP: number;
  29244. /**
  29245. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29246. */
  29247. static readonly FLIP_TILE: number;
  29248. /**
  29249. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29250. */
  29251. static readonly ROTATE_TILE: number;
  29252. /**
  29253. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29254. */
  29255. static readonly FLIP_ROW: number;
  29256. /**
  29257. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29258. */
  29259. static readonly ROTATE_ROW: number;
  29260. /**
  29261. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29262. */
  29263. static readonly FLIP_N_ROTATE_TILE: number;
  29264. /**
  29265. * Mesh pattern setting : rotate pattern and rotate
  29266. */
  29267. static readonly FLIP_N_ROTATE_ROW: number;
  29268. /**
  29269. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29270. */
  29271. static readonly CENTER: number;
  29272. /**
  29273. * Mesh tile positioning : part tiles on left
  29274. */
  29275. static readonly LEFT: number;
  29276. /**
  29277. * Mesh tile positioning : part tiles on right
  29278. */
  29279. static readonly RIGHT: number;
  29280. /**
  29281. * Mesh tile positioning : part tiles on top
  29282. */
  29283. static readonly TOP: number;
  29284. /**
  29285. * Mesh tile positioning : part tiles on bottom
  29286. */
  29287. static readonly BOTTOM: number;
  29288. /**
  29289. * Gets the default side orientation.
  29290. * @param orientation the orientation to value to attempt to get
  29291. * @returns the default orientation
  29292. * @hidden
  29293. */
  29294. static _GetDefaultSideOrientation(orientation?: number): number;
  29295. private _internalMeshDataInfo;
  29296. get computeBonesUsingShaders(): boolean;
  29297. set computeBonesUsingShaders(value: boolean);
  29298. /**
  29299. * An event triggered before rendering the mesh
  29300. */
  29301. get onBeforeRenderObservable(): Observable<Mesh>;
  29302. /**
  29303. * An event triggered before binding the mesh
  29304. */
  29305. get onBeforeBindObservable(): Observable<Mesh>;
  29306. /**
  29307. * An event triggered after rendering the mesh
  29308. */
  29309. get onAfterRenderObservable(): Observable<Mesh>;
  29310. /**
  29311. * An event triggered before drawing the mesh
  29312. */
  29313. get onBeforeDrawObservable(): Observable<Mesh>;
  29314. private _onBeforeDrawObserver;
  29315. /**
  29316. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29317. */
  29318. set onBeforeDraw(callback: () => void);
  29319. get hasInstances(): boolean;
  29320. get hasThinInstances(): boolean;
  29321. /**
  29322. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29323. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29324. */
  29325. delayLoadState: number;
  29326. /**
  29327. * Gets the list of instances created from this mesh
  29328. * it is not supposed to be modified manually.
  29329. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29330. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29331. */
  29332. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29333. /**
  29334. * Gets the file containing delay loading data for this mesh
  29335. */
  29336. delayLoadingFile: string;
  29337. /** @hidden */
  29338. _binaryInfo: any;
  29339. /**
  29340. * User defined function used to change how LOD level selection is done
  29341. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29342. */
  29343. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29344. /**
  29345. * Gets or sets the morph target manager
  29346. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29347. */
  29348. get morphTargetManager(): Nullable<MorphTargetManager>;
  29349. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29350. /** @hidden */
  29351. _creationDataStorage: Nullable<_CreationDataStorage>;
  29352. /** @hidden */
  29353. _geometry: Nullable<Geometry>;
  29354. /** @hidden */
  29355. _delayInfo: Array<string>;
  29356. /** @hidden */
  29357. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29358. /** @hidden */
  29359. _instanceDataStorage: _InstanceDataStorage;
  29360. /** @hidden */
  29361. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29362. private _effectiveMaterial;
  29363. /** @hidden */
  29364. _shouldGenerateFlatShading: boolean;
  29365. /** @hidden */
  29366. _originalBuilderSideOrientation: number;
  29367. /**
  29368. * Use this property to change the original side orientation defined at construction time
  29369. */
  29370. overrideMaterialSideOrientation: Nullable<number>;
  29371. /**
  29372. * Gets the source mesh (the one used to clone this one from)
  29373. */
  29374. get source(): Nullable<Mesh>;
  29375. /**
  29376. * Gets the list of clones of this mesh
  29377. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29378. * Note that useClonedMeshMap=true is the default setting
  29379. */
  29380. get cloneMeshMap(): Nullable<{
  29381. [id: string]: Mesh | undefined;
  29382. }>;
  29383. /**
  29384. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29385. */
  29386. get isUnIndexed(): boolean;
  29387. set isUnIndexed(value: boolean);
  29388. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29389. get worldMatrixInstancedBuffer(): Float32Array;
  29390. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29391. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29392. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29393. /**
  29394. * @constructor
  29395. * @param name The value used by scene.getMeshByName() to do a lookup.
  29396. * @param scene The scene to add this mesh to.
  29397. * @param parent The parent of this mesh, if it has one
  29398. * @param source An optional Mesh from which geometry is shared, cloned.
  29399. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29400. * When false, achieved by calling a clone(), also passing False.
  29401. * This will make creation of children, recursive.
  29402. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29403. */
  29404. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29405. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29406. doNotInstantiate: boolean;
  29407. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29408. /**
  29409. * Gets the class name
  29410. * @returns the string "Mesh".
  29411. */
  29412. getClassName(): string;
  29413. /** @hidden */
  29414. get _isMesh(): boolean;
  29415. /**
  29416. * Returns a description of this mesh
  29417. * @param fullDetails define if full details about this mesh must be used
  29418. * @returns a descriptive string representing this mesh
  29419. */
  29420. toString(fullDetails?: boolean): string;
  29421. /** @hidden */
  29422. _unBindEffect(): void;
  29423. /**
  29424. * Gets a boolean indicating if this mesh has LOD
  29425. */
  29426. get hasLODLevels(): boolean;
  29427. /**
  29428. * Gets the list of MeshLODLevel associated with the current mesh
  29429. * @returns an array of MeshLODLevel
  29430. */
  29431. getLODLevels(): MeshLODLevel[];
  29432. private _sortLODLevels;
  29433. /**
  29434. * Add a mesh as LOD level triggered at the given distance.
  29435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29436. * @param distance The distance from the center of the object to show this level
  29437. * @param mesh The mesh to be added as LOD level (can be null)
  29438. * @return This mesh (for chaining)
  29439. */
  29440. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29441. /**
  29442. * Returns the LOD level mesh at the passed distance or null if not found.
  29443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29444. * @param distance The distance from the center of the object to show this level
  29445. * @returns a Mesh or `null`
  29446. */
  29447. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29448. /**
  29449. * Remove a mesh from the LOD array
  29450. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29451. * @param mesh defines the mesh to be removed
  29452. * @return This mesh (for chaining)
  29453. */
  29454. removeLODLevel(mesh: Mesh): Mesh;
  29455. /**
  29456. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29457. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29458. * @param camera defines the camera to use to compute distance
  29459. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29460. * @return This mesh (for chaining)
  29461. */
  29462. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29463. /**
  29464. * Gets the mesh internal Geometry object
  29465. */
  29466. get geometry(): Nullable<Geometry>;
  29467. /**
  29468. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29469. * @returns the total number of vertices
  29470. */
  29471. getTotalVertices(): number;
  29472. /**
  29473. * Returns the content of an associated vertex buffer
  29474. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29475. * - VertexBuffer.PositionKind
  29476. * - VertexBuffer.UVKind
  29477. * - VertexBuffer.UV2Kind
  29478. * - VertexBuffer.UV3Kind
  29479. * - VertexBuffer.UV4Kind
  29480. * - VertexBuffer.UV5Kind
  29481. * - VertexBuffer.UV6Kind
  29482. * - VertexBuffer.ColorKind
  29483. * - VertexBuffer.MatricesIndicesKind
  29484. * - VertexBuffer.MatricesIndicesExtraKind
  29485. * - VertexBuffer.MatricesWeightsKind
  29486. * - VertexBuffer.MatricesWeightsExtraKind
  29487. * @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
  29488. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29489. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29490. */
  29491. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29492. /**
  29493. * Returns the mesh VertexBuffer object from the requested `kind`
  29494. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29495. * - VertexBuffer.PositionKind
  29496. * - VertexBuffer.NormalKind
  29497. * - VertexBuffer.UVKind
  29498. * - VertexBuffer.UV2Kind
  29499. * - VertexBuffer.UV3Kind
  29500. * - VertexBuffer.UV4Kind
  29501. * - VertexBuffer.UV5Kind
  29502. * - VertexBuffer.UV6Kind
  29503. * - VertexBuffer.ColorKind
  29504. * - VertexBuffer.MatricesIndicesKind
  29505. * - VertexBuffer.MatricesIndicesExtraKind
  29506. * - VertexBuffer.MatricesWeightsKind
  29507. * - VertexBuffer.MatricesWeightsExtraKind
  29508. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29509. */
  29510. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29511. /**
  29512. * Tests if a specific vertex buffer is associated with this mesh
  29513. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29514. * - VertexBuffer.PositionKind
  29515. * - VertexBuffer.NormalKind
  29516. * - VertexBuffer.UVKind
  29517. * - VertexBuffer.UV2Kind
  29518. * - VertexBuffer.UV3Kind
  29519. * - VertexBuffer.UV4Kind
  29520. * - VertexBuffer.UV5Kind
  29521. * - VertexBuffer.UV6Kind
  29522. * - VertexBuffer.ColorKind
  29523. * - VertexBuffer.MatricesIndicesKind
  29524. * - VertexBuffer.MatricesIndicesExtraKind
  29525. * - VertexBuffer.MatricesWeightsKind
  29526. * - VertexBuffer.MatricesWeightsExtraKind
  29527. * @returns a boolean
  29528. */
  29529. isVerticesDataPresent(kind: string): boolean;
  29530. /**
  29531. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29532. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29533. * - VertexBuffer.PositionKind
  29534. * - VertexBuffer.UVKind
  29535. * - VertexBuffer.UV2Kind
  29536. * - VertexBuffer.UV3Kind
  29537. * - VertexBuffer.UV4Kind
  29538. * - VertexBuffer.UV5Kind
  29539. * - VertexBuffer.UV6Kind
  29540. * - VertexBuffer.ColorKind
  29541. * - VertexBuffer.MatricesIndicesKind
  29542. * - VertexBuffer.MatricesIndicesExtraKind
  29543. * - VertexBuffer.MatricesWeightsKind
  29544. * - VertexBuffer.MatricesWeightsExtraKind
  29545. * @returns a boolean
  29546. */
  29547. isVertexBufferUpdatable(kind: string): boolean;
  29548. /**
  29549. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29550. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29551. * - VertexBuffer.PositionKind
  29552. * - VertexBuffer.NormalKind
  29553. * - VertexBuffer.UVKind
  29554. * - VertexBuffer.UV2Kind
  29555. * - VertexBuffer.UV3Kind
  29556. * - VertexBuffer.UV4Kind
  29557. * - VertexBuffer.UV5Kind
  29558. * - VertexBuffer.UV6Kind
  29559. * - VertexBuffer.ColorKind
  29560. * - VertexBuffer.MatricesIndicesKind
  29561. * - VertexBuffer.MatricesIndicesExtraKind
  29562. * - VertexBuffer.MatricesWeightsKind
  29563. * - VertexBuffer.MatricesWeightsExtraKind
  29564. * @returns an array of strings
  29565. */
  29566. getVerticesDataKinds(): string[];
  29567. /**
  29568. * Returns a positive integer : the total number of indices in this mesh geometry.
  29569. * @returns the numner of indices or zero if the mesh has no geometry.
  29570. */
  29571. getTotalIndices(): number;
  29572. /**
  29573. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29574. * @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.
  29575. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29576. * @returns the indices array or an empty array if the mesh has no geometry
  29577. */
  29578. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29579. get isBlocked(): boolean;
  29580. /**
  29581. * Determine if the current mesh is ready to be rendered
  29582. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29583. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29584. * @returns true if all associated assets are ready (material, textures, shaders)
  29585. */
  29586. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29587. /**
  29588. * 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.
  29589. */
  29590. get areNormalsFrozen(): boolean;
  29591. /**
  29592. * 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.
  29593. * @returns the current mesh
  29594. */
  29595. freezeNormals(): Mesh;
  29596. /**
  29597. * 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
  29598. * @returns the current mesh
  29599. */
  29600. unfreezeNormals(): Mesh;
  29601. /**
  29602. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29603. */
  29604. set overridenInstanceCount(count: number);
  29605. /** @hidden */
  29606. _preActivate(): Mesh;
  29607. /** @hidden */
  29608. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29609. /** @hidden */
  29610. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29611. protected _afterComputeWorldMatrix(): void;
  29612. /** @hidden */
  29613. _postActivate(): void;
  29614. /**
  29615. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29616. * This means the mesh underlying bounding box and sphere are recomputed.
  29617. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29618. * @returns the current mesh
  29619. */
  29620. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29621. /** @hidden */
  29622. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29623. /**
  29624. * This function will subdivide the mesh into multiple submeshes
  29625. * @param count defines the expected number of submeshes
  29626. */
  29627. subdivide(count: number): void;
  29628. /**
  29629. * Copy a FloatArray into a specific associated vertex buffer
  29630. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29631. * - VertexBuffer.PositionKind
  29632. * - VertexBuffer.UVKind
  29633. * - VertexBuffer.UV2Kind
  29634. * - VertexBuffer.UV3Kind
  29635. * - VertexBuffer.UV4Kind
  29636. * - VertexBuffer.UV5Kind
  29637. * - VertexBuffer.UV6Kind
  29638. * - VertexBuffer.ColorKind
  29639. * - VertexBuffer.MatricesIndicesKind
  29640. * - VertexBuffer.MatricesIndicesExtraKind
  29641. * - VertexBuffer.MatricesWeightsKind
  29642. * - VertexBuffer.MatricesWeightsExtraKind
  29643. * @param data defines the data source
  29644. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29645. * @param stride defines the data stride size (can be null)
  29646. * @returns the current mesh
  29647. */
  29648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29649. /**
  29650. * Delete a vertex buffer associated with this mesh
  29651. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29652. * - VertexBuffer.PositionKind
  29653. * - VertexBuffer.UVKind
  29654. * - VertexBuffer.UV2Kind
  29655. * - VertexBuffer.UV3Kind
  29656. * - VertexBuffer.UV4Kind
  29657. * - VertexBuffer.UV5Kind
  29658. * - VertexBuffer.UV6Kind
  29659. * - VertexBuffer.ColorKind
  29660. * - VertexBuffer.MatricesIndicesKind
  29661. * - VertexBuffer.MatricesIndicesExtraKind
  29662. * - VertexBuffer.MatricesWeightsKind
  29663. * - VertexBuffer.MatricesWeightsExtraKind
  29664. */
  29665. removeVerticesData(kind: string): void;
  29666. /**
  29667. * Flags an associated vertex buffer as updatable
  29668. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29669. * - VertexBuffer.PositionKind
  29670. * - VertexBuffer.UVKind
  29671. * - VertexBuffer.UV2Kind
  29672. * - VertexBuffer.UV3Kind
  29673. * - VertexBuffer.UV4Kind
  29674. * - VertexBuffer.UV5Kind
  29675. * - VertexBuffer.UV6Kind
  29676. * - VertexBuffer.ColorKind
  29677. * - VertexBuffer.MatricesIndicesKind
  29678. * - VertexBuffer.MatricesIndicesExtraKind
  29679. * - VertexBuffer.MatricesWeightsKind
  29680. * - VertexBuffer.MatricesWeightsExtraKind
  29681. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29682. */
  29683. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29684. /**
  29685. * Sets the mesh global Vertex Buffer
  29686. * @param buffer defines the buffer to use
  29687. * @returns the current mesh
  29688. */
  29689. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29690. /**
  29691. * Update a specific associated vertex buffer
  29692. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29693. * - VertexBuffer.PositionKind
  29694. * - VertexBuffer.UVKind
  29695. * - VertexBuffer.UV2Kind
  29696. * - VertexBuffer.UV3Kind
  29697. * - VertexBuffer.UV4Kind
  29698. * - VertexBuffer.UV5Kind
  29699. * - VertexBuffer.UV6Kind
  29700. * - VertexBuffer.ColorKind
  29701. * - VertexBuffer.MatricesIndicesKind
  29702. * - VertexBuffer.MatricesIndicesExtraKind
  29703. * - VertexBuffer.MatricesWeightsKind
  29704. * - VertexBuffer.MatricesWeightsExtraKind
  29705. * @param data defines the data source
  29706. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29707. * @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)
  29708. * @returns the current mesh
  29709. */
  29710. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29711. /**
  29712. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29713. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29714. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29715. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29716. * @returns the current mesh
  29717. */
  29718. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29719. /**
  29720. * Creates a un-shared specific occurence of the geometry for the mesh.
  29721. * @returns the current mesh
  29722. */
  29723. makeGeometryUnique(): Mesh;
  29724. /**
  29725. * Set the index buffer of this mesh
  29726. * @param indices defines the source data
  29727. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29728. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29729. * @returns the current mesh
  29730. */
  29731. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29732. /**
  29733. * Update the current index buffer
  29734. * @param indices defines the source data
  29735. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29736. * @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)
  29737. * @returns the current mesh
  29738. */
  29739. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29740. /**
  29741. * Invert the geometry to move from a right handed system to a left handed one.
  29742. * @returns the current mesh
  29743. */
  29744. toLeftHanded(): Mesh;
  29745. /** @hidden */
  29746. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29747. /** @hidden */
  29748. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29749. /**
  29750. * Registers for this mesh a javascript function called just before the rendering process
  29751. * @param func defines the function to call before rendering this mesh
  29752. * @returns the current mesh
  29753. */
  29754. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29755. /**
  29756. * Disposes a previously registered javascript function called before the rendering
  29757. * @param func defines the function to remove
  29758. * @returns the current mesh
  29759. */
  29760. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29761. /**
  29762. * Registers for this mesh a javascript function called just after the rendering is complete
  29763. * @param func defines the function to call after rendering this mesh
  29764. * @returns the current mesh
  29765. */
  29766. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29767. /**
  29768. * Disposes a previously registered javascript function called after the rendering.
  29769. * @param func defines the function to remove
  29770. * @returns the current mesh
  29771. */
  29772. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29773. /** @hidden */
  29774. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29775. /** @hidden */
  29776. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29777. /** @hidden */
  29778. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29779. /** @hidden */
  29780. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29781. /** @hidden */
  29782. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29783. /** @hidden */
  29784. _rebuild(): void;
  29785. /** @hidden */
  29786. _freeze(): void;
  29787. /** @hidden */
  29788. _unFreeze(): void;
  29789. /**
  29790. * 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
  29791. * @param subMesh defines the subMesh to render
  29792. * @param enableAlphaMode defines if alpha mode can be changed
  29793. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29794. * @returns the current mesh
  29795. */
  29796. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29797. private _onBeforeDraw;
  29798. /**
  29799. * Renormalize the mesh and patch it up if there are no weights
  29800. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29801. * However in the case of zero weights then we set just a single influence to 1.
  29802. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29803. */
  29804. cleanMatrixWeights(): void;
  29805. private normalizeSkinFourWeights;
  29806. private normalizeSkinWeightsAndExtra;
  29807. /**
  29808. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29809. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29810. * the user know there was an issue with importing the mesh
  29811. * @returns a validation object with skinned, valid and report string
  29812. */
  29813. validateSkinning(): {
  29814. skinned: boolean;
  29815. valid: boolean;
  29816. report: string;
  29817. };
  29818. /** @hidden */
  29819. _checkDelayState(): Mesh;
  29820. private _queueLoad;
  29821. /**
  29822. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29823. * A mesh is in the frustum if its bounding box intersects the frustum
  29824. * @param frustumPlanes defines the frustum to test
  29825. * @returns true if the mesh is in the frustum planes
  29826. */
  29827. isInFrustum(frustumPlanes: Plane[]): boolean;
  29828. /**
  29829. * Sets the mesh material by the material or multiMaterial `id` property
  29830. * @param id is a string identifying the material or the multiMaterial
  29831. * @returns the current mesh
  29832. */
  29833. setMaterialByID(id: string): Mesh;
  29834. /**
  29835. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29836. * @returns an array of IAnimatable
  29837. */
  29838. getAnimatables(): IAnimatable[];
  29839. /**
  29840. * Modifies the mesh geometry according to the passed transformation matrix.
  29841. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29842. * The mesh normals are modified using the same transformation.
  29843. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29844. * @param transform defines the transform matrix to use
  29845. * @see https://doc.babylonjs.com/resources/baking_transformations
  29846. * @returns the current mesh
  29847. */
  29848. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29849. /**
  29850. * Modifies the mesh geometry according to its own current World Matrix.
  29851. * The mesh World Matrix is then reset.
  29852. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29853. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29854. * @see https://doc.babylonjs.com/resources/baking_transformations
  29855. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29856. * @returns the current mesh
  29857. */
  29858. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29859. /** @hidden */
  29860. get _positions(): Nullable<Vector3[]>;
  29861. /** @hidden */
  29862. _resetPointsArrayCache(): Mesh;
  29863. /** @hidden */
  29864. _generatePointsArray(): boolean;
  29865. /**
  29866. * Returns a new Mesh object generated from the current mesh properties.
  29867. * This method must not get confused with createInstance()
  29868. * @param name is a string, the name given to the new mesh
  29869. * @param newParent can be any Node object (default `null`)
  29870. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29871. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29872. * @returns a new mesh
  29873. */
  29874. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29875. /**
  29876. * Releases resources associated with this mesh.
  29877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29879. */
  29880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29881. /** @hidden */
  29882. _disposeInstanceSpecificData(): void;
  29883. /** @hidden */
  29884. _disposeThinInstanceSpecificData(): void;
  29885. /**
  29886. * Modifies the mesh geometry according to a displacement map.
  29887. * 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.
  29888. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29889. * @param url is a string, the URL from the image file is to be downloaded.
  29890. * @param minHeight is the lower limit of the displacement.
  29891. * @param maxHeight is the upper limit of the displacement.
  29892. * @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.
  29893. * @param uvOffset is an optional vector2 used to offset UV.
  29894. * @param uvScale is an optional vector2 used to scale UV.
  29895. * @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.
  29896. * @returns the Mesh.
  29897. */
  29898. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29899. /**
  29900. * Modifies the mesh geometry according to a displacementMap buffer.
  29901. * 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.
  29902. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29903. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29904. * @param heightMapWidth is the width of the buffer image.
  29905. * @param heightMapHeight is the height of the buffer image.
  29906. * @param minHeight is the lower limit of the displacement.
  29907. * @param maxHeight is the upper limit of the displacement.
  29908. * @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.
  29909. * @param uvOffset is an optional vector2 used to offset UV.
  29910. * @param uvScale is an optional vector2 used to scale UV.
  29911. * @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.
  29912. * @returns the Mesh.
  29913. */
  29914. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29915. /**
  29916. * Modify the mesh to get a flat shading rendering.
  29917. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29918. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29919. * @returns current mesh
  29920. */
  29921. convertToFlatShadedMesh(): Mesh;
  29922. /**
  29923. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29924. * In other words, more vertices, no more indices and a single bigger VBO.
  29925. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29926. * @returns current mesh
  29927. */
  29928. convertToUnIndexedMesh(): Mesh;
  29929. /**
  29930. * Inverses facet orientations.
  29931. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29932. * @param flipNormals will also inverts the normals
  29933. * @returns current mesh
  29934. */
  29935. flipFaces(flipNormals?: boolean): Mesh;
  29936. /**
  29937. * Increase the number of facets and hence vertices in a mesh
  29938. * Vertex normals are interpolated from existing vertex normals
  29939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29940. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29941. */
  29942. increaseVertices(numberPerEdge: number): void;
  29943. /**
  29944. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29945. * This will undo any application of covertToFlatShadedMesh
  29946. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29947. */
  29948. forceSharedVertices(): void;
  29949. /** @hidden */
  29950. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29951. /** @hidden */
  29952. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29953. /**
  29954. * Creates a new InstancedMesh object from the mesh model.
  29955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29956. * @param name defines the name of the new instance
  29957. * @returns a new InstancedMesh
  29958. */
  29959. createInstance(name: string): InstancedMesh;
  29960. /**
  29961. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29962. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29963. * @returns the current mesh
  29964. */
  29965. synchronizeInstances(): Mesh;
  29966. /**
  29967. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29968. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29969. * This should be used together with the simplification to avoid disappearing triangles.
  29970. * @param successCallback an optional success callback to be called after the optimization finished.
  29971. * @returns the current mesh
  29972. */
  29973. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29974. /**
  29975. * Serialize current mesh
  29976. * @param serializationObject defines the object which will receive the serialization data
  29977. */
  29978. serialize(serializationObject: any): void;
  29979. /** @hidden */
  29980. _syncGeometryWithMorphTargetManager(): void;
  29981. /** @hidden */
  29982. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29983. /**
  29984. * Returns a new Mesh object parsed from the source provided.
  29985. * @param parsedMesh is the source
  29986. * @param scene defines the hosting scene
  29987. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29988. * @returns a new Mesh
  29989. */
  29990. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29991. /**
  29992. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29994. * @param name defines the name of the mesh to create
  29995. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29996. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29997. * @param closePath creates a seam between the first and the last points of each path of the path array
  29998. * @param offset is taken in account only if the `pathArray` is containing a single path
  29999. * @param scene defines the hosting scene
  30000. * @param updatable defines if the mesh must be flagged as updatable
  30001. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30002. * @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)
  30003. * @returns a new Mesh
  30004. */
  30005. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30006. /**
  30007. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30008. * @param name defines the name of the mesh to create
  30009. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30010. * @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
  30011. * @param scene defines the hosting scene
  30012. * @param updatable defines if the mesh must be flagged as updatable
  30013. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30014. * @returns a new Mesh
  30015. */
  30016. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30017. /**
  30018. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30019. * @param name defines the name of the mesh to create
  30020. * @param size sets the size (float) of each box side (default 1)
  30021. * @param scene defines the hosting scene
  30022. * @param updatable defines if the mesh must be flagged as updatable
  30023. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30024. * @returns a new Mesh
  30025. */
  30026. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30027. /**
  30028. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30029. * @param name defines the name of the mesh to create
  30030. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30031. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30032. * @param scene defines the hosting scene
  30033. * @param updatable defines if the mesh must be flagged as updatable
  30034. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30035. * @returns a new Mesh
  30036. */
  30037. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30038. /**
  30039. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30040. * @param name defines the name of the mesh to create
  30041. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30042. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30043. * @param scene defines the hosting scene
  30044. * @returns a new Mesh
  30045. */
  30046. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30047. /**
  30048. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30049. * @param name defines the name of the mesh to create
  30050. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30051. * @param diameterTop set the top cap diameter (floats, default 1)
  30052. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30053. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30054. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30055. * @param scene defines the hosting scene
  30056. * @param updatable defines if the mesh must be flagged as updatable
  30057. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30058. * @returns a new Mesh
  30059. */
  30060. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30061. /**
  30062. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30063. * @param name defines the name of the mesh to create
  30064. * @param diameter sets the diameter size (float) of the torus (default 1)
  30065. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30066. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30067. * @param scene defines the hosting scene
  30068. * @param updatable defines if the mesh must be flagged as updatable
  30069. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30070. * @returns a new Mesh
  30071. */
  30072. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30073. /**
  30074. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30075. * @param name defines the name of the mesh to create
  30076. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30077. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30078. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30079. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30080. * @param p the number of windings on X axis (positive integers, default 2)
  30081. * @param q the number of windings on Y axis (positive integers, default 3)
  30082. * @param scene defines the hosting scene
  30083. * @param updatable defines if the mesh must be flagged as updatable
  30084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30085. * @returns a new Mesh
  30086. */
  30087. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30088. /**
  30089. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30090. * @param name defines the name of the mesh to create
  30091. * @param points is an array successive Vector3
  30092. * @param scene defines the hosting scene
  30093. * @param updatable defines if the mesh must be flagged as updatable
  30094. * @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).
  30095. * @returns a new Mesh
  30096. */
  30097. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30098. /**
  30099. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30100. * @param name defines the name of the mesh to create
  30101. * @param points is an array successive Vector3
  30102. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30103. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30104. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30105. * @param scene defines the hosting scene
  30106. * @param updatable defines if the mesh must be flagged as updatable
  30107. * @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)
  30108. * @returns a new Mesh
  30109. */
  30110. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30111. /**
  30112. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30113. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30114. * 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.
  30115. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30116. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30117. * Remember you can only change the shape positions, not their number when updating a polygon.
  30118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30119. * @param name defines the name of the mesh to create
  30120. * @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
  30121. * @param scene defines the hosting scene
  30122. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30123. * @param updatable defines if the mesh must be flagged as updatable
  30124. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30125. * @param earcutInjection can be used to inject your own earcut reference
  30126. * @returns a new Mesh
  30127. */
  30128. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30129. /**
  30130. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30132. * @param name defines the name of the mesh to create
  30133. * @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
  30134. * @param depth defines the height of extrusion
  30135. * @param scene defines the hosting scene
  30136. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30137. * @param updatable defines if the mesh must be flagged as updatable
  30138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30139. * @param earcutInjection can be used to inject your own earcut reference
  30140. * @returns a new Mesh
  30141. */
  30142. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30143. /**
  30144. * Creates an extruded shape mesh.
  30145. * 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
  30146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30148. * @param name defines the name of the mesh to create
  30149. * @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
  30150. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30151. * @param scale is the value to scale the shape
  30152. * @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
  30153. * @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
  30154. * @param scene defines the hosting scene
  30155. * @param updatable defines if the mesh must be flagged as updatable
  30156. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30157. * @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)
  30158. * @returns a new Mesh
  30159. */
  30160. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30161. /**
  30162. * Creates an custom extruded shape mesh.
  30163. * The custom extrusion is a parametric shape.
  30164. * It has no predefined shape. Its final shape will depend on the input parameters.
  30165. * Please consider using the same method from the MeshBuilder class instead
  30166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30167. * @param name defines the name of the mesh to create
  30168. * @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
  30169. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30170. * @param scaleFunction is a custom Javascript function called on each path point
  30171. * @param rotationFunction is a custom Javascript function called on each path point
  30172. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30173. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30174. * @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
  30175. * @param scene defines the hosting scene
  30176. * @param updatable defines if the mesh must be flagged as updatable
  30177. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30178. * @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)
  30179. * @returns a new Mesh
  30180. */
  30181. 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;
  30182. /**
  30183. * Creates lathe mesh.
  30184. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30185. * Please consider using the same method from the MeshBuilder class instead
  30186. * @param name defines the name of the mesh to create
  30187. * @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
  30188. * @param radius is the radius value of the lathe
  30189. * @param tessellation is the side number of the lathe.
  30190. * @param scene defines the hosting scene
  30191. * @param updatable defines if the mesh must be flagged as updatable
  30192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30193. * @returns a new Mesh
  30194. */
  30195. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30196. /**
  30197. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30198. * @param name defines the name of the mesh to create
  30199. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30200. * @param scene defines the hosting scene
  30201. * @param updatable defines if the mesh must be flagged as updatable
  30202. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30203. * @returns a new Mesh
  30204. */
  30205. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30206. /**
  30207. * Creates a ground mesh.
  30208. * Please consider using the same method from the MeshBuilder class instead
  30209. * @param name defines the name of the mesh to create
  30210. * @param width set the width of the ground
  30211. * @param height set the height of the ground
  30212. * @param subdivisions sets the number of subdivisions per side
  30213. * @param scene defines the hosting scene
  30214. * @param updatable defines if the mesh must be flagged as updatable
  30215. * @returns a new Mesh
  30216. */
  30217. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30218. /**
  30219. * Creates a tiled ground mesh.
  30220. * Please consider using the same method from the MeshBuilder class instead
  30221. * @param name defines the name of the mesh to create
  30222. * @param xmin set the ground minimum X coordinate
  30223. * @param zmin set the ground minimum Y coordinate
  30224. * @param xmax set the ground maximum X coordinate
  30225. * @param zmax set the ground maximum Z coordinate
  30226. * @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
  30227. * @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
  30228. * @param scene defines the hosting scene
  30229. * @param updatable defines if the mesh must be flagged as updatable
  30230. * @returns a new Mesh
  30231. */
  30232. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30233. w: number;
  30234. h: number;
  30235. }, precision: {
  30236. w: number;
  30237. h: number;
  30238. }, scene: Scene, updatable?: boolean): Mesh;
  30239. /**
  30240. * Creates a ground mesh from a height map.
  30241. * Please consider using the same method from the MeshBuilder class instead
  30242. * @see https://doc.babylonjs.com/babylon101/height_map
  30243. * @param name defines the name of the mesh to create
  30244. * @param url sets the URL of the height map image resource
  30245. * @param width set the ground width size
  30246. * @param height set the ground height size
  30247. * @param subdivisions sets the number of subdivision per side
  30248. * @param minHeight is the minimum altitude on the ground
  30249. * @param maxHeight is the maximum altitude on the ground
  30250. * @param scene defines the hosting scene
  30251. * @param updatable defines if the mesh must be flagged as updatable
  30252. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30253. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30254. * @returns a new Mesh
  30255. */
  30256. 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;
  30257. /**
  30258. * Creates a tube mesh.
  30259. * The tube is a parametric shape.
  30260. * It has no predefined shape. Its final shape will depend on the input parameters.
  30261. * Please consider using the same method from the MeshBuilder class instead
  30262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30263. * @param name defines the name of the mesh to create
  30264. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30265. * @param radius sets the tube radius size
  30266. * @param tessellation is the number of sides on the tubular surface
  30267. * @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
  30268. * @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
  30269. * @param scene defines the hosting scene
  30270. * @param updatable defines if the mesh must be flagged as updatable
  30271. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30272. * @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)
  30273. * @returns a new Mesh
  30274. */
  30275. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30276. (i: number, distance: number): number;
  30277. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30278. /**
  30279. * Creates a polyhedron mesh.
  30280. * Please consider using the same method from the MeshBuilder class instead.
  30281. * * 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
  30282. * * The parameter `size` (positive float, default 1) sets the polygon size
  30283. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30284. * * 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`
  30285. * * 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
  30286. * * 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)`)
  30287. * * 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
  30288. * * 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
  30289. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30292. * @param name defines the name of the mesh to create
  30293. * @param options defines the options used to create the mesh
  30294. * @param scene defines the hosting scene
  30295. * @returns a new Mesh
  30296. */
  30297. static CreatePolyhedron(name: string, options: {
  30298. type?: number;
  30299. size?: number;
  30300. sizeX?: number;
  30301. sizeY?: number;
  30302. sizeZ?: number;
  30303. custom?: any;
  30304. faceUV?: Vector4[];
  30305. faceColors?: Color4[];
  30306. updatable?: boolean;
  30307. sideOrientation?: number;
  30308. }, scene: Scene): Mesh;
  30309. /**
  30310. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30311. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30312. * * 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`)
  30313. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30314. * * 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
  30315. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30318. * @param name defines the name of the mesh
  30319. * @param options defines the options used to create the mesh
  30320. * @param scene defines the hosting scene
  30321. * @returns a new Mesh
  30322. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30323. */
  30324. static CreateIcoSphere(name: string, options: {
  30325. radius?: number;
  30326. flat?: boolean;
  30327. subdivisions?: number;
  30328. sideOrientation?: number;
  30329. updatable?: boolean;
  30330. }, scene: Scene): Mesh;
  30331. /**
  30332. * Creates a decal mesh.
  30333. * Please consider using the same method from the MeshBuilder class instead.
  30334. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30335. * @param name defines the name of the mesh
  30336. * @param sourceMesh defines the mesh receiving the decal
  30337. * @param position sets the position of the decal in world coordinates
  30338. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30339. * @param size sets the decal scaling
  30340. * @param angle sets the angle to rotate the decal
  30341. * @returns a new Mesh
  30342. */
  30343. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30344. /** Creates a Capsule Mesh
  30345. * @param name defines the name of the mesh.
  30346. * @param options the constructors options used to shape the mesh.
  30347. * @param scene defines the scene the mesh is scoped to.
  30348. * @returns the capsule mesh
  30349. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30350. */
  30351. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30352. /**
  30353. * Prepare internal position array for software CPU skinning
  30354. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30355. */
  30356. setPositionsForCPUSkinning(): Float32Array;
  30357. /**
  30358. * Prepare internal normal array for software CPU skinning
  30359. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30360. */
  30361. setNormalsForCPUSkinning(): Float32Array;
  30362. /**
  30363. * Updates the vertex buffer by applying transformation from the bones
  30364. * @param skeleton defines the skeleton to apply to current mesh
  30365. * @returns the current mesh
  30366. */
  30367. applySkeleton(skeleton: Skeleton): Mesh;
  30368. /**
  30369. * 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
  30370. * @param meshes defines the list of meshes to scan
  30371. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30372. */
  30373. static MinMax(meshes: AbstractMesh[]): {
  30374. min: Vector3;
  30375. max: Vector3;
  30376. };
  30377. /**
  30378. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30379. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30380. * @returns a vector3
  30381. */
  30382. static Center(meshesOrMinMaxVector: {
  30383. min: Vector3;
  30384. max: Vector3;
  30385. } | AbstractMesh[]): Vector3;
  30386. /**
  30387. * Merge the array of meshes into a single mesh for performance reasons.
  30388. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30389. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30390. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30391. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30392. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30393. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30394. * @returns a new mesh
  30395. */
  30396. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30397. /** @hidden */
  30398. addInstance(instance: InstancedMesh): void;
  30399. /** @hidden */
  30400. removeInstance(instance: InstancedMesh): void;
  30401. }
  30402. }
  30403. declare module "babylonjs/Cameras/camera" {
  30404. import { SmartArray } from "babylonjs/Misc/smartArray";
  30405. import { Observable } from "babylonjs/Misc/observable";
  30406. import { Nullable } from "babylonjs/types";
  30407. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30408. import { Scene } from "babylonjs/scene";
  30409. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30410. import { Node } from "babylonjs/node";
  30411. import { Mesh } from "babylonjs/Meshes/mesh";
  30412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30413. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30414. import { Viewport } from "babylonjs/Maths/math.viewport";
  30415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30416. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30417. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30418. import { Ray } from "babylonjs/Culling/ray";
  30419. /**
  30420. * This is the base class of all the camera used in the application.
  30421. * @see https://doc.babylonjs.com/features/cameras
  30422. */
  30423. export class Camera extends Node {
  30424. /** @hidden */
  30425. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30426. /**
  30427. * This is the default projection mode used by the cameras.
  30428. * It helps recreating a feeling of perspective and better appreciate depth.
  30429. * This is the best way to simulate real life cameras.
  30430. */
  30431. static readonly PERSPECTIVE_CAMERA: number;
  30432. /**
  30433. * This helps creating camera with an orthographic mode.
  30434. * 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.
  30435. */
  30436. static readonly ORTHOGRAPHIC_CAMERA: number;
  30437. /**
  30438. * This is the default FOV mode for perspective cameras.
  30439. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30440. */
  30441. static readonly FOVMODE_VERTICAL_FIXED: number;
  30442. /**
  30443. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30444. */
  30445. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30446. /**
  30447. * This specifies ther is no need for a camera rig.
  30448. * Basically only one eye is rendered corresponding to the camera.
  30449. */
  30450. static readonly RIG_MODE_NONE: number;
  30451. /**
  30452. * Simulates a camera Rig with one blue eye and one red eye.
  30453. * This can be use with 3d blue and red glasses.
  30454. */
  30455. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30456. /**
  30457. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30458. */
  30459. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30460. /**
  30461. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30462. */
  30463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30464. /**
  30465. * Defines that both eyes of the camera will be rendered over under each other.
  30466. */
  30467. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30468. /**
  30469. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30470. */
  30471. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30472. /**
  30473. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30474. */
  30475. static readonly RIG_MODE_VR: number;
  30476. /**
  30477. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30478. */
  30479. static readonly RIG_MODE_WEBVR: number;
  30480. /**
  30481. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30482. */
  30483. static readonly RIG_MODE_CUSTOM: number;
  30484. /**
  30485. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30486. */
  30487. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30488. /**
  30489. * Define the input manager associated with the camera.
  30490. */
  30491. inputs: CameraInputsManager<Camera>;
  30492. /** @hidden */
  30493. _position: Vector3;
  30494. /**
  30495. * Define the current local position of the camera in the scene
  30496. */
  30497. get position(): Vector3;
  30498. set position(newPosition: Vector3);
  30499. protected _upVector: Vector3;
  30500. /**
  30501. * The vector the camera should consider as up.
  30502. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30503. */
  30504. set upVector(vec: Vector3);
  30505. get upVector(): Vector3;
  30506. /**
  30507. * Define the current limit on the left side for an orthographic camera
  30508. * In scene unit
  30509. */
  30510. orthoLeft: Nullable<number>;
  30511. /**
  30512. * Define the current limit on the right side for an orthographic camera
  30513. * In scene unit
  30514. */
  30515. orthoRight: Nullable<number>;
  30516. /**
  30517. * Define the current limit on the bottom side for an orthographic camera
  30518. * In scene unit
  30519. */
  30520. orthoBottom: Nullable<number>;
  30521. /**
  30522. * Define the current limit on the top side for an orthographic camera
  30523. * In scene unit
  30524. */
  30525. orthoTop: Nullable<number>;
  30526. /**
  30527. * Field Of View is set in Radians. (default is 0.8)
  30528. */
  30529. fov: number;
  30530. /**
  30531. * Define the minimum distance the camera can see from.
  30532. * This is important to note that the depth buffer are not infinite and the closer it starts
  30533. * the more your scene might encounter depth fighting issue.
  30534. */
  30535. minZ: number;
  30536. /**
  30537. * Define the maximum distance the camera can see to.
  30538. * This is important to note that the depth buffer are not infinite and the further it end
  30539. * the more your scene might encounter depth fighting issue.
  30540. */
  30541. maxZ: number;
  30542. /**
  30543. * Define the default inertia of the camera.
  30544. * This helps giving a smooth feeling to the camera movement.
  30545. */
  30546. inertia: number;
  30547. /**
  30548. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30549. */
  30550. mode: number;
  30551. /**
  30552. * Define whether the camera is intermediate.
  30553. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30554. */
  30555. isIntermediate: boolean;
  30556. /**
  30557. * Define the viewport of the camera.
  30558. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30559. */
  30560. viewport: Viewport;
  30561. /**
  30562. * Restricts the camera to viewing objects with the same layerMask.
  30563. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30564. */
  30565. layerMask: number;
  30566. /**
  30567. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30568. */
  30569. fovMode: number;
  30570. /**
  30571. * Rig mode of the camera.
  30572. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30573. * This is normally controlled byt the camera themselves as internal use.
  30574. */
  30575. cameraRigMode: number;
  30576. /**
  30577. * Defines the distance between both "eyes" in case of a RIG
  30578. */
  30579. interaxialDistance: number;
  30580. /**
  30581. * Defines if stereoscopic rendering is done side by side or over under.
  30582. */
  30583. isStereoscopicSideBySide: boolean;
  30584. /**
  30585. * 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
  30586. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30587. * else in the scene. (Eg. security camera)
  30588. *
  30589. * 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)
  30590. */
  30591. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30592. /**
  30593. * When set, the camera will render to this render target instead of the default canvas
  30594. *
  30595. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30596. */
  30597. outputRenderTarget: Nullable<RenderTargetTexture>;
  30598. /**
  30599. * Observable triggered when the camera view matrix has changed.
  30600. */
  30601. onViewMatrixChangedObservable: Observable<Camera>;
  30602. /**
  30603. * Observable triggered when the camera Projection matrix has changed.
  30604. */
  30605. onProjectionMatrixChangedObservable: Observable<Camera>;
  30606. /**
  30607. * Observable triggered when the inputs have been processed.
  30608. */
  30609. onAfterCheckInputsObservable: Observable<Camera>;
  30610. /**
  30611. * Observable triggered when reset has been called and applied to the camera.
  30612. */
  30613. onRestoreStateObservable: Observable<Camera>;
  30614. /**
  30615. * Is this camera a part of a rig system?
  30616. */
  30617. isRigCamera: boolean;
  30618. /**
  30619. * If isRigCamera set to true this will be set with the parent camera.
  30620. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30621. */
  30622. rigParent?: Camera;
  30623. /** @hidden */
  30624. _cameraRigParams: any;
  30625. /** @hidden */
  30626. _rigCameras: Camera[];
  30627. /** @hidden */
  30628. _rigPostProcess: Nullable<PostProcess>;
  30629. protected _webvrViewMatrix: Matrix;
  30630. /** @hidden */
  30631. _skipRendering: boolean;
  30632. /** @hidden */
  30633. _projectionMatrix: Matrix;
  30634. /** @hidden */
  30635. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30636. /** @hidden */
  30637. _activeMeshes: SmartArray<AbstractMesh>;
  30638. protected _globalPosition: Vector3;
  30639. /** @hidden */
  30640. _computedViewMatrix: Matrix;
  30641. private _doNotComputeProjectionMatrix;
  30642. private _transformMatrix;
  30643. private _frustumPlanes;
  30644. private _refreshFrustumPlanes;
  30645. private _storedFov;
  30646. private _stateStored;
  30647. /**
  30648. * Instantiates a new camera object.
  30649. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30650. * @see https://doc.babylonjs.com/features/cameras
  30651. * @param name Defines the name of the camera in the scene
  30652. * @param position Defines the position of the camera
  30653. * @param scene Defines the scene the camera belongs too
  30654. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30655. */
  30656. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30657. /**
  30658. * Store current camera state (fov, position, etc..)
  30659. * @returns the camera
  30660. */
  30661. storeState(): Camera;
  30662. /**
  30663. * Restores the camera state values if it has been stored. You must call storeState() first
  30664. */
  30665. protected _restoreStateValues(): boolean;
  30666. /**
  30667. * Restored camera state. You must call storeState() first.
  30668. * @returns true if restored and false otherwise
  30669. */
  30670. restoreState(): boolean;
  30671. /**
  30672. * Gets the class name of the camera.
  30673. * @returns the class name
  30674. */
  30675. getClassName(): string;
  30676. /** @hidden */
  30677. readonly _isCamera: boolean;
  30678. /**
  30679. * Gets a string representation of the camera useful for debug purpose.
  30680. * @param fullDetails Defines that a more verboe level of logging is required
  30681. * @returns the string representation
  30682. */
  30683. toString(fullDetails?: boolean): string;
  30684. /**
  30685. * Gets the current world space position of the camera.
  30686. */
  30687. get globalPosition(): Vector3;
  30688. /**
  30689. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30690. * @returns the active meshe list
  30691. */
  30692. getActiveMeshes(): SmartArray<AbstractMesh>;
  30693. /**
  30694. * Check whether a mesh is part of the current active mesh list of the camera
  30695. * @param mesh Defines the mesh to check
  30696. * @returns true if active, false otherwise
  30697. */
  30698. isActiveMesh(mesh: Mesh): boolean;
  30699. /**
  30700. * Is this camera ready to be used/rendered
  30701. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30702. * @return true if the camera is ready
  30703. */
  30704. isReady(completeCheck?: boolean): boolean;
  30705. /** @hidden */
  30706. _initCache(): void;
  30707. /** @hidden */
  30708. _updateCache(ignoreParentClass?: boolean): void;
  30709. /** @hidden */
  30710. _isSynchronized(): boolean;
  30711. /** @hidden */
  30712. _isSynchronizedViewMatrix(): boolean;
  30713. /** @hidden */
  30714. _isSynchronizedProjectionMatrix(): boolean;
  30715. /**
  30716. * Attach the input controls to a specific dom element to get the input from.
  30717. * @param element Defines the element the controls should be listened from
  30718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30719. */
  30720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30721. /**
  30722. * Detach the current controls from the specified dom element.
  30723. * @param element Defines the element to stop listening the inputs from
  30724. */
  30725. detachControl(element: HTMLElement): void;
  30726. /**
  30727. * Update the camera state according to the different inputs gathered during the frame.
  30728. */
  30729. update(): void;
  30730. /** @hidden */
  30731. _checkInputs(): void;
  30732. /** @hidden */
  30733. get rigCameras(): Camera[];
  30734. /**
  30735. * Gets the post process used by the rig cameras
  30736. */
  30737. get rigPostProcess(): Nullable<PostProcess>;
  30738. /**
  30739. * Internal, gets the first post proces.
  30740. * @returns the first post process to be run on this camera.
  30741. */
  30742. _getFirstPostProcess(): Nullable<PostProcess>;
  30743. private _cascadePostProcessesToRigCams;
  30744. /**
  30745. * Attach a post process to the camera.
  30746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30747. * @param postProcess The post process to attach to the camera
  30748. * @param insertAt The position of the post process in case several of them are in use in the scene
  30749. * @returns the position the post process has been inserted at
  30750. */
  30751. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30752. /**
  30753. * Detach a post process to the camera.
  30754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30755. * @param postProcess The post process to detach from the camera
  30756. */
  30757. detachPostProcess(postProcess: PostProcess): void;
  30758. /**
  30759. * Gets the current world matrix of the camera
  30760. */
  30761. getWorldMatrix(): Matrix;
  30762. /** @hidden */
  30763. _getViewMatrix(): Matrix;
  30764. /**
  30765. * Gets the current view matrix of the camera.
  30766. * @param force forces the camera to recompute the matrix without looking at the cached state
  30767. * @returns the view matrix
  30768. */
  30769. getViewMatrix(force?: boolean): Matrix;
  30770. /**
  30771. * Freeze the projection matrix.
  30772. * It will prevent the cache check of the camera projection compute and can speed up perf
  30773. * if no parameter of the camera are meant to change
  30774. * @param projection Defines manually a projection if necessary
  30775. */
  30776. freezeProjectionMatrix(projection?: Matrix): void;
  30777. /**
  30778. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30779. */
  30780. unfreezeProjectionMatrix(): void;
  30781. /**
  30782. * Gets the current projection matrix of the camera.
  30783. * @param force forces the camera to recompute the matrix without looking at the cached state
  30784. * @returns the projection matrix
  30785. */
  30786. getProjectionMatrix(force?: boolean): Matrix;
  30787. /**
  30788. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30789. * @returns a Matrix
  30790. */
  30791. getTransformationMatrix(): Matrix;
  30792. private _updateFrustumPlanes;
  30793. /**
  30794. * Checks if a cullable object (mesh...) is in the camera frustum
  30795. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30796. * @param target The object to check
  30797. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30798. * @returns true if the object is in frustum otherwise false
  30799. */
  30800. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30801. /**
  30802. * Checks if a cullable object (mesh...) is in the camera frustum
  30803. * Unlike isInFrustum this cheks the full bounding box
  30804. * @param target The object to check
  30805. * @returns true if the object is in frustum otherwise false
  30806. */
  30807. isCompletelyInFrustum(target: ICullable): boolean;
  30808. /**
  30809. * Gets a ray in the forward direction from the camera.
  30810. * @param length Defines the length of the ray to create
  30811. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30812. * @param origin Defines the start point of the ray which defaults to the camera position
  30813. * @returns the forward ray
  30814. */
  30815. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30816. /**
  30817. * Gets a ray in the forward direction from the camera.
  30818. * @param refRay the ray to (re)use when setting the values
  30819. * @param length Defines the length of the ray to create
  30820. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30821. * @param origin Defines the start point of the ray which defaults to the camera position
  30822. * @returns the forward ray
  30823. */
  30824. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30825. /**
  30826. * Releases resources associated with this node.
  30827. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30828. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30829. */
  30830. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30831. /** @hidden */
  30832. _isLeftCamera: boolean;
  30833. /**
  30834. * Gets the left camera of a rig setup in case of Rigged Camera
  30835. */
  30836. get isLeftCamera(): boolean;
  30837. /** @hidden */
  30838. _isRightCamera: boolean;
  30839. /**
  30840. * Gets the right camera of a rig setup in case of Rigged Camera
  30841. */
  30842. get isRightCamera(): boolean;
  30843. /**
  30844. * Gets the left camera of a rig setup in case of Rigged Camera
  30845. */
  30846. get leftCamera(): Nullable<FreeCamera>;
  30847. /**
  30848. * Gets the right camera of a rig setup in case of Rigged Camera
  30849. */
  30850. get rightCamera(): Nullable<FreeCamera>;
  30851. /**
  30852. * Gets the left camera target of a rig setup in case of Rigged Camera
  30853. * @returns the target position
  30854. */
  30855. getLeftTarget(): Nullable<Vector3>;
  30856. /**
  30857. * Gets the right camera target of a rig setup in case of Rigged Camera
  30858. * @returns the target position
  30859. */
  30860. getRightTarget(): Nullable<Vector3>;
  30861. /**
  30862. * @hidden
  30863. */
  30864. setCameraRigMode(mode: number, rigParams: any): void;
  30865. /** @hidden */
  30866. static _setStereoscopicRigMode(camera: Camera): void;
  30867. /** @hidden */
  30868. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30869. /** @hidden */
  30870. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30871. /** @hidden */
  30872. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30873. /** @hidden */
  30874. _getVRProjectionMatrix(): Matrix;
  30875. protected _updateCameraRotationMatrix(): void;
  30876. protected _updateWebVRCameraRotationMatrix(): void;
  30877. /**
  30878. * This function MUST be overwritten by the different WebVR cameras available.
  30879. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30880. * @hidden
  30881. */
  30882. _getWebVRProjectionMatrix(): Matrix;
  30883. /**
  30884. * This function MUST be overwritten by the different WebVR cameras available.
  30885. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30886. * @hidden
  30887. */
  30888. _getWebVRViewMatrix(): Matrix;
  30889. /** @hidden */
  30890. setCameraRigParameter(name: string, value: any): void;
  30891. /**
  30892. * needs to be overridden by children so sub has required properties to be copied
  30893. * @hidden
  30894. */
  30895. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30896. /**
  30897. * May need to be overridden by children
  30898. * @hidden
  30899. */
  30900. _updateRigCameras(): void;
  30901. /** @hidden */
  30902. _setupInputs(): void;
  30903. /**
  30904. * Serialiaze the camera setup to a json represention
  30905. * @returns the JSON representation
  30906. */
  30907. serialize(): any;
  30908. /**
  30909. * Clones the current camera.
  30910. * @param name The cloned camera name
  30911. * @returns the cloned camera
  30912. */
  30913. clone(name: string): Camera;
  30914. /**
  30915. * Gets the direction of the camera relative to a given local axis.
  30916. * @param localAxis Defines the reference axis to provide a relative direction.
  30917. * @return the direction
  30918. */
  30919. getDirection(localAxis: Vector3): Vector3;
  30920. /**
  30921. * Returns the current camera absolute rotation
  30922. */
  30923. get absoluteRotation(): Quaternion;
  30924. /**
  30925. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30926. * @param localAxis Defines the reference axis to provide a relative direction.
  30927. * @param result Defines the vector to store the result in
  30928. */
  30929. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30930. /**
  30931. * Gets a camera constructor for a given camera type
  30932. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30933. * @param name The name of the camera the result will be able to instantiate
  30934. * @param scene The scene the result will construct the camera in
  30935. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30936. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30937. * @returns a factory method to construc the camera
  30938. */
  30939. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30940. /**
  30941. * Compute the world matrix of the camera.
  30942. * @returns the camera world matrix
  30943. */
  30944. computeWorldMatrix(): Matrix;
  30945. /**
  30946. * Parse a JSON and creates the camera from the parsed information
  30947. * @param parsedCamera The JSON to parse
  30948. * @param scene The scene to instantiate the camera in
  30949. * @returns the newly constructed camera
  30950. */
  30951. static Parse(parsedCamera: any, scene: Scene): Camera;
  30952. }
  30953. }
  30954. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30955. import { Nullable } from "babylonjs/types";
  30956. import { Scene } from "babylonjs/scene";
  30957. import { Vector4 } from "babylonjs/Maths/math.vector";
  30958. import { Mesh } from "babylonjs/Meshes/mesh";
  30959. /**
  30960. * Class containing static functions to help procedurally build meshes
  30961. */
  30962. export class DiscBuilder {
  30963. /**
  30964. * Creates a plane polygonal mesh. By default, this is a disc
  30965. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30966. * * 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
  30967. * * 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
  30968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30971. * @param name defines the name of the mesh
  30972. * @param options defines the options used to create the mesh
  30973. * @param scene defines the hosting scene
  30974. * @returns the plane polygonal mesh
  30975. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30976. */
  30977. static CreateDisc(name: string, options: {
  30978. radius?: number;
  30979. tessellation?: number;
  30980. arc?: number;
  30981. updatable?: boolean;
  30982. sideOrientation?: number;
  30983. frontUVs?: Vector4;
  30984. backUVs?: Vector4;
  30985. }, scene?: Nullable<Scene>): Mesh;
  30986. }
  30987. }
  30988. declare module "babylonjs/Materials/fresnelParameters" {
  30989. import { DeepImmutable } from "babylonjs/types";
  30990. import { Color3 } from "babylonjs/Maths/math.color";
  30991. /**
  30992. * Options to be used when creating a FresnelParameters.
  30993. */
  30994. export type IFresnelParametersCreationOptions = {
  30995. /**
  30996. * Define the color used on edges (grazing angle)
  30997. */
  30998. leftColor?: Color3;
  30999. /**
  31000. * Define the color used on center
  31001. */
  31002. rightColor?: Color3;
  31003. /**
  31004. * Define bias applied to computed fresnel term
  31005. */
  31006. bias?: number;
  31007. /**
  31008. * Defined the power exponent applied to fresnel term
  31009. */
  31010. power?: number;
  31011. /**
  31012. * Define if the fresnel effect is enable or not.
  31013. */
  31014. isEnabled?: boolean;
  31015. };
  31016. /**
  31017. * Serialized format for FresnelParameters.
  31018. */
  31019. export type IFresnelParametersSerialized = {
  31020. /**
  31021. * Define the color used on edges (grazing angle) [as an array]
  31022. */
  31023. leftColor: number[];
  31024. /**
  31025. * Define the color used on center [as an array]
  31026. */
  31027. rightColor: number[];
  31028. /**
  31029. * Define bias applied to computed fresnel term
  31030. */
  31031. bias: number;
  31032. /**
  31033. * Defined the power exponent applied to fresnel term
  31034. */
  31035. power?: number;
  31036. /**
  31037. * Define if the fresnel effect is enable or not.
  31038. */
  31039. isEnabled: boolean;
  31040. };
  31041. /**
  31042. * This represents all the required information to add a fresnel effect on a material:
  31043. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31044. */
  31045. export class FresnelParameters {
  31046. private _isEnabled;
  31047. /**
  31048. * Define if the fresnel effect is enable or not.
  31049. */
  31050. get isEnabled(): boolean;
  31051. set isEnabled(value: boolean);
  31052. /**
  31053. * Define the color used on edges (grazing angle)
  31054. */
  31055. leftColor: Color3;
  31056. /**
  31057. * Define the color used on center
  31058. */
  31059. rightColor: Color3;
  31060. /**
  31061. * Define bias applied to computed fresnel term
  31062. */
  31063. bias: number;
  31064. /**
  31065. * Defined the power exponent applied to fresnel term
  31066. */
  31067. power: number;
  31068. /**
  31069. * Creates a new FresnelParameters object.
  31070. *
  31071. * @param options provide your own settings to optionally to override defaults
  31072. */
  31073. constructor(options?: IFresnelParametersCreationOptions);
  31074. /**
  31075. * Clones the current fresnel and its valuues
  31076. * @returns a clone fresnel configuration
  31077. */
  31078. clone(): FresnelParameters;
  31079. /**
  31080. * Determines equality between FresnelParameters objects
  31081. * @param otherFresnelParameters defines the second operand
  31082. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31083. */
  31084. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31085. /**
  31086. * Serializes the current fresnel parameters to a JSON representation.
  31087. * @return the JSON serialization
  31088. */
  31089. serialize(): IFresnelParametersSerialized;
  31090. /**
  31091. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31092. * @param parsedFresnelParameters Define the JSON representation
  31093. * @returns the parsed parameters
  31094. */
  31095. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31096. }
  31097. }
  31098. declare module "babylonjs/Materials/materialFlags" {
  31099. /**
  31100. * This groups all the flags used to control the materials channel.
  31101. */
  31102. export class MaterialFlags {
  31103. private static _DiffuseTextureEnabled;
  31104. /**
  31105. * Are diffuse textures enabled in the application.
  31106. */
  31107. static get DiffuseTextureEnabled(): boolean;
  31108. static set DiffuseTextureEnabled(value: boolean);
  31109. private static _DetailTextureEnabled;
  31110. /**
  31111. * Are detail textures enabled in the application.
  31112. */
  31113. static get DetailTextureEnabled(): boolean;
  31114. static set DetailTextureEnabled(value: boolean);
  31115. private static _AmbientTextureEnabled;
  31116. /**
  31117. * Are ambient textures enabled in the application.
  31118. */
  31119. static get AmbientTextureEnabled(): boolean;
  31120. static set AmbientTextureEnabled(value: boolean);
  31121. private static _OpacityTextureEnabled;
  31122. /**
  31123. * Are opacity textures enabled in the application.
  31124. */
  31125. static get OpacityTextureEnabled(): boolean;
  31126. static set OpacityTextureEnabled(value: boolean);
  31127. private static _ReflectionTextureEnabled;
  31128. /**
  31129. * Are reflection textures enabled in the application.
  31130. */
  31131. static get ReflectionTextureEnabled(): boolean;
  31132. static set ReflectionTextureEnabled(value: boolean);
  31133. private static _EmissiveTextureEnabled;
  31134. /**
  31135. * Are emissive textures enabled in the application.
  31136. */
  31137. static get EmissiveTextureEnabled(): boolean;
  31138. static set EmissiveTextureEnabled(value: boolean);
  31139. private static _SpecularTextureEnabled;
  31140. /**
  31141. * Are specular textures enabled in the application.
  31142. */
  31143. static get SpecularTextureEnabled(): boolean;
  31144. static set SpecularTextureEnabled(value: boolean);
  31145. private static _BumpTextureEnabled;
  31146. /**
  31147. * Are bump textures enabled in the application.
  31148. */
  31149. static get BumpTextureEnabled(): boolean;
  31150. static set BumpTextureEnabled(value: boolean);
  31151. private static _LightmapTextureEnabled;
  31152. /**
  31153. * Are lightmap textures enabled in the application.
  31154. */
  31155. static get LightmapTextureEnabled(): boolean;
  31156. static set LightmapTextureEnabled(value: boolean);
  31157. private static _RefractionTextureEnabled;
  31158. /**
  31159. * Are refraction textures enabled in the application.
  31160. */
  31161. static get RefractionTextureEnabled(): boolean;
  31162. static set RefractionTextureEnabled(value: boolean);
  31163. private static _ColorGradingTextureEnabled;
  31164. /**
  31165. * Are color grading textures enabled in the application.
  31166. */
  31167. static get ColorGradingTextureEnabled(): boolean;
  31168. static set ColorGradingTextureEnabled(value: boolean);
  31169. private static _FresnelEnabled;
  31170. /**
  31171. * Are fresnels enabled in the application.
  31172. */
  31173. static get FresnelEnabled(): boolean;
  31174. static set FresnelEnabled(value: boolean);
  31175. private static _ClearCoatTextureEnabled;
  31176. /**
  31177. * Are clear coat textures enabled in the application.
  31178. */
  31179. static get ClearCoatTextureEnabled(): boolean;
  31180. static set ClearCoatTextureEnabled(value: boolean);
  31181. private static _ClearCoatBumpTextureEnabled;
  31182. /**
  31183. * Are clear coat bump textures enabled in the application.
  31184. */
  31185. static get ClearCoatBumpTextureEnabled(): boolean;
  31186. static set ClearCoatBumpTextureEnabled(value: boolean);
  31187. private static _ClearCoatTintTextureEnabled;
  31188. /**
  31189. * Are clear coat tint textures enabled in the application.
  31190. */
  31191. static get ClearCoatTintTextureEnabled(): boolean;
  31192. static set ClearCoatTintTextureEnabled(value: boolean);
  31193. private static _SheenTextureEnabled;
  31194. /**
  31195. * Are sheen textures enabled in the application.
  31196. */
  31197. static get SheenTextureEnabled(): boolean;
  31198. static set SheenTextureEnabled(value: boolean);
  31199. private static _AnisotropicTextureEnabled;
  31200. /**
  31201. * Are anisotropic textures enabled in the application.
  31202. */
  31203. static get AnisotropicTextureEnabled(): boolean;
  31204. static set AnisotropicTextureEnabled(value: boolean);
  31205. private static _ThicknessTextureEnabled;
  31206. /**
  31207. * Are thickness textures enabled in the application.
  31208. */
  31209. static get ThicknessTextureEnabled(): boolean;
  31210. static set ThicknessTextureEnabled(value: boolean);
  31211. }
  31212. }
  31213. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31214. /** @hidden */
  31215. export var defaultFragmentDeclaration: {
  31216. name: string;
  31217. shader: string;
  31218. };
  31219. }
  31220. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31221. /** @hidden */
  31222. export var defaultUboDeclaration: {
  31223. name: string;
  31224. shader: string;
  31225. };
  31226. }
  31227. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31228. /** @hidden */
  31229. export var prePassDeclaration: {
  31230. name: string;
  31231. shader: string;
  31232. };
  31233. }
  31234. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31235. /** @hidden */
  31236. export var lightFragmentDeclaration: {
  31237. name: string;
  31238. shader: string;
  31239. };
  31240. }
  31241. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31242. /** @hidden */
  31243. export var lightUboDeclaration: {
  31244. name: string;
  31245. shader: string;
  31246. };
  31247. }
  31248. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31249. /** @hidden */
  31250. export var lightsFragmentFunctions: {
  31251. name: string;
  31252. shader: string;
  31253. };
  31254. }
  31255. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31256. /** @hidden */
  31257. export var shadowsFragmentFunctions: {
  31258. name: string;
  31259. shader: string;
  31260. };
  31261. }
  31262. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31263. /** @hidden */
  31264. export var fresnelFunction: {
  31265. name: string;
  31266. shader: string;
  31267. };
  31268. }
  31269. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31270. /** @hidden */
  31271. export var bumpFragmentMainFunctions: {
  31272. name: string;
  31273. shader: string;
  31274. };
  31275. }
  31276. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31277. /** @hidden */
  31278. export var bumpFragmentFunctions: {
  31279. name: string;
  31280. shader: string;
  31281. };
  31282. }
  31283. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31284. /** @hidden */
  31285. export var logDepthDeclaration: {
  31286. name: string;
  31287. shader: string;
  31288. };
  31289. }
  31290. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31291. /** @hidden */
  31292. export var bumpFragment: {
  31293. name: string;
  31294. shader: string;
  31295. };
  31296. }
  31297. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31298. /** @hidden */
  31299. export var depthPrePass: {
  31300. name: string;
  31301. shader: string;
  31302. };
  31303. }
  31304. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31305. /** @hidden */
  31306. export var lightFragment: {
  31307. name: string;
  31308. shader: string;
  31309. };
  31310. }
  31311. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31312. /** @hidden */
  31313. export var logDepthFragment: {
  31314. name: string;
  31315. shader: string;
  31316. };
  31317. }
  31318. declare module "babylonjs/Shaders/default.fragment" {
  31319. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31320. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31323. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31326. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31327. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31328. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31329. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31330. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31331. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31332. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31333. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31334. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31335. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31336. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31337. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31338. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31339. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31340. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31341. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31342. /** @hidden */
  31343. export var defaultPixelShader: {
  31344. name: string;
  31345. shader: string;
  31346. };
  31347. }
  31348. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31349. /** @hidden */
  31350. export var defaultVertexDeclaration: {
  31351. name: string;
  31352. shader: string;
  31353. };
  31354. }
  31355. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31356. /** @hidden */
  31357. export var bumpVertexDeclaration: {
  31358. name: string;
  31359. shader: string;
  31360. };
  31361. }
  31362. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31363. /** @hidden */
  31364. export var bumpVertex: {
  31365. name: string;
  31366. shader: string;
  31367. };
  31368. }
  31369. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31370. /** @hidden */
  31371. export var fogVertex: {
  31372. name: string;
  31373. shader: string;
  31374. };
  31375. }
  31376. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31377. /** @hidden */
  31378. export var shadowsVertex: {
  31379. name: string;
  31380. shader: string;
  31381. };
  31382. }
  31383. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31384. /** @hidden */
  31385. export var pointCloudVertex: {
  31386. name: string;
  31387. shader: string;
  31388. };
  31389. }
  31390. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31391. /** @hidden */
  31392. export var logDepthVertex: {
  31393. name: string;
  31394. shader: string;
  31395. };
  31396. }
  31397. declare module "babylonjs/Shaders/default.vertex" {
  31398. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31399. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31400. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31401. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31402. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31404. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31405. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31412. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31413. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31414. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31415. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31416. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31417. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31418. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31419. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31420. /** @hidden */
  31421. export var defaultVertexShader: {
  31422. name: string;
  31423. shader: string;
  31424. };
  31425. }
  31426. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31427. import { Nullable } from "babylonjs/types";
  31428. import { Scene } from "babylonjs/scene";
  31429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31430. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31431. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31432. /**
  31433. * @hidden
  31434. */
  31435. export interface IMaterialDetailMapDefines {
  31436. DETAIL: boolean;
  31437. DETAILDIRECTUV: number;
  31438. DETAIL_NORMALBLENDMETHOD: number;
  31439. /** @hidden */
  31440. _areTexturesDirty: boolean;
  31441. }
  31442. /**
  31443. * Define the code related to the detail map parameters of a material
  31444. *
  31445. * Inspired from:
  31446. * 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
  31447. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31448. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31449. */
  31450. export class DetailMapConfiguration {
  31451. private _texture;
  31452. /**
  31453. * The detail texture of the material.
  31454. */
  31455. texture: Nullable<BaseTexture>;
  31456. /**
  31457. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31458. * Bigger values mean stronger blending
  31459. */
  31460. diffuseBlendLevel: number;
  31461. /**
  31462. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31463. * Bigger values mean stronger blending. Only used with PBR materials
  31464. */
  31465. roughnessBlendLevel: number;
  31466. /**
  31467. * Defines how strong the bump effect from the detail map is
  31468. * Bigger values mean stronger effect
  31469. */
  31470. bumpLevel: number;
  31471. private _normalBlendMethod;
  31472. /**
  31473. * The method used to blend the bump and detail normals together
  31474. */
  31475. normalBlendMethod: number;
  31476. private _isEnabled;
  31477. /**
  31478. * Enable or disable the detail map on this material
  31479. */
  31480. isEnabled: boolean;
  31481. /** @hidden */
  31482. private _internalMarkAllSubMeshesAsTexturesDirty;
  31483. /** @hidden */
  31484. _markAllSubMeshesAsTexturesDirty(): void;
  31485. /**
  31486. * Instantiate a new detail map
  31487. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31488. */
  31489. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31490. /**
  31491. * Gets whether the submesh is ready to be used or not.
  31492. * @param defines the list of "defines" to update.
  31493. * @param scene defines the scene the material belongs to.
  31494. * @returns - boolean indicating that the submesh is ready or not.
  31495. */
  31496. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31497. /**
  31498. * Update the defines for detail map usage
  31499. * @param defines the list of "defines" to update.
  31500. * @param scene defines the scene the material belongs to.
  31501. */
  31502. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31503. /**
  31504. * Binds the material data.
  31505. * @param uniformBuffer defines the Uniform buffer to fill in.
  31506. * @param scene defines the scene the material belongs to.
  31507. * @param isFrozen defines whether the material is frozen or not.
  31508. */
  31509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31510. /**
  31511. * Checks to see if a texture is used in the material.
  31512. * @param texture - Base texture to use.
  31513. * @returns - Boolean specifying if a texture is used in the material.
  31514. */
  31515. hasTexture(texture: BaseTexture): boolean;
  31516. /**
  31517. * Returns an array of the actively used textures.
  31518. * @param activeTextures Array of BaseTextures
  31519. */
  31520. getActiveTextures(activeTextures: BaseTexture[]): void;
  31521. /**
  31522. * Returns the animatable textures.
  31523. * @param animatables Array of animatable textures.
  31524. */
  31525. getAnimatables(animatables: IAnimatable[]): void;
  31526. /**
  31527. * Disposes the resources of the material.
  31528. * @param forceDisposeTextures - Forces the disposal of all textures.
  31529. */
  31530. dispose(forceDisposeTextures?: boolean): void;
  31531. /**
  31532. * Get the current class name useful for serialization or dynamic coding.
  31533. * @returns "DetailMap"
  31534. */
  31535. getClassName(): string;
  31536. /**
  31537. * Add the required uniforms to the current list.
  31538. * @param uniforms defines the current uniform list.
  31539. */
  31540. static AddUniforms(uniforms: string[]): void;
  31541. /**
  31542. * Add the required samplers to the current list.
  31543. * @param samplers defines the current sampler list.
  31544. */
  31545. static AddSamplers(samplers: string[]): void;
  31546. /**
  31547. * Add the required uniforms to the current buffer.
  31548. * @param uniformBuffer defines the current uniform buffer.
  31549. */
  31550. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31551. /**
  31552. * Makes a duplicate of the current instance into another one.
  31553. * @param detailMap define the instance where to copy the info
  31554. */
  31555. copyTo(detailMap: DetailMapConfiguration): void;
  31556. /**
  31557. * Serializes this detail map instance
  31558. * @returns - An object with the serialized instance.
  31559. */
  31560. serialize(): any;
  31561. /**
  31562. * Parses a detail map setting from a serialized object.
  31563. * @param source - Serialized object.
  31564. * @param scene Defines the scene we are parsing for
  31565. * @param rootUrl Defines the rootUrl to load from
  31566. */
  31567. parse(source: any, scene: Scene, rootUrl: string): void;
  31568. }
  31569. }
  31570. declare module "babylonjs/Materials/standardMaterial" {
  31571. import { SmartArray } from "babylonjs/Misc/smartArray";
  31572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31573. import { Nullable } from "babylonjs/types";
  31574. import { Scene } from "babylonjs/scene";
  31575. import { Matrix } from "babylonjs/Maths/math.vector";
  31576. import { Color3 } from "babylonjs/Maths/math.color";
  31577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31579. import { Mesh } from "babylonjs/Meshes/mesh";
  31580. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31581. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31582. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31583. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31584. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31587. import "babylonjs/Shaders/default.fragment";
  31588. import "babylonjs/Shaders/default.vertex";
  31589. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31590. /** @hidden */
  31591. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31592. MAINUV1: boolean;
  31593. MAINUV2: boolean;
  31594. DIFFUSE: boolean;
  31595. DIFFUSEDIRECTUV: number;
  31596. DETAIL: boolean;
  31597. DETAILDIRECTUV: number;
  31598. DETAIL_NORMALBLENDMETHOD: number;
  31599. AMBIENT: boolean;
  31600. AMBIENTDIRECTUV: number;
  31601. OPACITY: boolean;
  31602. OPACITYDIRECTUV: number;
  31603. OPACITYRGB: boolean;
  31604. REFLECTION: boolean;
  31605. EMISSIVE: boolean;
  31606. EMISSIVEDIRECTUV: number;
  31607. SPECULAR: boolean;
  31608. SPECULARDIRECTUV: number;
  31609. BUMP: boolean;
  31610. BUMPDIRECTUV: number;
  31611. PARALLAX: boolean;
  31612. PARALLAXOCCLUSION: boolean;
  31613. SPECULAROVERALPHA: boolean;
  31614. CLIPPLANE: boolean;
  31615. CLIPPLANE2: boolean;
  31616. CLIPPLANE3: boolean;
  31617. CLIPPLANE4: boolean;
  31618. CLIPPLANE5: boolean;
  31619. CLIPPLANE6: boolean;
  31620. ALPHATEST: boolean;
  31621. DEPTHPREPASS: boolean;
  31622. ALPHAFROMDIFFUSE: boolean;
  31623. POINTSIZE: boolean;
  31624. FOG: boolean;
  31625. SPECULARTERM: boolean;
  31626. DIFFUSEFRESNEL: boolean;
  31627. OPACITYFRESNEL: boolean;
  31628. REFLECTIONFRESNEL: boolean;
  31629. REFRACTIONFRESNEL: boolean;
  31630. EMISSIVEFRESNEL: boolean;
  31631. FRESNEL: boolean;
  31632. NORMAL: boolean;
  31633. UV1: boolean;
  31634. UV2: boolean;
  31635. VERTEXCOLOR: boolean;
  31636. VERTEXALPHA: boolean;
  31637. NUM_BONE_INFLUENCERS: number;
  31638. BonesPerMesh: number;
  31639. BONETEXTURE: boolean;
  31640. INSTANCES: boolean;
  31641. THIN_INSTANCES: boolean;
  31642. GLOSSINESS: boolean;
  31643. ROUGHNESS: boolean;
  31644. EMISSIVEASILLUMINATION: boolean;
  31645. LINKEMISSIVEWITHDIFFUSE: boolean;
  31646. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31647. LIGHTMAP: boolean;
  31648. LIGHTMAPDIRECTUV: number;
  31649. OBJECTSPACE_NORMALMAP: boolean;
  31650. USELIGHTMAPASSHADOWMAP: boolean;
  31651. REFLECTIONMAP_3D: boolean;
  31652. REFLECTIONMAP_SPHERICAL: boolean;
  31653. REFLECTIONMAP_PLANAR: boolean;
  31654. REFLECTIONMAP_CUBIC: boolean;
  31655. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31656. REFLECTIONMAP_PROJECTION: boolean;
  31657. REFLECTIONMAP_SKYBOX: boolean;
  31658. REFLECTIONMAP_EXPLICIT: boolean;
  31659. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31660. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31661. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31662. INVERTCUBICMAP: boolean;
  31663. LOGARITHMICDEPTH: boolean;
  31664. REFRACTION: boolean;
  31665. REFRACTIONMAP_3D: boolean;
  31666. REFLECTIONOVERALPHA: boolean;
  31667. TWOSIDEDLIGHTING: boolean;
  31668. SHADOWFLOAT: boolean;
  31669. MORPHTARGETS: boolean;
  31670. MORPHTARGETS_NORMAL: boolean;
  31671. MORPHTARGETS_TANGENT: boolean;
  31672. MORPHTARGETS_UV: boolean;
  31673. NUM_MORPH_INFLUENCERS: number;
  31674. NONUNIFORMSCALING: boolean;
  31675. PREMULTIPLYALPHA: boolean;
  31676. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31677. ALPHABLEND: boolean;
  31678. PREPASS: boolean;
  31679. PREPASS_IRRADIANCE: boolean;
  31680. PREPASS_IRRADIANCE_INDEX: number;
  31681. PREPASS_ALBEDO: boolean;
  31682. PREPASS_ALBEDO_INDEX: number;
  31683. PREPASS_DEPTHNORMAL: boolean;
  31684. PREPASS_DEPTHNORMAL_INDEX: number;
  31685. SCENE_MRT_COUNT: number;
  31686. RGBDLIGHTMAP: boolean;
  31687. RGBDREFLECTION: boolean;
  31688. RGBDREFRACTION: boolean;
  31689. IMAGEPROCESSING: boolean;
  31690. VIGNETTE: boolean;
  31691. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31692. VIGNETTEBLENDMODEOPAQUE: boolean;
  31693. TONEMAPPING: boolean;
  31694. TONEMAPPING_ACES: boolean;
  31695. CONTRAST: boolean;
  31696. COLORCURVES: boolean;
  31697. COLORGRADING: boolean;
  31698. COLORGRADING3D: boolean;
  31699. SAMPLER3DGREENDEPTH: boolean;
  31700. SAMPLER3DBGRMAP: boolean;
  31701. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31702. MULTIVIEW: boolean;
  31703. /**
  31704. * If the reflection texture on this material is in linear color space
  31705. * @hidden
  31706. */
  31707. IS_REFLECTION_LINEAR: boolean;
  31708. /**
  31709. * If the refraction texture on this material is in linear color space
  31710. * @hidden
  31711. */
  31712. IS_REFRACTION_LINEAR: boolean;
  31713. EXPOSURE: boolean;
  31714. constructor();
  31715. setReflectionMode(modeToEnable: string): void;
  31716. }
  31717. /**
  31718. * This is the default material used in Babylon. It is the best trade off between quality
  31719. * and performances.
  31720. * @see https://doc.babylonjs.com/babylon101/materials
  31721. */
  31722. export class StandardMaterial extends PushMaterial {
  31723. private _diffuseTexture;
  31724. /**
  31725. * The basic texture of the material as viewed under a light.
  31726. */
  31727. diffuseTexture: Nullable<BaseTexture>;
  31728. private _ambientTexture;
  31729. /**
  31730. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31731. */
  31732. ambientTexture: Nullable<BaseTexture>;
  31733. private _opacityTexture;
  31734. /**
  31735. * Define the transparency of the material from a texture.
  31736. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31737. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31738. */
  31739. opacityTexture: Nullable<BaseTexture>;
  31740. private _reflectionTexture;
  31741. /**
  31742. * Define the texture used to display the reflection.
  31743. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31744. */
  31745. reflectionTexture: Nullable<BaseTexture>;
  31746. private _emissiveTexture;
  31747. /**
  31748. * Define texture of the material as if self lit.
  31749. * This will be mixed in the final result even in the absence of light.
  31750. */
  31751. emissiveTexture: Nullable<BaseTexture>;
  31752. private _specularTexture;
  31753. /**
  31754. * Define how the color and intensity of the highlight given by the light in the material.
  31755. */
  31756. specularTexture: Nullable<BaseTexture>;
  31757. private _bumpTexture;
  31758. /**
  31759. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31760. * 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.
  31761. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31762. */
  31763. bumpTexture: Nullable<BaseTexture>;
  31764. private _lightmapTexture;
  31765. /**
  31766. * Complex lighting can be computationally expensive to compute at runtime.
  31767. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31768. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31769. */
  31770. lightmapTexture: Nullable<BaseTexture>;
  31771. private _refractionTexture;
  31772. /**
  31773. * Define the texture used to display the refraction.
  31774. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31775. */
  31776. refractionTexture: Nullable<BaseTexture>;
  31777. /**
  31778. * The color of the material lit by the environmental background lighting.
  31779. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31780. */
  31781. ambientColor: Color3;
  31782. /**
  31783. * The basic color of the material as viewed under a light.
  31784. */
  31785. diffuseColor: Color3;
  31786. /**
  31787. * Define how the color and intensity of the highlight given by the light in the material.
  31788. */
  31789. specularColor: Color3;
  31790. /**
  31791. * Define the color of the material as if self lit.
  31792. * This will be mixed in the final result even in the absence of light.
  31793. */
  31794. emissiveColor: Color3;
  31795. /**
  31796. * Defines how sharp are the highlights in the material.
  31797. * The bigger the value the sharper giving a more glossy feeling to the result.
  31798. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31799. */
  31800. specularPower: number;
  31801. private _useAlphaFromDiffuseTexture;
  31802. /**
  31803. * Does the transparency come from the diffuse texture alpha channel.
  31804. */
  31805. useAlphaFromDiffuseTexture: boolean;
  31806. private _useEmissiveAsIllumination;
  31807. /**
  31808. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31809. */
  31810. useEmissiveAsIllumination: boolean;
  31811. private _linkEmissiveWithDiffuse;
  31812. /**
  31813. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31814. * the emissive level when the final color is close to one.
  31815. */
  31816. linkEmissiveWithDiffuse: boolean;
  31817. private _useSpecularOverAlpha;
  31818. /**
  31819. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31820. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31821. */
  31822. useSpecularOverAlpha: boolean;
  31823. private _useReflectionOverAlpha;
  31824. /**
  31825. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31826. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31827. */
  31828. useReflectionOverAlpha: boolean;
  31829. private _disableLighting;
  31830. /**
  31831. * Does lights from the scene impacts this material.
  31832. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31833. */
  31834. disableLighting: boolean;
  31835. private _useObjectSpaceNormalMap;
  31836. /**
  31837. * Allows using an object space normal map (instead of tangent space).
  31838. */
  31839. useObjectSpaceNormalMap: boolean;
  31840. private _useParallax;
  31841. /**
  31842. * Is parallax enabled or not.
  31843. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31844. */
  31845. useParallax: boolean;
  31846. private _useParallaxOcclusion;
  31847. /**
  31848. * Is parallax occlusion enabled or not.
  31849. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31850. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31851. */
  31852. useParallaxOcclusion: boolean;
  31853. /**
  31854. * 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.
  31855. */
  31856. parallaxScaleBias: number;
  31857. private _roughness;
  31858. /**
  31859. * Helps to define how blurry the reflections should appears in the material.
  31860. */
  31861. roughness: number;
  31862. /**
  31863. * In case of refraction, define the value of the index of refraction.
  31864. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31865. */
  31866. indexOfRefraction: number;
  31867. /**
  31868. * Invert the refraction texture alongside the y axis.
  31869. * It can be useful with procedural textures or probe for instance.
  31870. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31871. */
  31872. invertRefractionY: boolean;
  31873. /**
  31874. * Defines the alpha limits in alpha test mode.
  31875. */
  31876. alphaCutOff: number;
  31877. private _useLightmapAsShadowmap;
  31878. /**
  31879. * In case of light mapping, define whether the map contains light or shadow informations.
  31880. */
  31881. useLightmapAsShadowmap: boolean;
  31882. private _diffuseFresnelParameters;
  31883. /**
  31884. * Define the diffuse fresnel parameters of the material.
  31885. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31886. */
  31887. diffuseFresnelParameters: FresnelParameters;
  31888. private _opacityFresnelParameters;
  31889. /**
  31890. * Define the opacity fresnel parameters of the material.
  31891. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31892. */
  31893. opacityFresnelParameters: FresnelParameters;
  31894. private _reflectionFresnelParameters;
  31895. /**
  31896. * Define the reflection fresnel parameters of the material.
  31897. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31898. */
  31899. reflectionFresnelParameters: FresnelParameters;
  31900. private _refractionFresnelParameters;
  31901. /**
  31902. * Define the refraction fresnel parameters of the material.
  31903. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31904. */
  31905. refractionFresnelParameters: FresnelParameters;
  31906. private _emissiveFresnelParameters;
  31907. /**
  31908. * Define the emissive fresnel parameters of the material.
  31909. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31910. */
  31911. emissiveFresnelParameters: FresnelParameters;
  31912. private _useReflectionFresnelFromSpecular;
  31913. /**
  31914. * If true automatically deducts the fresnels values from the material specularity.
  31915. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31916. */
  31917. useReflectionFresnelFromSpecular: boolean;
  31918. private _useGlossinessFromSpecularMapAlpha;
  31919. /**
  31920. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31921. */
  31922. useGlossinessFromSpecularMapAlpha: boolean;
  31923. private _maxSimultaneousLights;
  31924. /**
  31925. * Defines the maximum number of lights that can be used in the material
  31926. */
  31927. maxSimultaneousLights: number;
  31928. private _invertNormalMapX;
  31929. /**
  31930. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31931. */
  31932. invertNormalMapX: boolean;
  31933. private _invertNormalMapY;
  31934. /**
  31935. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31936. */
  31937. invertNormalMapY: boolean;
  31938. private _twoSidedLighting;
  31939. /**
  31940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31941. */
  31942. twoSidedLighting: boolean;
  31943. /**
  31944. * Default configuration related to image processing available in the standard Material.
  31945. */
  31946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31947. /**
  31948. * Gets the image processing configuration used either in this material.
  31949. */
  31950. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31951. /**
  31952. * Sets the Default image processing configuration used either in the this material.
  31953. *
  31954. * If sets to null, the scene one is in use.
  31955. */
  31956. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31957. /**
  31958. * Keep track of the image processing observer to allow dispose and replace.
  31959. */
  31960. private _imageProcessingObserver;
  31961. /**
  31962. * Attaches a new image processing configuration to the Standard Material.
  31963. * @param configuration
  31964. */
  31965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31966. /**
  31967. * Gets wether the color curves effect is enabled.
  31968. */
  31969. get cameraColorCurvesEnabled(): boolean;
  31970. /**
  31971. * Sets wether the color curves effect is enabled.
  31972. */
  31973. set cameraColorCurvesEnabled(value: boolean);
  31974. /**
  31975. * Gets wether the color grading effect is enabled.
  31976. */
  31977. get cameraColorGradingEnabled(): boolean;
  31978. /**
  31979. * Gets wether the color grading effect is enabled.
  31980. */
  31981. set cameraColorGradingEnabled(value: boolean);
  31982. /**
  31983. * Gets wether tonemapping is enabled or not.
  31984. */
  31985. get cameraToneMappingEnabled(): boolean;
  31986. /**
  31987. * Sets wether tonemapping is enabled or not
  31988. */
  31989. set cameraToneMappingEnabled(value: boolean);
  31990. /**
  31991. * The camera exposure used on this material.
  31992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31993. * This corresponds to a photographic exposure.
  31994. */
  31995. get cameraExposure(): number;
  31996. /**
  31997. * The camera exposure used on this material.
  31998. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31999. * This corresponds to a photographic exposure.
  32000. */
  32001. set cameraExposure(value: number);
  32002. /**
  32003. * Gets The camera contrast used on this material.
  32004. */
  32005. get cameraContrast(): number;
  32006. /**
  32007. * Sets The camera contrast used on this material.
  32008. */
  32009. set cameraContrast(value: number);
  32010. /**
  32011. * Gets the Color Grading 2D Lookup Texture.
  32012. */
  32013. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32014. /**
  32015. * Sets the Color Grading 2D Lookup Texture.
  32016. */
  32017. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32018. /**
  32019. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32020. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32021. * 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;
  32022. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32023. */
  32024. get cameraColorCurves(): Nullable<ColorCurves>;
  32025. /**
  32026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32028. * 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;
  32029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32030. */
  32031. set cameraColorCurves(value: Nullable<ColorCurves>);
  32032. /**
  32033. * Can this material render to several textures at once
  32034. */
  32035. get canRenderToMRT(): boolean;
  32036. /**
  32037. * Defines the detail map parameters for the material.
  32038. */
  32039. readonly detailMap: DetailMapConfiguration;
  32040. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32041. protected _worldViewProjectionMatrix: Matrix;
  32042. protected _globalAmbientColor: Color3;
  32043. protected _useLogarithmicDepth: boolean;
  32044. protected _rebuildInParallel: boolean;
  32045. /**
  32046. * Instantiates a new standard material.
  32047. * This is the default material used in Babylon. It is the best trade off between quality
  32048. * and performances.
  32049. * @see https://doc.babylonjs.com/babylon101/materials
  32050. * @param name Define the name of the material in the scene
  32051. * @param scene Define the scene the material belong to
  32052. */
  32053. constructor(name: string, scene: Scene);
  32054. /**
  32055. * Gets a boolean indicating that current material needs to register RTT
  32056. */
  32057. get hasRenderTargetTextures(): boolean;
  32058. /**
  32059. * Gets the current class name of the material e.g. "StandardMaterial"
  32060. * Mainly use in serialization.
  32061. * @returns the class name
  32062. */
  32063. getClassName(): string;
  32064. /**
  32065. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32066. * You can try switching to logarithmic depth.
  32067. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32068. */
  32069. get useLogarithmicDepth(): boolean;
  32070. set useLogarithmicDepth(value: boolean);
  32071. /**
  32072. * Specifies if the material will require alpha blending
  32073. * @returns a boolean specifying if alpha blending is needed
  32074. */
  32075. needAlphaBlending(): boolean;
  32076. /**
  32077. * Specifies if this material should be rendered in alpha test mode
  32078. * @returns a boolean specifying if an alpha test is needed.
  32079. */
  32080. needAlphaTesting(): boolean;
  32081. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32082. /**
  32083. * Get the texture used for alpha test purpose.
  32084. * @returns the diffuse texture in case of the standard material.
  32085. */
  32086. getAlphaTestTexture(): Nullable<BaseTexture>;
  32087. /**
  32088. * Get if the submesh is ready to be used and all its information available.
  32089. * Child classes can use it to update shaders
  32090. * @param mesh defines the mesh to check
  32091. * @param subMesh defines which submesh to check
  32092. * @param useInstances specifies that instances should be used
  32093. * @returns a boolean indicating that the submesh is ready or not
  32094. */
  32095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32096. /**
  32097. * Builds the material UBO layouts.
  32098. * Used internally during the effect preparation.
  32099. */
  32100. buildUniformLayout(): void;
  32101. /**
  32102. * Unbinds the material from the mesh
  32103. */
  32104. unbind(): void;
  32105. /**
  32106. * Binds the submesh to this material by preparing the effect and shader to draw
  32107. * @param world defines the world transformation matrix
  32108. * @param mesh defines the mesh containing the submesh
  32109. * @param subMesh defines the submesh to bind the material to
  32110. */
  32111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32112. /**
  32113. * Get the list of animatables in the material.
  32114. * @returns the list of animatables object used in the material
  32115. */
  32116. getAnimatables(): IAnimatable[];
  32117. /**
  32118. * Gets the active textures from the material
  32119. * @returns an array of textures
  32120. */
  32121. getActiveTextures(): BaseTexture[];
  32122. /**
  32123. * Specifies if the material uses a texture
  32124. * @param texture defines the texture to check against the material
  32125. * @returns a boolean specifying if the material uses the texture
  32126. */
  32127. hasTexture(texture: BaseTexture): boolean;
  32128. /**
  32129. * Disposes the material
  32130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32132. */
  32133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32134. /**
  32135. * Makes a duplicate of the material, and gives it a new name
  32136. * @param name defines the new name for the duplicated material
  32137. * @returns the cloned material
  32138. */
  32139. clone(name: string): StandardMaterial;
  32140. /**
  32141. * Serializes this material in a JSON representation
  32142. * @returns the serialized material object
  32143. */
  32144. serialize(): any;
  32145. /**
  32146. * Creates a standard material from parsed material data
  32147. * @param source defines the JSON representation of the material
  32148. * @param scene defines the hosting scene
  32149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32150. * @returns a new standard material
  32151. */
  32152. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32153. /**
  32154. * Are diffuse textures enabled in the application.
  32155. */
  32156. static get DiffuseTextureEnabled(): boolean;
  32157. static set DiffuseTextureEnabled(value: boolean);
  32158. /**
  32159. * Are detail textures enabled in the application.
  32160. */
  32161. static get DetailTextureEnabled(): boolean;
  32162. static set DetailTextureEnabled(value: boolean);
  32163. /**
  32164. * Are ambient textures enabled in the application.
  32165. */
  32166. static get AmbientTextureEnabled(): boolean;
  32167. static set AmbientTextureEnabled(value: boolean);
  32168. /**
  32169. * Are opacity textures enabled in the application.
  32170. */
  32171. static get OpacityTextureEnabled(): boolean;
  32172. static set OpacityTextureEnabled(value: boolean);
  32173. /**
  32174. * Are reflection textures enabled in the application.
  32175. */
  32176. static get ReflectionTextureEnabled(): boolean;
  32177. static set ReflectionTextureEnabled(value: boolean);
  32178. /**
  32179. * Are emissive textures enabled in the application.
  32180. */
  32181. static get EmissiveTextureEnabled(): boolean;
  32182. static set EmissiveTextureEnabled(value: boolean);
  32183. /**
  32184. * Are specular textures enabled in the application.
  32185. */
  32186. static get SpecularTextureEnabled(): boolean;
  32187. static set SpecularTextureEnabled(value: boolean);
  32188. /**
  32189. * Are bump textures enabled in the application.
  32190. */
  32191. static get BumpTextureEnabled(): boolean;
  32192. static set BumpTextureEnabled(value: boolean);
  32193. /**
  32194. * Are lightmap textures enabled in the application.
  32195. */
  32196. static get LightmapTextureEnabled(): boolean;
  32197. static set LightmapTextureEnabled(value: boolean);
  32198. /**
  32199. * Are refraction textures enabled in the application.
  32200. */
  32201. static get RefractionTextureEnabled(): boolean;
  32202. static set RefractionTextureEnabled(value: boolean);
  32203. /**
  32204. * Are color grading textures enabled in the application.
  32205. */
  32206. static get ColorGradingTextureEnabled(): boolean;
  32207. static set ColorGradingTextureEnabled(value: boolean);
  32208. /**
  32209. * Are fresnels enabled in the application.
  32210. */
  32211. static get FresnelEnabled(): boolean;
  32212. static set FresnelEnabled(value: boolean);
  32213. }
  32214. }
  32215. declare module "babylonjs/Particles/solidParticleSystem" {
  32216. import { Nullable } from "babylonjs/types";
  32217. import { Mesh } from "babylonjs/Meshes/mesh";
  32218. import { Scene, IDisposable } from "babylonjs/scene";
  32219. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32220. import { Material } from "babylonjs/Materials/material";
  32221. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32222. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32223. /**
  32224. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32225. *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.
  32226. * The SPS is also a particle system. It provides some methods to manage the particles.
  32227. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32228. *
  32229. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32230. */
  32231. export class SolidParticleSystem implements IDisposable {
  32232. /**
  32233. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32234. * Example : var p = SPS.particles[i];
  32235. */
  32236. particles: SolidParticle[];
  32237. /**
  32238. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32239. */
  32240. nbParticles: number;
  32241. /**
  32242. * If the particles must ever face the camera (default false). Useful for planar particles.
  32243. */
  32244. billboard: boolean;
  32245. /**
  32246. * Recompute normals when adding a shape
  32247. */
  32248. recomputeNormals: boolean;
  32249. /**
  32250. * This a counter ofr your own usage. It's not set by any SPS functions.
  32251. */
  32252. counter: number;
  32253. /**
  32254. * The SPS name. This name is also given to the underlying mesh.
  32255. */
  32256. name: string;
  32257. /**
  32258. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32259. */
  32260. mesh: Mesh;
  32261. /**
  32262. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32263. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32264. */
  32265. vars: any;
  32266. /**
  32267. * This array is populated when the SPS is set as 'pickable'.
  32268. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32269. * Each element of this array is an object `{idx: int, faceId: int}`.
  32270. * `idx` is the picked particle index in the `SPS.particles` array
  32271. * `faceId` is the picked face index counted within this particle.
  32272. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32273. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32274. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32275. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32276. */
  32277. pickedParticles: {
  32278. idx: number;
  32279. faceId: number;
  32280. }[];
  32281. /**
  32282. * This array is populated when the SPS is set as 'pickable'
  32283. * Each key of this array is a submesh index.
  32284. * Each element of this array is a second array defined like this :
  32285. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32286. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32287. * `idx` is the picked particle index in the `SPS.particles` array
  32288. * `faceId` is the picked face index counted within this particle.
  32289. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32290. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32291. */
  32292. pickedBySubMesh: {
  32293. idx: number;
  32294. faceId: number;
  32295. }[][];
  32296. /**
  32297. * This array is populated when `enableDepthSort` is set to true.
  32298. * Each element of this array is an instance of the class DepthSortedParticle.
  32299. */
  32300. depthSortedParticles: DepthSortedParticle[];
  32301. /**
  32302. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32303. * @hidden
  32304. */
  32305. _bSphereOnly: boolean;
  32306. /**
  32307. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32308. * @hidden
  32309. */
  32310. _bSphereRadiusFactor: number;
  32311. private _scene;
  32312. private _positions;
  32313. private _indices;
  32314. private _normals;
  32315. private _colors;
  32316. private _uvs;
  32317. private _indices32;
  32318. private _positions32;
  32319. private _normals32;
  32320. private _fixedNormal32;
  32321. private _colors32;
  32322. private _uvs32;
  32323. private _index;
  32324. private _updatable;
  32325. private _pickable;
  32326. private _isVisibilityBoxLocked;
  32327. private _alwaysVisible;
  32328. private _depthSort;
  32329. private _expandable;
  32330. private _shapeCounter;
  32331. private _copy;
  32332. private _color;
  32333. private _computeParticleColor;
  32334. private _computeParticleTexture;
  32335. private _computeParticleRotation;
  32336. private _computeParticleVertex;
  32337. private _computeBoundingBox;
  32338. private _depthSortParticles;
  32339. private _camera;
  32340. private _mustUnrotateFixedNormals;
  32341. private _particlesIntersect;
  32342. private _needs32Bits;
  32343. private _isNotBuilt;
  32344. private _lastParticleId;
  32345. private _idxOfId;
  32346. private _multimaterialEnabled;
  32347. private _useModelMaterial;
  32348. private _indicesByMaterial;
  32349. private _materialIndexes;
  32350. private _depthSortFunction;
  32351. private _materialSortFunction;
  32352. private _materials;
  32353. private _multimaterial;
  32354. private _materialIndexesById;
  32355. private _defaultMaterial;
  32356. private _autoUpdateSubMeshes;
  32357. private _tmpVertex;
  32358. /**
  32359. * Creates a SPS (Solid Particle System) object.
  32360. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32361. * @param scene (Scene) is the scene in which the SPS is added.
  32362. * @param options defines the options of the sps e.g.
  32363. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32364. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32365. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32366. * * 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.
  32367. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32368. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32369. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32370. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32371. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32372. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32373. */
  32374. constructor(name: string, scene: Scene, options?: {
  32375. updatable?: boolean;
  32376. isPickable?: boolean;
  32377. enableDepthSort?: boolean;
  32378. particleIntersection?: boolean;
  32379. boundingSphereOnly?: boolean;
  32380. bSphereRadiusFactor?: number;
  32381. expandable?: boolean;
  32382. useModelMaterial?: boolean;
  32383. enableMultiMaterial?: boolean;
  32384. });
  32385. /**
  32386. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32387. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32388. * @returns the created mesh
  32389. */
  32390. buildMesh(): Mesh;
  32391. /**
  32392. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32393. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32394. * Thus the particles generated from `digest()` have their property `position` set yet.
  32395. * @param mesh ( Mesh ) is the mesh to be digested
  32396. * @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
  32397. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32398. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32399. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32400. * @returns the current SPS
  32401. */
  32402. digest(mesh: Mesh, options?: {
  32403. facetNb?: number;
  32404. number?: number;
  32405. delta?: number;
  32406. storage?: [];
  32407. }): SolidParticleSystem;
  32408. /**
  32409. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32410. * @hidden
  32411. */
  32412. private _unrotateFixedNormals;
  32413. /**
  32414. * Resets the temporary working copy particle
  32415. * @hidden
  32416. */
  32417. private _resetCopy;
  32418. /**
  32419. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32420. * @param p the current index in the positions array to be updated
  32421. * @param ind the current index in the indices array
  32422. * @param shape a Vector3 array, the shape geometry
  32423. * @param positions the positions array to be updated
  32424. * @param meshInd the shape indices array
  32425. * @param indices the indices array to be updated
  32426. * @param meshUV the shape uv array
  32427. * @param uvs the uv array to be updated
  32428. * @param meshCol the shape color array
  32429. * @param colors the color array to be updated
  32430. * @param meshNor the shape normals array
  32431. * @param normals the normals array to be updated
  32432. * @param idx the particle index
  32433. * @param idxInShape the particle index in its shape
  32434. * @param options the addShape() method passed options
  32435. * @model the particle model
  32436. * @hidden
  32437. */
  32438. private _meshBuilder;
  32439. /**
  32440. * Returns a shape Vector3 array from positions float array
  32441. * @param positions float array
  32442. * @returns a vector3 array
  32443. * @hidden
  32444. */
  32445. private _posToShape;
  32446. /**
  32447. * Returns a shapeUV array from a float uvs (array deep copy)
  32448. * @param uvs as a float array
  32449. * @returns a shapeUV array
  32450. * @hidden
  32451. */
  32452. private _uvsToShapeUV;
  32453. /**
  32454. * Adds a new particle object in the particles array
  32455. * @param idx particle index in particles array
  32456. * @param id particle id
  32457. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32458. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32459. * @param model particle ModelShape object
  32460. * @param shapeId model shape identifier
  32461. * @param idxInShape index of the particle in the current model
  32462. * @param bInfo model bounding info object
  32463. * @param storage target storage array, if any
  32464. * @hidden
  32465. */
  32466. private _addParticle;
  32467. /**
  32468. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32469. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32470. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32471. * @param nb (positive integer) the number of particles to be created from this model
  32472. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32473. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32474. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32475. * @returns the number of shapes in the system
  32476. */
  32477. addShape(mesh: Mesh, nb: number, options?: {
  32478. positionFunction?: any;
  32479. vertexFunction?: any;
  32480. storage?: [];
  32481. }): number;
  32482. /**
  32483. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32484. * @hidden
  32485. */
  32486. private _rebuildParticle;
  32487. /**
  32488. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32489. * @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.
  32490. * @returns the SPS.
  32491. */
  32492. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32493. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32494. * Returns an array with the removed particles.
  32495. * 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.
  32496. * The SPS can't be empty so at least one particle needs to remain in place.
  32497. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32498. * @param start index of the first particle to remove
  32499. * @param end index of the last particle to remove (included)
  32500. * @returns an array populated with the removed particles
  32501. */
  32502. removeParticles(start: number, end: number): SolidParticle[];
  32503. /**
  32504. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32505. * @param solidParticleArray an array populated with Solid Particles objects
  32506. * @returns the SPS
  32507. */
  32508. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32509. /**
  32510. * Creates a new particle and modifies the SPS mesh geometry :
  32511. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32512. * - calls _addParticle() to populate the particle array
  32513. * factorized code from addShape() and insertParticlesFromArray()
  32514. * @param idx particle index in the particles array
  32515. * @param i particle index in its shape
  32516. * @param modelShape particle ModelShape object
  32517. * @param shape shape vertex array
  32518. * @param meshInd shape indices array
  32519. * @param meshUV shape uv array
  32520. * @param meshCol shape color array
  32521. * @param meshNor shape normals array
  32522. * @param bbInfo shape bounding info
  32523. * @param storage target particle storage
  32524. * @options addShape() passed options
  32525. * @hidden
  32526. */
  32527. private _insertNewParticle;
  32528. /**
  32529. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32530. * This method calls `updateParticle()` for each particle of the SPS.
  32531. * For an animated SPS, it is usually called within the render loop.
  32532. * 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.
  32533. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32534. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32535. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32536. * @returns the SPS.
  32537. */
  32538. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32539. /**
  32540. * Disposes the SPS.
  32541. */
  32542. dispose(): void;
  32543. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32544. * idx is the particle index in the SPS
  32545. * faceId is the picked face index counted within this particle.
  32546. * Returns null if the pickInfo can't identify a picked particle.
  32547. * @param pickingInfo (PickingInfo object)
  32548. * @returns {idx: number, faceId: number} or null
  32549. */
  32550. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32551. idx: number;
  32552. faceId: number;
  32553. }>;
  32554. /**
  32555. * Returns a SolidParticle object from its identifier : particle.id
  32556. * @param id (integer) the particle Id
  32557. * @returns the searched particle or null if not found in the SPS.
  32558. */
  32559. getParticleById(id: number): Nullable<SolidParticle>;
  32560. /**
  32561. * Returns a new array populated with the particles having the passed shapeId.
  32562. * @param shapeId (integer) the shape identifier
  32563. * @returns a new solid particle array
  32564. */
  32565. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32566. /**
  32567. * Populates the passed array "ref" with the particles having the passed shapeId.
  32568. * @param shapeId the shape identifier
  32569. * @returns the SPS
  32570. * @param ref
  32571. */
  32572. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32573. /**
  32574. * Computes the required SubMeshes according the materials assigned to the particles.
  32575. * @returns the solid particle system.
  32576. * Does nothing if called before the SPS mesh is built.
  32577. */
  32578. computeSubMeshes(): SolidParticleSystem;
  32579. /**
  32580. * Sorts the solid particles by material when MultiMaterial is enabled.
  32581. * Updates the indices32 array.
  32582. * Updates the indicesByMaterial array.
  32583. * Updates the mesh indices array.
  32584. * @returns the SPS
  32585. * @hidden
  32586. */
  32587. private _sortParticlesByMaterial;
  32588. /**
  32589. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32590. * @hidden
  32591. */
  32592. private _setMaterialIndexesById;
  32593. /**
  32594. * Returns an array with unique values of Materials from the passed array
  32595. * @param array the material array to be checked and filtered
  32596. * @hidden
  32597. */
  32598. private _filterUniqueMaterialId;
  32599. /**
  32600. * Sets a new Standard Material as _defaultMaterial if not already set.
  32601. * @hidden
  32602. */
  32603. private _setDefaultMaterial;
  32604. /**
  32605. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32606. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32607. * @returns the SPS.
  32608. */
  32609. refreshVisibleSize(): SolidParticleSystem;
  32610. /**
  32611. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32612. * @param size the size (float) of the visibility box
  32613. * note : this doesn't lock the SPS mesh bounding box.
  32614. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32615. */
  32616. setVisibilityBox(size: number): void;
  32617. /**
  32618. * Gets whether the SPS as always visible or not
  32619. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32620. */
  32621. get isAlwaysVisible(): boolean;
  32622. /**
  32623. * Sets the SPS as always visible or not
  32624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32625. */
  32626. set isAlwaysVisible(val: boolean);
  32627. /**
  32628. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32630. */
  32631. set isVisibilityBoxLocked(val: boolean);
  32632. /**
  32633. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32634. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32635. */
  32636. get isVisibilityBoxLocked(): boolean;
  32637. /**
  32638. * Tells to `setParticles()` to compute the particle rotations or not.
  32639. * Default value : true. The SPS is faster when it's set to false.
  32640. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32641. */
  32642. set computeParticleRotation(val: boolean);
  32643. /**
  32644. * Tells to `setParticles()` to compute the particle colors or not.
  32645. * Default value : true. The SPS is faster when it's set to false.
  32646. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32647. */
  32648. set computeParticleColor(val: boolean);
  32649. set computeParticleTexture(val: boolean);
  32650. /**
  32651. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32652. * Default value : false. The SPS is faster when it's set to false.
  32653. * Note : the particle custom vertex positions aren't stored values.
  32654. */
  32655. set computeParticleVertex(val: boolean);
  32656. /**
  32657. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32658. */
  32659. set computeBoundingBox(val: boolean);
  32660. /**
  32661. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32662. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32663. * Default : `true`
  32664. */
  32665. set depthSortParticles(val: boolean);
  32666. /**
  32667. * Gets if `setParticles()` computes the particle rotations or not.
  32668. * Default value : true. The SPS is faster when it's set to false.
  32669. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32670. */
  32671. get computeParticleRotation(): boolean;
  32672. /**
  32673. * Gets if `setParticles()` computes the particle colors or not.
  32674. * Default value : true. The SPS is faster when it's set to false.
  32675. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32676. */
  32677. get computeParticleColor(): boolean;
  32678. /**
  32679. * Gets if `setParticles()` computes the particle textures or not.
  32680. * Default value : true. The SPS is faster when it's set to false.
  32681. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32682. */
  32683. get computeParticleTexture(): boolean;
  32684. /**
  32685. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32686. * Default value : false. The SPS is faster when it's set to false.
  32687. * Note : the particle custom vertex positions aren't stored values.
  32688. */
  32689. get computeParticleVertex(): boolean;
  32690. /**
  32691. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32692. */
  32693. get computeBoundingBox(): boolean;
  32694. /**
  32695. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32696. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32697. * Default : `true`
  32698. */
  32699. get depthSortParticles(): boolean;
  32700. /**
  32701. * Gets if the SPS is created as expandable at construction time.
  32702. * Default : `false`
  32703. */
  32704. get expandable(): boolean;
  32705. /**
  32706. * Gets if the SPS supports the Multi Materials
  32707. */
  32708. get multimaterialEnabled(): boolean;
  32709. /**
  32710. * Gets if the SPS uses the model materials for its own multimaterial.
  32711. */
  32712. get useModelMaterial(): boolean;
  32713. /**
  32714. * The SPS used material array.
  32715. */
  32716. get materials(): Material[];
  32717. /**
  32718. * Sets the SPS MultiMaterial from the passed materials.
  32719. * Note : the passed array is internally copied and not used then by reference.
  32720. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32721. */
  32722. setMultiMaterial(materials: Material[]): void;
  32723. /**
  32724. * The SPS computed multimaterial object
  32725. */
  32726. get multimaterial(): MultiMaterial;
  32727. set multimaterial(mm: MultiMaterial);
  32728. /**
  32729. * If the subMeshes must be updated on the next call to setParticles()
  32730. */
  32731. get autoUpdateSubMeshes(): boolean;
  32732. set autoUpdateSubMeshes(val: boolean);
  32733. /**
  32734. * This function does nothing. It may be overwritten to set all the particle first values.
  32735. * The SPS doesn't call this function, you may have to call it by your own.
  32736. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32737. */
  32738. initParticles(): void;
  32739. /**
  32740. * This function does nothing. It may be overwritten to recycle a particle.
  32741. * The SPS doesn't call this function, you may have to call it by your own.
  32742. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32743. * @param particle The particle to recycle
  32744. * @returns the recycled particle
  32745. */
  32746. recycleParticle(particle: SolidParticle): SolidParticle;
  32747. /**
  32748. * Updates a particle : this function should be overwritten by the user.
  32749. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32750. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32751. * @example : just set a particle position or velocity and recycle conditions
  32752. * @param particle The particle to update
  32753. * @returns the updated particle
  32754. */
  32755. updateParticle(particle: SolidParticle): SolidParticle;
  32756. /**
  32757. * Updates a vertex of a particle : it can be overwritten by the user.
  32758. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32759. * @param particle the current particle
  32760. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32761. * @param pt the index of the current vertex in the particle shape
  32762. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32763. * @example : just set a vertex particle position or color
  32764. * @returns the sps
  32765. */
  32766. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32767. /**
  32768. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32769. * This does nothing and may be overwritten by the user.
  32770. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32771. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32772. * @param update the boolean update value actually passed to setParticles()
  32773. */
  32774. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32775. /**
  32776. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32777. * This will be passed three parameters.
  32778. * This does nothing and may be overwritten by the user.
  32779. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32780. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32781. * @param update the boolean update value actually passed to setParticles()
  32782. */
  32783. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32784. }
  32785. }
  32786. declare module "babylonjs/Particles/solidParticle" {
  32787. import { Nullable } from "babylonjs/types";
  32788. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32789. import { Color4 } from "babylonjs/Maths/math.color";
  32790. import { Mesh } from "babylonjs/Meshes/mesh";
  32791. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32792. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32793. import { Plane } from "babylonjs/Maths/math.plane";
  32794. import { Material } from "babylonjs/Materials/material";
  32795. /**
  32796. * Represents one particle of a solid particle system.
  32797. */
  32798. export class SolidParticle {
  32799. /**
  32800. * particle global index
  32801. */
  32802. idx: number;
  32803. /**
  32804. * particle identifier
  32805. */
  32806. id: number;
  32807. /**
  32808. * The color of the particle
  32809. */
  32810. color: Nullable<Color4>;
  32811. /**
  32812. * The world space position of the particle.
  32813. */
  32814. position: Vector3;
  32815. /**
  32816. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32817. */
  32818. rotation: Vector3;
  32819. /**
  32820. * The world space rotation quaternion of the particle.
  32821. */
  32822. rotationQuaternion: Nullable<Quaternion>;
  32823. /**
  32824. * The scaling of the particle.
  32825. */
  32826. scaling: Vector3;
  32827. /**
  32828. * The uvs of the particle.
  32829. */
  32830. uvs: Vector4;
  32831. /**
  32832. * The current speed of the particle.
  32833. */
  32834. velocity: Vector3;
  32835. /**
  32836. * The pivot point in the particle local space.
  32837. */
  32838. pivot: Vector3;
  32839. /**
  32840. * Must the particle be translated from its pivot point in its local space ?
  32841. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32842. * Default : false
  32843. */
  32844. translateFromPivot: boolean;
  32845. /**
  32846. * Is the particle active or not ?
  32847. */
  32848. alive: boolean;
  32849. /**
  32850. * Is the particle visible or not ?
  32851. */
  32852. isVisible: boolean;
  32853. /**
  32854. * Index of this particle in the global "positions" array (Internal use)
  32855. * @hidden
  32856. */
  32857. _pos: number;
  32858. /**
  32859. * @hidden Index of this particle in the global "indices" array (Internal use)
  32860. */
  32861. _ind: number;
  32862. /**
  32863. * @hidden ModelShape of this particle (Internal use)
  32864. */
  32865. _model: ModelShape;
  32866. /**
  32867. * ModelShape id of this particle
  32868. */
  32869. shapeId: number;
  32870. /**
  32871. * Index of the particle in its shape id
  32872. */
  32873. idxInShape: number;
  32874. /**
  32875. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32876. */
  32877. _modelBoundingInfo: BoundingInfo;
  32878. /**
  32879. * @hidden Particle BoundingInfo object (Internal use)
  32880. */
  32881. _boundingInfo: BoundingInfo;
  32882. /**
  32883. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32884. */
  32885. _sps: SolidParticleSystem;
  32886. /**
  32887. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32888. */
  32889. _stillInvisible: boolean;
  32890. /**
  32891. * @hidden Last computed particle rotation matrix
  32892. */
  32893. _rotationMatrix: number[];
  32894. /**
  32895. * Parent particle Id, if any.
  32896. * Default null.
  32897. */
  32898. parentId: Nullable<number>;
  32899. /**
  32900. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32901. */
  32902. materialIndex: Nullable<number>;
  32903. /**
  32904. * Custom object or properties.
  32905. */
  32906. props: Nullable<any>;
  32907. /**
  32908. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32909. * The possible values are :
  32910. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32911. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32912. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32913. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32914. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32915. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32916. * */
  32917. cullingStrategy: number;
  32918. /**
  32919. * @hidden Internal global position in the SPS.
  32920. */
  32921. _globalPosition: Vector3;
  32922. /**
  32923. * Creates a Solid Particle object.
  32924. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32925. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32926. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32927. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32928. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32929. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32930. * @param shapeId (integer) is the model shape identifier in the SPS.
  32931. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32932. * @param sps defines the sps it is associated to
  32933. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32934. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32935. */
  32936. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32937. /**
  32938. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32939. * @param target the particle target
  32940. * @returns the current particle
  32941. */
  32942. copyToRef(target: SolidParticle): SolidParticle;
  32943. /**
  32944. * Legacy support, changed scale to scaling
  32945. */
  32946. get scale(): Vector3;
  32947. /**
  32948. * Legacy support, changed scale to scaling
  32949. */
  32950. set scale(scale: Vector3);
  32951. /**
  32952. * Legacy support, changed quaternion to rotationQuaternion
  32953. */
  32954. get quaternion(): Nullable<Quaternion>;
  32955. /**
  32956. * Legacy support, changed quaternion to rotationQuaternion
  32957. */
  32958. set quaternion(q: Nullable<Quaternion>);
  32959. /**
  32960. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32961. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32962. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32963. * @returns true if it intersects
  32964. */
  32965. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32966. /**
  32967. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32968. * A particle is in the frustum if its bounding box intersects the frustum
  32969. * @param frustumPlanes defines the frustum to test
  32970. * @returns true if the particle is in the frustum planes
  32971. */
  32972. isInFrustum(frustumPlanes: Plane[]): boolean;
  32973. /**
  32974. * get the rotation matrix of the particle
  32975. * @hidden
  32976. */
  32977. getRotationMatrix(m: Matrix): void;
  32978. }
  32979. /**
  32980. * Represents the shape of the model used by one particle of a solid particle system.
  32981. * SPS internal tool, don't use it manually.
  32982. */
  32983. export class ModelShape {
  32984. /**
  32985. * The shape id
  32986. * @hidden
  32987. */
  32988. shapeID: number;
  32989. /**
  32990. * flat array of model positions (internal use)
  32991. * @hidden
  32992. */
  32993. _shape: Vector3[];
  32994. /**
  32995. * flat array of model UVs (internal use)
  32996. * @hidden
  32997. */
  32998. _shapeUV: number[];
  32999. /**
  33000. * color array of the model
  33001. * @hidden
  33002. */
  33003. _shapeColors: number[];
  33004. /**
  33005. * indices array of the model
  33006. * @hidden
  33007. */
  33008. _indices: number[];
  33009. /**
  33010. * normals array of the model
  33011. * @hidden
  33012. */
  33013. _normals: number[];
  33014. /**
  33015. * length of the shape in the model indices array (internal use)
  33016. * @hidden
  33017. */
  33018. _indicesLength: number;
  33019. /**
  33020. * Custom position function (internal use)
  33021. * @hidden
  33022. */
  33023. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33024. /**
  33025. * Custom vertex function (internal use)
  33026. * @hidden
  33027. */
  33028. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33029. /**
  33030. * Model material (internal use)
  33031. * @hidden
  33032. */
  33033. _material: Nullable<Material>;
  33034. /**
  33035. * 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.
  33036. * SPS internal tool, don't use it manually.
  33037. * @hidden
  33038. */
  33039. 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>);
  33040. }
  33041. /**
  33042. * Represents a Depth Sorted Particle in the solid particle system.
  33043. * @hidden
  33044. */
  33045. export class DepthSortedParticle {
  33046. /**
  33047. * Particle index
  33048. */
  33049. idx: number;
  33050. /**
  33051. * Index of the particle in the "indices" array
  33052. */
  33053. ind: number;
  33054. /**
  33055. * Length of the particle shape in the "indices" array
  33056. */
  33057. indicesLength: number;
  33058. /**
  33059. * Squared distance from the particle to the camera
  33060. */
  33061. sqDistance: number;
  33062. /**
  33063. * Material index when used with MultiMaterials
  33064. */
  33065. materialIndex: number;
  33066. /**
  33067. * Creates a new sorted particle
  33068. * @param materialIndex
  33069. */
  33070. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33071. }
  33072. /**
  33073. * Represents a solid particle vertex
  33074. */
  33075. export class SolidParticleVertex {
  33076. /**
  33077. * Vertex position
  33078. */
  33079. position: Vector3;
  33080. /**
  33081. * Vertex color
  33082. */
  33083. color: Color4;
  33084. /**
  33085. * Vertex UV
  33086. */
  33087. uv: Vector2;
  33088. /**
  33089. * Creates a new solid particle vertex
  33090. */
  33091. constructor();
  33092. /** Vertex x coordinate */
  33093. get x(): number;
  33094. set x(val: number);
  33095. /** Vertex y coordinate */
  33096. get y(): number;
  33097. set y(val: number);
  33098. /** Vertex z coordinate */
  33099. get z(): number;
  33100. set z(val: number);
  33101. }
  33102. }
  33103. declare module "babylonjs/Collisions/meshCollisionData" {
  33104. import { Collider } from "babylonjs/Collisions/collider";
  33105. import { Vector3 } from "babylonjs/Maths/math.vector";
  33106. import { Nullable } from "babylonjs/types";
  33107. import { Observer } from "babylonjs/Misc/observable";
  33108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33109. /**
  33110. * @hidden
  33111. */
  33112. export class _MeshCollisionData {
  33113. _checkCollisions: boolean;
  33114. _collisionMask: number;
  33115. _collisionGroup: number;
  33116. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33117. _collider: Nullable<Collider>;
  33118. _oldPositionForCollisions: Vector3;
  33119. _diffPositionForCollisions: Vector3;
  33120. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33121. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33122. _collisionResponse: boolean;
  33123. }
  33124. }
  33125. declare module "babylonjs/Meshes/abstractMesh" {
  33126. import { Observable } from "babylonjs/Misc/observable";
  33127. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33128. import { Camera } from "babylonjs/Cameras/camera";
  33129. import { Scene, IDisposable } from "babylonjs/scene";
  33130. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33131. import { Node } from "babylonjs/node";
  33132. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33133. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33136. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33137. import { Material } from "babylonjs/Materials/material";
  33138. import { Light } from "babylonjs/Lights/light";
  33139. import { Skeleton } from "babylonjs/Bones/skeleton";
  33140. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33141. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33142. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33143. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33144. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33145. import { Plane } from "babylonjs/Maths/math.plane";
  33146. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33147. import { Ray } from "babylonjs/Culling/ray";
  33148. import { Collider } from "babylonjs/Collisions/collider";
  33149. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33150. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33151. /** @hidden */
  33152. class _FacetDataStorage {
  33153. facetPositions: Vector3[];
  33154. facetNormals: Vector3[];
  33155. facetPartitioning: number[][];
  33156. facetNb: number;
  33157. partitioningSubdivisions: number;
  33158. partitioningBBoxRatio: number;
  33159. facetDataEnabled: boolean;
  33160. facetParameters: any;
  33161. bbSize: Vector3;
  33162. subDiv: {
  33163. max: number;
  33164. X: number;
  33165. Y: number;
  33166. Z: number;
  33167. };
  33168. facetDepthSort: boolean;
  33169. facetDepthSortEnabled: boolean;
  33170. depthSortedIndices: IndicesArray;
  33171. depthSortedFacets: {
  33172. ind: number;
  33173. sqDistance: number;
  33174. }[];
  33175. facetDepthSortFunction: (f1: {
  33176. ind: number;
  33177. sqDistance: number;
  33178. }, f2: {
  33179. ind: number;
  33180. sqDistance: number;
  33181. }) => number;
  33182. facetDepthSortFrom: Vector3;
  33183. facetDepthSortOrigin: Vector3;
  33184. invertedMatrix: Matrix;
  33185. }
  33186. /**
  33187. * @hidden
  33188. **/
  33189. class _InternalAbstractMeshDataInfo {
  33190. _hasVertexAlpha: boolean;
  33191. _useVertexColors: boolean;
  33192. _numBoneInfluencers: number;
  33193. _applyFog: boolean;
  33194. _receiveShadows: boolean;
  33195. _facetData: _FacetDataStorage;
  33196. _visibility: number;
  33197. _skeleton: Nullable<Skeleton>;
  33198. _layerMask: number;
  33199. _computeBonesUsingShaders: boolean;
  33200. _isActive: boolean;
  33201. _onlyForInstances: boolean;
  33202. _isActiveIntermediate: boolean;
  33203. _onlyForInstancesIntermediate: boolean;
  33204. _actAsRegularMesh: boolean;
  33205. }
  33206. /**
  33207. * Class used to store all common mesh properties
  33208. */
  33209. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33210. /** No occlusion */
  33211. static OCCLUSION_TYPE_NONE: number;
  33212. /** Occlusion set to optimisitic */
  33213. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33214. /** Occlusion set to strict */
  33215. static OCCLUSION_TYPE_STRICT: number;
  33216. /** Use an accurante occlusion algorithm */
  33217. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33218. /** Use a conservative occlusion algorithm */
  33219. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33220. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33221. * Test order :
  33222. * Is the bounding sphere outside the frustum ?
  33223. * If not, are the bounding box vertices outside the frustum ?
  33224. * It not, then the cullable object is in the frustum.
  33225. */
  33226. static readonly CULLINGSTRATEGY_STANDARD: number;
  33227. /** Culling strategy : Bounding Sphere Only.
  33228. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33229. * It's also less accurate than the standard because some not visible objects can still be selected.
  33230. * Test : is the bounding sphere outside the frustum ?
  33231. * If not, then the cullable object is in the frustum.
  33232. */
  33233. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33234. /** Culling strategy : Optimistic Inclusion.
  33235. * This in an inclusion test first, then the standard exclusion test.
  33236. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33237. * 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.
  33238. * Anyway, it's as accurate as the standard strategy.
  33239. * Test :
  33240. * Is the cullable object bounding sphere center in the frustum ?
  33241. * If not, apply the default culling strategy.
  33242. */
  33243. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33244. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33245. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33246. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33247. * 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.
  33248. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33249. * Test :
  33250. * Is the cullable object bounding sphere center in the frustum ?
  33251. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33252. */
  33253. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33254. /**
  33255. * No billboard
  33256. */
  33257. static get BILLBOARDMODE_NONE(): number;
  33258. /** Billboard on X axis */
  33259. static get BILLBOARDMODE_X(): number;
  33260. /** Billboard on Y axis */
  33261. static get BILLBOARDMODE_Y(): number;
  33262. /** Billboard on Z axis */
  33263. static get BILLBOARDMODE_Z(): number;
  33264. /** Billboard on all axes */
  33265. static get BILLBOARDMODE_ALL(): number;
  33266. /** Billboard on using position instead of orientation */
  33267. static get BILLBOARDMODE_USE_POSITION(): number;
  33268. /** @hidden */
  33269. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33270. /**
  33271. * The culling strategy to use to check whether the mesh must be rendered or not.
  33272. * This value can be changed at any time and will be used on the next render mesh selection.
  33273. * The possible values are :
  33274. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33275. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33276. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33277. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33278. * Please read each static variable documentation to get details about the culling process.
  33279. * */
  33280. cullingStrategy: number;
  33281. /**
  33282. * Gets the number of facets in the mesh
  33283. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33284. */
  33285. get facetNb(): number;
  33286. /**
  33287. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33288. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33289. */
  33290. get partitioningSubdivisions(): number;
  33291. set partitioningSubdivisions(nb: number);
  33292. /**
  33293. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33294. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33295. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33296. */
  33297. get partitioningBBoxRatio(): number;
  33298. set partitioningBBoxRatio(ratio: number);
  33299. /**
  33300. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33301. * Works only for updatable meshes.
  33302. * Doesn't work with multi-materials
  33303. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33304. */
  33305. get mustDepthSortFacets(): boolean;
  33306. set mustDepthSortFacets(sort: boolean);
  33307. /**
  33308. * The location (Vector3) where the facet depth sort must be computed from.
  33309. * By default, the active camera position.
  33310. * Used only when facet depth sort is enabled
  33311. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33312. */
  33313. get facetDepthSortFrom(): Vector3;
  33314. set facetDepthSortFrom(location: Vector3);
  33315. /**
  33316. * gets a boolean indicating if facetData is enabled
  33317. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33318. */
  33319. get isFacetDataEnabled(): boolean;
  33320. /** @hidden */
  33321. _updateNonUniformScalingState(value: boolean): boolean;
  33322. /**
  33323. * An event triggered when this mesh collides with another one
  33324. */
  33325. onCollideObservable: Observable<AbstractMesh>;
  33326. /** Set a function to call when this mesh collides with another one */
  33327. set onCollide(callback: () => void);
  33328. /**
  33329. * An event triggered when the collision's position changes
  33330. */
  33331. onCollisionPositionChangeObservable: Observable<Vector3>;
  33332. /** Set a function to call when the collision's position changes */
  33333. set onCollisionPositionChange(callback: () => void);
  33334. /**
  33335. * An event triggered when material is changed
  33336. */
  33337. onMaterialChangedObservable: Observable<AbstractMesh>;
  33338. /**
  33339. * Gets or sets the orientation for POV movement & rotation
  33340. */
  33341. definedFacingForward: boolean;
  33342. /** @hidden */
  33343. _occlusionQuery: Nullable<WebGLQuery>;
  33344. /** @hidden */
  33345. _renderingGroup: Nullable<RenderingGroup>;
  33346. /**
  33347. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33348. */
  33349. get visibility(): number;
  33350. /**
  33351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33352. */
  33353. set visibility(value: number);
  33354. /** Gets or sets the alpha index used to sort transparent meshes
  33355. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33356. */
  33357. alphaIndex: number;
  33358. /**
  33359. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33360. */
  33361. isVisible: boolean;
  33362. /**
  33363. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33364. */
  33365. isPickable: boolean;
  33366. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33367. showSubMeshesBoundingBox: boolean;
  33368. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33369. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33370. */
  33371. isBlocker: boolean;
  33372. /**
  33373. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33374. */
  33375. enablePointerMoveEvents: boolean;
  33376. private _renderingGroupId;
  33377. /**
  33378. * Specifies the rendering group id for this mesh (0 by default)
  33379. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33380. */
  33381. get renderingGroupId(): number;
  33382. set renderingGroupId(value: number);
  33383. private _material;
  33384. /** Gets or sets current material */
  33385. get material(): Nullable<Material>;
  33386. set material(value: Nullable<Material>);
  33387. /**
  33388. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33389. * @see https://doc.babylonjs.com/babylon101/shadows
  33390. */
  33391. get receiveShadows(): boolean;
  33392. set receiveShadows(value: boolean);
  33393. /** Defines color to use when rendering outline */
  33394. outlineColor: Color3;
  33395. /** Define width to use when rendering outline */
  33396. outlineWidth: number;
  33397. /** Defines color to use when rendering overlay */
  33398. overlayColor: Color3;
  33399. /** Defines alpha to use when rendering overlay */
  33400. overlayAlpha: number;
  33401. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33402. get hasVertexAlpha(): boolean;
  33403. set hasVertexAlpha(value: boolean);
  33404. /** 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) */
  33405. get useVertexColors(): boolean;
  33406. set useVertexColors(value: boolean);
  33407. /**
  33408. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33409. */
  33410. get computeBonesUsingShaders(): boolean;
  33411. set computeBonesUsingShaders(value: boolean);
  33412. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33413. get numBoneInfluencers(): number;
  33414. set numBoneInfluencers(value: number);
  33415. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33416. get applyFog(): boolean;
  33417. set applyFog(value: boolean);
  33418. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33419. useOctreeForRenderingSelection: boolean;
  33420. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33421. useOctreeForPicking: boolean;
  33422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33423. useOctreeForCollisions: boolean;
  33424. /**
  33425. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33426. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33427. */
  33428. get layerMask(): number;
  33429. set layerMask(value: number);
  33430. /**
  33431. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33432. */
  33433. alwaysSelectAsActiveMesh: boolean;
  33434. /**
  33435. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33436. */
  33437. doNotSyncBoundingInfo: boolean;
  33438. /**
  33439. * Gets or sets the current action manager
  33440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33441. */
  33442. actionManager: Nullable<AbstractActionManager>;
  33443. private _meshCollisionData;
  33444. /**
  33445. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33446. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33447. */
  33448. ellipsoid: Vector3;
  33449. /**
  33450. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33451. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33452. */
  33453. ellipsoidOffset: Vector3;
  33454. /**
  33455. * Gets or sets a collision mask used to mask collisions (default is -1).
  33456. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33457. */
  33458. get collisionMask(): number;
  33459. set collisionMask(mask: number);
  33460. /**
  33461. * Gets or sets a collision response flag (default is true).
  33462. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33463. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33464. * to respond to the collision.
  33465. */
  33466. get collisionResponse(): boolean;
  33467. set collisionResponse(response: boolean);
  33468. /**
  33469. * Gets or sets the current collision group mask (-1 by default).
  33470. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33471. */
  33472. get collisionGroup(): number;
  33473. set collisionGroup(mask: number);
  33474. /**
  33475. * Gets or sets current surrounding meshes (null by default).
  33476. *
  33477. * By default collision detection is tested against every mesh in the scene.
  33478. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33479. * meshes will be tested for the collision.
  33480. *
  33481. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33482. */
  33483. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33484. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33485. /**
  33486. * Defines edge width used when edgesRenderer is enabled
  33487. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33488. */
  33489. edgesWidth: number;
  33490. /**
  33491. * Defines edge color used when edgesRenderer is enabled
  33492. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33493. */
  33494. edgesColor: Color4;
  33495. /** @hidden */
  33496. _edgesRenderer: Nullable<IEdgesRenderer>;
  33497. /** @hidden */
  33498. _masterMesh: Nullable<AbstractMesh>;
  33499. /** @hidden */
  33500. _boundingInfo: Nullable<BoundingInfo>;
  33501. /** @hidden */
  33502. _renderId: number;
  33503. /**
  33504. * Gets or sets the list of subMeshes
  33505. * @see https://doc.babylonjs.com/how_to/multi_materials
  33506. */
  33507. subMeshes: SubMesh[];
  33508. /** @hidden */
  33509. _intersectionsInProgress: AbstractMesh[];
  33510. /** @hidden */
  33511. _unIndexed: boolean;
  33512. /** @hidden */
  33513. _lightSources: Light[];
  33514. /** Gets the list of lights affecting that mesh */
  33515. get lightSources(): Light[];
  33516. /** @hidden */
  33517. get _positions(): Nullable<Vector3[]>;
  33518. /** @hidden */
  33519. _waitingData: {
  33520. lods: Nullable<any>;
  33521. actions: Nullable<any>;
  33522. freezeWorldMatrix: Nullable<boolean>;
  33523. };
  33524. /** @hidden */
  33525. _bonesTransformMatrices: Nullable<Float32Array>;
  33526. /** @hidden */
  33527. _transformMatrixTexture: Nullable<RawTexture>;
  33528. /**
  33529. * Gets or sets a skeleton to apply skining transformations
  33530. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33531. */
  33532. set skeleton(value: Nullable<Skeleton>);
  33533. get skeleton(): Nullable<Skeleton>;
  33534. /**
  33535. * An event triggered when the mesh is rebuilt.
  33536. */
  33537. onRebuildObservable: Observable<AbstractMesh>;
  33538. /**
  33539. * Creates a new AbstractMesh
  33540. * @param name defines the name of the mesh
  33541. * @param scene defines the hosting scene
  33542. */
  33543. constructor(name: string, scene?: Nullable<Scene>);
  33544. /**
  33545. * Returns the string "AbstractMesh"
  33546. * @returns "AbstractMesh"
  33547. */
  33548. getClassName(): string;
  33549. /**
  33550. * Gets a string representation of the current mesh
  33551. * @param fullDetails defines a boolean indicating if full details must be included
  33552. * @returns a string representation of the current mesh
  33553. */
  33554. toString(fullDetails?: boolean): string;
  33555. /**
  33556. * @hidden
  33557. */
  33558. protected _getEffectiveParent(): Nullable<Node>;
  33559. /** @hidden */
  33560. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33561. /** @hidden */
  33562. _rebuild(): void;
  33563. /** @hidden */
  33564. _resyncLightSources(): void;
  33565. /** @hidden */
  33566. _resyncLightSource(light: Light): void;
  33567. /** @hidden */
  33568. _unBindEffect(): void;
  33569. /** @hidden */
  33570. _removeLightSource(light: Light, dispose: boolean): void;
  33571. private _markSubMeshesAsDirty;
  33572. /** @hidden */
  33573. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33574. /** @hidden */
  33575. _markSubMeshesAsAttributesDirty(): void;
  33576. /** @hidden */
  33577. _markSubMeshesAsMiscDirty(): void;
  33578. /**
  33579. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33580. */
  33581. get scaling(): Vector3;
  33582. set scaling(newScaling: Vector3);
  33583. /**
  33584. * Returns true if the mesh is blocked. Implemented by child classes
  33585. */
  33586. get isBlocked(): boolean;
  33587. /**
  33588. * Returns the mesh itself by default. Implemented by child classes
  33589. * @param camera defines the camera to use to pick the right LOD level
  33590. * @returns the currentAbstractMesh
  33591. */
  33592. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33593. /**
  33594. * Returns 0 by default. Implemented by child classes
  33595. * @returns an integer
  33596. */
  33597. getTotalVertices(): number;
  33598. /**
  33599. * Returns a positive integer : the total number of indices in this mesh geometry.
  33600. * @returns the numner of indices or zero if the mesh has no geometry.
  33601. */
  33602. getTotalIndices(): number;
  33603. /**
  33604. * Returns null by default. Implemented by child classes
  33605. * @returns null
  33606. */
  33607. getIndices(): Nullable<IndicesArray>;
  33608. /**
  33609. * Returns the array of the requested vertex data kind. Implemented by child classes
  33610. * @param kind defines the vertex data kind to use
  33611. * @returns null
  33612. */
  33613. getVerticesData(kind: string): Nullable<FloatArray>;
  33614. /**
  33615. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33616. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33617. * Note that a new underlying VertexBuffer object is created each call.
  33618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33619. * @param kind defines vertex data kind:
  33620. * * VertexBuffer.PositionKind
  33621. * * VertexBuffer.UVKind
  33622. * * VertexBuffer.UV2Kind
  33623. * * VertexBuffer.UV3Kind
  33624. * * VertexBuffer.UV4Kind
  33625. * * VertexBuffer.UV5Kind
  33626. * * VertexBuffer.UV6Kind
  33627. * * VertexBuffer.ColorKind
  33628. * * VertexBuffer.MatricesIndicesKind
  33629. * * VertexBuffer.MatricesIndicesExtraKind
  33630. * * VertexBuffer.MatricesWeightsKind
  33631. * * VertexBuffer.MatricesWeightsExtraKind
  33632. * @param data defines the data source
  33633. * @param updatable defines if the data must be flagged as updatable (or static)
  33634. * @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
  33635. * @returns the current mesh
  33636. */
  33637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33638. /**
  33639. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33640. * If the mesh has no geometry, it is simply returned as it is.
  33641. * @param kind defines vertex data kind:
  33642. * * VertexBuffer.PositionKind
  33643. * * VertexBuffer.UVKind
  33644. * * VertexBuffer.UV2Kind
  33645. * * VertexBuffer.UV3Kind
  33646. * * VertexBuffer.UV4Kind
  33647. * * VertexBuffer.UV5Kind
  33648. * * VertexBuffer.UV6Kind
  33649. * * VertexBuffer.ColorKind
  33650. * * VertexBuffer.MatricesIndicesKind
  33651. * * VertexBuffer.MatricesIndicesExtraKind
  33652. * * VertexBuffer.MatricesWeightsKind
  33653. * * VertexBuffer.MatricesWeightsExtraKind
  33654. * @param data defines the data source
  33655. * @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
  33656. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33657. * @returns the current mesh
  33658. */
  33659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33660. /**
  33661. * Sets the mesh indices,
  33662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33663. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33664. * @param totalVertices Defines the total number of vertices
  33665. * @returns the current mesh
  33666. */
  33667. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33668. /**
  33669. * Gets a boolean indicating if specific vertex data is present
  33670. * @param kind defines the vertex data kind to use
  33671. * @returns true is data kind is present
  33672. */
  33673. isVerticesDataPresent(kind: string): boolean;
  33674. /**
  33675. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33676. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33677. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33678. * @returns a BoundingInfo
  33679. */
  33680. getBoundingInfo(): BoundingInfo;
  33681. /**
  33682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33685. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33686. * @returns the current mesh
  33687. */
  33688. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33689. /**
  33690. * Overwrite the current bounding info
  33691. * @param boundingInfo defines the new bounding info
  33692. * @returns the current mesh
  33693. */
  33694. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33695. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33696. get useBones(): boolean;
  33697. /** @hidden */
  33698. _preActivate(): void;
  33699. /** @hidden */
  33700. _preActivateForIntermediateRendering(renderId: number): void;
  33701. /** @hidden */
  33702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33703. /** @hidden */
  33704. _postActivate(): void;
  33705. /** @hidden */
  33706. _freeze(): void;
  33707. /** @hidden */
  33708. _unFreeze(): void;
  33709. /**
  33710. * Gets the current world matrix
  33711. * @returns a Matrix
  33712. */
  33713. getWorldMatrix(): Matrix;
  33714. /** @hidden */
  33715. _getWorldMatrixDeterminant(): number;
  33716. /**
  33717. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33718. */
  33719. get isAnInstance(): boolean;
  33720. /**
  33721. * Gets a boolean indicating if this mesh has instances
  33722. */
  33723. get hasInstances(): boolean;
  33724. /**
  33725. * Gets a boolean indicating if this mesh has thin instances
  33726. */
  33727. get hasThinInstances(): boolean;
  33728. /**
  33729. * Perform relative position change from the point of view of behind the front of the mesh.
  33730. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33731. * Supports definition of mesh facing forward or backward
  33732. * @param amountRight defines the distance on the right axis
  33733. * @param amountUp defines the distance on the up axis
  33734. * @param amountForward defines the distance on the forward axis
  33735. * @returns the current mesh
  33736. */
  33737. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33738. /**
  33739. * Calculate relative position change from the point of view of behind the front of the mesh.
  33740. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33741. * Supports definition of mesh facing forward or backward
  33742. * @param amountRight defines the distance on the right axis
  33743. * @param amountUp defines the distance on the up axis
  33744. * @param amountForward defines the distance on the forward axis
  33745. * @returns the new displacement vector
  33746. */
  33747. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33748. /**
  33749. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33750. * Supports definition of mesh facing forward or backward
  33751. * @param flipBack defines the flip
  33752. * @param twirlClockwise defines the twirl
  33753. * @param tiltRight defines the tilt
  33754. * @returns the current mesh
  33755. */
  33756. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33757. /**
  33758. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33759. * Supports definition of mesh facing forward or backward.
  33760. * @param flipBack defines the flip
  33761. * @param twirlClockwise defines the twirl
  33762. * @param tiltRight defines the tilt
  33763. * @returns the new rotation vector
  33764. */
  33765. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33766. /**
  33767. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33768. * This means the mesh underlying bounding box and sphere are recomputed.
  33769. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33770. * @returns the current mesh
  33771. */
  33772. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33773. /** @hidden */
  33774. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33775. /** @hidden */
  33776. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33777. /** @hidden */
  33778. _updateBoundingInfo(): AbstractMesh;
  33779. /** @hidden */
  33780. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33781. /** @hidden */
  33782. protected _afterComputeWorldMatrix(): void;
  33783. /** @hidden */
  33784. get _effectiveMesh(): AbstractMesh;
  33785. /**
  33786. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33787. * A mesh is in the frustum if its bounding box intersects the frustum
  33788. * @param frustumPlanes defines the frustum to test
  33789. * @returns true if the mesh is in the frustum planes
  33790. */
  33791. isInFrustum(frustumPlanes: Plane[]): boolean;
  33792. /**
  33793. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33794. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33795. * @param frustumPlanes defines the frustum to test
  33796. * @returns true if the mesh is completely in the frustum planes
  33797. */
  33798. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33799. /**
  33800. * True if the mesh intersects another mesh or a SolidParticle object
  33801. * @param mesh defines a target mesh or SolidParticle to test
  33802. * @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)
  33803. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33804. * @returns true if there is an intersection
  33805. */
  33806. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33807. /**
  33808. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33809. * @param point defines the point to test
  33810. * @returns true if there is an intersection
  33811. */
  33812. intersectsPoint(point: Vector3): boolean;
  33813. /**
  33814. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33815. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33816. */
  33817. get checkCollisions(): boolean;
  33818. set checkCollisions(collisionEnabled: boolean);
  33819. /**
  33820. * Gets Collider object used to compute collisions (not physics)
  33821. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33822. */
  33823. get collider(): Nullable<Collider>;
  33824. /**
  33825. * Move the mesh using collision engine
  33826. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33827. * @param displacement defines the requested displacement vector
  33828. * @returns the current mesh
  33829. */
  33830. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33831. private _onCollisionPositionChange;
  33832. /** @hidden */
  33833. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33834. /** @hidden */
  33835. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33836. /** @hidden */
  33837. _checkCollision(collider: Collider): AbstractMesh;
  33838. /** @hidden */
  33839. _generatePointsArray(): boolean;
  33840. /**
  33841. * Checks if the passed Ray intersects with the mesh
  33842. * @param ray defines the ray to use
  33843. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33844. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33845. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33846. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33847. * @returns the picking info
  33848. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33849. */
  33850. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33851. /**
  33852. * Clones the current mesh
  33853. * @param name defines the mesh name
  33854. * @param newParent defines the new mesh parent
  33855. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33856. * @returns the new mesh
  33857. */
  33858. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33859. /**
  33860. * Disposes all the submeshes of the current meshnp
  33861. * @returns the current mesh
  33862. */
  33863. releaseSubMeshes(): AbstractMesh;
  33864. /**
  33865. * Releases resources associated with this abstract mesh.
  33866. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33867. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33868. */
  33869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33870. /**
  33871. * Adds the passed mesh as a child to the current mesh
  33872. * @param mesh defines the child mesh
  33873. * @returns the current mesh
  33874. */
  33875. addChild(mesh: AbstractMesh): AbstractMesh;
  33876. /**
  33877. * Removes the passed mesh from the current mesh children list
  33878. * @param mesh defines the child mesh
  33879. * @returns the current mesh
  33880. */
  33881. removeChild(mesh: AbstractMesh): AbstractMesh;
  33882. /** @hidden */
  33883. private _initFacetData;
  33884. /**
  33885. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33886. * This method can be called within the render loop.
  33887. * 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
  33888. * @returns the current mesh
  33889. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33890. */
  33891. updateFacetData(): AbstractMesh;
  33892. /**
  33893. * Returns the facetLocalNormals array.
  33894. * The normals are expressed in the mesh local spac
  33895. * @returns an array of Vector3
  33896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33897. */
  33898. getFacetLocalNormals(): Vector3[];
  33899. /**
  33900. * Returns the facetLocalPositions array.
  33901. * The facet positions are expressed in the mesh local space
  33902. * @returns an array of Vector3
  33903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33904. */
  33905. getFacetLocalPositions(): Vector3[];
  33906. /**
  33907. * Returns the facetLocalPartioning array
  33908. * @returns an array of array of numbers
  33909. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33910. */
  33911. getFacetLocalPartitioning(): number[][];
  33912. /**
  33913. * Returns the i-th facet position in the world system.
  33914. * This method allocates a new Vector3 per call
  33915. * @param i defines the facet index
  33916. * @returns a new Vector3
  33917. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33918. */
  33919. getFacetPosition(i: number): Vector3;
  33920. /**
  33921. * Sets the reference Vector3 with the i-th facet position in the world system
  33922. * @param i defines the facet index
  33923. * @param ref defines the target vector
  33924. * @returns the current mesh
  33925. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33926. */
  33927. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33928. /**
  33929. * Returns the i-th facet normal in the world system.
  33930. * This method allocates a new Vector3 per call
  33931. * @param i defines the facet index
  33932. * @returns a new Vector3
  33933. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33934. */
  33935. getFacetNormal(i: number): Vector3;
  33936. /**
  33937. * Sets the reference Vector3 with the i-th facet normal in the world system
  33938. * @param i defines the facet index
  33939. * @param ref defines the target vector
  33940. * @returns the current mesh
  33941. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33942. */
  33943. getFacetNormalToRef(i: number, ref: Vector3): this;
  33944. /**
  33945. * 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)
  33946. * @param x defines x coordinate
  33947. * @param y defines y coordinate
  33948. * @param z defines z coordinate
  33949. * @returns the array of facet indexes
  33950. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33951. */
  33952. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33953. /**
  33954. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33955. * @param projected sets as the (x,y,z) world projection on the facet
  33956. * @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
  33957. * @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
  33958. * @param x defines x coordinate
  33959. * @param y defines y coordinate
  33960. * @param z defines z coordinate
  33961. * @returns the face index if found (or null instead)
  33962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33963. */
  33964. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33965. /**
  33966. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33967. * @param projected sets as the (x,y,z) local projection on the facet
  33968. * @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
  33969. * @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
  33970. * @param x defines x coordinate
  33971. * @param y defines y coordinate
  33972. * @param z defines z coordinate
  33973. * @returns the face index if found (or null instead)
  33974. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33975. */
  33976. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33977. /**
  33978. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33979. * @returns the parameters
  33980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33981. */
  33982. getFacetDataParameters(): any;
  33983. /**
  33984. * Disables the feature FacetData and frees the related memory
  33985. * @returns the current mesh
  33986. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33987. */
  33988. disableFacetData(): AbstractMesh;
  33989. /**
  33990. * Updates the AbstractMesh indices array
  33991. * @param indices defines the data source
  33992. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33993. * @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)
  33994. * @returns the current mesh
  33995. */
  33996. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33997. /**
  33998. * Creates new normals data for the mesh
  33999. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34000. * @returns the current mesh
  34001. */
  34002. createNormals(updatable: boolean): AbstractMesh;
  34003. /**
  34004. * Align the mesh with a normal
  34005. * @param normal defines the normal to use
  34006. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34007. * @returns the current mesh
  34008. */
  34009. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34010. /** @hidden */
  34011. _checkOcclusionQuery(): boolean;
  34012. /**
  34013. * Disables the mesh edge rendering mode
  34014. * @returns the currentAbstractMesh
  34015. */
  34016. disableEdgesRendering(): AbstractMesh;
  34017. /**
  34018. * Enables the edge rendering mode on the mesh.
  34019. * This mode makes the mesh edges visible
  34020. * @param epsilon defines the maximal distance between two angles to detect a face
  34021. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34022. * @returns the currentAbstractMesh
  34023. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34024. */
  34025. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34026. /**
  34027. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34028. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34029. */
  34030. getConnectedParticleSystems(): IParticleSystem[];
  34031. }
  34032. }
  34033. declare module "babylonjs/Actions/actionEvent" {
  34034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34035. import { Nullable } from "babylonjs/types";
  34036. import { Sprite } from "babylonjs/Sprites/sprite";
  34037. import { Scene } from "babylonjs/scene";
  34038. import { Vector2 } from "babylonjs/Maths/math.vector";
  34039. /**
  34040. * Interface used to define ActionEvent
  34041. */
  34042. export interface IActionEvent {
  34043. /** The mesh or sprite that triggered the action */
  34044. source: any;
  34045. /** The X mouse cursor position at the time of the event */
  34046. pointerX: number;
  34047. /** The Y mouse cursor position at the time of the event */
  34048. pointerY: number;
  34049. /** The mesh that is currently pointed at (can be null) */
  34050. meshUnderPointer: Nullable<AbstractMesh>;
  34051. /** the original (browser) event that triggered the ActionEvent */
  34052. sourceEvent?: any;
  34053. /** additional data for the event */
  34054. additionalData?: any;
  34055. }
  34056. /**
  34057. * ActionEvent is the event being sent when an action is triggered.
  34058. */
  34059. export class ActionEvent implements IActionEvent {
  34060. /** The mesh or sprite that triggered the action */
  34061. source: any;
  34062. /** The X mouse cursor position at the time of the event */
  34063. pointerX: number;
  34064. /** The Y mouse cursor position at the time of the event */
  34065. pointerY: number;
  34066. /** The mesh that is currently pointed at (can be null) */
  34067. meshUnderPointer: Nullable<AbstractMesh>;
  34068. /** the original (browser) event that triggered the ActionEvent */
  34069. sourceEvent?: any;
  34070. /** additional data for the event */
  34071. additionalData?: any;
  34072. /**
  34073. * Creates a new ActionEvent
  34074. * @param source The mesh or sprite that triggered the action
  34075. * @param pointerX The X mouse cursor position at the time of the event
  34076. * @param pointerY The Y mouse cursor position at the time of the event
  34077. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34078. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34079. * @param additionalData additional data for the event
  34080. */
  34081. constructor(
  34082. /** The mesh or sprite that triggered the action */
  34083. source: any,
  34084. /** The X mouse cursor position at the time of the event */
  34085. pointerX: number,
  34086. /** The Y mouse cursor position at the time of the event */
  34087. pointerY: number,
  34088. /** The mesh that is currently pointed at (can be null) */
  34089. meshUnderPointer: Nullable<AbstractMesh>,
  34090. /** the original (browser) event that triggered the ActionEvent */
  34091. sourceEvent?: any,
  34092. /** additional data for the event */
  34093. additionalData?: any);
  34094. /**
  34095. * Helper function to auto-create an ActionEvent from a source mesh.
  34096. * @param source The source mesh that triggered the event
  34097. * @param evt The original (browser) event
  34098. * @param additionalData additional data for the event
  34099. * @returns the new ActionEvent
  34100. */
  34101. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34102. /**
  34103. * Helper function to auto-create an ActionEvent from a source sprite
  34104. * @param source The source sprite that triggered the event
  34105. * @param scene Scene associated with the sprite
  34106. * @param evt The original (browser) event
  34107. * @param additionalData additional data for the event
  34108. * @returns the new ActionEvent
  34109. */
  34110. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34111. /**
  34112. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34113. * @param scene the scene where the event occurred
  34114. * @param evt The original (browser) event
  34115. * @returns the new ActionEvent
  34116. */
  34117. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34118. /**
  34119. * Helper function to auto-create an ActionEvent from a primitive
  34120. * @param prim defines the target primitive
  34121. * @param pointerPos defines the pointer position
  34122. * @param evt The original (browser) event
  34123. * @param additionalData additional data for the event
  34124. * @returns the new ActionEvent
  34125. */
  34126. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34127. }
  34128. }
  34129. declare module "babylonjs/Actions/abstractActionManager" {
  34130. import { IDisposable } from "babylonjs/scene";
  34131. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34132. import { IAction } from "babylonjs/Actions/action";
  34133. import { Nullable } from "babylonjs/types";
  34134. /**
  34135. * Abstract class used to decouple action Manager from scene and meshes.
  34136. * Do not instantiate.
  34137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34138. */
  34139. export abstract class AbstractActionManager implements IDisposable {
  34140. /** Gets the list of active triggers */
  34141. static Triggers: {
  34142. [key: string]: number;
  34143. };
  34144. /** Gets the cursor to use when hovering items */
  34145. hoverCursor: string;
  34146. /** Gets the list of actions */
  34147. actions: IAction[];
  34148. /**
  34149. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34150. */
  34151. isRecursive: boolean;
  34152. /**
  34153. * Releases all associated resources
  34154. */
  34155. abstract dispose(): void;
  34156. /**
  34157. * Does this action manager has pointer triggers
  34158. */
  34159. abstract get hasPointerTriggers(): boolean;
  34160. /**
  34161. * Does this action manager has pick triggers
  34162. */
  34163. abstract get hasPickTriggers(): boolean;
  34164. /**
  34165. * Process a specific trigger
  34166. * @param trigger defines the trigger to process
  34167. * @param evt defines the event details to be processed
  34168. */
  34169. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34170. /**
  34171. * Does this action manager handles actions of any of the given triggers
  34172. * @param triggers defines the triggers to be tested
  34173. * @return a boolean indicating whether one (or more) of the triggers is handled
  34174. */
  34175. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34176. /**
  34177. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34178. * speed.
  34179. * @param triggerA defines the trigger to be tested
  34180. * @param triggerB defines the trigger to be tested
  34181. * @return a boolean indicating whether one (or more) of the triggers is handled
  34182. */
  34183. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34184. /**
  34185. * Does this action manager handles actions of a given trigger
  34186. * @param trigger defines the trigger to be tested
  34187. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34188. * @return whether the trigger is handled
  34189. */
  34190. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34191. /**
  34192. * Serialize this manager to a JSON object
  34193. * @param name defines the property name to store this manager
  34194. * @returns a JSON representation of this manager
  34195. */
  34196. abstract serialize(name: string): any;
  34197. /**
  34198. * Registers an action to this action manager
  34199. * @param action defines the action to be registered
  34200. * @return the action amended (prepared) after registration
  34201. */
  34202. abstract registerAction(action: IAction): Nullable<IAction>;
  34203. /**
  34204. * Unregisters an action to this action manager
  34205. * @param action defines the action to be unregistered
  34206. * @return a boolean indicating whether the action has been unregistered
  34207. */
  34208. abstract unregisterAction(action: IAction): Boolean;
  34209. /**
  34210. * Does exist one action manager with at least one trigger
  34211. **/
  34212. static get HasTriggers(): boolean;
  34213. /**
  34214. * Does exist one action manager with at least one pick trigger
  34215. **/
  34216. static get HasPickTriggers(): boolean;
  34217. /**
  34218. * Does exist one action manager that handles actions of a given trigger
  34219. * @param trigger defines the trigger to be tested
  34220. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34221. **/
  34222. static HasSpecificTrigger(trigger: number): boolean;
  34223. }
  34224. }
  34225. declare module "babylonjs/node" {
  34226. import { Scene } from "babylonjs/scene";
  34227. import { Nullable } from "babylonjs/types";
  34228. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34229. import { Engine } from "babylonjs/Engines/engine";
  34230. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34231. import { Observable } from "babylonjs/Misc/observable";
  34232. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34233. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34234. import { Animatable } from "babylonjs/Animations/animatable";
  34235. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34236. import { Animation } from "babylonjs/Animations/animation";
  34237. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34239. /**
  34240. * Defines how a node can be built from a string name.
  34241. */
  34242. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34243. /**
  34244. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34245. */
  34246. export class Node implements IBehaviorAware<Node> {
  34247. /** @hidden */
  34248. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34249. private static _NodeConstructors;
  34250. /**
  34251. * Add a new node constructor
  34252. * @param type defines the type name of the node to construct
  34253. * @param constructorFunc defines the constructor function
  34254. */
  34255. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34256. /**
  34257. * Returns a node constructor based on type name
  34258. * @param type defines the type name
  34259. * @param name defines the new node name
  34260. * @param scene defines the hosting scene
  34261. * @param options defines optional options to transmit to constructors
  34262. * @returns the new constructor or null
  34263. */
  34264. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34265. /**
  34266. * Gets or sets the name of the node
  34267. */
  34268. name: string;
  34269. /**
  34270. * Gets or sets the id of the node
  34271. */
  34272. id: string;
  34273. /**
  34274. * Gets or sets the unique id of the node
  34275. */
  34276. uniqueId: number;
  34277. /**
  34278. * Gets or sets a string used to store user defined state for the node
  34279. */
  34280. state: string;
  34281. /**
  34282. * Gets or sets an object used to store user defined information for the node
  34283. */
  34284. metadata: any;
  34285. /**
  34286. * For internal use only. Please do not use.
  34287. */
  34288. reservedDataStore: any;
  34289. /**
  34290. * List of inspectable custom properties (used by the Inspector)
  34291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34292. */
  34293. inspectableCustomProperties: IInspectable[];
  34294. private _doNotSerialize;
  34295. /**
  34296. * Gets or sets a boolean used to define if the node must be serialized
  34297. */
  34298. get doNotSerialize(): boolean;
  34299. set doNotSerialize(value: boolean);
  34300. /** @hidden */
  34301. _isDisposed: boolean;
  34302. /**
  34303. * Gets a list of Animations associated with the node
  34304. */
  34305. animations: import("babylonjs/Animations/animation").Animation[];
  34306. protected _ranges: {
  34307. [name: string]: Nullable<AnimationRange>;
  34308. };
  34309. /**
  34310. * Callback raised when the node is ready to be used
  34311. */
  34312. onReady: Nullable<(node: Node) => void>;
  34313. private _isEnabled;
  34314. private _isParentEnabled;
  34315. private _isReady;
  34316. /** @hidden */
  34317. _currentRenderId: number;
  34318. private _parentUpdateId;
  34319. /** @hidden */
  34320. _childUpdateId: number;
  34321. /** @hidden */
  34322. _waitingParentId: Nullable<string>;
  34323. /** @hidden */
  34324. _scene: Scene;
  34325. /** @hidden */
  34326. _cache: any;
  34327. private _parentNode;
  34328. private _children;
  34329. /** @hidden */
  34330. _worldMatrix: Matrix;
  34331. /** @hidden */
  34332. _worldMatrixDeterminant: number;
  34333. /** @hidden */
  34334. _worldMatrixDeterminantIsDirty: boolean;
  34335. /** @hidden */
  34336. private _sceneRootNodesIndex;
  34337. /**
  34338. * Gets a boolean indicating if the node has been disposed
  34339. * @returns true if the node was disposed
  34340. */
  34341. isDisposed(): boolean;
  34342. /**
  34343. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34344. * @see https://doc.babylonjs.com/how_to/parenting
  34345. */
  34346. set parent(parent: Nullable<Node>);
  34347. get parent(): Nullable<Node>;
  34348. /** @hidden */
  34349. _addToSceneRootNodes(): void;
  34350. /** @hidden */
  34351. _removeFromSceneRootNodes(): void;
  34352. private _animationPropertiesOverride;
  34353. /**
  34354. * Gets or sets the animation properties override
  34355. */
  34356. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34357. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34358. /**
  34359. * Gets a string identifying the name of the class
  34360. * @returns "Node" string
  34361. */
  34362. getClassName(): string;
  34363. /** @hidden */
  34364. readonly _isNode: boolean;
  34365. /**
  34366. * An event triggered when the mesh is disposed
  34367. */
  34368. onDisposeObservable: Observable<Node>;
  34369. private _onDisposeObserver;
  34370. /**
  34371. * Sets a callback that will be raised when the node will be disposed
  34372. */
  34373. set onDispose(callback: () => void);
  34374. /**
  34375. * Creates a new Node
  34376. * @param name the name and id to be given to this node
  34377. * @param scene the scene this node will be added to
  34378. */
  34379. constructor(name: string, scene?: Nullable<Scene>);
  34380. /**
  34381. * Gets the scene of the node
  34382. * @returns a scene
  34383. */
  34384. getScene(): Scene;
  34385. /**
  34386. * Gets the engine of the node
  34387. * @returns a Engine
  34388. */
  34389. getEngine(): Engine;
  34390. private _behaviors;
  34391. /**
  34392. * Attach a behavior to the node
  34393. * @see https://doc.babylonjs.com/features/behaviour
  34394. * @param behavior defines the behavior to attach
  34395. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34396. * @returns the current Node
  34397. */
  34398. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34399. /**
  34400. * Remove an attached behavior
  34401. * @see https://doc.babylonjs.com/features/behaviour
  34402. * @param behavior defines the behavior to attach
  34403. * @returns the current Node
  34404. */
  34405. removeBehavior(behavior: Behavior<Node>): Node;
  34406. /**
  34407. * Gets the list of attached behaviors
  34408. * @see https://doc.babylonjs.com/features/behaviour
  34409. */
  34410. get behaviors(): Behavior<Node>[];
  34411. /**
  34412. * Gets an attached behavior by name
  34413. * @param name defines the name of the behavior to look for
  34414. * @see https://doc.babylonjs.com/features/behaviour
  34415. * @returns null if behavior was not found else the requested behavior
  34416. */
  34417. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34418. /**
  34419. * Returns the latest update of the World matrix
  34420. * @returns a Matrix
  34421. */
  34422. getWorldMatrix(): Matrix;
  34423. /** @hidden */
  34424. _getWorldMatrixDeterminant(): number;
  34425. /**
  34426. * Returns directly the latest state of the mesh World matrix.
  34427. * A Matrix is returned.
  34428. */
  34429. get worldMatrixFromCache(): Matrix;
  34430. /** @hidden */
  34431. _initCache(): void;
  34432. /** @hidden */
  34433. updateCache(force?: boolean): void;
  34434. /** @hidden */
  34435. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34436. /** @hidden */
  34437. _updateCache(ignoreParentClass?: boolean): void;
  34438. /** @hidden */
  34439. _isSynchronized(): boolean;
  34440. /** @hidden */
  34441. _markSyncedWithParent(): void;
  34442. /** @hidden */
  34443. isSynchronizedWithParent(): boolean;
  34444. /** @hidden */
  34445. isSynchronized(): boolean;
  34446. /**
  34447. * Is this node ready to be used/rendered
  34448. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34449. * @return true if the node is ready
  34450. */
  34451. isReady(completeCheck?: boolean): boolean;
  34452. /**
  34453. * Is this node enabled?
  34454. * 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
  34455. * @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
  34456. * @return whether this node (and its parent) is enabled
  34457. */
  34458. isEnabled(checkAncestors?: boolean): boolean;
  34459. /** @hidden */
  34460. protected _syncParentEnabledState(): void;
  34461. /**
  34462. * Set the enabled state of this node
  34463. * @param value defines the new enabled state
  34464. */
  34465. setEnabled(value: boolean): void;
  34466. /**
  34467. * Is this node a descendant of the given node?
  34468. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34469. * @param ancestor defines the parent node to inspect
  34470. * @returns a boolean indicating if this node is a descendant of the given node
  34471. */
  34472. isDescendantOf(ancestor: Node): boolean;
  34473. /** @hidden */
  34474. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34475. /**
  34476. * Will return all nodes that have this node as ascendant
  34477. * @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
  34478. * @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
  34479. * @return all children nodes of all types
  34480. */
  34481. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34482. /**
  34483. * Get all child-meshes of this node
  34484. * @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)
  34485. * @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
  34486. * @returns an array of AbstractMesh
  34487. */
  34488. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34489. /**
  34490. * Get all direct children of this node
  34491. * @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
  34492. * @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)
  34493. * @returns an array of Node
  34494. */
  34495. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34496. /** @hidden */
  34497. _setReady(state: boolean): void;
  34498. /**
  34499. * Get an animation by name
  34500. * @param name defines the name of the animation to look for
  34501. * @returns null if not found else the requested animation
  34502. */
  34503. getAnimationByName(name: string): Nullable<Animation>;
  34504. /**
  34505. * Creates an animation range for this node
  34506. * @param name defines the name of the range
  34507. * @param from defines the starting key
  34508. * @param to defines the end key
  34509. */
  34510. createAnimationRange(name: string, from: number, to: number): void;
  34511. /**
  34512. * Delete a specific animation range
  34513. * @param name defines the name of the range to delete
  34514. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34515. */
  34516. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34517. /**
  34518. * Get an animation range by name
  34519. * @param name defines the name of the animation range to look for
  34520. * @returns null if not found else the requested animation range
  34521. */
  34522. getAnimationRange(name: string): Nullable<AnimationRange>;
  34523. /**
  34524. * Gets the list of all animation ranges defined on this node
  34525. * @returns an array
  34526. */
  34527. getAnimationRanges(): Nullable<AnimationRange>[];
  34528. /**
  34529. * Will start the animation sequence
  34530. * @param name defines the range frames for animation sequence
  34531. * @param loop defines if the animation should loop (false by default)
  34532. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34533. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34534. * @returns the object created for this animation. If range does not exist, it will return null
  34535. */
  34536. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34537. /**
  34538. * Serialize animation ranges into a JSON compatible object
  34539. * @returns serialization object
  34540. */
  34541. serializeAnimationRanges(): any;
  34542. /**
  34543. * Computes the world matrix of the node
  34544. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34545. * @returns the world matrix
  34546. */
  34547. computeWorldMatrix(force?: boolean): Matrix;
  34548. /**
  34549. * Releases resources associated with this node.
  34550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34552. */
  34553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34554. /**
  34555. * Parse animation range data from a serialization object and store them into a given node
  34556. * @param node defines where to store the animation ranges
  34557. * @param parsedNode defines the serialization object to read data from
  34558. * @param scene defines the hosting scene
  34559. */
  34560. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34561. /**
  34562. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34563. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34564. * @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
  34565. * @returns the new bounding vectors
  34566. */
  34567. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34568. min: Vector3;
  34569. max: Vector3;
  34570. };
  34571. }
  34572. }
  34573. declare module "babylonjs/Animations/animation" {
  34574. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34575. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34576. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34577. import { Nullable } from "babylonjs/types";
  34578. import { Scene } from "babylonjs/scene";
  34579. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34580. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34581. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34582. import { Node } from "babylonjs/node";
  34583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34584. import { Size } from "babylonjs/Maths/math.size";
  34585. import { Animatable } from "babylonjs/Animations/animatable";
  34586. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34587. /**
  34588. * @hidden
  34589. */
  34590. export class _IAnimationState {
  34591. key: number;
  34592. repeatCount: number;
  34593. workValue?: any;
  34594. loopMode?: number;
  34595. offsetValue?: any;
  34596. highLimitValue?: any;
  34597. }
  34598. /**
  34599. * Class used to store any kind of animation
  34600. */
  34601. export class Animation {
  34602. /**Name of the animation */
  34603. name: string;
  34604. /**Property to animate */
  34605. targetProperty: string;
  34606. /**The frames per second of the animation */
  34607. framePerSecond: number;
  34608. /**The data type of the animation */
  34609. dataType: number;
  34610. /**The loop mode of the animation */
  34611. loopMode?: number | undefined;
  34612. /**Specifies if blending should be enabled */
  34613. enableBlending?: boolean | undefined;
  34614. /**
  34615. * Use matrix interpolation instead of using direct key value when animating matrices
  34616. */
  34617. static AllowMatricesInterpolation: boolean;
  34618. /**
  34619. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34620. */
  34621. static AllowMatrixDecomposeForInterpolation: boolean;
  34622. /** Define the Url to load snippets */
  34623. static SnippetUrl: string;
  34624. /** Snippet ID if the animation was created from the snippet server */
  34625. snippetId: string;
  34626. /**
  34627. * Stores the key frames of the animation
  34628. */
  34629. private _keys;
  34630. /**
  34631. * Stores the easing function of the animation
  34632. */
  34633. private _easingFunction;
  34634. /**
  34635. * @hidden Internal use only
  34636. */
  34637. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34638. /**
  34639. * The set of event that will be linked to this animation
  34640. */
  34641. private _events;
  34642. /**
  34643. * Stores an array of target property paths
  34644. */
  34645. targetPropertyPath: string[];
  34646. /**
  34647. * Stores the blending speed of the animation
  34648. */
  34649. blendingSpeed: number;
  34650. /**
  34651. * Stores the animation ranges for the animation
  34652. */
  34653. private _ranges;
  34654. /**
  34655. * @hidden Internal use
  34656. */
  34657. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34658. /**
  34659. * Sets up an animation
  34660. * @param property The property to animate
  34661. * @param animationType The animation type to apply
  34662. * @param framePerSecond The frames per second of the animation
  34663. * @param easingFunction The easing function used in the animation
  34664. * @returns The created animation
  34665. */
  34666. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34667. /**
  34668. * Create and start an animation on a node
  34669. * @param name defines the name of the global animation that will be run on all nodes
  34670. * @param node defines the root node where the animation will take place
  34671. * @param targetProperty defines property to animate
  34672. * @param framePerSecond defines the number of frame per second yo use
  34673. * @param totalFrame defines the number of frames in total
  34674. * @param from defines the initial value
  34675. * @param to defines the final value
  34676. * @param loopMode defines which loop mode you want to use (off by default)
  34677. * @param easingFunction defines the easing function to use (linear by default)
  34678. * @param onAnimationEnd defines the callback to call when animation end
  34679. * @returns the animatable created for this animation
  34680. */
  34681. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34682. /**
  34683. * Create and start an animation on a node and its descendants
  34684. * @param name defines the name of the global animation that will be run on all nodes
  34685. * @param node defines the root node where the animation will take place
  34686. * @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
  34687. * @param targetProperty defines property to animate
  34688. * @param framePerSecond defines the number of frame per second to use
  34689. * @param totalFrame defines the number of frames in total
  34690. * @param from defines the initial value
  34691. * @param to defines the final value
  34692. * @param loopMode defines which loop mode you want to use (off by default)
  34693. * @param easingFunction defines the easing function to use (linear by default)
  34694. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34695. * @returns the list of animatables created for all nodes
  34696. * @example https://www.babylonjs-playground.com/#MH0VLI
  34697. */
  34698. 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[]>;
  34699. /**
  34700. * Creates a new animation, merges it with the existing animations and starts it
  34701. * @param name Name of the animation
  34702. * @param node Node which contains the scene that begins the animations
  34703. * @param targetProperty Specifies which property to animate
  34704. * @param framePerSecond The frames per second of the animation
  34705. * @param totalFrame The total number of frames
  34706. * @param from The frame at the beginning of the animation
  34707. * @param to The frame at the end of the animation
  34708. * @param loopMode Specifies the loop mode of the animation
  34709. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34710. * @param onAnimationEnd Callback to run once the animation is complete
  34711. * @returns Nullable animation
  34712. */
  34713. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34714. /**
  34715. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34716. * @param sourceAnimation defines the Animation containing keyframes to convert
  34717. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34718. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34719. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34720. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34721. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34722. */
  34723. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34724. /**
  34725. * Transition property of an host to the target Value
  34726. * @param property The property to transition
  34727. * @param targetValue The target Value of the property
  34728. * @param host The object where the property to animate belongs
  34729. * @param scene Scene used to run the animation
  34730. * @param frameRate Framerate (in frame/s) to use
  34731. * @param transition The transition type we want to use
  34732. * @param duration The duration of the animation, in milliseconds
  34733. * @param onAnimationEnd Callback trigger at the end of the animation
  34734. * @returns Nullable animation
  34735. */
  34736. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34737. /**
  34738. * Return the array of runtime animations currently using this animation
  34739. */
  34740. get runtimeAnimations(): RuntimeAnimation[];
  34741. /**
  34742. * Specifies if any of the runtime animations are currently running
  34743. */
  34744. get hasRunningRuntimeAnimations(): boolean;
  34745. /**
  34746. * Initializes the animation
  34747. * @param name Name of the animation
  34748. * @param targetProperty Property to animate
  34749. * @param framePerSecond The frames per second of the animation
  34750. * @param dataType The data type of the animation
  34751. * @param loopMode The loop mode of the animation
  34752. * @param enableBlending Specifies if blending should be enabled
  34753. */
  34754. constructor(
  34755. /**Name of the animation */
  34756. name: string,
  34757. /**Property to animate */
  34758. targetProperty: string,
  34759. /**The frames per second of the animation */
  34760. framePerSecond: number,
  34761. /**The data type of the animation */
  34762. dataType: number,
  34763. /**The loop mode of the animation */
  34764. loopMode?: number | undefined,
  34765. /**Specifies if blending should be enabled */
  34766. enableBlending?: boolean | undefined);
  34767. /**
  34768. * Converts the animation to a string
  34769. * @param fullDetails support for multiple levels of logging within scene loading
  34770. * @returns String form of the animation
  34771. */
  34772. toString(fullDetails?: boolean): string;
  34773. /**
  34774. * Add an event to this animation
  34775. * @param event Event to add
  34776. */
  34777. addEvent(event: AnimationEvent): void;
  34778. /**
  34779. * Remove all events found at the given frame
  34780. * @param frame The frame to remove events from
  34781. */
  34782. removeEvents(frame: number): void;
  34783. /**
  34784. * Retrieves all the events from the animation
  34785. * @returns Events from the animation
  34786. */
  34787. getEvents(): AnimationEvent[];
  34788. /**
  34789. * Creates an animation range
  34790. * @param name Name of the animation range
  34791. * @param from Starting frame of the animation range
  34792. * @param to Ending frame of the animation
  34793. */
  34794. createRange(name: string, from: number, to: number): void;
  34795. /**
  34796. * Deletes an animation range by name
  34797. * @param name Name of the animation range to delete
  34798. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34799. */
  34800. deleteRange(name: string, deleteFrames?: boolean): void;
  34801. /**
  34802. * Gets the animation range by name, or null if not defined
  34803. * @param name Name of the animation range
  34804. * @returns Nullable animation range
  34805. */
  34806. getRange(name: string): Nullable<AnimationRange>;
  34807. /**
  34808. * Gets the key frames from the animation
  34809. * @returns The key frames of the animation
  34810. */
  34811. getKeys(): Array<IAnimationKey>;
  34812. /**
  34813. * Gets the highest frame rate of the animation
  34814. * @returns Highest frame rate of the animation
  34815. */
  34816. getHighestFrame(): number;
  34817. /**
  34818. * Gets the easing function of the animation
  34819. * @returns Easing function of the animation
  34820. */
  34821. getEasingFunction(): IEasingFunction;
  34822. /**
  34823. * Sets the easing function of the animation
  34824. * @param easingFunction A custom mathematical formula for animation
  34825. */
  34826. setEasingFunction(easingFunction: EasingFunction): void;
  34827. /**
  34828. * Interpolates a scalar linearly
  34829. * @param startValue Start value of the animation curve
  34830. * @param endValue End value of the animation curve
  34831. * @param gradient Scalar amount to interpolate
  34832. * @returns Interpolated scalar value
  34833. */
  34834. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34835. /**
  34836. * Interpolates a scalar cubically
  34837. * @param startValue Start value of the animation curve
  34838. * @param outTangent End tangent of the animation
  34839. * @param endValue End value of the animation curve
  34840. * @param inTangent Start tangent of the animation curve
  34841. * @param gradient Scalar amount to interpolate
  34842. * @returns Interpolated scalar value
  34843. */
  34844. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34845. /**
  34846. * Interpolates a quaternion using a spherical linear interpolation
  34847. * @param startValue Start value of the animation curve
  34848. * @param endValue End value of the animation curve
  34849. * @param gradient Scalar amount to interpolate
  34850. * @returns Interpolated quaternion value
  34851. */
  34852. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34853. /**
  34854. * Interpolates a quaternion cubically
  34855. * @param startValue Start value of the animation curve
  34856. * @param outTangent End tangent of the animation curve
  34857. * @param endValue End value of the animation curve
  34858. * @param inTangent Start tangent of the animation curve
  34859. * @param gradient Scalar amount to interpolate
  34860. * @returns Interpolated quaternion value
  34861. */
  34862. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34863. /**
  34864. * Interpolates a Vector3 linearl
  34865. * @param startValue Start value of the animation curve
  34866. * @param endValue End value of the animation curve
  34867. * @param gradient Scalar amount to interpolate
  34868. * @returns Interpolated scalar value
  34869. */
  34870. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34871. /**
  34872. * Interpolates a Vector3 cubically
  34873. * @param startValue Start value of the animation curve
  34874. * @param outTangent End tangent of the animation
  34875. * @param endValue End value of the animation curve
  34876. * @param inTangent Start tangent of the animation curve
  34877. * @param gradient Scalar amount to interpolate
  34878. * @returns InterpolatedVector3 value
  34879. */
  34880. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34881. /**
  34882. * Interpolates a Vector2 linearly
  34883. * @param startValue Start value of the animation curve
  34884. * @param endValue End value of the animation curve
  34885. * @param gradient Scalar amount to interpolate
  34886. * @returns Interpolated Vector2 value
  34887. */
  34888. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34889. /**
  34890. * Interpolates a Vector2 cubically
  34891. * @param startValue Start value of the animation curve
  34892. * @param outTangent End tangent of the animation
  34893. * @param endValue End value of the animation curve
  34894. * @param inTangent Start tangent of the animation curve
  34895. * @param gradient Scalar amount to interpolate
  34896. * @returns Interpolated Vector2 value
  34897. */
  34898. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34899. /**
  34900. * Interpolates a size linearly
  34901. * @param startValue Start value of the animation curve
  34902. * @param endValue End value of the animation curve
  34903. * @param gradient Scalar amount to interpolate
  34904. * @returns Interpolated Size value
  34905. */
  34906. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34907. /**
  34908. * Interpolates a Color3 linearly
  34909. * @param startValue Start value of the animation curve
  34910. * @param endValue End value of the animation curve
  34911. * @param gradient Scalar amount to interpolate
  34912. * @returns Interpolated Color3 value
  34913. */
  34914. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34915. /**
  34916. * Interpolates a Color4 linearly
  34917. * @param startValue Start value of the animation curve
  34918. * @param endValue End value of the animation curve
  34919. * @param gradient Scalar amount to interpolate
  34920. * @returns Interpolated Color3 value
  34921. */
  34922. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34923. /**
  34924. * @hidden Internal use only
  34925. */
  34926. _getKeyValue(value: any): any;
  34927. /**
  34928. * @hidden Internal use only
  34929. */
  34930. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34931. /**
  34932. * Defines the function to use to interpolate matrices
  34933. * @param startValue defines the start matrix
  34934. * @param endValue defines the end matrix
  34935. * @param gradient defines the gradient between both matrices
  34936. * @param result defines an optional target matrix where to store the interpolation
  34937. * @returns the interpolated matrix
  34938. */
  34939. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34940. /**
  34941. * Makes a copy of the animation
  34942. * @returns Cloned animation
  34943. */
  34944. clone(): Animation;
  34945. /**
  34946. * Sets the key frames of the animation
  34947. * @param values The animation key frames to set
  34948. */
  34949. setKeys(values: Array<IAnimationKey>): void;
  34950. /**
  34951. * Serializes the animation to an object
  34952. * @returns Serialized object
  34953. */
  34954. serialize(): any;
  34955. /**
  34956. * Float animation type
  34957. */
  34958. static readonly ANIMATIONTYPE_FLOAT: number;
  34959. /**
  34960. * Vector3 animation type
  34961. */
  34962. static readonly ANIMATIONTYPE_VECTOR3: number;
  34963. /**
  34964. * Quaternion animation type
  34965. */
  34966. static readonly ANIMATIONTYPE_QUATERNION: number;
  34967. /**
  34968. * Matrix animation type
  34969. */
  34970. static readonly ANIMATIONTYPE_MATRIX: number;
  34971. /**
  34972. * Color3 animation type
  34973. */
  34974. static readonly ANIMATIONTYPE_COLOR3: number;
  34975. /**
  34976. * Color3 animation type
  34977. */
  34978. static readonly ANIMATIONTYPE_COLOR4: number;
  34979. /**
  34980. * Vector2 animation type
  34981. */
  34982. static readonly ANIMATIONTYPE_VECTOR2: number;
  34983. /**
  34984. * Size animation type
  34985. */
  34986. static readonly ANIMATIONTYPE_SIZE: number;
  34987. /**
  34988. * Relative Loop Mode
  34989. */
  34990. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34991. /**
  34992. * Cycle Loop Mode
  34993. */
  34994. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34995. /**
  34996. * Constant Loop Mode
  34997. */
  34998. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34999. /** @hidden */
  35000. static _UniversalLerp(left: any, right: any, amount: number): any;
  35001. /**
  35002. * Parses an animation object and creates an animation
  35003. * @param parsedAnimation Parsed animation object
  35004. * @returns Animation object
  35005. */
  35006. static Parse(parsedAnimation: any): Animation;
  35007. /**
  35008. * Appends the serialized animations from the source animations
  35009. * @param source Source containing the animations
  35010. * @param destination Target to store the animations
  35011. */
  35012. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35013. /**
  35014. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35015. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35016. * @param url defines the url to load from
  35017. * @returns a promise that will resolve to the new animation or an array of animations
  35018. */
  35019. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35020. /**
  35021. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35022. * @param snippetId defines the snippet to load
  35023. * @returns a promise that will resolve to the new animation or a new array of animations
  35024. */
  35025. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35026. }
  35027. }
  35028. declare module "babylonjs/Animations/animatable.interface" {
  35029. import { Nullable } from "babylonjs/types";
  35030. import { Animation } from "babylonjs/Animations/animation";
  35031. /**
  35032. * Interface containing an array of animations
  35033. */
  35034. export interface IAnimatable {
  35035. /**
  35036. * Array of animations
  35037. */
  35038. animations: Nullable<Array<Animation>>;
  35039. }
  35040. }
  35041. declare module "babylonjs/Misc/decorators" {
  35042. import { Nullable } from "babylonjs/types";
  35043. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35044. import { Scene } from "babylonjs/scene";
  35045. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35046. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35047. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35049. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35050. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35051. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35052. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35053. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35054. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35055. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35056. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35057. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35058. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35059. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35060. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35061. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35062. /**
  35063. * Decorator used to define property that can be serialized as reference to a camera
  35064. * @param sourceName defines the name of the property to decorate
  35065. */
  35066. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35067. /**
  35068. * Class used to help serialization objects
  35069. */
  35070. export class SerializationHelper {
  35071. /** @hidden */
  35072. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35073. /** @hidden */
  35074. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35075. /** @hidden */
  35076. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35077. /** @hidden */
  35078. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35079. /**
  35080. * Appends the serialized animations from the source animations
  35081. * @param source Source containing the animations
  35082. * @param destination Target to store the animations
  35083. */
  35084. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35085. /**
  35086. * Static function used to serialized a specific entity
  35087. * @param entity defines the entity to serialize
  35088. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35089. * @returns a JSON compatible object representing the serialization of the entity
  35090. */
  35091. static Serialize<T>(entity: T, serializationObject?: any): any;
  35092. /**
  35093. * Creates a new entity from a serialization data object
  35094. * @param creationFunction defines a function used to instanciated the new entity
  35095. * @param source defines the source serialization data
  35096. * @param scene defines the hosting scene
  35097. * @param rootUrl defines the root url for resources
  35098. * @returns a new entity
  35099. */
  35100. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35101. /**
  35102. * Clones an object
  35103. * @param creationFunction defines the function used to instanciate the new object
  35104. * @param source defines the source object
  35105. * @returns the cloned object
  35106. */
  35107. static Clone<T>(creationFunction: () => T, source: T): T;
  35108. /**
  35109. * Instanciates a new object based on a source one (some data will be shared between both object)
  35110. * @param creationFunction defines the function used to instanciate the new object
  35111. * @param source defines the source object
  35112. * @returns the new object
  35113. */
  35114. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35115. }
  35116. }
  35117. declare module "babylonjs/Materials/Textures/baseTexture" {
  35118. import { Observable } from "babylonjs/Misc/observable";
  35119. import { Nullable } from "babylonjs/types";
  35120. import { Scene } from "babylonjs/scene";
  35121. import { Matrix } from "babylonjs/Maths/math.vector";
  35122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35124. import { ISize } from "babylonjs/Maths/math.size";
  35125. import "babylonjs/Misc/fileTools";
  35126. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35127. /**
  35128. * Base class of all the textures in babylon.
  35129. * It groups all the common properties the materials, post process, lights... might need
  35130. * in order to make a correct use of the texture.
  35131. */
  35132. export class BaseTexture implements IAnimatable {
  35133. /**
  35134. * Default anisotropic filtering level for the application.
  35135. * It is set to 4 as a good tradeoff between perf and quality.
  35136. */
  35137. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35138. /**
  35139. * Gets or sets the unique id of the texture
  35140. */
  35141. uniqueId: number;
  35142. /**
  35143. * Define the name of the texture.
  35144. */
  35145. name: string;
  35146. /**
  35147. * Gets or sets an object used to store user defined information.
  35148. */
  35149. metadata: any;
  35150. /**
  35151. * For internal use only. Please do not use.
  35152. */
  35153. reservedDataStore: any;
  35154. private _hasAlpha;
  35155. /**
  35156. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35157. */
  35158. set hasAlpha(value: boolean);
  35159. get hasAlpha(): boolean;
  35160. /**
  35161. * Defines if the alpha value should be determined via the rgb values.
  35162. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35163. */
  35164. getAlphaFromRGB: boolean;
  35165. /**
  35166. * Intensity or strength of the texture.
  35167. * It is commonly used by materials to fine tune the intensity of the texture
  35168. */
  35169. level: number;
  35170. /**
  35171. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35172. * This is part of the texture as textures usually maps to one uv set.
  35173. */
  35174. coordinatesIndex: number;
  35175. protected _coordinatesMode: number;
  35176. /**
  35177. * How a texture is mapped.
  35178. *
  35179. * | Value | Type | Description |
  35180. * | ----- | ----------------------------------- | ----------- |
  35181. * | 0 | EXPLICIT_MODE | |
  35182. * | 1 | SPHERICAL_MODE | |
  35183. * | 2 | PLANAR_MODE | |
  35184. * | 3 | CUBIC_MODE | |
  35185. * | 4 | PROJECTION_MODE | |
  35186. * | 5 | SKYBOX_MODE | |
  35187. * | 6 | INVCUBIC_MODE | |
  35188. * | 7 | EQUIRECTANGULAR_MODE | |
  35189. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35190. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35191. */
  35192. set coordinatesMode(value: number);
  35193. get coordinatesMode(): number;
  35194. private _wrapU;
  35195. /**
  35196. * | Value | Type | Description |
  35197. * | ----- | ------------------ | ----------- |
  35198. * | 0 | CLAMP_ADDRESSMODE | |
  35199. * | 1 | WRAP_ADDRESSMODE | |
  35200. * | 2 | MIRROR_ADDRESSMODE | |
  35201. */
  35202. get wrapU(): number;
  35203. set wrapU(value: number);
  35204. private _wrapV;
  35205. /**
  35206. * | Value | Type | Description |
  35207. * | ----- | ------------------ | ----------- |
  35208. * | 0 | CLAMP_ADDRESSMODE | |
  35209. * | 1 | WRAP_ADDRESSMODE | |
  35210. * | 2 | MIRROR_ADDRESSMODE | |
  35211. */
  35212. get wrapV(): number;
  35213. set wrapV(value: number);
  35214. /**
  35215. * | Value | Type | Description |
  35216. * | ----- | ------------------ | ----------- |
  35217. * | 0 | CLAMP_ADDRESSMODE | |
  35218. * | 1 | WRAP_ADDRESSMODE | |
  35219. * | 2 | MIRROR_ADDRESSMODE | |
  35220. */
  35221. wrapR: number;
  35222. /**
  35223. * With compliant hardware and browser (supporting anisotropic filtering)
  35224. * this defines the level of anisotropic filtering in the texture.
  35225. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35226. */
  35227. anisotropicFilteringLevel: number;
  35228. /**
  35229. * Define if the texture is a cube texture or if false a 2d texture.
  35230. */
  35231. get isCube(): boolean;
  35232. set isCube(value: boolean);
  35233. /**
  35234. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35235. */
  35236. get is3D(): boolean;
  35237. set is3D(value: boolean);
  35238. /**
  35239. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35240. */
  35241. get is2DArray(): boolean;
  35242. set is2DArray(value: boolean);
  35243. private _gammaSpace;
  35244. /**
  35245. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35246. * HDR texture are usually stored in linear space.
  35247. * This only impacts the PBR and Background materials
  35248. */
  35249. get gammaSpace(): boolean;
  35250. set gammaSpace(gamma: boolean);
  35251. /**
  35252. * Gets or sets whether or not the texture contains RGBD data.
  35253. */
  35254. get isRGBD(): boolean;
  35255. set isRGBD(value: boolean);
  35256. /**
  35257. * Is Z inverted in the texture (useful in a cube texture).
  35258. */
  35259. invertZ: boolean;
  35260. /**
  35261. * Are mip maps generated for this texture or not.
  35262. */
  35263. get noMipmap(): boolean;
  35264. /**
  35265. * @hidden
  35266. */
  35267. lodLevelInAlpha: boolean;
  35268. /**
  35269. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35270. */
  35271. get lodGenerationOffset(): number;
  35272. set lodGenerationOffset(value: number);
  35273. /**
  35274. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35275. */
  35276. get lodGenerationScale(): number;
  35277. set lodGenerationScale(value: number);
  35278. /**
  35279. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35280. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35281. * average roughness values.
  35282. */
  35283. get linearSpecularLOD(): boolean;
  35284. set linearSpecularLOD(value: boolean);
  35285. /**
  35286. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35287. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35288. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35289. */
  35290. get irradianceTexture(): Nullable<BaseTexture>;
  35291. set irradianceTexture(value: Nullable<BaseTexture>);
  35292. /**
  35293. * Define if the texture is a render target.
  35294. */
  35295. isRenderTarget: boolean;
  35296. /**
  35297. * Define the unique id of the texture in the scene.
  35298. */
  35299. get uid(): string;
  35300. /** @hidden */
  35301. _prefiltered: boolean;
  35302. /**
  35303. * Return a string representation of the texture.
  35304. * @returns the texture as a string
  35305. */
  35306. toString(): string;
  35307. /**
  35308. * Get the class name of the texture.
  35309. * @returns "BaseTexture"
  35310. */
  35311. getClassName(): string;
  35312. /**
  35313. * Define the list of animation attached to the texture.
  35314. */
  35315. animations: import("babylonjs/Animations/animation").Animation[];
  35316. /**
  35317. * An event triggered when the texture is disposed.
  35318. */
  35319. onDisposeObservable: Observable<BaseTexture>;
  35320. private _onDisposeObserver;
  35321. /**
  35322. * Callback triggered when the texture has been disposed.
  35323. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35324. */
  35325. set onDispose(callback: () => void);
  35326. /**
  35327. * Define the current state of the loading sequence when in delayed load mode.
  35328. */
  35329. delayLoadState: number;
  35330. protected _scene: Nullable<Scene>;
  35331. protected _engine: Nullable<ThinEngine>;
  35332. /** @hidden */
  35333. _texture: Nullable<InternalTexture>;
  35334. private _uid;
  35335. /**
  35336. * Define if the texture is preventinga material to render or not.
  35337. * If not and the texture is not ready, the engine will use a default black texture instead.
  35338. */
  35339. get isBlocking(): boolean;
  35340. /**
  35341. * Instantiates a new BaseTexture.
  35342. * Base class of all the textures in babylon.
  35343. * It groups all the common properties the materials, post process, lights... might need
  35344. * in order to make a correct use of the texture.
  35345. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35346. */
  35347. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35348. /**
  35349. * Get the scene the texture belongs to.
  35350. * @returns the scene or null if undefined
  35351. */
  35352. getScene(): Nullable<Scene>;
  35353. /** @hidden */
  35354. protected _getEngine(): Nullable<ThinEngine>;
  35355. /**
  35356. * Get the texture transform matrix used to offset tile the texture for istance.
  35357. * @returns the transformation matrix
  35358. */
  35359. getTextureMatrix(): Matrix;
  35360. /**
  35361. * Get the texture reflection matrix used to rotate/transform the reflection.
  35362. * @returns the reflection matrix
  35363. */
  35364. getReflectionTextureMatrix(): Matrix;
  35365. /**
  35366. * Get the underlying lower level texture from Babylon.
  35367. * @returns the insternal texture
  35368. */
  35369. getInternalTexture(): Nullable<InternalTexture>;
  35370. /**
  35371. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35372. * @returns true if ready or not blocking
  35373. */
  35374. isReadyOrNotBlocking(): boolean;
  35375. /**
  35376. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35377. * @returns true if fully ready
  35378. */
  35379. isReady(): boolean;
  35380. private _cachedSize;
  35381. /**
  35382. * Get the size of the texture.
  35383. * @returns the texture size.
  35384. */
  35385. getSize(): ISize;
  35386. /**
  35387. * Get the base size of the texture.
  35388. * It can be different from the size if the texture has been resized for POT for instance
  35389. * @returns the base size
  35390. */
  35391. getBaseSize(): ISize;
  35392. /**
  35393. * Update the sampling mode of the texture.
  35394. * Default is Trilinear mode.
  35395. *
  35396. * | Value | Type | Description |
  35397. * | ----- | ------------------ | ----------- |
  35398. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35399. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35400. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35401. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35402. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35403. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35404. * | 7 | NEAREST_LINEAR | |
  35405. * | 8 | NEAREST_NEAREST | |
  35406. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35407. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35408. * | 11 | LINEAR_LINEAR | |
  35409. * | 12 | LINEAR_NEAREST | |
  35410. *
  35411. * > _mag_: magnification filter (close to the viewer)
  35412. * > _min_: minification filter (far from the viewer)
  35413. * > _mip_: filter used between mip map levels
  35414. *@param samplingMode Define the new sampling mode of the texture
  35415. */
  35416. updateSamplingMode(samplingMode: number): void;
  35417. /**
  35418. * Scales the texture if is `canRescale()`
  35419. * @param ratio the resize factor we want to use to rescale
  35420. */
  35421. scale(ratio: number): void;
  35422. /**
  35423. * Get if the texture can rescale.
  35424. */
  35425. get canRescale(): boolean;
  35426. /** @hidden */
  35427. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35428. /** @hidden */
  35429. _rebuild(): void;
  35430. /**
  35431. * Triggers the load sequence in delayed load mode.
  35432. */
  35433. delayLoad(): void;
  35434. /**
  35435. * Clones the texture.
  35436. * @returns the cloned texture
  35437. */
  35438. clone(): Nullable<BaseTexture>;
  35439. /**
  35440. * Get the texture underlying type (INT, FLOAT...)
  35441. */
  35442. get textureType(): number;
  35443. /**
  35444. * Get the texture underlying format (RGB, RGBA...)
  35445. */
  35446. get textureFormat(): number;
  35447. /**
  35448. * Indicates that textures need to be re-calculated for all materials
  35449. */
  35450. protected _markAllSubMeshesAsTexturesDirty(): void;
  35451. /**
  35452. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35453. * This will returns an RGBA array buffer containing either in values (0-255) or
  35454. * float values (0-1) depending of the underlying buffer type.
  35455. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35456. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35457. * @param buffer defines a user defined buffer to fill with data (can be null)
  35458. * @returns The Array buffer containing the pixels data.
  35459. */
  35460. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35461. /**
  35462. * Release and destroy the underlying lower level texture aka internalTexture.
  35463. */
  35464. releaseInternalTexture(): void;
  35465. /** @hidden */
  35466. get _lodTextureHigh(): Nullable<BaseTexture>;
  35467. /** @hidden */
  35468. get _lodTextureMid(): Nullable<BaseTexture>;
  35469. /** @hidden */
  35470. get _lodTextureLow(): Nullable<BaseTexture>;
  35471. /**
  35472. * Dispose the texture and release its associated resources.
  35473. */
  35474. dispose(): void;
  35475. /**
  35476. * Serialize the texture into a JSON representation that can be parsed later on.
  35477. * @returns the JSON representation of the texture
  35478. */
  35479. serialize(): any;
  35480. /**
  35481. * Helper function to be called back once a list of texture contains only ready textures.
  35482. * @param textures Define the list of textures to wait for
  35483. * @param callback Define the callback triggered once the entire list will be ready
  35484. */
  35485. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35486. private static _isScene;
  35487. }
  35488. }
  35489. declare module "babylonjs/Materials/effect" {
  35490. import { Observable } from "babylonjs/Misc/observable";
  35491. import { Nullable } from "babylonjs/types";
  35492. import { IDisposable } from "babylonjs/scene";
  35493. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35495. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35496. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35497. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35498. import { Engine } from "babylonjs/Engines/engine";
  35499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35501. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35502. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35503. /**
  35504. * Options to be used when creating an effect.
  35505. */
  35506. export interface IEffectCreationOptions {
  35507. /**
  35508. * Atrributes that will be used in the shader.
  35509. */
  35510. attributes: string[];
  35511. /**
  35512. * Uniform varible names that will be set in the shader.
  35513. */
  35514. uniformsNames: string[];
  35515. /**
  35516. * Uniform buffer variable names that will be set in the shader.
  35517. */
  35518. uniformBuffersNames: string[];
  35519. /**
  35520. * Sampler texture variable names that will be set in the shader.
  35521. */
  35522. samplers: string[];
  35523. /**
  35524. * Define statements that will be set in the shader.
  35525. */
  35526. defines: any;
  35527. /**
  35528. * Possible fallbacks for this effect to improve performance when needed.
  35529. */
  35530. fallbacks: Nullable<IEffectFallbacks>;
  35531. /**
  35532. * Callback that will be called when the shader is compiled.
  35533. */
  35534. onCompiled: Nullable<(effect: Effect) => void>;
  35535. /**
  35536. * Callback that will be called if an error occurs during shader compilation.
  35537. */
  35538. onError: Nullable<(effect: Effect, errors: string) => void>;
  35539. /**
  35540. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35541. */
  35542. indexParameters?: any;
  35543. /**
  35544. * Max number of lights that can be used in the shader.
  35545. */
  35546. maxSimultaneousLights?: number;
  35547. /**
  35548. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35549. */
  35550. transformFeedbackVaryings?: Nullable<string[]>;
  35551. /**
  35552. * 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
  35553. */
  35554. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35555. /**
  35556. * Is this effect rendering to several color attachments ?
  35557. */
  35558. multiTarget?: boolean;
  35559. }
  35560. /**
  35561. * Effect containing vertex and fragment shader that can be executed on an object.
  35562. */
  35563. export class Effect implements IDisposable {
  35564. /**
  35565. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35566. */
  35567. static ShadersRepository: string;
  35568. /**
  35569. * Enable logging of the shader code when a compilation error occurs
  35570. */
  35571. static LogShaderCodeOnCompilationError: boolean;
  35572. /**
  35573. * Name of the effect.
  35574. */
  35575. name: any;
  35576. /**
  35577. * String container all the define statements that should be set on the shader.
  35578. */
  35579. defines: string;
  35580. /**
  35581. * Callback that will be called when the shader is compiled.
  35582. */
  35583. onCompiled: Nullable<(effect: Effect) => void>;
  35584. /**
  35585. * Callback that will be called if an error occurs during shader compilation.
  35586. */
  35587. onError: Nullable<(effect: Effect, errors: string) => void>;
  35588. /**
  35589. * Callback that will be called when effect is bound.
  35590. */
  35591. onBind: Nullable<(effect: Effect) => void>;
  35592. /**
  35593. * Unique ID of the effect.
  35594. */
  35595. uniqueId: number;
  35596. /**
  35597. * Observable that will be called when the shader is compiled.
  35598. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35599. */
  35600. onCompileObservable: Observable<Effect>;
  35601. /**
  35602. * Observable that will be called if an error occurs during shader compilation.
  35603. */
  35604. onErrorObservable: Observable<Effect>;
  35605. /** @hidden */
  35606. _onBindObservable: Nullable<Observable<Effect>>;
  35607. /**
  35608. * @hidden
  35609. * Specifies if the effect was previously ready
  35610. */
  35611. _wasPreviouslyReady: boolean;
  35612. /**
  35613. * Observable that will be called when effect is bound.
  35614. */
  35615. get onBindObservable(): Observable<Effect>;
  35616. /** @hidden */
  35617. _bonesComputationForcedToCPU: boolean;
  35618. /** @hidden */
  35619. _multiTarget: boolean;
  35620. private static _uniqueIdSeed;
  35621. private _engine;
  35622. private _uniformBuffersNames;
  35623. private _uniformBuffersNamesList;
  35624. private _uniformsNames;
  35625. private _samplerList;
  35626. private _samplers;
  35627. private _isReady;
  35628. private _compilationError;
  35629. private _allFallbacksProcessed;
  35630. private _attributesNames;
  35631. private _attributes;
  35632. private _attributeLocationByName;
  35633. private _uniforms;
  35634. /**
  35635. * Key for the effect.
  35636. * @hidden
  35637. */
  35638. _key: string;
  35639. private _indexParameters;
  35640. private _fallbacks;
  35641. private _vertexSourceCode;
  35642. private _fragmentSourceCode;
  35643. private _vertexSourceCodeOverride;
  35644. private _fragmentSourceCodeOverride;
  35645. private _transformFeedbackVaryings;
  35646. /**
  35647. * Compiled shader to webGL program.
  35648. * @hidden
  35649. */
  35650. _pipelineContext: Nullable<IPipelineContext>;
  35651. private _valueCache;
  35652. private static _baseCache;
  35653. /**
  35654. * Instantiates an effect.
  35655. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35656. * @param baseName Name of the effect.
  35657. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35658. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35659. * @param samplers List of sampler variables that will be passed to the shader.
  35660. * @param engine Engine to be used to render the effect
  35661. * @param defines Define statements to be added to the shader.
  35662. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35663. * @param onCompiled Callback that will be called when the shader is compiled.
  35664. * @param onError Callback that will be called if an error occurs during shader compilation.
  35665. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35666. */
  35667. 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);
  35668. private _useFinalCode;
  35669. /**
  35670. * Unique key for this effect
  35671. */
  35672. get key(): string;
  35673. /**
  35674. * If the effect has been compiled and prepared.
  35675. * @returns if the effect is compiled and prepared.
  35676. */
  35677. isReady(): boolean;
  35678. private _isReadyInternal;
  35679. /**
  35680. * The engine the effect was initialized with.
  35681. * @returns the engine.
  35682. */
  35683. getEngine(): Engine;
  35684. /**
  35685. * The pipeline context for this effect
  35686. * @returns the associated pipeline context
  35687. */
  35688. getPipelineContext(): Nullable<IPipelineContext>;
  35689. /**
  35690. * The set of names of attribute variables for the shader.
  35691. * @returns An array of attribute names.
  35692. */
  35693. getAttributesNames(): string[];
  35694. /**
  35695. * Returns the attribute at the given index.
  35696. * @param index The index of the attribute.
  35697. * @returns The location of the attribute.
  35698. */
  35699. getAttributeLocation(index: number): number;
  35700. /**
  35701. * Returns the attribute based on the name of the variable.
  35702. * @param name of the attribute to look up.
  35703. * @returns the attribute location.
  35704. */
  35705. getAttributeLocationByName(name: string): number;
  35706. /**
  35707. * The number of attributes.
  35708. * @returns the numnber of attributes.
  35709. */
  35710. getAttributesCount(): number;
  35711. /**
  35712. * Gets the index of a uniform variable.
  35713. * @param uniformName of the uniform to look up.
  35714. * @returns the index.
  35715. */
  35716. getUniformIndex(uniformName: string): number;
  35717. /**
  35718. * Returns the attribute based on the name of the variable.
  35719. * @param uniformName of the uniform to look up.
  35720. * @returns the location of the uniform.
  35721. */
  35722. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35723. /**
  35724. * Returns an array of sampler variable names
  35725. * @returns The array of sampler variable names.
  35726. */
  35727. getSamplers(): string[];
  35728. /**
  35729. * Returns an array of uniform variable names
  35730. * @returns The array of uniform variable names.
  35731. */
  35732. getUniformNames(): string[];
  35733. /**
  35734. * Returns an array of uniform buffer variable names
  35735. * @returns The array of uniform buffer variable names.
  35736. */
  35737. getUniformBuffersNames(): string[];
  35738. /**
  35739. * Returns the index parameters used to create the effect
  35740. * @returns The index parameters object
  35741. */
  35742. getIndexParameters(): any;
  35743. /**
  35744. * The error from the last compilation.
  35745. * @returns the error string.
  35746. */
  35747. getCompilationError(): string;
  35748. /**
  35749. * Gets a boolean indicating that all fallbacks were used during compilation
  35750. * @returns true if all fallbacks were used
  35751. */
  35752. allFallbacksProcessed(): boolean;
  35753. /**
  35754. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35755. * @param func The callback to be used.
  35756. */
  35757. executeWhenCompiled(func: (effect: Effect) => void): void;
  35758. private _checkIsReady;
  35759. private _loadShader;
  35760. /**
  35761. * Gets the vertex shader source code of this effect
  35762. */
  35763. get vertexSourceCode(): string;
  35764. /**
  35765. * Gets the fragment shader source code of this effect
  35766. */
  35767. get fragmentSourceCode(): string;
  35768. /**
  35769. * Recompiles the webGL program
  35770. * @param vertexSourceCode The source code for the vertex shader.
  35771. * @param fragmentSourceCode The source code for the fragment shader.
  35772. * @param onCompiled Callback called when completed.
  35773. * @param onError Callback called on error.
  35774. * @hidden
  35775. */
  35776. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35777. /**
  35778. * Prepares the effect
  35779. * @hidden
  35780. */
  35781. _prepareEffect(): void;
  35782. private _getShaderCodeAndErrorLine;
  35783. private _processCompilationErrors;
  35784. /**
  35785. * Checks if the effect is supported. (Must be called after compilation)
  35786. */
  35787. get isSupported(): boolean;
  35788. /**
  35789. * Binds a texture to the engine to be used as output of the shader.
  35790. * @param channel Name of the output variable.
  35791. * @param texture Texture to bind.
  35792. * @hidden
  35793. */
  35794. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35795. /**
  35796. * Sets a texture on the engine to be used in the shader.
  35797. * @param channel Name of the sampler variable.
  35798. * @param texture Texture to set.
  35799. */
  35800. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35801. /**
  35802. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35803. * @param channel Name of the sampler variable.
  35804. * @param texture Texture to set.
  35805. */
  35806. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35807. /**
  35808. * Sets an array of textures on the engine to be used in the shader.
  35809. * @param channel Name of the variable.
  35810. * @param textures Textures to set.
  35811. */
  35812. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35813. /**
  35814. * 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)
  35815. * @param channel Name of the sampler variable.
  35816. * @param postProcess Post process to get the input texture from.
  35817. */
  35818. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35819. /**
  35820. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35821. * 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)
  35822. * @param channel Name of the sampler variable.
  35823. * @param postProcess Post process to get the output texture from.
  35824. */
  35825. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35826. /** @hidden */
  35827. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35828. /** @hidden */
  35829. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35830. /** @hidden */
  35831. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35832. /** @hidden */
  35833. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35834. /**
  35835. * Binds a buffer to a uniform.
  35836. * @param buffer Buffer to bind.
  35837. * @param name Name of the uniform variable to bind to.
  35838. */
  35839. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35840. /**
  35841. * Binds block to a uniform.
  35842. * @param blockName Name of the block to bind.
  35843. * @param index Index to bind.
  35844. */
  35845. bindUniformBlock(blockName: string, index: number): void;
  35846. /**
  35847. * Sets an interger value on a uniform variable.
  35848. * @param uniformName Name of the variable.
  35849. * @param value Value to be set.
  35850. * @returns this effect.
  35851. */
  35852. setInt(uniformName: string, value: number): Effect;
  35853. /**
  35854. * Sets an int array on a uniform variable.
  35855. * @param uniformName Name of the variable.
  35856. * @param array array to be set.
  35857. * @returns this effect.
  35858. */
  35859. setIntArray(uniformName: string, array: Int32Array): Effect;
  35860. /**
  35861. * 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)
  35862. * @param uniformName Name of the variable.
  35863. * @param array array to be set.
  35864. * @returns this effect.
  35865. */
  35866. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35867. /**
  35868. * 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)
  35869. * @param uniformName Name of the variable.
  35870. * @param array array to be set.
  35871. * @returns this effect.
  35872. */
  35873. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35874. /**
  35875. * 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)
  35876. * @param uniformName Name of the variable.
  35877. * @param array array to be set.
  35878. * @returns this effect.
  35879. */
  35880. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35881. /**
  35882. * Sets an float array on a uniform variable.
  35883. * @param uniformName Name of the variable.
  35884. * @param array array to be set.
  35885. * @returns this effect.
  35886. */
  35887. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35888. /**
  35889. * 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)
  35890. * @param uniformName Name of the variable.
  35891. * @param array array to be set.
  35892. * @returns this effect.
  35893. */
  35894. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35895. /**
  35896. * 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)
  35897. * @param uniformName Name of the variable.
  35898. * @param array array to be set.
  35899. * @returns this effect.
  35900. */
  35901. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35902. /**
  35903. * 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)
  35904. * @param uniformName Name of the variable.
  35905. * @param array array to be set.
  35906. * @returns this effect.
  35907. */
  35908. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35909. /**
  35910. * Sets an array on a uniform variable.
  35911. * @param uniformName Name of the variable.
  35912. * @param array array to be set.
  35913. * @returns this effect.
  35914. */
  35915. setArray(uniformName: string, array: number[]): Effect;
  35916. /**
  35917. * 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)
  35918. * @param uniformName Name of the variable.
  35919. * @param array array to be set.
  35920. * @returns this effect.
  35921. */
  35922. setArray2(uniformName: string, array: number[]): Effect;
  35923. /**
  35924. * 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)
  35925. * @param uniformName Name of the variable.
  35926. * @param array array to be set.
  35927. * @returns this effect.
  35928. */
  35929. setArray3(uniformName: string, array: number[]): Effect;
  35930. /**
  35931. * 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)
  35932. * @param uniformName Name of the variable.
  35933. * @param array array to be set.
  35934. * @returns this effect.
  35935. */
  35936. setArray4(uniformName: string, array: number[]): Effect;
  35937. /**
  35938. * Sets matrices on a uniform variable.
  35939. * @param uniformName Name of the variable.
  35940. * @param matrices matrices to be set.
  35941. * @returns this effect.
  35942. */
  35943. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35944. /**
  35945. * Sets matrix on a uniform variable.
  35946. * @param uniformName Name of the variable.
  35947. * @param matrix matrix to be set.
  35948. * @returns this effect.
  35949. */
  35950. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35951. /**
  35952. * 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)
  35953. * @param uniformName Name of the variable.
  35954. * @param matrix matrix to be set.
  35955. * @returns this effect.
  35956. */
  35957. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35958. /**
  35959. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35960. * @param uniformName Name of the variable.
  35961. * @param matrix matrix to be set.
  35962. * @returns this effect.
  35963. */
  35964. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35965. /**
  35966. * Sets a float on a uniform variable.
  35967. * @param uniformName Name of the variable.
  35968. * @param value value to be set.
  35969. * @returns this effect.
  35970. */
  35971. setFloat(uniformName: string, value: number): Effect;
  35972. /**
  35973. * Sets a boolean on a uniform variable.
  35974. * @param uniformName Name of the variable.
  35975. * @param bool value to be set.
  35976. * @returns this effect.
  35977. */
  35978. setBool(uniformName: string, bool: boolean): Effect;
  35979. /**
  35980. * Sets a Vector2 on a uniform variable.
  35981. * @param uniformName Name of the variable.
  35982. * @param vector2 vector2 to be set.
  35983. * @returns this effect.
  35984. */
  35985. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35986. /**
  35987. * Sets a float2 on a uniform variable.
  35988. * @param uniformName Name of the variable.
  35989. * @param x First float in float2.
  35990. * @param y Second float in float2.
  35991. * @returns this effect.
  35992. */
  35993. setFloat2(uniformName: string, x: number, y: number): Effect;
  35994. /**
  35995. * Sets a Vector3 on a uniform variable.
  35996. * @param uniformName Name of the variable.
  35997. * @param vector3 Value to be set.
  35998. * @returns this effect.
  35999. */
  36000. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36001. /**
  36002. * Sets a float3 on a uniform variable.
  36003. * @param uniformName Name of the variable.
  36004. * @param x First float in float3.
  36005. * @param y Second float in float3.
  36006. * @param z Third float in float3.
  36007. * @returns this effect.
  36008. */
  36009. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36010. /**
  36011. * Sets a Vector4 on a uniform variable.
  36012. * @param uniformName Name of the variable.
  36013. * @param vector4 Value to be set.
  36014. * @returns this effect.
  36015. */
  36016. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36017. /**
  36018. * Sets a float4 on a uniform variable.
  36019. * @param uniformName Name of the variable.
  36020. * @param x First float in float4.
  36021. * @param y Second float in float4.
  36022. * @param z Third float in float4.
  36023. * @param w Fourth float in float4.
  36024. * @returns this effect.
  36025. */
  36026. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36027. /**
  36028. * Sets a Color3 on a uniform variable.
  36029. * @param uniformName Name of the variable.
  36030. * @param color3 Value to be set.
  36031. * @returns this effect.
  36032. */
  36033. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36034. /**
  36035. * Sets a Color4 on a uniform variable.
  36036. * @param uniformName Name of the variable.
  36037. * @param color3 Value to be set.
  36038. * @param alpha Alpha value to be set.
  36039. * @returns this effect.
  36040. */
  36041. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36042. /**
  36043. * Sets a Color4 on a uniform variable
  36044. * @param uniformName defines the name of the variable
  36045. * @param color4 defines the value to be set
  36046. * @returns this effect.
  36047. */
  36048. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36049. /** Release all associated resources */
  36050. dispose(): void;
  36051. /**
  36052. * This function will add a new shader to the shader store
  36053. * @param name the name of the shader
  36054. * @param pixelShader optional pixel shader content
  36055. * @param vertexShader optional vertex shader content
  36056. */
  36057. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36058. /**
  36059. * Store of each shader (The can be looked up using effect.key)
  36060. */
  36061. static ShadersStore: {
  36062. [key: string]: string;
  36063. };
  36064. /**
  36065. * Store of each included file for a shader (The can be looked up using effect.key)
  36066. */
  36067. static IncludesShadersStore: {
  36068. [key: string]: string;
  36069. };
  36070. /**
  36071. * Resets the cache of effects.
  36072. */
  36073. static ResetCache(): void;
  36074. }
  36075. }
  36076. declare module "babylonjs/Engines/engineCapabilities" {
  36077. /**
  36078. * Interface used to describe the capabilities of the engine relatively to the current browser
  36079. */
  36080. export interface EngineCapabilities {
  36081. /** Maximum textures units per fragment shader */
  36082. maxTexturesImageUnits: number;
  36083. /** Maximum texture units per vertex shader */
  36084. maxVertexTextureImageUnits: number;
  36085. /** Maximum textures units in the entire pipeline */
  36086. maxCombinedTexturesImageUnits: number;
  36087. /** Maximum texture size */
  36088. maxTextureSize: number;
  36089. /** Maximum texture samples */
  36090. maxSamples?: number;
  36091. /** Maximum cube texture size */
  36092. maxCubemapTextureSize: number;
  36093. /** Maximum render texture size */
  36094. maxRenderTextureSize: number;
  36095. /** Maximum number of vertex attributes */
  36096. maxVertexAttribs: number;
  36097. /** Maximum number of varyings */
  36098. maxVaryingVectors: number;
  36099. /** Maximum number of uniforms per vertex shader */
  36100. maxVertexUniformVectors: number;
  36101. /** Maximum number of uniforms per fragment shader */
  36102. maxFragmentUniformVectors: number;
  36103. /** Defines if standard derivates (dx/dy) are supported */
  36104. standardDerivatives: boolean;
  36105. /** Defines if s3tc texture compression is supported */
  36106. s3tc?: WEBGL_compressed_texture_s3tc;
  36107. /** Defines if pvrtc texture compression is supported */
  36108. pvrtc: any;
  36109. /** Defines if etc1 texture compression is supported */
  36110. etc1: any;
  36111. /** Defines if etc2 texture compression is supported */
  36112. etc2: any;
  36113. /** Defines if astc texture compression is supported */
  36114. astc: any;
  36115. /** Defines if bptc texture compression is supported */
  36116. bptc: any;
  36117. /** Defines if float textures are supported */
  36118. textureFloat: boolean;
  36119. /** Defines if vertex array objects are supported */
  36120. vertexArrayObject: boolean;
  36121. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36122. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36123. /** Gets the maximum level of anisotropy supported */
  36124. maxAnisotropy: number;
  36125. /** Defines if instancing is supported */
  36126. instancedArrays: boolean;
  36127. /** Defines if 32 bits indices are supported */
  36128. uintIndices: boolean;
  36129. /** Defines if high precision shaders are supported */
  36130. highPrecisionShaderSupported: boolean;
  36131. /** Defines if depth reading in the fragment shader is supported */
  36132. fragmentDepthSupported: boolean;
  36133. /** Defines if float texture linear filtering is supported*/
  36134. textureFloatLinearFiltering: boolean;
  36135. /** Defines if rendering to float textures is supported */
  36136. textureFloatRender: boolean;
  36137. /** Defines if half float textures are supported*/
  36138. textureHalfFloat: boolean;
  36139. /** Defines if half float texture linear filtering is supported*/
  36140. textureHalfFloatLinearFiltering: boolean;
  36141. /** Defines if rendering to half float textures is supported */
  36142. textureHalfFloatRender: boolean;
  36143. /** Defines if textureLOD shader command is supported */
  36144. textureLOD: boolean;
  36145. /** Defines if draw buffers extension is supported */
  36146. drawBuffersExtension: boolean;
  36147. /** Defines if depth textures are supported */
  36148. depthTextureExtension: boolean;
  36149. /** Defines if float color buffer are supported */
  36150. colorBufferFloat: boolean;
  36151. /** Gets disjoint timer query extension (null if not supported) */
  36152. timerQuery?: EXT_disjoint_timer_query;
  36153. /** Defines if timestamp can be used with timer query */
  36154. canUseTimestampForTimerQuery: boolean;
  36155. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36156. multiview?: any;
  36157. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36158. oculusMultiview?: any;
  36159. /** Function used to let the system compiles shaders in background */
  36160. parallelShaderCompile?: {
  36161. COMPLETION_STATUS_KHR: number;
  36162. };
  36163. /** Max number of texture samples for MSAA */
  36164. maxMSAASamples: number;
  36165. /** Defines if the blend min max extension is supported */
  36166. blendMinMax: boolean;
  36167. }
  36168. }
  36169. declare module "babylonjs/States/depthCullingState" {
  36170. import { Nullable } from "babylonjs/types";
  36171. /**
  36172. * @hidden
  36173. **/
  36174. export class DepthCullingState {
  36175. private _isDepthTestDirty;
  36176. private _isDepthMaskDirty;
  36177. private _isDepthFuncDirty;
  36178. private _isCullFaceDirty;
  36179. private _isCullDirty;
  36180. private _isZOffsetDirty;
  36181. private _isFrontFaceDirty;
  36182. private _depthTest;
  36183. private _depthMask;
  36184. private _depthFunc;
  36185. private _cull;
  36186. private _cullFace;
  36187. private _zOffset;
  36188. private _frontFace;
  36189. /**
  36190. * Initializes the state.
  36191. */
  36192. constructor();
  36193. get isDirty(): boolean;
  36194. get zOffset(): number;
  36195. set zOffset(value: number);
  36196. get cullFace(): Nullable<number>;
  36197. set cullFace(value: Nullable<number>);
  36198. get cull(): Nullable<boolean>;
  36199. set cull(value: Nullable<boolean>);
  36200. get depthFunc(): Nullable<number>;
  36201. set depthFunc(value: Nullable<number>);
  36202. get depthMask(): boolean;
  36203. set depthMask(value: boolean);
  36204. get depthTest(): boolean;
  36205. set depthTest(value: boolean);
  36206. get frontFace(): Nullable<number>;
  36207. set frontFace(value: Nullable<number>);
  36208. reset(): void;
  36209. apply(gl: WebGLRenderingContext): void;
  36210. }
  36211. }
  36212. declare module "babylonjs/States/stencilState" {
  36213. /**
  36214. * @hidden
  36215. **/
  36216. export class StencilState {
  36217. /** 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 */
  36218. static readonly ALWAYS: number;
  36219. /** Passed to stencilOperation to specify that stencil value must be kept */
  36220. static readonly KEEP: number;
  36221. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36222. static readonly REPLACE: number;
  36223. private _isStencilTestDirty;
  36224. private _isStencilMaskDirty;
  36225. private _isStencilFuncDirty;
  36226. private _isStencilOpDirty;
  36227. private _stencilTest;
  36228. private _stencilMask;
  36229. private _stencilFunc;
  36230. private _stencilFuncRef;
  36231. private _stencilFuncMask;
  36232. private _stencilOpStencilFail;
  36233. private _stencilOpDepthFail;
  36234. private _stencilOpStencilDepthPass;
  36235. get isDirty(): boolean;
  36236. get stencilFunc(): number;
  36237. set stencilFunc(value: number);
  36238. get stencilFuncRef(): number;
  36239. set stencilFuncRef(value: number);
  36240. get stencilFuncMask(): number;
  36241. set stencilFuncMask(value: number);
  36242. get stencilOpStencilFail(): number;
  36243. set stencilOpStencilFail(value: number);
  36244. get stencilOpDepthFail(): number;
  36245. set stencilOpDepthFail(value: number);
  36246. get stencilOpStencilDepthPass(): number;
  36247. set stencilOpStencilDepthPass(value: number);
  36248. get stencilMask(): number;
  36249. set stencilMask(value: number);
  36250. get stencilTest(): boolean;
  36251. set stencilTest(value: boolean);
  36252. constructor();
  36253. reset(): void;
  36254. apply(gl: WebGLRenderingContext): void;
  36255. }
  36256. }
  36257. declare module "babylonjs/States/alphaCullingState" {
  36258. /**
  36259. * @hidden
  36260. **/
  36261. export class AlphaState {
  36262. private _isAlphaBlendDirty;
  36263. private _isBlendFunctionParametersDirty;
  36264. private _isBlendEquationParametersDirty;
  36265. private _isBlendConstantsDirty;
  36266. private _alphaBlend;
  36267. private _blendFunctionParameters;
  36268. private _blendEquationParameters;
  36269. private _blendConstants;
  36270. /**
  36271. * Initializes the state.
  36272. */
  36273. constructor();
  36274. get isDirty(): boolean;
  36275. get alphaBlend(): boolean;
  36276. set alphaBlend(value: boolean);
  36277. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36278. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36279. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36280. reset(): void;
  36281. apply(gl: WebGLRenderingContext): void;
  36282. }
  36283. }
  36284. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36285. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36286. /** @hidden */
  36287. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36288. attributeProcessor(attribute: string): string;
  36289. varyingProcessor(varying: string, isFragment: boolean): string;
  36290. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36291. }
  36292. }
  36293. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36294. /**
  36295. * Interface for attribute information associated with buffer instanciation
  36296. */
  36297. export interface InstancingAttributeInfo {
  36298. /**
  36299. * Name of the GLSL attribute
  36300. * if attribute index is not specified, this is used to retrieve the index from the effect
  36301. */
  36302. attributeName: string;
  36303. /**
  36304. * Index/offset of the attribute in the vertex shader
  36305. * if not specified, this will be computes from the name.
  36306. */
  36307. index?: number;
  36308. /**
  36309. * size of the attribute, 1, 2, 3 or 4
  36310. */
  36311. attributeSize: number;
  36312. /**
  36313. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36314. */
  36315. offset: number;
  36316. /**
  36317. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36318. * default to 1
  36319. */
  36320. divisor?: number;
  36321. /**
  36322. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36323. * default is FLOAT
  36324. */
  36325. attributeType?: number;
  36326. /**
  36327. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36328. */
  36329. normalized?: boolean;
  36330. }
  36331. }
  36332. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36334. import { Nullable } from "babylonjs/types";
  36335. module "babylonjs/Engines/thinEngine" {
  36336. interface ThinEngine {
  36337. /**
  36338. * Update a video texture
  36339. * @param texture defines the texture to update
  36340. * @param video defines the video element to use
  36341. * @param invertY defines if data must be stored with Y axis inverted
  36342. */
  36343. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36344. }
  36345. }
  36346. }
  36347. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36349. import { Nullable } from "babylonjs/types";
  36350. module "babylonjs/Engines/thinEngine" {
  36351. interface ThinEngine {
  36352. /**
  36353. * Creates a dynamic texture
  36354. * @param width defines the width of the texture
  36355. * @param height defines the height of the texture
  36356. * @param generateMipMaps defines if the engine should generate the mip levels
  36357. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36358. * @returns the dynamic texture inside an InternalTexture
  36359. */
  36360. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36361. /**
  36362. * Update the content of a dynamic texture
  36363. * @param texture defines the texture to update
  36364. * @param canvas defines the canvas containing the source
  36365. * @param invertY defines if data must be stored with Y axis inverted
  36366. * @param premulAlpha defines if alpha is stored as premultiplied
  36367. * @param format defines the format of the data
  36368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36369. */
  36370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36371. }
  36372. }
  36373. }
  36374. declare module "babylonjs/Materials/Textures/videoTexture" {
  36375. import { Observable } from "babylonjs/Misc/observable";
  36376. import { Nullable } from "babylonjs/types";
  36377. import { Scene } from "babylonjs/scene";
  36378. import { Texture } from "babylonjs/Materials/Textures/texture";
  36379. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36380. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36381. /**
  36382. * Settings for finer control over video usage
  36383. */
  36384. export interface VideoTextureSettings {
  36385. /**
  36386. * Applies `autoplay` to video, if specified
  36387. */
  36388. autoPlay?: boolean;
  36389. /**
  36390. * Applies `loop` to video, if specified
  36391. */
  36392. loop?: boolean;
  36393. /**
  36394. * Automatically updates internal texture from video at every frame in the render loop
  36395. */
  36396. autoUpdateTexture: boolean;
  36397. /**
  36398. * Image src displayed during the video loading or until the user interacts with the video.
  36399. */
  36400. poster?: string;
  36401. }
  36402. /**
  36403. * If you want to display a video in your scene, this is the special texture for that.
  36404. * This special texture works similar to other textures, with the exception of a few parameters.
  36405. * @see https://doc.babylonjs.com/how_to/video_texture
  36406. */
  36407. export class VideoTexture extends Texture {
  36408. /**
  36409. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36410. */
  36411. readonly autoUpdateTexture: boolean;
  36412. /**
  36413. * The video instance used by the texture internally
  36414. */
  36415. readonly video: HTMLVideoElement;
  36416. private _onUserActionRequestedObservable;
  36417. /**
  36418. * Event triggerd when a dom action is required by the user to play the video.
  36419. * This happens due to recent changes in browser policies preventing video to auto start.
  36420. */
  36421. get onUserActionRequestedObservable(): Observable<Texture>;
  36422. private _generateMipMaps;
  36423. private _stillImageCaptured;
  36424. private _displayingPosterTexture;
  36425. private _settings;
  36426. private _createInternalTextureOnEvent;
  36427. private _frameId;
  36428. private _currentSrc;
  36429. /**
  36430. * Creates a video texture.
  36431. * If you want to display a video in your scene, this is the special texture for that.
  36432. * This special texture works similar to other textures, with the exception of a few parameters.
  36433. * @see https://doc.babylonjs.com/how_to/video_texture
  36434. * @param name optional name, will detect from video source, if not defined
  36435. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36436. * @param scene is obviously the current scene.
  36437. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36438. * @param invertY is false by default but can be used to invert video on Y axis
  36439. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36440. * @param settings allows finer control over video usage
  36441. */
  36442. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36443. private _getName;
  36444. private _getVideo;
  36445. private _createInternalTexture;
  36446. private reset;
  36447. /**
  36448. * @hidden Internal method to initiate `update`.
  36449. */
  36450. _rebuild(): void;
  36451. /**
  36452. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36453. */
  36454. update(): void;
  36455. /**
  36456. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36457. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36458. */
  36459. updateTexture(isVisible: boolean): void;
  36460. protected _updateInternalTexture: () => void;
  36461. /**
  36462. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36463. * @param url New url.
  36464. */
  36465. updateURL(url: string): void;
  36466. /**
  36467. * Clones the texture.
  36468. * @returns the cloned texture
  36469. */
  36470. clone(): VideoTexture;
  36471. /**
  36472. * Dispose the texture and release its associated resources.
  36473. */
  36474. dispose(): void;
  36475. /**
  36476. * Creates a video texture straight from a stream.
  36477. * @param scene Define the scene the texture should be created in
  36478. * @param stream Define the stream the texture should be created from
  36479. * @returns The created video texture as a promise
  36480. */
  36481. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36482. /**
  36483. * Creates a video texture straight from your WebCam video feed.
  36484. * @param scene Define the scene the texture should be created in
  36485. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36486. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36487. * @returns The created video texture as a promise
  36488. */
  36489. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36490. minWidth: number;
  36491. maxWidth: number;
  36492. minHeight: number;
  36493. maxHeight: number;
  36494. deviceId: string;
  36495. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36496. /**
  36497. * Creates a video texture straight from your WebCam video feed.
  36498. * @param scene Define the scene the texture should be created in
  36499. * @param onReady Define a callback to triggered once the texture will be ready
  36500. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36501. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36502. */
  36503. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36504. minWidth: number;
  36505. maxWidth: number;
  36506. minHeight: number;
  36507. maxHeight: number;
  36508. deviceId: string;
  36509. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36510. }
  36511. }
  36512. declare module "babylonjs/Engines/thinEngine" {
  36513. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36514. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36515. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36516. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36517. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36518. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36519. import { Observable } from "babylonjs/Misc/observable";
  36520. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36521. import { StencilState } from "babylonjs/States/stencilState";
  36522. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36524. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36525. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36526. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36527. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36528. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36529. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36530. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36532. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36533. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36534. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36535. import { WebRequest } from "babylonjs/Misc/webRequest";
  36536. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36537. /**
  36538. * Defines the interface used by objects working like Scene
  36539. * @hidden
  36540. */
  36541. export interface ISceneLike {
  36542. _addPendingData(data: any): void;
  36543. _removePendingData(data: any): void;
  36544. offlineProvider: IOfflineProvider;
  36545. }
  36546. /**
  36547. * Information about the current host
  36548. */
  36549. export interface HostInformation {
  36550. /**
  36551. * Defines if the current host is a mobile
  36552. */
  36553. isMobile: boolean;
  36554. }
  36555. /** Interface defining initialization parameters for Engine class */
  36556. export interface EngineOptions extends WebGLContextAttributes {
  36557. /**
  36558. * Defines if the engine should no exceed a specified device ratio
  36559. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36560. */
  36561. limitDeviceRatio?: number;
  36562. /**
  36563. * Defines if webvr should be enabled automatically
  36564. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36565. */
  36566. autoEnableWebVR?: boolean;
  36567. /**
  36568. * Defines if webgl2 should be turned off even if supported
  36569. * @see https://doc.babylonjs.com/features/webgl2
  36570. */
  36571. disableWebGL2Support?: boolean;
  36572. /**
  36573. * Defines if webaudio should be initialized as well
  36574. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36575. */
  36576. audioEngine?: boolean;
  36577. /**
  36578. * Defines if animations should run using a deterministic lock step
  36579. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36580. */
  36581. deterministicLockstep?: boolean;
  36582. /** Defines the maximum steps to use with deterministic lock step mode */
  36583. lockstepMaxSteps?: number;
  36584. /** Defines the seconds between each deterministic lock step */
  36585. timeStep?: number;
  36586. /**
  36587. * Defines that engine should ignore context lost events
  36588. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36589. */
  36590. doNotHandleContextLost?: boolean;
  36591. /**
  36592. * Defines that engine should ignore modifying touch action attribute and style
  36593. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36594. */
  36595. doNotHandleTouchAction?: boolean;
  36596. /**
  36597. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36598. */
  36599. useHighPrecisionFloats?: boolean;
  36600. /**
  36601. * Make the canvas XR Compatible for XR sessions
  36602. */
  36603. xrCompatible?: boolean;
  36604. /**
  36605. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36606. */
  36607. useHighPrecisionMatrix?: boolean;
  36608. }
  36609. /**
  36610. * The base engine class (root of all engines)
  36611. */
  36612. export class ThinEngine {
  36613. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36614. static ExceptionList: ({
  36615. key: string;
  36616. capture: string;
  36617. captureConstraint: number;
  36618. targets: string[];
  36619. } | {
  36620. key: string;
  36621. capture: null;
  36622. captureConstraint: null;
  36623. targets: string[];
  36624. })[];
  36625. /** @hidden */
  36626. static _TextureLoaders: IInternalTextureLoader[];
  36627. /**
  36628. * Returns the current npm package of the sdk
  36629. */
  36630. static get NpmPackage(): string;
  36631. /**
  36632. * Returns the current version of the framework
  36633. */
  36634. static get Version(): string;
  36635. /**
  36636. * Returns a string describing the current engine
  36637. */
  36638. get description(): string;
  36639. /**
  36640. * Gets or sets the epsilon value used by collision engine
  36641. */
  36642. static CollisionsEpsilon: number;
  36643. /**
  36644. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36645. */
  36646. static get ShadersRepository(): string;
  36647. static set ShadersRepository(value: string);
  36648. /** @hidden */
  36649. _shaderProcessor: IShaderProcessor;
  36650. /**
  36651. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36652. */
  36653. forcePOTTextures: boolean;
  36654. /**
  36655. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36656. */
  36657. isFullscreen: boolean;
  36658. /**
  36659. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36660. */
  36661. cullBackFaces: boolean;
  36662. /**
  36663. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36664. */
  36665. renderEvenInBackground: boolean;
  36666. /**
  36667. * Gets or sets a boolean indicating that cache can be kept between frames
  36668. */
  36669. preventCacheWipeBetweenFrames: boolean;
  36670. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36671. validateShaderPrograms: boolean;
  36672. /**
  36673. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36674. * This can provide greater z depth for distant objects.
  36675. */
  36676. useReverseDepthBuffer: boolean;
  36677. /**
  36678. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36679. */
  36680. disableUniformBuffers: boolean;
  36681. /** @hidden */
  36682. _uniformBuffers: UniformBuffer[];
  36683. /**
  36684. * Gets a boolean indicating that the engine supports uniform buffers
  36685. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36686. */
  36687. get supportsUniformBuffers(): boolean;
  36688. /** @hidden */
  36689. _gl: WebGLRenderingContext;
  36690. /** @hidden */
  36691. _webGLVersion: number;
  36692. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36693. protected _windowIsBackground: boolean;
  36694. protected _creationOptions: EngineOptions;
  36695. protected _highPrecisionShadersAllowed: boolean;
  36696. /** @hidden */
  36697. get _shouldUseHighPrecisionShader(): boolean;
  36698. /**
  36699. * Gets a boolean indicating that only power of 2 textures are supported
  36700. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36701. */
  36702. get needPOTTextures(): boolean;
  36703. /** @hidden */
  36704. _badOS: boolean;
  36705. /** @hidden */
  36706. _badDesktopOS: boolean;
  36707. private _hardwareScalingLevel;
  36708. /** @hidden */
  36709. _caps: EngineCapabilities;
  36710. private _isStencilEnable;
  36711. private _glVersion;
  36712. private _glRenderer;
  36713. private _glVendor;
  36714. /** @hidden */
  36715. _videoTextureSupported: boolean;
  36716. protected _renderingQueueLaunched: boolean;
  36717. protected _activeRenderLoops: (() => void)[];
  36718. /**
  36719. * Observable signaled when a context lost event is raised
  36720. */
  36721. onContextLostObservable: Observable<ThinEngine>;
  36722. /**
  36723. * Observable signaled when a context restored event is raised
  36724. */
  36725. onContextRestoredObservable: Observable<ThinEngine>;
  36726. private _onContextLost;
  36727. private _onContextRestored;
  36728. protected _contextWasLost: boolean;
  36729. /** @hidden */
  36730. _doNotHandleContextLost: boolean;
  36731. /**
  36732. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36733. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36734. */
  36735. get doNotHandleContextLost(): boolean;
  36736. set doNotHandleContextLost(value: boolean);
  36737. /**
  36738. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36739. */
  36740. disableVertexArrayObjects: boolean;
  36741. /** @hidden */
  36742. protected _colorWrite: boolean;
  36743. /** @hidden */
  36744. protected _colorWriteChanged: boolean;
  36745. /** @hidden */
  36746. protected _depthCullingState: DepthCullingState;
  36747. /** @hidden */
  36748. protected _stencilState: StencilState;
  36749. /** @hidden */
  36750. _alphaState: AlphaState;
  36751. /** @hidden */
  36752. _alphaMode: number;
  36753. /** @hidden */
  36754. _alphaEquation: number;
  36755. /** @hidden */
  36756. _internalTexturesCache: InternalTexture[];
  36757. /** @hidden */
  36758. protected _activeChannel: number;
  36759. private _currentTextureChannel;
  36760. /** @hidden */
  36761. protected _boundTexturesCache: {
  36762. [key: string]: Nullable<InternalTexture>;
  36763. };
  36764. /** @hidden */
  36765. protected _currentEffect: Nullable<Effect>;
  36766. /** @hidden */
  36767. protected _currentProgram: Nullable<WebGLProgram>;
  36768. private _compiledEffects;
  36769. private _vertexAttribArraysEnabled;
  36770. /** @hidden */
  36771. protected _cachedViewport: Nullable<IViewportLike>;
  36772. private _cachedVertexArrayObject;
  36773. /** @hidden */
  36774. protected _cachedVertexBuffers: any;
  36775. /** @hidden */
  36776. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36777. /** @hidden */
  36778. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36779. /** @hidden */
  36780. _currentRenderTarget: Nullable<InternalTexture>;
  36781. private _uintIndicesCurrentlySet;
  36782. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36783. /** @hidden */
  36784. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36785. /** @hidden */
  36786. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36787. private _currentBufferPointers;
  36788. private _currentInstanceLocations;
  36789. private _currentInstanceBuffers;
  36790. private _textureUnits;
  36791. /** @hidden */
  36792. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36793. /** @hidden */
  36794. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36795. /** @hidden */
  36796. _boundRenderFunction: any;
  36797. private _vaoRecordInProgress;
  36798. private _mustWipeVertexAttributes;
  36799. private _emptyTexture;
  36800. private _emptyCubeTexture;
  36801. private _emptyTexture3D;
  36802. private _emptyTexture2DArray;
  36803. /** @hidden */
  36804. _frameHandler: number;
  36805. private _nextFreeTextureSlots;
  36806. private _maxSimultaneousTextures;
  36807. private _activeRequests;
  36808. /** @hidden */
  36809. _transformTextureUrl: Nullable<(url: string) => string>;
  36810. /**
  36811. * Gets information about the current host
  36812. */
  36813. hostInformation: HostInformation;
  36814. protected get _supportsHardwareTextureRescaling(): boolean;
  36815. private _framebufferDimensionsObject;
  36816. /**
  36817. * sets the object from which width and height will be taken from when getting render width and height
  36818. * Will fallback to the gl object
  36819. * @param dimensions the framebuffer width and height that will be used.
  36820. */
  36821. set framebufferDimensionsObject(dimensions: Nullable<{
  36822. framebufferWidth: number;
  36823. framebufferHeight: number;
  36824. }>);
  36825. /**
  36826. * Gets the current viewport
  36827. */
  36828. get currentViewport(): Nullable<IViewportLike>;
  36829. /**
  36830. * Gets the default empty texture
  36831. */
  36832. get emptyTexture(): InternalTexture;
  36833. /**
  36834. * Gets the default empty 3D texture
  36835. */
  36836. get emptyTexture3D(): InternalTexture;
  36837. /**
  36838. * Gets the default empty 2D array texture
  36839. */
  36840. get emptyTexture2DArray(): InternalTexture;
  36841. /**
  36842. * Gets the default empty cube texture
  36843. */
  36844. get emptyCubeTexture(): InternalTexture;
  36845. /**
  36846. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36847. */
  36848. readonly premultipliedAlpha: boolean;
  36849. /**
  36850. * Observable event triggered before each texture is initialized
  36851. */
  36852. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36853. /**
  36854. * Creates a new engine
  36855. * @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
  36856. * @param antialias defines enable antialiasing (default: false)
  36857. * @param options defines further options to be sent to the getContext() function
  36858. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36859. */
  36860. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36861. private _rebuildInternalTextures;
  36862. private _rebuildEffects;
  36863. /**
  36864. * Gets a boolean indicating if all created effects are ready
  36865. * @returns true if all effects are ready
  36866. */
  36867. areAllEffectsReady(): boolean;
  36868. protected _rebuildBuffers(): void;
  36869. protected _initGLContext(): void;
  36870. /**
  36871. * Gets version of the current webGL context
  36872. */
  36873. get webGLVersion(): number;
  36874. /**
  36875. * Gets a string identifying the name of the class
  36876. * @returns "Engine" string
  36877. */
  36878. getClassName(): string;
  36879. /**
  36880. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36881. */
  36882. get isStencilEnable(): boolean;
  36883. /** @hidden */
  36884. _prepareWorkingCanvas(): void;
  36885. /**
  36886. * Reset the texture cache to empty state
  36887. */
  36888. resetTextureCache(): void;
  36889. /**
  36890. * Gets an object containing information about the current webGL context
  36891. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36892. */
  36893. getGlInfo(): {
  36894. vendor: string;
  36895. renderer: string;
  36896. version: string;
  36897. };
  36898. /**
  36899. * Defines the hardware scaling level.
  36900. * By default the hardware scaling level is computed from the window device ratio.
  36901. * 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.
  36902. * @param level defines the level to use
  36903. */
  36904. setHardwareScalingLevel(level: number): void;
  36905. /**
  36906. * Gets the current hardware scaling level.
  36907. * By default the hardware scaling level is computed from the window device ratio.
  36908. * 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.
  36909. * @returns a number indicating the current hardware scaling level
  36910. */
  36911. getHardwareScalingLevel(): number;
  36912. /**
  36913. * Gets the list of loaded textures
  36914. * @returns an array containing all loaded textures
  36915. */
  36916. getLoadedTexturesCache(): InternalTexture[];
  36917. /**
  36918. * Gets the object containing all engine capabilities
  36919. * @returns the EngineCapabilities object
  36920. */
  36921. getCaps(): EngineCapabilities;
  36922. /**
  36923. * stop executing a render loop function and remove it from the execution array
  36924. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36925. */
  36926. stopRenderLoop(renderFunction?: () => void): void;
  36927. /** @hidden */
  36928. _renderLoop(): void;
  36929. /**
  36930. * Gets the HTML canvas attached with the current webGL context
  36931. * @returns a HTML canvas
  36932. */
  36933. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36934. /**
  36935. * Gets host window
  36936. * @returns the host window object
  36937. */
  36938. getHostWindow(): Nullable<Window>;
  36939. /**
  36940. * Gets the current render width
  36941. * @param useScreen defines if screen size must be used (or the current render target if any)
  36942. * @returns a number defining the current render width
  36943. */
  36944. getRenderWidth(useScreen?: boolean): number;
  36945. /**
  36946. * Gets the current render height
  36947. * @param useScreen defines if screen size must be used (or the current render target if any)
  36948. * @returns a number defining the current render height
  36949. */
  36950. getRenderHeight(useScreen?: boolean): number;
  36951. /**
  36952. * Can be used to override the current requestAnimationFrame requester.
  36953. * @hidden
  36954. */
  36955. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36956. /**
  36957. * Register and execute a render loop. The engine can have more than one render function
  36958. * @param renderFunction defines the function to continuously execute
  36959. */
  36960. runRenderLoop(renderFunction: () => void): void;
  36961. /**
  36962. * Clear the current render buffer or the current render target (if any is set up)
  36963. * @param color defines the color to use
  36964. * @param backBuffer defines if the back buffer must be cleared
  36965. * @param depth defines if the depth buffer must be cleared
  36966. * @param stencil defines if the stencil buffer must be cleared
  36967. */
  36968. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36969. private _viewportCached;
  36970. /** @hidden */
  36971. _viewport(x: number, y: number, width: number, height: number): void;
  36972. /**
  36973. * Set the WebGL's viewport
  36974. * @param viewport defines the viewport element to be used
  36975. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36976. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36977. */
  36978. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36979. /**
  36980. * Begin a new frame
  36981. */
  36982. beginFrame(): void;
  36983. /**
  36984. * Enf the current frame
  36985. */
  36986. endFrame(): void;
  36987. /**
  36988. * Resize the view according to the canvas' size
  36989. */
  36990. resize(): void;
  36991. /**
  36992. * Force a specific size of the canvas
  36993. * @param width defines the new canvas' width
  36994. * @param height defines the new canvas' height
  36995. * @returns true if the size was changed
  36996. */
  36997. setSize(width: number, height: number): boolean;
  36998. /**
  36999. * Binds the frame buffer to the specified texture.
  37000. * @param texture The texture to render to or null for the default canvas
  37001. * @param faceIndex The face of the texture to render to in case of cube texture
  37002. * @param requiredWidth The width of the target to render to
  37003. * @param requiredHeight The height of the target to render to
  37004. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37005. * @param lodLevel defines the lod level to bind to the frame buffer
  37006. * @param layer defines the 2d array index to bind to frame buffer to
  37007. */
  37008. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37009. /** @hidden */
  37010. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37011. /**
  37012. * Unbind the current render target texture from the webGL context
  37013. * @param texture defines the render target texture to unbind
  37014. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37015. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37016. */
  37017. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37018. /**
  37019. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37020. */
  37021. flushFramebuffer(): void;
  37022. /**
  37023. * Unbind the current render target and bind the default framebuffer
  37024. */
  37025. restoreDefaultFramebuffer(): void;
  37026. /** @hidden */
  37027. protected _resetVertexBufferBinding(): void;
  37028. /**
  37029. * Creates a vertex buffer
  37030. * @param data the data for the vertex buffer
  37031. * @returns the new WebGL static buffer
  37032. */
  37033. createVertexBuffer(data: DataArray): DataBuffer;
  37034. private _createVertexBuffer;
  37035. /**
  37036. * Creates a dynamic vertex buffer
  37037. * @param data the data for the dynamic vertex buffer
  37038. * @returns the new WebGL dynamic buffer
  37039. */
  37040. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37041. protected _resetIndexBufferBinding(): void;
  37042. /**
  37043. * Creates a new index buffer
  37044. * @param indices defines the content of the index buffer
  37045. * @param updatable defines if the index buffer must be updatable
  37046. * @returns a new webGL buffer
  37047. */
  37048. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37049. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37050. /**
  37051. * Bind a webGL buffer to the webGL context
  37052. * @param buffer defines the buffer to bind
  37053. */
  37054. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37055. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37056. private bindBuffer;
  37057. /**
  37058. * update the bound buffer with the given data
  37059. * @param data defines the data to update
  37060. */
  37061. updateArrayBuffer(data: Float32Array): void;
  37062. private _vertexAttribPointer;
  37063. /** @hidden */
  37064. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37065. private _bindVertexBuffersAttributes;
  37066. /**
  37067. * Records a vertex array object
  37068. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37069. * @param vertexBuffers defines the list of vertex buffers to store
  37070. * @param indexBuffer defines the index buffer to store
  37071. * @param effect defines the effect to store
  37072. * @returns the new vertex array object
  37073. */
  37074. recordVertexArrayObject(vertexBuffers: {
  37075. [key: string]: VertexBuffer;
  37076. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37077. /**
  37078. * Bind a specific vertex array object
  37079. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37080. * @param vertexArrayObject defines the vertex array object to bind
  37081. * @param indexBuffer defines the index buffer to bind
  37082. */
  37083. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37084. /**
  37085. * Bind webGl buffers directly to the webGL context
  37086. * @param vertexBuffer defines the vertex buffer to bind
  37087. * @param indexBuffer defines the index buffer to bind
  37088. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37089. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37090. * @param effect defines the effect associated with the vertex buffer
  37091. */
  37092. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37093. private _unbindVertexArrayObject;
  37094. /**
  37095. * Bind a list of vertex buffers to the webGL context
  37096. * @param vertexBuffers defines the list of vertex buffers to bind
  37097. * @param indexBuffer defines the index buffer to bind
  37098. * @param effect defines the effect associated with the vertex buffers
  37099. */
  37100. bindBuffers(vertexBuffers: {
  37101. [key: string]: Nullable<VertexBuffer>;
  37102. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37103. /**
  37104. * Unbind all instance attributes
  37105. */
  37106. unbindInstanceAttributes(): void;
  37107. /**
  37108. * Release and free the memory of a vertex array object
  37109. * @param vao defines the vertex array object to delete
  37110. */
  37111. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37112. /** @hidden */
  37113. _releaseBuffer(buffer: DataBuffer): boolean;
  37114. protected _deleteBuffer(buffer: DataBuffer): void;
  37115. /**
  37116. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37117. * @param instancesBuffer defines the webGL buffer to update and bind
  37118. * @param data defines the data to store in the buffer
  37119. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37120. */
  37121. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37122. /**
  37123. * Bind the content of a webGL buffer used with instantiation
  37124. * @param instancesBuffer defines the webGL buffer to bind
  37125. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37126. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37127. */
  37128. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37129. /**
  37130. * Disable the instance attribute corresponding to the name in parameter
  37131. * @param name defines the name of the attribute to disable
  37132. */
  37133. disableInstanceAttributeByName(name: string): void;
  37134. /**
  37135. * Disable the instance attribute corresponding to the location in parameter
  37136. * @param attributeLocation defines the attribute location of the attribute to disable
  37137. */
  37138. disableInstanceAttribute(attributeLocation: number): void;
  37139. /**
  37140. * Disable the attribute corresponding to the location in parameter
  37141. * @param attributeLocation defines the attribute location of the attribute to disable
  37142. */
  37143. disableAttributeByIndex(attributeLocation: number): void;
  37144. /**
  37145. * Send a draw order
  37146. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37147. * @param indexStart defines the starting index
  37148. * @param indexCount defines the number of index to draw
  37149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37150. */
  37151. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37152. /**
  37153. * Draw a list of points
  37154. * @param verticesStart defines the index of first vertex to draw
  37155. * @param verticesCount defines the count of vertices to draw
  37156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37157. */
  37158. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37159. /**
  37160. * Draw a list of unindexed primitives
  37161. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37162. * @param verticesStart defines the index of first vertex to draw
  37163. * @param verticesCount defines the count of vertices to draw
  37164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37165. */
  37166. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37167. /**
  37168. * Draw a list of indexed primitives
  37169. * @param fillMode defines the primitive to use
  37170. * @param indexStart defines the starting index
  37171. * @param indexCount defines the number of index to draw
  37172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37173. */
  37174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37175. /**
  37176. * Draw a list of unindexed primitives
  37177. * @param fillMode defines the primitive to use
  37178. * @param verticesStart defines the index of first vertex to draw
  37179. * @param verticesCount defines the count of vertices to draw
  37180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37181. */
  37182. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37183. private _drawMode;
  37184. /** @hidden */
  37185. protected _reportDrawCall(): void;
  37186. /** @hidden */
  37187. _releaseEffect(effect: Effect): void;
  37188. /** @hidden */
  37189. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37190. /**
  37191. * Create a new effect (used to store vertex/fragment shaders)
  37192. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37193. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37194. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37195. * @param samplers defines an array of string used to represent textures
  37196. * @param defines defines the string containing the defines to use to compile the shaders
  37197. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37198. * @param onCompiled defines a function to call when the effect creation is successful
  37199. * @param onError defines a function to call when the effect creation has failed
  37200. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37201. * @returns the new Effect
  37202. */
  37203. 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;
  37204. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37205. private _compileShader;
  37206. private _compileRawShader;
  37207. /** @hidden */
  37208. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37209. /**
  37210. * Directly creates a webGL program
  37211. * @param pipelineContext defines the pipeline context to attach to
  37212. * @param vertexCode defines the vertex shader code to use
  37213. * @param fragmentCode defines the fragment shader code to use
  37214. * @param context defines the webGL context to use (if not set, the current one will be used)
  37215. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37216. * @returns the new webGL program
  37217. */
  37218. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37219. /**
  37220. * Creates a webGL program
  37221. * @param pipelineContext defines the pipeline context to attach to
  37222. * @param vertexCode defines the vertex shader code to use
  37223. * @param fragmentCode defines the fragment shader code to use
  37224. * @param defines defines the string containing the defines to use to compile the shaders
  37225. * @param context defines the webGL context to use (if not set, the current one will be used)
  37226. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37227. * @returns the new webGL program
  37228. */
  37229. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37230. /**
  37231. * Creates a new pipeline context
  37232. * @returns the new pipeline
  37233. */
  37234. createPipelineContext(): IPipelineContext;
  37235. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37236. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37237. /** @hidden */
  37238. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37239. /** @hidden */
  37240. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37241. /** @hidden */
  37242. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37243. /**
  37244. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37245. * @param pipelineContext defines the pipeline context to use
  37246. * @param uniformsNames defines the list of uniform names
  37247. * @returns an array of webGL uniform locations
  37248. */
  37249. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37250. /**
  37251. * Gets the lsit of active attributes for a given webGL program
  37252. * @param pipelineContext defines the pipeline context to use
  37253. * @param attributesNames defines the list of attribute names to get
  37254. * @returns an array of indices indicating the offset of each attribute
  37255. */
  37256. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37257. /**
  37258. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37259. * @param effect defines the effect to activate
  37260. */
  37261. enableEffect(effect: Nullable<Effect>): void;
  37262. /**
  37263. * Set the value of an uniform to a number (int)
  37264. * @param uniform defines the webGL uniform location where to store the value
  37265. * @param value defines the int number to store
  37266. * @returns true if the value was set
  37267. */
  37268. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37269. /**
  37270. * Set the value of an uniform to an array of int32
  37271. * @param uniform defines the webGL uniform location where to store the value
  37272. * @param array defines the array of int32 to store
  37273. * @returns true if the value was set
  37274. */
  37275. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37276. /**
  37277. * Set the value of an uniform to an array of int32 (stored as vec2)
  37278. * @param uniform defines the webGL uniform location where to store the value
  37279. * @param array defines the array of int32 to store
  37280. * @returns true if the value was set
  37281. */
  37282. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37283. /**
  37284. * Set the value of an uniform to an array of int32 (stored as vec3)
  37285. * @param uniform defines the webGL uniform location where to store the value
  37286. * @param array defines the array of int32 to store
  37287. * @returns true if the value was set
  37288. */
  37289. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37290. /**
  37291. * Set the value of an uniform to an array of int32 (stored as vec4)
  37292. * @param uniform defines the webGL uniform location where to store the value
  37293. * @param array defines the array of int32 to store
  37294. * @returns true if the value was set
  37295. */
  37296. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37297. /**
  37298. * Set the value of an uniform to an array of number
  37299. * @param uniform defines the webGL uniform location where to store the value
  37300. * @param array defines the array of number to store
  37301. * @returns true if the value was set
  37302. */
  37303. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37304. /**
  37305. * Set the value of an uniform to an array of number (stored as vec2)
  37306. * @param uniform defines the webGL uniform location where to store the value
  37307. * @param array defines the array of number to store
  37308. * @returns true if the value was set
  37309. */
  37310. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37311. /**
  37312. * Set the value of an uniform to an array of number (stored as vec3)
  37313. * @param uniform defines the webGL uniform location where to store the value
  37314. * @param array defines the array of number to store
  37315. * @returns true if the value was set
  37316. */
  37317. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37318. /**
  37319. * Set the value of an uniform to an array of number (stored as vec4)
  37320. * @param uniform defines the webGL uniform location where to store the value
  37321. * @param array defines the array of number to store
  37322. * @returns true if the value was set
  37323. */
  37324. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37325. /**
  37326. * Set the value of an uniform to an array of float32 (stored as matrices)
  37327. * @param uniform defines the webGL uniform location where to store the value
  37328. * @param matrices defines the array of float32 to store
  37329. * @returns true if the value was set
  37330. */
  37331. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37332. /**
  37333. * Set the value of an uniform to a matrix (3x3)
  37334. * @param uniform defines the webGL uniform location where to store the value
  37335. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37336. * @returns true if the value was set
  37337. */
  37338. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37339. /**
  37340. * Set the value of an uniform to a matrix (2x2)
  37341. * @param uniform defines the webGL uniform location where to store the value
  37342. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37343. * @returns true if the value was set
  37344. */
  37345. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37346. /**
  37347. * Set the value of an uniform to a number (float)
  37348. * @param uniform defines the webGL uniform location where to store the value
  37349. * @param value defines the float number to store
  37350. * @returns true if the value was transfered
  37351. */
  37352. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37353. /**
  37354. * Set the value of an uniform to a vec2
  37355. * @param uniform defines the webGL uniform location where to store the value
  37356. * @param x defines the 1st component of the value
  37357. * @param y defines the 2nd component of the value
  37358. * @returns true if the value was set
  37359. */
  37360. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37361. /**
  37362. * Set the value of an uniform to a vec3
  37363. * @param uniform defines the webGL uniform location where to store the value
  37364. * @param x defines the 1st component of the value
  37365. * @param y defines the 2nd component of the value
  37366. * @param z defines the 3rd component of the value
  37367. * @returns true if the value was set
  37368. */
  37369. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37370. /**
  37371. * Set the value of an uniform to a vec4
  37372. * @param uniform defines the webGL uniform location where to store the value
  37373. * @param x defines the 1st component of the value
  37374. * @param y defines the 2nd component of the value
  37375. * @param z defines the 3rd component of the value
  37376. * @param w defines the 4th component of the value
  37377. * @returns true if the value was set
  37378. */
  37379. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37380. /**
  37381. * Apply all cached states (depth, culling, stencil and alpha)
  37382. */
  37383. applyStates(): void;
  37384. /**
  37385. * Enable or disable color writing
  37386. * @param enable defines the state to set
  37387. */
  37388. setColorWrite(enable: boolean): void;
  37389. /**
  37390. * Gets a boolean indicating if color writing is enabled
  37391. * @returns the current color writing state
  37392. */
  37393. getColorWrite(): boolean;
  37394. /**
  37395. * Gets the depth culling state manager
  37396. */
  37397. get depthCullingState(): DepthCullingState;
  37398. /**
  37399. * Gets the alpha state manager
  37400. */
  37401. get alphaState(): AlphaState;
  37402. /**
  37403. * Gets the stencil state manager
  37404. */
  37405. get stencilState(): StencilState;
  37406. /**
  37407. * Clears the list of texture accessible through engine.
  37408. * This can help preventing texture load conflict due to name collision.
  37409. */
  37410. clearInternalTexturesCache(): void;
  37411. /**
  37412. * Force the entire cache to be cleared
  37413. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37414. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37415. */
  37416. wipeCaches(bruteForce?: boolean): void;
  37417. /** @hidden */
  37418. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37419. min: number;
  37420. mag: number;
  37421. };
  37422. /** @hidden */
  37423. _createTexture(): WebGLTexture;
  37424. /**
  37425. * Usually called from Texture.ts.
  37426. * Passed information to create a WebGLTexture
  37427. * @param url defines a value which contains one of the following:
  37428. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37429. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37430. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37432. * @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)
  37433. * @param scene needed for loading to the correct scene
  37434. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37435. * @param onLoad optional callback to be called upon successful completion
  37436. * @param onError optional callback to be called upon failure
  37437. * @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
  37438. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37439. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37440. * @param forcedExtension defines the extension to use to pick the right loader
  37441. * @param mimeType defines an optional mime type
  37442. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37443. */
  37444. 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;
  37445. /**
  37446. * Loads an image as an HTMLImageElement.
  37447. * @param input url string, ArrayBuffer, or Blob to load
  37448. * @param onLoad callback called when the image successfully loads
  37449. * @param onError callback called when the image fails to load
  37450. * @param offlineProvider offline provider for caching
  37451. * @param mimeType optional mime type
  37452. * @returns the HTMLImageElement of the loaded image
  37453. * @hidden
  37454. */
  37455. 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>;
  37456. /**
  37457. * @hidden
  37458. */
  37459. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37460. private _unpackFlipYCached;
  37461. /**
  37462. * In case you are sharing the context with other applications, it might
  37463. * be interested to not cache the unpack flip y state to ensure a consistent
  37464. * value would be set.
  37465. */
  37466. enableUnpackFlipYCached: boolean;
  37467. /** @hidden */
  37468. _unpackFlipY(value: boolean): void;
  37469. /** @hidden */
  37470. _getUnpackAlignement(): number;
  37471. private _getTextureTarget;
  37472. /**
  37473. * Update the sampling mode of a given texture
  37474. * @param samplingMode defines the required sampling mode
  37475. * @param texture defines the texture to update
  37476. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37477. */
  37478. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37479. /**
  37480. * Update the sampling mode of a given texture
  37481. * @param texture defines the texture to update
  37482. * @param wrapU defines the texture wrap mode of the u coordinates
  37483. * @param wrapV defines the texture wrap mode of the v coordinates
  37484. * @param wrapR defines the texture wrap mode of the r coordinates
  37485. */
  37486. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37487. /** @hidden */
  37488. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37489. width: number;
  37490. height: number;
  37491. layers?: number;
  37492. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37493. /** @hidden */
  37494. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37495. /** @hidden */
  37496. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37497. /**
  37498. * Update a portion of an internal texture
  37499. * @param texture defines the texture to update
  37500. * @param imageData defines the data to store into the texture
  37501. * @param xOffset defines the x coordinates of the update rectangle
  37502. * @param yOffset defines the y coordinates of the update rectangle
  37503. * @param width defines the width of the update rectangle
  37504. * @param height defines the height of the update rectangle
  37505. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37506. * @param lod defines the lod level to update (0 by default)
  37507. */
  37508. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37509. /** @hidden */
  37510. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37511. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37512. private _prepareWebGLTexture;
  37513. /** @hidden */
  37514. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37515. private _getDepthStencilBuffer;
  37516. /** @hidden */
  37517. _releaseFramebufferObjects(texture: InternalTexture): void;
  37518. /** @hidden */
  37519. _releaseTexture(texture: InternalTexture): void;
  37520. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37521. protected _setProgram(program: WebGLProgram): void;
  37522. protected _boundUniforms: {
  37523. [key: number]: WebGLUniformLocation;
  37524. };
  37525. /**
  37526. * Binds an effect to the webGL context
  37527. * @param effect defines the effect to bind
  37528. */
  37529. bindSamplers(effect: Effect): void;
  37530. private _activateCurrentTexture;
  37531. /** @hidden */
  37532. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37533. /** @hidden */
  37534. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37535. /**
  37536. * Unbind all textures from the webGL context
  37537. */
  37538. unbindAllTextures(): void;
  37539. /**
  37540. * Sets a texture to the according uniform.
  37541. * @param channel The texture channel
  37542. * @param uniform The uniform to set
  37543. * @param texture The texture to apply
  37544. */
  37545. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37546. private _bindSamplerUniformToChannel;
  37547. private _getTextureWrapMode;
  37548. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37549. /**
  37550. * Sets an array of texture to the webGL context
  37551. * @param channel defines the channel where the texture array must be set
  37552. * @param uniform defines the associated uniform location
  37553. * @param textures defines the array of textures to bind
  37554. */
  37555. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37556. /** @hidden */
  37557. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37558. private _setTextureParameterFloat;
  37559. private _setTextureParameterInteger;
  37560. /**
  37561. * Unbind all vertex attributes from the webGL context
  37562. */
  37563. unbindAllAttributes(): void;
  37564. /**
  37565. * 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
  37566. */
  37567. releaseEffects(): void;
  37568. /**
  37569. * Dispose and release all associated resources
  37570. */
  37571. dispose(): void;
  37572. /**
  37573. * Attach a new callback raised when context lost event is fired
  37574. * @param callback defines the callback to call
  37575. */
  37576. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37577. /**
  37578. * Attach a new callback raised when context restored event is fired
  37579. * @param callback defines the callback to call
  37580. */
  37581. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37582. /**
  37583. * Get the current error code of the webGL context
  37584. * @returns the error code
  37585. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37586. */
  37587. getError(): number;
  37588. private _canRenderToFloatFramebuffer;
  37589. private _canRenderToHalfFloatFramebuffer;
  37590. private _canRenderToFramebuffer;
  37591. /** @hidden */
  37592. _getWebGLTextureType(type: number): number;
  37593. /** @hidden */
  37594. _getInternalFormat(format: number): number;
  37595. /** @hidden */
  37596. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37597. /** @hidden */
  37598. _getRGBAMultiSampleBufferFormat(type: number): number;
  37599. /** @hidden */
  37600. _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;
  37601. /**
  37602. * Loads a file from a url
  37603. * @param url url to load
  37604. * @param onSuccess callback called when the file successfully loads
  37605. * @param onProgress callback called while file is loading (if the server supports this mode)
  37606. * @param offlineProvider defines the offline provider for caching
  37607. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37608. * @param onError callback called when the file fails to load
  37609. * @returns a file request object
  37610. * @hidden
  37611. */
  37612. 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;
  37613. /**
  37614. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37615. * @param x defines the x coordinate of the rectangle where pixels must be read
  37616. * @param y defines the y coordinate of the rectangle where pixels must be read
  37617. * @param width defines the width of the rectangle where pixels must be read
  37618. * @param height defines the height of the rectangle where pixels must be read
  37619. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37620. * @returns a Uint8Array containing RGBA colors
  37621. */
  37622. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37623. private static _isSupported;
  37624. /**
  37625. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37626. * @returns true if the engine can be created
  37627. * @ignorenaming
  37628. */
  37629. static isSupported(): boolean;
  37630. /**
  37631. * Find the next highest power of two.
  37632. * @param x Number to start search from.
  37633. * @return Next highest power of two.
  37634. */
  37635. static CeilingPOT(x: number): number;
  37636. /**
  37637. * Find the next lowest power of two.
  37638. * @param x Number to start search from.
  37639. * @return Next lowest power of two.
  37640. */
  37641. static FloorPOT(x: number): number;
  37642. /**
  37643. * Find the nearest power of two.
  37644. * @param x Number to start search from.
  37645. * @return Next nearest power of two.
  37646. */
  37647. static NearestPOT(x: number): number;
  37648. /**
  37649. * Get the closest exponent of two
  37650. * @param value defines the value to approximate
  37651. * @param max defines the maximum value to return
  37652. * @param mode defines how to define the closest value
  37653. * @returns closest exponent of two of the given value
  37654. */
  37655. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37656. /**
  37657. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37658. * @param func - the function to be called
  37659. * @param requester - the object that will request the next frame. Falls back to window.
  37660. * @returns frame number
  37661. */
  37662. static QueueNewFrame(func: () => void, requester?: any): number;
  37663. /**
  37664. * Gets host document
  37665. * @returns the host document object
  37666. */
  37667. getHostDocument(): Nullable<Document>;
  37668. }
  37669. }
  37670. declare module "babylonjs/Maths/sphericalPolynomial" {
  37671. import { Vector3 } from "babylonjs/Maths/math.vector";
  37672. import { Color3 } from "babylonjs/Maths/math.color";
  37673. /**
  37674. * Class representing spherical harmonics coefficients to the 3rd degree
  37675. */
  37676. export class SphericalHarmonics {
  37677. /**
  37678. * Defines whether or not the harmonics have been prescaled for rendering.
  37679. */
  37680. preScaled: boolean;
  37681. /**
  37682. * The l0,0 coefficients of the spherical harmonics
  37683. */
  37684. l00: Vector3;
  37685. /**
  37686. * The l1,-1 coefficients of the spherical harmonics
  37687. */
  37688. l1_1: Vector3;
  37689. /**
  37690. * The l1,0 coefficients of the spherical harmonics
  37691. */
  37692. l10: Vector3;
  37693. /**
  37694. * The l1,1 coefficients of the spherical harmonics
  37695. */
  37696. l11: Vector3;
  37697. /**
  37698. * The l2,-2 coefficients of the spherical harmonics
  37699. */
  37700. l2_2: Vector3;
  37701. /**
  37702. * The l2,-1 coefficients of the spherical harmonics
  37703. */
  37704. l2_1: Vector3;
  37705. /**
  37706. * The l2,0 coefficients of the spherical harmonics
  37707. */
  37708. l20: Vector3;
  37709. /**
  37710. * The l2,1 coefficients of the spherical harmonics
  37711. */
  37712. l21: Vector3;
  37713. /**
  37714. * The l2,2 coefficients of the spherical harmonics
  37715. */
  37716. l22: Vector3;
  37717. /**
  37718. * Adds a light to the spherical harmonics
  37719. * @param direction the direction of the light
  37720. * @param color the color of the light
  37721. * @param deltaSolidAngle the delta solid angle of the light
  37722. */
  37723. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37724. /**
  37725. * Scales the spherical harmonics by the given amount
  37726. * @param scale the amount to scale
  37727. */
  37728. scaleInPlace(scale: number): void;
  37729. /**
  37730. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37731. *
  37732. * ```
  37733. * E_lm = A_l * L_lm
  37734. * ```
  37735. *
  37736. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37737. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37738. * the scaling factors are given in equation 9.
  37739. */
  37740. convertIncidentRadianceToIrradiance(): void;
  37741. /**
  37742. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37743. *
  37744. * ```
  37745. * L = (1/pi) * E * rho
  37746. * ```
  37747. *
  37748. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37749. */
  37750. convertIrradianceToLambertianRadiance(): void;
  37751. /**
  37752. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37753. * required operations at run time.
  37754. *
  37755. * This is simply done by scaling back the SH with Ylm constants parameter.
  37756. * The trigonometric part being applied by the shader at run time.
  37757. */
  37758. preScaleForRendering(): void;
  37759. /**
  37760. * Constructs a spherical harmonics from an array.
  37761. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37762. * @returns the spherical harmonics
  37763. */
  37764. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37765. /**
  37766. * Gets the spherical harmonics from polynomial
  37767. * @param polynomial the spherical polynomial
  37768. * @returns the spherical harmonics
  37769. */
  37770. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37771. }
  37772. /**
  37773. * Class representing spherical polynomial coefficients to the 3rd degree
  37774. */
  37775. export class SphericalPolynomial {
  37776. private _harmonics;
  37777. /**
  37778. * The spherical harmonics used to create the polynomials.
  37779. */
  37780. get preScaledHarmonics(): SphericalHarmonics;
  37781. /**
  37782. * The x coefficients of the spherical polynomial
  37783. */
  37784. x: Vector3;
  37785. /**
  37786. * The y coefficients of the spherical polynomial
  37787. */
  37788. y: Vector3;
  37789. /**
  37790. * The z coefficients of the spherical polynomial
  37791. */
  37792. z: Vector3;
  37793. /**
  37794. * The xx coefficients of the spherical polynomial
  37795. */
  37796. xx: Vector3;
  37797. /**
  37798. * The yy coefficients of the spherical polynomial
  37799. */
  37800. yy: Vector3;
  37801. /**
  37802. * The zz coefficients of the spherical polynomial
  37803. */
  37804. zz: Vector3;
  37805. /**
  37806. * The xy coefficients of the spherical polynomial
  37807. */
  37808. xy: Vector3;
  37809. /**
  37810. * The yz coefficients of the spherical polynomial
  37811. */
  37812. yz: Vector3;
  37813. /**
  37814. * The zx coefficients of the spherical polynomial
  37815. */
  37816. zx: Vector3;
  37817. /**
  37818. * Adds an ambient color to the spherical polynomial
  37819. * @param color the color to add
  37820. */
  37821. addAmbient(color: Color3): void;
  37822. /**
  37823. * Scales the spherical polynomial by the given amount
  37824. * @param scale the amount to scale
  37825. */
  37826. scaleInPlace(scale: number): void;
  37827. /**
  37828. * Gets the spherical polynomial from harmonics
  37829. * @param harmonics the spherical harmonics
  37830. * @returns the spherical polynomial
  37831. */
  37832. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37833. /**
  37834. * Constructs a spherical polynomial from an array.
  37835. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37836. * @returns the spherical polynomial
  37837. */
  37838. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37839. }
  37840. }
  37841. declare module "babylonjs/Materials/Textures/internalTexture" {
  37842. import { Observable } from "babylonjs/Misc/observable";
  37843. import { Nullable, int } from "babylonjs/types";
  37844. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37846. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37847. /**
  37848. * Defines the source of the internal texture
  37849. */
  37850. export enum InternalTextureSource {
  37851. /**
  37852. * The source of the texture data is unknown
  37853. */
  37854. Unknown = 0,
  37855. /**
  37856. * Texture data comes from an URL
  37857. */
  37858. Url = 1,
  37859. /**
  37860. * Texture data is only used for temporary storage
  37861. */
  37862. Temp = 2,
  37863. /**
  37864. * Texture data comes from raw data (ArrayBuffer)
  37865. */
  37866. Raw = 3,
  37867. /**
  37868. * Texture content is dynamic (video or dynamic texture)
  37869. */
  37870. Dynamic = 4,
  37871. /**
  37872. * Texture content is generated by rendering to it
  37873. */
  37874. RenderTarget = 5,
  37875. /**
  37876. * Texture content is part of a multi render target process
  37877. */
  37878. MultiRenderTarget = 6,
  37879. /**
  37880. * Texture data comes from a cube data file
  37881. */
  37882. Cube = 7,
  37883. /**
  37884. * Texture data comes from a raw cube data
  37885. */
  37886. CubeRaw = 8,
  37887. /**
  37888. * Texture data come from a prefiltered cube data file
  37889. */
  37890. CubePrefiltered = 9,
  37891. /**
  37892. * Texture content is raw 3D data
  37893. */
  37894. Raw3D = 10,
  37895. /**
  37896. * Texture content is raw 2D array data
  37897. */
  37898. Raw2DArray = 11,
  37899. /**
  37900. * Texture content is a depth texture
  37901. */
  37902. Depth = 12,
  37903. /**
  37904. * Texture data comes from a raw cube data encoded with RGBD
  37905. */
  37906. CubeRawRGBD = 13
  37907. }
  37908. /**
  37909. * Class used to store data associated with WebGL texture data for the engine
  37910. * This class should not be used directly
  37911. */
  37912. export class InternalTexture {
  37913. /** @hidden */
  37914. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37915. /**
  37916. * Defines if the texture is ready
  37917. */
  37918. isReady: boolean;
  37919. /**
  37920. * Defines if the texture is a cube texture
  37921. */
  37922. isCube: boolean;
  37923. /**
  37924. * Defines if the texture contains 3D data
  37925. */
  37926. is3D: boolean;
  37927. /**
  37928. * Defines if the texture contains 2D array data
  37929. */
  37930. is2DArray: boolean;
  37931. /**
  37932. * Defines if the texture contains multiview data
  37933. */
  37934. isMultiview: boolean;
  37935. /**
  37936. * Gets the URL used to load this texture
  37937. */
  37938. url: string;
  37939. /**
  37940. * Gets the sampling mode of the texture
  37941. */
  37942. samplingMode: number;
  37943. /**
  37944. * Gets a boolean indicating if the texture needs mipmaps generation
  37945. */
  37946. generateMipMaps: boolean;
  37947. /**
  37948. * Gets the number of samples used by the texture (WebGL2+ only)
  37949. */
  37950. samples: number;
  37951. /**
  37952. * Gets the type of the texture (int, float...)
  37953. */
  37954. type: number;
  37955. /**
  37956. * Gets the format of the texture (RGB, RGBA...)
  37957. */
  37958. format: number;
  37959. /**
  37960. * Observable called when the texture is loaded
  37961. */
  37962. onLoadedObservable: Observable<InternalTexture>;
  37963. /**
  37964. * Gets the width of the texture
  37965. */
  37966. width: number;
  37967. /**
  37968. * Gets the height of the texture
  37969. */
  37970. height: number;
  37971. /**
  37972. * Gets the depth of the texture
  37973. */
  37974. depth: number;
  37975. /**
  37976. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37977. */
  37978. baseWidth: number;
  37979. /**
  37980. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37981. */
  37982. baseHeight: number;
  37983. /**
  37984. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37985. */
  37986. baseDepth: number;
  37987. /**
  37988. * Gets a boolean indicating if the texture is inverted on Y axis
  37989. */
  37990. invertY: boolean;
  37991. /** @hidden */
  37992. _invertVScale: boolean;
  37993. /** @hidden */
  37994. _associatedChannel: number;
  37995. /** @hidden */
  37996. _source: InternalTextureSource;
  37997. /** @hidden */
  37998. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37999. /** @hidden */
  38000. _bufferView: Nullable<ArrayBufferView>;
  38001. /** @hidden */
  38002. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38003. /** @hidden */
  38004. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38005. /** @hidden */
  38006. _size: number;
  38007. /** @hidden */
  38008. _extension: string;
  38009. /** @hidden */
  38010. _files: Nullable<string[]>;
  38011. /** @hidden */
  38012. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38013. /** @hidden */
  38014. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38015. /** @hidden */
  38016. _framebuffer: Nullable<WebGLFramebuffer>;
  38017. /** @hidden */
  38018. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38019. /** @hidden */
  38020. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38021. /** @hidden */
  38022. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38023. /** @hidden */
  38024. _attachments: Nullable<number[]>;
  38025. /** @hidden */
  38026. _textureArray: Nullable<InternalTexture[]>;
  38027. /** @hidden */
  38028. _cachedCoordinatesMode: Nullable<number>;
  38029. /** @hidden */
  38030. _cachedWrapU: Nullable<number>;
  38031. /** @hidden */
  38032. _cachedWrapV: Nullable<number>;
  38033. /** @hidden */
  38034. _cachedWrapR: Nullable<number>;
  38035. /** @hidden */
  38036. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38037. /** @hidden */
  38038. _isDisabled: boolean;
  38039. /** @hidden */
  38040. _compression: Nullable<string>;
  38041. /** @hidden */
  38042. _generateStencilBuffer: boolean;
  38043. /** @hidden */
  38044. _generateDepthBuffer: boolean;
  38045. /** @hidden */
  38046. _comparisonFunction: number;
  38047. /** @hidden */
  38048. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38049. /** @hidden */
  38050. _lodGenerationScale: number;
  38051. /** @hidden */
  38052. _lodGenerationOffset: number;
  38053. /** @hidden */
  38054. _depthStencilTexture: Nullable<InternalTexture>;
  38055. /** @hidden */
  38056. _colorTextureArray: Nullable<WebGLTexture>;
  38057. /** @hidden */
  38058. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38059. /** @hidden */
  38060. _lodTextureHigh: Nullable<BaseTexture>;
  38061. /** @hidden */
  38062. _lodTextureMid: Nullable<BaseTexture>;
  38063. /** @hidden */
  38064. _lodTextureLow: Nullable<BaseTexture>;
  38065. /** @hidden */
  38066. _isRGBD: boolean;
  38067. /** @hidden */
  38068. _linearSpecularLOD: boolean;
  38069. /** @hidden */
  38070. _irradianceTexture: Nullable<BaseTexture>;
  38071. /** @hidden */
  38072. _webGLTexture: Nullable<WebGLTexture>;
  38073. /** @hidden */
  38074. _references: number;
  38075. /** @hidden */
  38076. _gammaSpace: Nullable<boolean>;
  38077. private _engine;
  38078. /**
  38079. * Gets the Engine the texture belongs to.
  38080. * @returns The babylon engine
  38081. */
  38082. getEngine(): ThinEngine;
  38083. /**
  38084. * Gets the data source type of the texture
  38085. */
  38086. get source(): InternalTextureSource;
  38087. /**
  38088. * Creates a new InternalTexture
  38089. * @param engine defines the engine to use
  38090. * @param source defines the type of data that will be used
  38091. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38092. */
  38093. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38094. /**
  38095. * Increments the number of references (ie. the number of Texture that point to it)
  38096. */
  38097. incrementReferences(): void;
  38098. /**
  38099. * Change the size of the texture (not the size of the content)
  38100. * @param width defines the new width
  38101. * @param height defines the new height
  38102. * @param depth defines the new depth (1 by default)
  38103. */
  38104. updateSize(width: int, height: int, depth?: int): void;
  38105. /** @hidden */
  38106. _rebuild(): void;
  38107. /** @hidden */
  38108. _swapAndDie(target: InternalTexture): void;
  38109. /**
  38110. * Dispose the current allocated resources
  38111. */
  38112. dispose(): void;
  38113. }
  38114. }
  38115. declare module "babylonjs/Audio/analyser" {
  38116. import { Scene } from "babylonjs/scene";
  38117. /**
  38118. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38120. */
  38121. export class Analyser {
  38122. /**
  38123. * Gets or sets the smoothing
  38124. * @ignorenaming
  38125. */
  38126. SMOOTHING: number;
  38127. /**
  38128. * Gets or sets the FFT table size
  38129. * @ignorenaming
  38130. */
  38131. FFT_SIZE: number;
  38132. /**
  38133. * Gets or sets the bar graph amplitude
  38134. * @ignorenaming
  38135. */
  38136. BARGRAPHAMPLITUDE: number;
  38137. /**
  38138. * Gets or sets the position of the debug canvas
  38139. * @ignorenaming
  38140. */
  38141. DEBUGCANVASPOS: {
  38142. x: number;
  38143. y: number;
  38144. };
  38145. /**
  38146. * Gets or sets the debug canvas size
  38147. * @ignorenaming
  38148. */
  38149. DEBUGCANVASSIZE: {
  38150. width: number;
  38151. height: number;
  38152. };
  38153. private _byteFreqs;
  38154. private _byteTime;
  38155. private _floatFreqs;
  38156. private _webAudioAnalyser;
  38157. private _debugCanvas;
  38158. private _debugCanvasContext;
  38159. private _scene;
  38160. private _registerFunc;
  38161. private _audioEngine;
  38162. /**
  38163. * Creates a new analyser
  38164. * @param scene defines hosting scene
  38165. */
  38166. constructor(scene: Scene);
  38167. /**
  38168. * Get the number of data values you will have to play with for the visualization
  38169. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38170. * @returns a number
  38171. */
  38172. getFrequencyBinCount(): number;
  38173. /**
  38174. * Gets the current frequency data as a byte array
  38175. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38176. * @returns a Uint8Array
  38177. */
  38178. getByteFrequencyData(): Uint8Array;
  38179. /**
  38180. * Gets the current waveform as a byte array
  38181. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38182. * @returns a Uint8Array
  38183. */
  38184. getByteTimeDomainData(): Uint8Array;
  38185. /**
  38186. * Gets the current frequency data as a float array
  38187. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38188. * @returns a Float32Array
  38189. */
  38190. getFloatFrequencyData(): Float32Array;
  38191. /**
  38192. * Renders the debug canvas
  38193. */
  38194. drawDebugCanvas(): void;
  38195. /**
  38196. * Stops rendering the debug canvas and removes it
  38197. */
  38198. stopDebugCanvas(): void;
  38199. /**
  38200. * Connects two audio nodes
  38201. * @param inputAudioNode defines first node to connect
  38202. * @param outputAudioNode defines second node to connect
  38203. */
  38204. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38205. /**
  38206. * Releases all associated resources
  38207. */
  38208. dispose(): void;
  38209. }
  38210. }
  38211. declare module "babylonjs/Audio/audioEngine" {
  38212. import { IDisposable } from "babylonjs/scene";
  38213. import { Analyser } from "babylonjs/Audio/analyser";
  38214. import { Nullable } from "babylonjs/types";
  38215. import { Observable } from "babylonjs/Misc/observable";
  38216. /**
  38217. * This represents an audio engine and it is responsible
  38218. * to play, synchronize and analyse sounds throughout the application.
  38219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38220. */
  38221. export interface IAudioEngine extends IDisposable {
  38222. /**
  38223. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38224. */
  38225. readonly canUseWebAudio: boolean;
  38226. /**
  38227. * Gets the current AudioContext if available.
  38228. */
  38229. readonly audioContext: Nullable<AudioContext>;
  38230. /**
  38231. * The master gain node defines the global audio volume of your audio engine.
  38232. */
  38233. readonly masterGain: GainNode;
  38234. /**
  38235. * Gets whether or not mp3 are supported by your browser.
  38236. */
  38237. readonly isMP3supported: boolean;
  38238. /**
  38239. * Gets whether or not ogg are supported by your browser.
  38240. */
  38241. readonly isOGGsupported: boolean;
  38242. /**
  38243. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38244. * @ignoreNaming
  38245. */
  38246. WarnedWebAudioUnsupported: boolean;
  38247. /**
  38248. * Defines if the audio engine relies on a custom unlocked button.
  38249. * In this case, the embedded button will not be displayed.
  38250. */
  38251. useCustomUnlockedButton: boolean;
  38252. /**
  38253. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38254. */
  38255. readonly unlocked: boolean;
  38256. /**
  38257. * Event raised when audio has been unlocked on the browser.
  38258. */
  38259. onAudioUnlockedObservable: Observable<AudioEngine>;
  38260. /**
  38261. * Event raised when audio has been locked on the browser.
  38262. */
  38263. onAudioLockedObservable: Observable<AudioEngine>;
  38264. /**
  38265. * Flags the audio engine in Locked state.
  38266. * This happens due to new browser policies preventing audio to autoplay.
  38267. */
  38268. lock(): void;
  38269. /**
  38270. * Unlocks the audio engine once a user action has been done on the dom.
  38271. * This is helpful to resume play once browser policies have been satisfied.
  38272. */
  38273. unlock(): void;
  38274. /**
  38275. * Gets the global volume sets on the master gain.
  38276. * @returns the global volume if set or -1 otherwise
  38277. */
  38278. getGlobalVolume(): number;
  38279. /**
  38280. * Sets the global volume of your experience (sets on the master gain).
  38281. * @param newVolume Defines the new global volume of the application
  38282. */
  38283. setGlobalVolume(newVolume: number): void;
  38284. /**
  38285. * Connect the audio engine to an audio analyser allowing some amazing
  38286. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38287. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38288. * @param analyser The analyser to connect to the engine
  38289. */
  38290. connectToAnalyser(analyser: Analyser): void;
  38291. }
  38292. /**
  38293. * This represents the default audio engine used in babylon.
  38294. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38296. */
  38297. export class AudioEngine implements IAudioEngine {
  38298. private _audioContext;
  38299. private _audioContextInitialized;
  38300. private _muteButton;
  38301. private _hostElement;
  38302. /**
  38303. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38304. */
  38305. canUseWebAudio: boolean;
  38306. /**
  38307. * The master gain node defines the global audio volume of your audio engine.
  38308. */
  38309. masterGain: GainNode;
  38310. /**
  38311. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38312. * @ignoreNaming
  38313. */
  38314. WarnedWebAudioUnsupported: boolean;
  38315. /**
  38316. * Gets whether or not mp3 are supported by your browser.
  38317. */
  38318. isMP3supported: boolean;
  38319. /**
  38320. * Gets whether or not ogg are supported by your browser.
  38321. */
  38322. isOGGsupported: boolean;
  38323. /**
  38324. * Gets whether audio has been unlocked on the device.
  38325. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38326. * a user interaction has happened.
  38327. */
  38328. unlocked: boolean;
  38329. /**
  38330. * Defines if the audio engine relies on a custom unlocked button.
  38331. * In this case, the embedded button will not be displayed.
  38332. */
  38333. useCustomUnlockedButton: boolean;
  38334. /**
  38335. * Event raised when audio has been unlocked on the browser.
  38336. */
  38337. onAudioUnlockedObservable: Observable<AudioEngine>;
  38338. /**
  38339. * Event raised when audio has been locked on the browser.
  38340. */
  38341. onAudioLockedObservable: Observable<AudioEngine>;
  38342. /**
  38343. * Gets the current AudioContext if available.
  38344. */
  38345. get audioContext(): Nullable<AudioContext>;
  38346. private _connectedAnalyser;
  38347. /**
  38348. * Instantiates a new audio engine.
  38349. *
  38350. * There should be only one per page as some browsers restrict the number
  38351. * of audio contexts you can create.
  38352. * @param hostElement defines the host element where to display the mute icon if necessary
  38353. */
  38354. constructor(hostElement?: Nullable<HTMLElement>);
  38355. /**
  38356. * Flags the audio engine in Locked state.
  38357. * This happens due to new browser policies preventing audio to autoplay.
  38358. */
  38359. lock(): void;
  38360. /**
  38361. * Unlocks the audio engine once a user action has been done on the dom.
  38362. * This is helpful to resume play once browser policies have been satisfied.
  38363. */
  38364. unlock(): void;
  38365. private _resumeAudioContext;
  38366. private _initializeAudioContext;
  38367. private _tryToRun;
  38368. private _triggerRunningState;
  38369. private _triggerSuspendedState;
  38370. private _displayMuteButton;
  38371. private _moveButtonToTopLeft;
  38372. private _onResize;
  38373. private _hideMuteButton;
  38374. /**
  38375. * Destroy and release the resources associated with the audio ccontext.
  38376. */
  38377. dispose(): void;
  38378. /**
  38379. * Gets the global volume sets on the master gain.
  38380. * @returns the global volume if set or -1 otherwise
  38381. */
  38382. getGlobalVolume(): number;
  38383. /**
  38384. * Sets the global volume of your experience (sets on the master gain).
  38385. * @param newVolume Defines the new global volume of the application
  38386. */
  38387. setGlobalVolume(newVolume: number): void;
  38388. /**
  38389. * Connect the audio engine to an audio analyser allowing some amazing
  38390. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38391. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38392. * @param analyser The analyser to connect to the engine
  38393. */
  38394. connectToAnalyser(analyser: Analyser): void;
  38395. }
  38396. }
  38397. declare module "babylonjs/Loading/loadingScreen" {
  38398. /**
  38399. * Interface used to present a loading screen while loading a scene
  38400. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38401. */
  38402. export interface ILoadingScreen {
  38403. /**
  38404. * Function called to display the loading screen
  38405. */
  38406. displayLoadingUI: () => void;
  38407. /**
  38408. * Function called to hide the loading screen
  38409. */
  38410. hideLoadingUI: () => void;
  38411. /**
  38412. * Gets or sets the color to use for the background
  38413. */
  38414. loadingUIBackgroundColor: string;
  38415. /**
  38416. * Gets or sets the text to display while loading
  38417. */
  38418. loadingUIText: string;
  38419. }
  38420. /**
  38421. * Class used for the default loading screen
  38422. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38423. */
  38424. export class DefaultLoadingScreen implements ILoadingScreen {
  38425. private _renderingCanvas;
  38426. private _loadingText;
  38427. private _loadingDivBackgroundColor;
  38428. private _loadingDiv;
  38429. private _loadingTextDiv;
  38430. /** Gets or sets the logo url to use for the default loading screen */
  38431. static DefaultLogoUrl: string;
  38432. /** Gets or sets the spinner url to use for the default loading screen */
  38433. static DefaultSpinnerUrl: string;
  38434. /**
  38435. * Creates a new default loading screen
  38436. * @param _renderingCanvas defines the canvas used to render the scene
  38437. * @param _loadingText defines the default text to display
  38438. * @param _loadingDivBackgroundColor defines the default background color
  38439. */
  38440. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38441. /**
  38442. * Function called to display the loading screen
  38443. */
  38444. displayLoadingUI(): void;
  38445. /**
  38446. * Function called to hide the loading screen
  38447. */
  38448. hideLoadingUI(): void;
  38449. /**
  38450. * Gets or sets the text to display while loading
  38451. */
  38452. set loadingUIText(text: string);
  38453. get loadingUIText(): string;
  38454. /**
  38455. * Gets or sets the color to use for the background
  38456. */
  38457. get loadingUIBackgroundColor(): string;
  38458. set loadingUIBackgroundColor(color: string);
  38459. private _resizeLoadingUI;
  38460. }
  38461. }
  38462. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38463. /**
  38464. * Interface for any object that can request an animation frame
  38465. */
  38466. export interface ICustomAnimationFrameRequester {
  38467. /**
  38468. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38469. */
  38470. renderFunction?: Function;
  38471. /**
  38472. * Called to request the next frame to render to
  38473. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38474. */
  38475. requestAnimationFrame: Function;
  38476. /**
  38477. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38478. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38479. */
  38480. requestID?: number;
  38481. }
  38482. }
  38483. declare module "babylonjs/Misc/performanceMonitor" {
  38484. /**
  38485. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38486. */
  38487. export class PerformanceMonitor {
  38488. private _enabled;
  38489. private _rollingFrameTime;
  38490. private _lastFrameTimeMs;
  38491. /**
  38492. * constructor
  38493. * @param frameSampleSize The number of samples required to saturate the sliding window
  38494. */
  38495. constructor(frameSampleSize?: number);
  38496. /**
  38497. * Samples current frame
  38498. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38499. */
  38500. sampleFrame(timeMs?: number): void;
  38501. /**
  38502. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38503. */
  38504. get averageFrameTime(): number;
  38505. /**
  38506. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38507. */
  38508. get averageFrameTimeVariance(): number;
  38509. /**
  38510. * Returns the frame time of the most recent frame
  38511. */
  38512. get instantaneousFrameTime(): number;
  38513. /**
  38514. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38515. */
  38516. get averageFPS(): number;
  38517. /**
  38518. * Returns the average framerate in frames per second using the most recent frame time
  38519. */
  38520. get instantaneousFPS(): number;
  38521. /**
  38522. * Returns true if enough samples have been taken to completely fill the sliding window
  38523. */
  38524. get isSaturated(): boolean;
  38525. /**
  38526. * Enables contributions to the sliding window sample set
  38527. */
  38528. enable(): void;
  38529. /**
  38530. * Disables contributions to the sliding window sample set
  38531. * Samples will not be interpolated over the disabled period
  38532. */
  38533. disable(): void;
  38534. /**
  38535. * Returns true if sampling is enabled
  38536. */
  38537. get isEnabled(): boolean;
  38538. /**
  38539. * Resets performance monitor
  38540. */
  38541. reset(): void;
  38542. }
  38543. /**
  38544. * RollingAverage
  38545. *
  38546. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38547. */
  38548. export class RollingAverage {
  38549. /**
  38550. * Current average
  38551. */
  38552. average: number;
  38553. /**
  38554. * Current variance
  38555. */
  38556. variance: number;
  38557. protected _samples: Array<number>;
  38558. protected _sampleCount: number;
  38559. protected _pos: number;
  38560. protected _m2: number;
  38561. /**
  38562. * constructor
  38563. * @param length The number of samples required to saturate the sliding window
  38564. */
  38565. constructor(length: number);
  38566. /**
  38567. * Adds a sample to the sample set
  38568. * @param v The sample value
  38569. */
  38570. add(v: number): void;
  38571. /**
  38572. * Returns previously added values or null if outside of history or outside the sliding window domain
  38573. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38574. * @return Value previously recorded with add() or null if outside of range
  38575. */
  38576. history(i: number): number;
  38577. /**
  38578. * Returns true if enough samples have been taken to completely fill the sliding window
  38579. * @return true if sample-set saturated
  38580. */
  38581. isSaturated(): boolean;
  38582. /**
  38583. * Resets the rolling average (equivalent to 0 samples taken so far)
  38584. */
  38585. reset(): void;
  38586. /**
  38587. * Wraps a value around the sample range boundaries
  38588. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38589. * @return Wrapped position in sample range
  38590. */
  38591. protected _wrapPosition(i: number): number;
  38592. }
  38593. }
  38594. declare module "babylonjs/Misc/perfCounter" {
  38595. /**
  38596. * This class is used to track a performance counter which is number based.
  38597. * The user has access to many properties which give statistics of different nature.
  38598. *
  38599. * The implementer can track two kinds of Performance Counter: time and count.
  38600. * 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.
  38601. * 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.
  38602. */
  38603. export class PerfCounter {
  38604. /**
  38605. * Gets or sets a global boolean to turn on and off all the counters
  38606. */
  38607. static Enabled: boolean;
  38608. /**
  38609. * Returns the smallest value ever
  38610. */
  38611. get min(): number;
  38612. /**
  38613. * Returns the biggest value ever
  38614. */
  38615. get max(): number;
  38616. /**
  38617. * Returns the average value since the performance counter is running
  38618. */
  38619. get average(): number;
  38620. /**
  38621. * Returns the average value of the last second the counter was monitored
  38622. */
  38623. get lastSecAverage(): number;
  38624. /**
  38625. * Returns the current value
  38626. */
  38627. get current(): number;
  38628. /**
  38629. * Gets the accumulated total
  38630. */
  38631. get total(): number;
  38632. /**
  38633. * Gets the total value count
  38634. */
  38635. get count(): number;
  38636. /**
  38637. * Creates a new counter
  38638. */
  38639. constructor();
  38640. /**
  38641. * Call this method to start monitoring a new frame.
  38642. * 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.
  38643. */
  38644. fetchNewFrame(): void;
  38645. /**
  38646. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38647. * @param newCount the count value to add to the monitored count
  38648. * @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.
  38649. */
  38650. addCount(newCount: number, fetchResult: boolean): void;
  38651. /**
  38652. * Start monitoring this performance counter
  38653. */
  38654. beginMonitoring(): void;
  38655. /**
  38656. * Compute the time lapsed since the previous beginMonitoring() call.
  38657. * @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
  38658. */
  38659. endMonitoring(newFrame?: boolean): void;
  38660. private _fetchResult;
  38661. private _startMonitoringTime;
  38662. private _min;
  38663. private _max;
  38664. private _average;
  38665. private _current;
  38666. private _totalValueCount;
  38667. private _totalAccumulated;
  38668. private _lastSecAverage;
  38669. private _lastSecAccumulated;
  38670. private _lastSecTime;
  38671. private _lastSecValueCount;
  38672. }
  38673. }
  38674. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38675. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38676. import { Nullable } from "babylonjs/types";
  38677. module "babylonjs/Engines/thinEngine" {
  38678. interface ThinEngine {
  38679. /** @hidden */
  38680. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38681. }
  38682. }
  38683. }
  38684. declare module "babylonjs/Engines/engine" {
  38685. import { Observable } from "babylonjs/Misc/observable";
  38686. import { Nullable } from "babylonjs/types";
  38687. import { Scene } from "babylonjs/scene";
  38688. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38689. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38690. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38691. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38692. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38693. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38694. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38695. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38696. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38697. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38698. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38699. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38700. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38701. import "babylonjs/Engines/Extensions/engine.alpha";
  38702. import "babylonjs/Engines/Extensions/engine.readTexture";
  38703. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38704. import { Material } from "babylonjs/Materials/material";
  38705. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38706. /**
  38707. * Defines the interface used by display changed events
  38708. */
  38709. export interface IDisplayChangedEventArgs {
  38710. /** Gets the vrDisplay object (if any) */
  38711. vrDisplay: Nullable<any>;
  38712. /** Gets a boolean indicating if webVR is supported */
  38713. vrSupported: boolean;
  38714. }
  38715. /**
  38716. * Defines the interface used by objects containing a viewport (like a camera)
  38717. */
  38718. interface IViewportOwnerLike {
  38719. /**
  38720. * Gets or sets the viewport
  38721. */
  38722. viewport: IViewportLike;
  38723. }
  38724. /**
  38725. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38726. */
  38727. export class Engine extends ThinEngine {
  38728. /** Defines that alpha blending is disabled */
  38729. static readonly ALPHA_DISABLE: number;
  38730. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38731. static readonly ALPHA_ADD: number;
  38732. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38733. static readonly ALPHA_COMBINE: number;
  38734. /** Defines that alpha blending to DEST - SRC * DEST */
  38735. static readonly ALPHA_SUBTRACT: number;
  38736. /** Defines that alpha blending to SRC * DEST */
  38737. static readonly ALPHA_MULTIPLY: number;
  38738. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38739. static readonly ALPHA_MAXIMIZED: number;
  38740. /** Defines that alpha blending to SRC + DEST */
  38741. static readonly ALPHA_ONEONE: number;
  38742. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38743. static readonly ALPHA_PREMULTIPLIED: number;
  38744. /**
  38745. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38746. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38747. */
  38748. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38749. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38750. static readonly ALPHA_INTERPOLATE: number;
  38751. /**
  38752. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38753. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38754. */
  38755. static readonly ALPHA_SCREENMODE: number;
  38756. /** Defines that the ressource is not delayed*/
  38757. static readonly DELAYLOADSTATE_NONE: number;
  38758. /** Defines that the ressource was successfully delay loaded */
  38759. static readonly DELAYLOADSTATE_LOADED: number;
  38760. /** Defines that the ressource is currently delay loading */
  38761. static readonly DELAYLOADSTATE_LOADING: number;
  38762. /** Defines that the ressource is delayed and has not started loading */
  38763. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38765. static readonly NEVER: number;
  38766. /** 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 */
  38767. static readonly ALWAYS: number;
  38768. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38769. static readonly LESS: number;
  38770. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38771. static readonly EQUAL: number;
  38772. /** 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 */
  38773. static readonly LEQUAL: number;
  38774. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38775. static readonly GREATER: number;
  38776. /** 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 */
  38777. static readonly GEQUAL: number;
  38778. /** 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 */
  38779. static readonly NOTEQUAL: number;
  38780. /** Passed to stencilOperation to specify that stencil value must be kept */
  38781. static readonly KEEP: number;
  38782. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38783. static readonly REPLACE: number;
  38784. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38785. static readonly INCR: number;
  38786. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38787. static readonly DECR: number;
  38788. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38789. static readonly INVERT: number;
  38790. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38791. static readonly INCR_WRAP: number;
  38792. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38793. static readonly DECR_WRAP: number;
  38794. /** Texture is not repeating outside of 0..1 UVs */
  38795. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38796. /** Texture is repeating outside of 0..1 UVs */
  38797. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38798. /** Texture is repeating and mirrored */
  38799. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38800. /** ALPHA */
  38801. static readonly TEXTUREFORMAT_ALPHA: number;
  38802. /** LUMINANCE */
  38803. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38804. /** LUMINANCE_ALPHA */
  38805. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38806. /** RGB */
  38807. static readonly TEXTUREFORMAT_RGB: number;
  38808. /** RGBA */
  38809. static readonly TEXTUREFORMAT_RGBA: number;
  38810. /** RED */
  38811. static readonly TEXTUREFORMAT_RED: number;
  38812. /** RED (2nd reference) */
  38813. static readonly TEXTUREFORMAT_R: number;
  38814. /** RG */
  38815. static readonly TEXTUREFORMAT_RG: number;
  38816. /** RED_INTEGER */
  38817. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38818. /** RED_INTEGER (2nd reference) */
  38819. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38820. /** RG_INTEGER */
  38821. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38822. /** RGB_INTEGER */
  38823. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38824. /** RGBA_INTEGER */
  38825. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38826. /** UNSIGNED_BYTE */
  38827. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38828. /** UNSIGNED_BYTE (2nd reference) */
  38829. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38830. /** FLOAT */
  38831. static readonly TEXTURETYPE_FLOAT: number;
  38832. /** HALF_FLOAT */
  38833. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38834. /** BYTE */
  38835. static readonly TEXTURETYPE_BYTE: number;
  38836. /** SHORT */
  38837. static readonly TEXTURETYPE_SHORT: number;
  38838. /** UNSIGNED_SHORT */
  38839. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38840. /** INT */
  38841. static readonly TEXTURETYPE_INT: number;
  38842. /** UNSIGNED_INT */
  38843. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38844. /** UNSIGNED_SHORT_4_4_4_4 */
  38845. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38846. /** UNSIGNED_SHORT_5_5_5_1 */
  38847. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38848. /** UNSIGNED_SHORT_5_6_5 */
  38849. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38850. /** UNSIGNED_INT_2_10_10_10_REV */
  38851. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38852. /** UNSIGNED_INT_24_8 */
  38853. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38854. /** UNSIGNED_INT_10F_11F_11F_REV */
  38855. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38856. /** UNSIGNED_INT_5_9_9_9_REV */
  38857. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38858. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38859. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38860. /** nearest is mag = nearest and min = nearest and mip = linear */
  38861. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38863. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38864. /** Trilinear is mag = linear and min = linear and mip = linear */
  38865. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38866. /** nearest is mag = nearest and min = nearest and mip = linear */
  38867. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38868. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38869. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38870. /** Trilinear is mag = linear and min = linear and mip = linear */
  38871. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38872. /** mag = nearest and min = nearest and mip = nearest */
  38873. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38874. /** mag = nearest and min = linear and mip = nearest */
  38875. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38876. /** mag = nearest and min = linear and mip = linear */
  38877. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38878. /** mag = nearest and min = linear and mip = none */
  38879. static readonly TEXTURE_NEAREST_LINEAR: number;
  38880. /** mag = nearest and min = nearest and mip = none */
  38881. static readonly TEXTURE_NEAREST_NEAREST: number;
  38882. /** mag = linear and min = nearest and mip = nearest */
  38883. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38884. /** mag = linear and min = nearest and mip = linear */
  38885. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38886. /** mag = linear and min = linear and mip = none */
  38887. static readonly TEXTURE_LINEAR_LINEAR: number;
  38888. /** mag = linear and min = nearest and mip = none */
  38889. static readonly TEXTURE_LINEAR_NEAREST: number;
  38890. /** Explicit coordinates mode */
  38891. static readonly TEXTURE_EXPLICIT_MODE: number;
  38892. /** Spherical coordinates mode */
  38893. static readonly TEXTURE_SPHERICAL_MODE: number;
  38894. /** Planar coordinates mode */
  38895. static readonly TEXTURE_PLANAR_MODE: number;
  38896. /** Cubic coordinates mode */
  38897. static readonly TEXTURE_CUBIC_MODE: number;
  38898. /** Projection coordinates mode */
  38899. static readonly TEXTURE_PROJECTION_MODE: number;
  38900. /** Skybox coordinates mode */
  38901. static readonly TEXTURE_SKYBOX_MODE: number;
  38902. /** Inverse Cubic coordinates mode */
  38903. static readonly TEXTURE_INVCUBIC_MODE: number;
  38904. /** Equirectangular coordinates mode */
  38905. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38906. /** Equirectangular Fixed coordinates mode */
  38907. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38908. /** Equirectangular Fixed Mirrored coordinates mode */
  38909. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38910. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38911. static readonly SCALEMODE_FLOOR: number;
  38912. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38913. static readonly SCALEMODE_NEAREST: number;
  38914. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38915. static readonly SCALEMODE_CEILING: number;
  38916. /**
  38917. * Returns the current npm package of the sdk
  38918. */
  38919. static get NpmPackage(): string;
  38920. /**
  38921. * Returns the current version of the framework
  38922. */
  38923. static get Version(): string;
  38924. /** Gets the list of created engines */
  38925. static get Instances(): Engine[];
  38926. /**
  38927. * Gets the latest created engine
  38928. */
  38929. static get LastCreatedEngine(): Nullable<Engine>;
  38930. /**
  38931. * Gets the latest created scene
  38932. */
  38933. static get LastCreatedScene(): Nullable<Scene>;
  38934. /**
  38935. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38936. * @param flag defines which part of the materials must be marked as dirty
  38937. * @param predicate defines a predicate used to filter which materials should be affected
  38938. */
  38939. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38940. /**
  38941. * Method called to create the default loading screen.
  38942. * This can be overriden in your own app.
  38943. * @param canvas The rendering canvas element
  38944. * @returns The loading screen
  38945. */
  38946. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38947. /**
  38948. * Method called to create the default rescale post process on each engine.
  38949. */
  38950. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38951. /**
  38952. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38953. **/
  38954. enableOfflineSupport: boolean;
  38955. /**
  38956. * 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)
  38957. **/
  38958. disableManifestCheck: boolean;
  38959. /**
  38960. * Gets the list of created scenes
  38961. */
  38962. scenes: Scene[];
  38963. /**
  38964. * Event raised when a new scene is created
  38965. */
  38966. onNewSceneAddedObservable: Observable<Scene>;
  38967. /**
  38968. * Gets the list of created postprocesses
  38969. */
  38970. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38971. /**
  38972. * Gets a boolean indicating if the pointer is currently locked
  38973. */
  38974. isPointerLock: boolean;
  38975. /**
  38976. * Observable event triggered each time the rendering canvas is resized
  38977. */
  38978. onResizeObservable: Observable<Engine>;
  38979. /**
  38980. * Observable event triggered each time the canvas loses focus
  38981. */
  38982. onCanvasBlurObservable: Observable<Engine>;
  38983. /**
  38984. * Observable event triggered each time the canvas gains focus
  38985. */
  38986. onCanvasFocusObservable: Observable<Engine>;
  38987. /**
  38988. * Observable event triggered each time the canvas receives pointerout event
  38989. */
  38990. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38991. /**
  38992. * Observable raised when the engine begins a new frame
  38993. */
  38994. onBeginFrameObservable: Observable<Engine>;
  38995. /**
  38996. * If set, will be used to request the next animation frame for the render loop
  38997. */
  38998. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38999. /**
  39000. * Observable raised when the engine ends the current frame
  39001. */
  39002. onEndFrameObservable: Observable<Engine>;
  39003. /**
  39004. * Observable raised when the engine is about to compile a shader
  39005. */
  39006. onBeforeShaderCompilationObservable: Observable<Engine>;
  39007. /**
  39008. * Observable raised when the engine has jsut compiled a shader
  39009. */
  39010. onAfterShaderCompilationObservable: Observable<Engine>;
  39011. /**
  39012. * Gets the audio engine
  39013. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39014. * @ignorenaming
  39015. */
  39016. static audioEngine: IAudioEngine;
  39017. /**
  39018. * Default AudioEngine factory responsible of creating the Audio Engine.
  39019. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39020. */
  39021. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39022. /**
  39023. * Default offline support factory responsible of creating a tool used to store data locally.
  39024. * By default, this will create a Database object if the workload has been embedded.
  39025. */
  39026. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39027. private _loadingScreen;
  39028. private _pointerLockRequested;
  39029. private _rescalePostProcess;
  39030. private _deterministicLockstep;
  39031. private _lockstepMaxSteps;
  39032. private _timeStep;
  39033. protected get _supportsHardwareTextureRescaling(): boolean;
  39034. private _fps;
  39035. private _deltaTime;
  39036. /** @hidden */
  39037. _drawCalls: PerfCounter;
  39038. /** 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 */
  39039. canvasTabIndex: number;
  39040. /**
  39041. * Turn this value on if you want to pause FPS computation when in background
  39042. */
  39043. disablePerformanceMonitorInBackground: boolean;
  39044. private _performanceMonitor;
  39045. /**
  39046. * Gets the performance monitor attached to this engine
  39047. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39048. */
  39049. get performanceMonitor(): PerformanceMonitor;
  39050. private _onFocus;
  39051. private _onBlur;
  39052. private _onCanvasPointerOut;
  39053. private _onCanvasBlur;
  39054. private _onCanvasFocus;
  39055. private _onFullscreenChange;
  39056. private _onPointerLockChange;
  39057. /**
  39058. * Gets the HTML element used to attach event listeners
  39059. * @returns a HTML element
  39060. */
  39061. getInputElement(): Nullable<HTMLElement>;
  39062. /**
  39063. * Creates a new engine
  39064. * @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
  39065. * @param antialias defines enable antialiasing (default: false)
  39066. * @param options defines further options to be sent to the getContext() function
  39067. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39068. */
  39069. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39070. /**
  39071. * Gets current aspect ratio
  39072. * @param viewportOwner defines the camera to use to get the aspect ratio
  39073. * @param useScreen defines if screen size must be used (or the current render target if any)
  39074. * @returns a number defining the aspect ratio
  39075. */
  39076. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39077. /**
  39078. * Gets current screen aspect ratio
  39079. * @returns a number defining the aspect ratio
  39080. */
  39081. getScreenAspectRatio(): number;
  39082. /**
  39083. * Gets the client rect of the HTML canvas attached with the current webGL context
  39084. * @returns a client rectanglee
  39085. */
  39086. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39087. /**
  39088. * Gets the client rect of the HTML element used for events
  39089. * @returns a client rectanglee
  39090. */
  39091. getInputElementClientRect(): Nullable<ClientRect>;
  39092. /**
  39093. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39095. * @returns true if engine is in deterministic lock step mode
  39096. */
  39097. isDeterministicLockStep(): boolean;
  39098. /**
  39099. * Gets the max steps when engine is running in deterministic lock step
  39100. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39101. * @returns the max steps
  39102. */
  39103. getLockstepMaxSteps(): number;
  39104. /**
  39105. * Returns the time in ms between steps when using deterministic lock step.
  39106. * @returns time step in (ms)
  39107. */
  39108. getTimeStep(): number;
  39109. /**
  39110. * Force the mipmap generation for the given render target texture
  39111. * @param texture defines the render target texture to use
  39112. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39113. */
  39114. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39115. /** States */
  39116. /**
  39117. * Set various states to the webGL context
  39118. * @param culling defines backface culling state
  39119. * @param zOffset defines the value to apply to zOffset (0 by default)
  39120. * @param force defines if states must be applied even if cache is up to date
  39121. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39122. */
  39123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39124. /**
  39125. * Set the z offset to apply to current rendering
  39126. * @param value defines the offset to apply
  39127. */
  39128. setZOffset(value: number): void;
  39129. /**
  39130. * Gets the current value of the zOffset
  39131. * @returns the current zOffset state
  39132. */
  39133. getZOffset(): number;
  39134. /**
  39135. * Enable or disable depth buffering
  39136. * @param enable defines the state to set
  39137. */
  39138. setDepthBuffer(enable: boolean): void;
  39139. /**
  39140. * Gets a boolean indicating if depth writing is enabled
  39141. * @returns the current depth writing state
  39142. */
  39143. getDepthWrite(): boolean;
  39144. /**
  39145. * Enable or disable depth writing
  39146. * @param enable defines the state to set
  39147. */
  39148. setDepthWrite(enable: boolean): void;
  39149. /**
  39150. * Gets a boolean indicating if stencil buffer is enabled
  39151. * @returns the current stencil buffer state
  39152. */
  39153. getStencilBuffer(): boolean;
  39154. /**
  39155. * Enable or disable the stencil buffer
  39156. * @param enable defines if the stencil buffer must be enabled or disabled
  39157. */
  39158. setStencilBuffer(enable: boolean): void;
  39159. /**
  39160. * Gets the current stencil mask
  39161. * @returns a number defining the new stencil mask to use
  39162. */
  39163. getStencilMask(): number;
  39164. /**
  39165. * Sets the current stencil mask
  39166. * @param mask defines the new stencil mask to use
  39167. */
  39168. setStencilMask(mask: number): void;
  39169. /**
  39170. * Gets the current stencil function
  39171. * @returns a number defining the stencil function to use
  39172. */
  39173. getStencilFunction(): number;
  39174. /**
  39175. * Gets the current stencil reference value
  39176. * @returns a number defining the stencil reference value to use
  39177. */
  39178. getStencilFunctionReference(): number;
  39179. /**
  39180. * Gets the current stencil mask
  39181. * @returns a number defining the stencil mask to use
  39182. */
  39183. getStencilFunctionMask(): number;
  39184. /**
  39185. * Sets the current stencil function
  39186. * @param stencilFunc defines the new stencil function to use
  39187. */
  39188. setStencilFunction(stencilFunc: number): void;
  39189. /**
  39190. * Sets the current stencil reference
  39191. * @param reference defines the new stencil reference to use
  39192. */
  39193. setStencilFunctionReference(reference: number): void;
  39194. /**
  39195. * Sets the current stencil mask
  39196. * @param mask defines the new stencil mask to use
  39197. */
  39198. setStencilFunctionMask(mask: number): void;
  39199. /**
  39200. * Gets the current stencil operation when stencil fails
  39201. * @returns a number defining stencil operation to use when stencil fails
  39202. */
  39203. getStencilOperationFail(): number;
  39204. /**
  39205. * Gets the current stencil operation when depth fails
  39206. * @returns a number defining stencil operation to use when depth fails
  39207. */
  39208. getStencilOperationDepthFail(): number;
  39209. /**
  39210. * Gets the current stencil operation when stencil passes
  39211. * @returns a number defining stencil operation to use when stencil passes
  39212. */
  39213. getStencilOperationPass(): number;
  39214. /**
  39215. * Sets the stencil operation to use when stencil fails
  39216. * @param operation defines the stencil operation to use when stencil fails
  39217. */
  39218. setStencilOperationFail(operation: number): void;
  39219. /**
  39220. * Sets the stencil operation to use when depth fails
  39221. * @param operation defines the stencil operation to use when depth fails
  39222. */
  39223. setStencilOperationDepthFail(operation: number): void;
  39224. /**
  39225. * Sets the stencil operation to use when stencil passes
  39226. * @param operation defines the stencil operation to use when stencil passes
  39227. */
  39228. setStencilOperationPass(operation: number): void;
  39229. /**
  39230. * Sets a boolean indicating if the dithering state is enabled or disabled
  39231. * @param value defines the dithering state
  39232. */
  39233. setDitheringState(value: boolean): void;
  39234. /**
  39235. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39236. * @param value defines the rasterizer state
  39237. */
  39238. setRasterizerState(value: boolean): void;
  39239. /**
  39240. * Gets the current depth function
  39241. * @returns a number defining the depth function
  39242. */
  39243. getDepthFunction(): Nullable<number>;
  39244. /**
  39245. * Sets the current depth function
  39246. * @param depthFunc defines the function to use
  39247. */
  39248. setDepthFunction(depthFunc: number): void;
  39249. /**
  39250. * Sets the current depth function to GREATER
  39251. */
  39252. setDepthFunctionToGreater(): void;
  39253. /**
  39254. * Sets the current depth function to GEQUAL
  39255. */
  39256. setDepthFunctionToGreaterOrEqual(): void;
  39257. /**
  39258. * Sets the current depth function to LESS
  39259. */
  39260. setDepthFunctionToLess(): void;
  39261. /**
  39262. * Sets the current depth function to LEQUAL
  39263. */
  39264. setDepthFunctionToLessOrEqual(): void;
  39265. private _cachedStencilBuffer;
  39266. private _cachedStencilFunction;
  39267. private _cachedStencilMask;
  39268. private _cachedStencilOperationPass;
  39269. private _cachedStencilOperationFail;
  39270. private _cachedStencilOperationDepthFail;
  39271. private _cachedStencilReference;
  39272. /**
  39273. * Caches the the state of the stencil buffer
  39274. */
  39275. cacheStencilState(): void;
  39276. /**
  39277. * Restores the state of the stencil buffer
  39278. */
  39279. restoreStencilState(): void;
  39280. /**
  39281. * Directly set the WebGL Viewport
  39282. * @param x defines the x coordinate of the viewport (in screen space)
  39283. * @param y defines the y coordinate of the viewport (in screen space)
  39284. * @param width defines the width of the viewport (in screen space)
  39285. * @param height defines the height of the viewport (in screen space)
  39286. * @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
  39287. */
  39288. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39289. /**
  39290. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39291. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39292. * @param y defines the y-coordinate of the corner of the clear rectangle
  39293. * @param width defines the width of the clear rectangle
  39294. * @param height defines the height of the clear rectangle
  39295. * @param clearColor defines the clear color
  39296. */
  39297. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39298. /**
  39299. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39300. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39301. * @param y defines the y-coordinate of the corner of the clear rectangle
  39302. * @param width defines the width of the clear rectangle
  39303. * @param height defines the height of the clear rectangle
  39304. */
  39305. enableScissor(x: number, y: number, width: number, height: number): void;
  39306. /**
  39307. * Disable previously set scissor test rectangle
  39308. */
  39309. disableScissor(): void;
  39310. protected _reportDrawCall(): void;
  39311. /**
  39312. * Initializes a webVR display and starts listening to display change events
  39313. * The onVRDisplayChangedObservable will be notified upon these changes
  39314. * @returns The onVRDisplayChangedObservable
  39315. */
  39316. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39317. /** @hidden */
  39318. _prepareVRComponent(): void;
  39319. /** @hidden */
  39320. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39321. /** @hidden */
  39322. _submitVRFrame(): void;
  39323. /**
  39324. * Call this function to leave webVR mode
  39325. * Will do nothing if webVR is not supported or if there is no webVR device
  39326. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39327. */
  39328. disableVR(): void;
  39329. /**
  39330. * Gets a boolean indicating that the system is in VR mode and is presenting
  39331. * @returns true if VR mode is engaged
  39332. */
  39333. isVRPresenting(): boolean;
  39334. /** @hidden */
  39335. _requestVRFrame(): void;
  39336. /** @hidden */
  39337. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39338. /**
  39339. * Gets the source code of the vertex shader associated with a specific webGL program
  39340. * @param program defines the program to use
  39341. * @returns a string containing the source code of the vertex shader associated with the program
  39342. */
  39343. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39344. /**
  39345. * Gets the source code of the fragment shader associated with a specific webGL program
  39346. * @param program defines the program to use
  39347. * @returns a string containing the source code of the fragment shader associated with the program
  39348. */
  39349. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39350. /**
  39351. * Sets a depth stencil texture from a render target to the according uniform.
  39352. * @param channel The texture channel
  39353. * @param uniform The uniform to set
  39354. * @param texture The render target texture containing the depth stencil texture to apply
  39355. */
  39356. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39357. /**
  39358. * Sets a texture to the webGL context from a postprocess
  39359. * @param channel defines the channel to use
  39360. * @param postProcess defines the source postprocess
  39361. */
  39362. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39363. /**
  39364. * Binds the output of the passed in post process to the texture channel specified
  39365. * @param channel The channel the texture should be bound to
  39366. * @param postProcess The post process which's output should be bound
  39367. */
  39368. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39369. protected _rebuildBuffers(): void;
  39370. /** @hidden */
  39371. _renderFrame(): void;
  39372. _renderLoop(): void;
  39373. /** @hidden */
  39374. _renderViews(): boolean;
  39375. /**
  39376. * Toggle full screen mode
  39377. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39378. */
  39379. switchFullscreen(requestPointerLock: boolean): void;
  39380. /**
  39381. * Enters full screen mode
  39382. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39383. */
  39384. enterFullscreen(requestPointerLock: boolean): void;
  39385. /**
  39386. * Exits full screen mode
  39387. */
  39388. exitFullscreen(): void;
  39389. /**
  39390. * Enters Pointerlock mode
  39391. */
  39392. enterPointerlock(): void;
  39393. /**
  39394. * Exits Pointerlock mode
  39395. */
  39396. exitPointerlock(): void;
  39397. /**
  39398. * Begin a new frame
  39399. */
  39400. beginFrame(): void;
  39401. /**
  39402. * Enf the current frame
  39403. */
  39404. endFrame(): void;
  39405. resize(): void;
  39406. /**
  39407. * Force a specific size of the canvas
  39408. * @param width defines the new canvas' width
  39409. * @param height defines the new canvas' height
  39410. * @returns true if the size was changed
  39411. */
  39412. setSize(width: number, height: number): boolean;
  39413. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39415. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39416. _releaseTexture(texture: InternalTexture): void;
  39417. /**
  39418. * @hidden
  39419. * Rescales a texture
  39420. * @param source input texutre
  39421. * @param destination destination texture
  39422. * @param scene scene to use to render the resize
  39423. * @param internalFormat format to use when resizing
  39424. * @param onComplete callback to be called when resize has completed
  39425. */
  39426. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39427. /**
  39428. * Gets the current framerate
  39429. * @returns a number representing the framerate
  39430. */
  39431. getFps(): number;
  39432. /**
  39433. * Gets the time spent between current and previous frame
  39434. * @returns a number representing the delta time in ms
  39435. */
  39436. getDeltaTime(): number;
  39437. private _measureFps;
  39438. /** @hidden */
  39439. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39440. /**
  39441. * Updates the sample count of a render target texture
  39442. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39443. * @param texture defines the texture to update
  39444. * @param samples defines the sample count to set
  39445. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39446. */
  39447. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39448. /**
  39449. * Updates a depth texture Comparison Mode and Function.
  39450. * If the comparison Function is equal to 0, the mode will be set to none.
  39451. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39452. * @param texture The texture to set the comparison function for
  39453. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39454. */
  39455. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39456. /**
  39457. * Creates a webGL buffer to use with instanciation
  39458. * @param capacity defines the size of the buffer
  39459. * @returns the webGL buffer
  39460. */
  39461. createInstancesBuffer(capacity: number): DataBuffer;
  39462. /**
  39463. * Delete a webGL buffer used with instanciation
  39464. * @param buffer defines the webGL buffer to delete
  39465. */
  39466. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39467. private _clientWaitAsync;
  39468. /** @hidden */
  39469. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39470. dispose(): void;
  39471. private _disableTouchAction;
  39472. /**
  39473. * Display the loading screen
  39474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39475. */
  39476. displayLoadingUI(): void;
  39477. /**
  39478. * Hide the loading screen
  39479. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39480. */
  39481. hideLoadingUI(): void;
  39482. /**
  39483. * Gets the current loading screen object
  39484. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39485. */
  39486. get loadingScreen(): ILoadingScreen;
  39487. /**
  39488. * Sets the current loading screen object
  39489. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39490. */
  39491. set loadingScreen(loadingScreen: ILoadingScreen);
  39492. /**
  39493. * Sets the current loading screen text
  39494. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39495. */
  39496. set loadingUIText(text: string);
  39497. /**
  39498. * Sets the current loading screen background color
  39499. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39500. */
  39501. set loadingUIBackgroundColor(color: string);
  39502. /** Pointerlock and fullscreen */
  39503. /**
  39504. * Ask the browser to promote the current element to pointerlock mode
  39505. * @param element defines the DOM element to promote
  39506. */
  39507. static _RequestPointerlock(element: HTMLElement): void;
  39508. /**
  39509. * Asks the browser to exit pointerlock mode
  39510. */
  39511. static _ExitPointerlock(): void;
  39512. /**
  39513. * Ask the browser to promote the current element to fullscreen rendering mode
  39514. * @param element defines the DOM element to promote
  39515. */
  39516. static _RequestFullscreen(element: HTMLElement): void;
  39517. /**
  39518. * Asks the browser to exit fullscreen mode
  39519. */
  39520. static _ExitFullscreen(): void;
  39521. }
  39522. }
  39523. declare module "babylonjs/Engines/engineStore" {
  39524. import { Nullable } from "babylonjs/types";
  39525. import { Engine } from "babylonjs/Engines/engine";
  39526. import { Scene } from "babylonjs/scene";
  39527. /**
  39528. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39529. * during the life time of the application.
  39530. */
  39531. export class EngineStore {
  39532. /** Gets the list of created engines */
  39533. static Instances: import("babylonjs/Engines/engine").Engine[];
  39534. /** @hidden */
  39535. static _LastCreatedScene: Nullable<Scene>;
  39536. /**
  39537. * Gets the latest created engine
  39538. */
  39539. static get LastCreatedEngine(): Nullable<Engine>;
  39540. /**
  39541. * Gets the latest created scene
  39542. */
  39543. static get LastCreatedScene(): Nullable<Scene>;
  39544. /**
  39545. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39546. * @ignorenaming
  39547. */
  39548. static UseFallbackTexture: boolean;
  39549. /**
  39550. * Texture content used if a texture cannot loaded
  39551. * @ignorenaming
  39552. */
  39553. static FallbackTexture: string;
  39554. }
  39555. }
  39556. declare module "babylonjs/Misc/promise" {
  39557. /**
  39558. * Helper class that provides a small promise polyfill
  39559. */
  39560. export class PromisePolyfill {
  39561. /**
  39562. * Static function used to check if the polyfill is required
  39563. * If this is the case then the function will inject the polyfill to window.Promise
  39564. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39565. */
  39566. static Apply(force?: boolean): void;
  39567. }
  39568. }
  39569. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39570. /**
  39571. * Interface for screenshot methods with describe argument called `size` as object with options
  39572. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39573. */
  39574. export interface IScreenshotSize {
  39575. /**
  39576. * number in pixels for canvas height
  39577. */
  39578. height?: number;
  39579. /**
  39580. * multiplier allowing render at a higher or lower resolution
  39581. * If value is defined then height and width will be ignored and taken from camera
  39582. */
  39583. precision?: number;
  39584. /**
  39585. * number in pixels for canvas width
  39586. */
  39587. width?: number;
  39588. }
  39589. }
  39590. declare module "babylonjs/Misc/tools" {
  39591. import { Nullable, float } from "babylonjs/types";
  39592. import { DomManagement } from "babylonjs/Misc/domManagement";
  39593. import { WebRequest } from "babylonjs/Misc/webRequest";
  39594. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39595. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39596. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39597. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39598. import { Camera } from "babylonjs/Cameras/camera";
  39599. import { Engine } from "babylonjs/Engines/engine";
  39600. interface IColor4Like {
  39601. r: float;
  39602. g: float;
  39603. b: float;
  39604. a: float;
  39605. }
  39606. /**
  39607. * Class containing a set of static utilities functions
  39608. */
  39609. export class Tools {
  39610. /**
  39611. * Gets or sets the base URL to use to load assets
  39612. */
  39613. static get BaseUrl(): string;
  39614. static set BaseUrl(value: string);
  39615. /**
  39616. * Enable/Disable Custom HTTP Request Headers globally.
  39617. * default = false
  39618. * @see CustomRequestHeaders
  39619. */
  39620. static UseCustomRequestHeaders: boolean;
  39621. /**
  39622. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39623. * i.e. when loading files, where the server/service expects an Authorization header
  39624. */
  39625. static CustomRequestHeaders: {
  39626. [key: string]: string;
  39627. };
  39628. /**
  39629. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39630. */
  39631. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39632. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39633. /**
  39634. * Default behaviour for cors in the application.
  39635. * It can be a string if the expected behavior is identical in the entire app.
  39636. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39637. */
  39638. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39639. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39640. /**
  39641. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39642. * @ignorenaming
  39643. */
  39644. static get UseFallbackTexture(): boolean;
  39645. static set UseFallbackTexture(value: boolean);
  39646. /**
  39647. * Use this object to register external classes like custom textures or material
  39648. * to allow the laoders to instantiate them
  39649. */
  39650. static get RegisteredExternalClasses(): {
  39651. [key: string]: Object;
  39652. };
  39653. static set RegisteredExternalClasses(classes: {
  39654. [key: string]: Object;
  39655. });
  39656. /**
  39657. * Texture content used if a texture cannot loaded
  39658. * @ignorenaming
  39659. */
  39660. static get fallbackTexture(): string;
  39661. static set fallbackTexture(value: string);
  39662. /**
  39663. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39664. * @param u defines the coordinate on X axis
  39665. * @param v defines the coordinate on Y axis
  39666. * @param width defines the width of the source data
  39667. * @param height defines the height of the source data
  39668. * @param pixels defines the source byte array
  39669. * @param color defines the output color
  39670. */
  39671. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39672. /**
  39673. * Interpolates between a and b via alpha
  39674. * @param a The lower value (returned when alpha = 0)
  39675. * @param b The upper value (returned when alpha = 1)
  39676. * @param alpha The interpolation-factor
  39677. * @return The mixed value
  39678. */
  39679. static Mix(a: number, b: number, alpha: number): number;
  39680. /**
  39681. * Tries to instantiate a new object from a given class name
  39682. * @param className defines the class name to instantiate
  39683. * @returns the new object or null if the system was not able to do the instantiation
  39684. */
  39685. static Instantiate(className: string): any;
  39686. /**
  39687. * Provides a slice function that will work even on IE
  39688. * @param data defines the array to slice
  39689. * @param start defines the start of the data (optional)
  39690. * @param end defines the end of the data (optional)
  39691. * @returns the new sliced array
  39692. */
  39693. static Slice<T>(data: T, start?: number, end?: number): T;
  39694. /**
  39695. * Polyfill for setImmediate
  39696. * @param action defines the action to execute after the current execution block
  39697. */
  39698. static SetImmediate(action: () => void): void;
  39699. /**
  39700. * Function indicating if a number is an exponent of 2
  39701. * @param value defines the value to test
  39702. * @returns true if the value is an exponent of 2
  39703. */
  39704. static IsExponentOfTwo(value: number): boolean;
  39705. private static _tmpFloatArray;
  39706. /**
  39707. * Returns the nearest 32-bit single precision float representation of a Number
  39708. * @param value A Number. If the parameter is of a different type, it will get converted
  39709. * to a number or to NaN if it cannot be converted
  39710. * @returns number
  39711. */
  39712. static FloatRound(value: number): number;
  39713. /**
  39714. * Extracts the filename from a path
  39715. * @param path defines the path to use
  39716. * @returns the filename
  39717. */
  39718. static GetFilename(path: string): string;
  39719. /**
  39720. * Extracts the "folder" part of a path (everything before the filename).
  39721. * @param uri The URI to extract the info from
  39722. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39723. * @returns The "folder" part of the path
  39724. */
  39725. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39726. /**
  39727. * Extracts text content from a DOM element hierarchy
  39728. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39729. */
  39730. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39731. /**
  39732. * Convert an angle in radians to degrees
  39733. * @param angle defines the angle to convert
  39734. * @returns the angle in degrees
  39735. */
  39736. static ToDegrees(angle: number): number;
  39737. /**
  39738. * Convert an angle in degrees to radians
  39739. * @param angle defines the angle to convert
  39740. * @returns the angle in radians
  39741. */
  39742. static ToRadians(angle: number): number;
  39743. /**
  39744. * Returns an array if obj is not an array
  39745. * @param obj defines the object to evaluate as an array
  39746. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39747. * @returns either obj directly if obj is an array or a new array containing obj
  39748. */
  39749. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39750. /**
  39751. * Gets the pointer prefix to use
  39752. * @param engine defines the engine we are finding the prefix for
  39753. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39754. */
  39755. static GetPointerPrefix(engine: Engine): string;
  39756. /**
  39757. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39758. * @param url define the url we are trying
  39759. * @param element define the dom element where to configure the cors policy
  39760. */
  39761. static SetCorsBehavior(url: string | string[], element: {
  39762. crossOrigin: string | null;
  39763. }): void;
  39764. /**
  39765. * Removes unwanted characters from an url
  39766. * @param url defines the url to clean
  39767. * @returns the cleaned url
  39768. */
  39769. static CleanUrl(url: string): string;
  39770. /**
  39771. * Gets or sets a function used to pre-process url before using them to load assets
  39772. */
  39773. static get PreprocessUrl(): (url: string) => string;
  39774. static set PreprocessUrl(processor: (url: string) => string);
  39775. /**
  39776. * Loads an image as an HTMLImageElement.
  39777. * @param input url string, ArrayBuffer, or Blob to load
  39778. * @param onLoad callback called when the image successfully loads
  39779. * @param onError callback called when the image fails to load
  39780. * @param offlineProvider offline provider for caching
  39781. * @param mimeType optional mime type
  39782. * @returns the HTMLImageElement of the loaded image
  39783. */
  39784. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39785. /**
  39786. * Loads a file from a url
  39787. * @param url url string, ArrayBuffer, or Blob to load
  39788. * @param onSuccess callback called when the file successfully loads
  39789. * @param onProgress callback called while file is loading (if the server supports this mode)
  39790. * @param offlineProvider defines the offline provider for caching
  39791. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39792. * @param onError callback called when the file fails to load
  39793. * @returns a file request object
  39794. */
  39795. 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;
  39796. /**
  39797. * Loads a file from a url
  39798. * @param url the file url to load
  39799. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39800. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39801. */
  39802. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39803. /**
  39804. * Load a script (identified by an url). When the url returns, the
  39805. * content of this file is added into a new script element, attached to the DOM (body element)
  39806. * @param scriptUrl defines the url of the script to laod
  39807. * @param onSuccess defines the callback called when the script is loaded
  39808. * @param onError defines the callback to call if an error occurs
  39809. * @param scriptId defines the id of the script element
  39810. */
  39811. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39812. /**
  39813. * Load an asynchronous script (identified by an url). When the url returns, the
  39814. * content of this file is added into a new script element, attached to the DOM (body element)
  39815. * @param scriptUrl defines the url of the script to laod
  39816. * @param scriptId defines the id of the script element
  39817. * @returns a promise request object
  39818. */
  39819. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39820. /**
  39821. * Loads a file from a blob
  39822. * @param fileToLoad defines the blob to use
  39823. * @param callback defines the callback to call when data is loaded
  39824. * @param progressCallback defines the callback to call during loading process
  39825. * @returns a file request object
  39826. */
  39827. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39828. /**
  39829. * Reads a file from a File object
  39830. * @param file defines the file to load
  39831. * @param onSuccess defines the callback to call when data is loaded
  39832. * @param onProgress defines the callback to call during loading process
  39833. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39834. * @param onError defines the callback to call when an error occurs
  39835. * @returns a file request object
  39836. */
  39837. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39838. /**
  39839. * Creates a data url from a given string content
  39840. * @param content defines the content to convert
  39841. * @returns the new data url link
  39842. */
  39843. static FileAsURL(content: string): string;
  39844. /**
  39845. * Format the given number to a specific decimal format
  39846. * @param value defines the number to format
  39847. * @param decimals defines the number of decimals to use
  39848. * @returns the formatted string
  39849. */
  39850. static Format(value: number, decimals?: number): string;
  39851. /**
  39852. * Tries to copy an object by duplicating every property
  39853. * @param source defines the source object
  39854. * @param destination defines the target object
  39855. * @param doNotCopyList defines a list of properties to avoid
  39856. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39857. */
  39858. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39859. /**
  39860. * Gets a boolean indicating if the given object has no own property
  39861. * @param obj defines the object to test
  39862. * @returns true if object has no own property
  39863. */
  39864. static IsEmpty(obj: any): boolean;
  39865. /**
  39866. * Function used to register events at window level
  39867. * @param windowElement defines the Window object to use
  39868. * @param events defines the events to register
  39869. */
  39870. static RegisterTopRootEvents(windowElement: Window, events: {
  39871. name: string;
  39872. handler: Nullable<(e: FocusEvent) => any>;
  39873. }[]): void;
  39874. /**
  39875. * Function used to unregister events from window level
  39876. * @param windowElement defines the Window object to use
  39877. * @param events defines the events to unregister
  39878. */
  39879. static UnregisterTopRootEvents(windowElement: Window, events: {
  39880. name: string;
  39881. handler: Nullable<(e: FocusEvent) => any>;
  39882. }[]): void;
  39883. /**
  39884. * @ignore
  39885. */
  39886. static _ScreenshotCanvas: HTMLCanvasElement;
  39887. /**
  39888. * Dumps the current bound framebuffer
  39889. * @param width defines the rendering width
  39890. * @param height defines the rendering height
  39891. * @param engine defines the hosting engine
  39892. * @param successCallback defines the callback triggered once the data are available
  39893. * @param mimeType defines the mime type of the result
  39894. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39895. */
  39896. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39897. /**
  39898. * Converts the canvas data to blob.
  39899. * This acts as a polyfill for browsers not supporting the to blob function.
  39900. * @param canvas Defines the canvas to extract the data from
  39901. * @param successCallback Defines the callback triggered once the data are available
  39902. * @param mimeType Defines the mime type of the result
  39903. */
  39904. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39905. /**
  39906. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39907. * @param successCallback defines the callback triggered once the data are available
  39908. * @param mimeType defines the mime type of the result
  39909. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39910. */
  39911. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39912. /**
  39913. * Downloads a blob in the browser
  39914. * @param blob defines the blob to download
  39915. * @param fileName defines the name of the downloaded file
  39916. */
  39917. static Download(blob: Blob, fileName: string): void;
  39918. /**
  39919. * Captures a screenshot of the current rendering
  39920. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39921. * @param engine defines the rendering engine
  39922. * @param camera defines the source camera
  39923. * @param size This parameter can be set to a single number or to an object with the
  39924. * following (optional) properties: precision, width, height. If a single number is passed,
  39925. * it will be used for both width and height. If an object is passed, the screenshot size
  39926. * will be derived from the parameters. The precision property is a multiplier allowing
  39927. * rendering at a higher or lower resolution
  39928. * @param successCallback defines the callback receives a single parameter which contains the
  39929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39930. * src parameter of an <img> to display it
  39931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39932. * Check your browser for supported MIME types
  39933. */
  39934. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39935. /**
  39936. * Captures a screenshot of the current rendering
  39937. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39938. * @param engine defines the rendering engine
  39939. * @param camera defines the source camera
  39940. * @param size This parameter can be set to a single number or to an object with the
  39941. * following (optional) properties: precision, width, height. If a single number is passed,
  39942. * it will be used for both width and height. If an object is passed, the screenshot size
  39943. * will be derived from the parameters. The precision property is a multiplier allowing
  39944. * rendering at a higher or lower resolution
  39945. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39946. * Check your browser for supported MIME types
  39947. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39948. * to the src parameter of an <img> to display it
  39949. */
  39950. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39951. /**
  39952. * Generates an image screenshot from the specified camera.
  39953. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39954. * @param engine The engine to use for rendering
  39955. * @param camera The camera to use for rendering
  39956. * @param size This parameter can be set to a single number or to an object with the
  39957. * following (optional) properties: precision, width, height. If a single number is passed,
  39958. * it will be used for both width and height. If an object is passed, the screenshot size
  39959. * will be derived from the parameters. The precision property is a multiplier allowing
  39960. * rendering at a higher or lower resolution
  39961. * @param successCallback The callback receives a single parameter which contains the
  39962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39963. * src parameter of an <img> to display it
  39964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39965. * Check your browser for supported MIME types
  39966. * @param samples Texture samples (default: 1)
  39967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39968. * @param fileName A name for for the downloaded file.
  39969. */
  39970. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39971. /**
  39972. * Generates an image screenshot from the specified camera.
  39973. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39974. * @param engine The engine to use for rendering
  39975. * @param camera The camera to use for rendering
  39976. * @param size This parameter can be set to a single number or to an object with the
  39977. * following (optional) properties: precision, width, height. If a single number is passed,
  39978. * it will be used for both width and height. If an object is passed, the screenshot size
  39979. * will be derived from the parameters. The precision property is a multiplier allowing
  39980. * rendering at a higher or lower resolution
  39981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39982. * Check your browser for supported MIME types
  39983. * @param samples Texture samples (default: 1)
  39984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39985. * @param fileName A name for for the downloaded file.
  39986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39987. * to the src parameter of an <img> to display it
  39988. */
  39989. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39990. /**
  39991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39992. * Be aware Math.random() could cause collisions, but:
  39993. * "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"
  39994. * @returns a pseudo random id
  39995. */
  39996. static RandomId(): string;
  39997. /**
  39998. * Test if the given uri is a base64 string
  39999. * @param uri The uri to test
  40000. * @return True if the uri is a base64 string or false otherwise
  40001. */
  40002. static IsBase64(uri: string): boolean;
  40003. /**
  40004. * Decode the given base64 uri.
  40005. * @param uri The uri to decode
  40006. * @return The decoded base64 data.
  40007. */
  40008. static DecodeBase64(uri: string): ArrayBuffer;
  40009. /**
  40010. * Gets the absolute url.
  40011. * @param url the input url
  40012. * @return the absolute url
  40013. */
  40014. static GetAbsoluteUrl(url: string): string;
  40015. /**
  40016. * No log
  40017. */
  40018. static readonly NoneLogLevel: number;
  40019. /**
  40020. * Only message logs
  40021. */
  40022. static readonly MessageLogLevel: number;
  40023. /**
  40024. * Only warning logs
  40025. */
  40026. static readonly WarningLogLevel: number;
  40027. /**
  40028. * Only error logs
  40029. */
  40030. static readonly ErrorLogLevel: number;
  40031. /**
  40032. * All logs
  40033. */
  40034. static readonly AllLogLevel: number;
  40035. /**
  40036. * Gets a value indicating the number of loading errors
  40037. * @ignorenaming
  40038. */
  40039. static get errorsCount(): number;
  40040. /**
  40041. * Callback called when a new log is added
  40042. */
  40043. static OnNewCacheEntry: (entry: string) => void;
  40044. /**
  40045. * Log a message to the console
  40046. * @param message defines the message to log
  40047. */
  40048. static Log(message: string): void;
  40049. /**
  40050. * Write a warning message to the console
  40051. * @param message defines the message to log
  40052. */
  40053. static Warn(message: string): void;
  40054. /**
  40055. * Write an error message to the console
  40056. * @param message defines the message to log
  40057. */
  40058. static Error(message: string): void;
  40059. /**
  40060. * Gets current log cache (list of logs)
  40061. */
  40062. static get LogCache(): string;
  40063. /**
  40064. * Clears the log cache
  40065. */
  40066. static ClearLogCache(): void;
  40067. /**
  40068. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40069. */
  40070. static set LogLevels(level: number);
  40071. /**
  40072. * Checks if the window object exists
  40073. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40074. */
  40075. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40076. /**
  40077. * No performance log
  40078. */
  40079. static readonly PerformanceNoneLogLevel: number;
  40080. /**
  40081. * Use user marks to log performance
  40082. */
  40083. static readonly PerformanceUserMarkLogLevel: number;
  40084. /**
  40085. * Log performance to the console
  40086. */
  40087. static readonly PerformanceConsoleLogLevel: number;
  40088. private static _performance;
  40089. /**
  40090. * Sets the current performance log level
  40091. */
  40092. static set PerformanceLogLevel(level: number);
  40093. private static _StartPerformanceCounterDisabled;
  40094. private static _EndPerformanceCounterDisabled;
  40095. private static _StartUserMark;
  40096. private static _EndUserMark;
  40097. private static _StartPerformanceConsole;
  40098. private static _EndPerformanceConsole;
  40099. /**
  40100. * Starts a performance counter
  40101. */
  40102. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40103. /**
  40104. * Ends a specific performance coutner
  40105. */
  40106. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40107. /**
  40108. * Gets either window.performance.now() if supported or Date.now() else
  40109. */
  40110. static get Now(): number;
  40111. /**
  40112. * This method will return the name of the class used to create the instance of the given object.
  40113. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40114. * @param object the object to get the class name from
  40115. * @param isType defines if the object is actually a type
  40116. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40117. */
  40118. static GetClassName(object: any, isType?: boolean): string;
  40119. /**
  40120. * Gets the first element of an array satisfying a given predicate
  40121. * @param array defines the array to browse
  40122. * @param predicate defines the predicate to use
  40123. * @returns null if not found or the element
  40124. */
  40125. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40126. /**
  40127. * This method will return the name of the full name of the class, including its owning module (if any).
  40128. * 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).
  40129. * @param object the object to get the class name from
  40130. * @param isType defines if the object is actually a type
  40131. * @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.
  40132. * @ignorenaming
  40133. */
  40134. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40135. /**
  40136. * Returns a promise that resolves after the given amount of time.
  40137. * @param delay Number of milliseconds to delay
  40138. * @returns Promise that resolves after the given amount of time
  40139. */
  40140. static DelayAsync(delay: number): Promise<void>;
  40141. /**
  40142. * Utility function to detect if the current user agent is Safari
  40143. * @returns whether or not the current user agent is safari
  40144. */
  40145. static IsSafari(): boolean;
  40146. }
  40147. /**
  40148. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40149. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40150. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40151. * @param name The name of the class, case should be preserved
  40152. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40153. */
  40154. export function className(name: string, module?: string): (target: Object) => void;
  40155. /**
  40156. * An implementation of a loop for asynchronous functions.
  40157. */
  40158. export class AsyncLoop {
  40159. /**
  40160. * Defines the number of iterations for the loop
  40161. */
  40162. iterations: number;
  40163. /**
  40164. * Defines the current index of the loop.
  40165. */
  40166. index: number;
  40167. private _done;
  40168. private _fn;
  40169. private _successCallback;
  40170. /**
  40171. * Constructor.
  40172. * @param iterations the number of iterations.
  40173. * @param func the function to run each iteration
  40174. * @param successCallback the callback that will be called upon succesful execution
  40175. * @param offset starting offset.
  40176. */
  40177. constructor(
  40178. /**
  40179. * Defines the number of iterations for the loop
  40180. */
  40181. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40182. /**
  40183. * Execute the next iteration. Must be called after the last iteration was finished.
  40184. */
  40185. executeNext(): void;
  40186. /**
  40187. * Break the loop and run the success callback.
  40188. */
  40189. breakLoop(): void;
  40190. /**
  40191. * Create and run an async loop.
  40192. * @param iterations the number of iterations.
  40193. * @param fn the function to run each iteration
  40194. * @param successCallback the callback that will be called upon succesful execution
  40195. * @param offset starting offset.
  40196. * @returns the created async loop object
  40197. */
  40198. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40199. /**
  40200. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40201. * @param iterations total number of iterations
  40202. * @param syncedIterations number of synchronous iterations in each async iteration.
  40203. * @param fn the function to call each iteration.
  40204. * @param callback a success call back that will be called when iterating stops.
  40205. * @param breakFunction a break condition (optional)
  40206. * @param timeout timeout settings for the setTimeout function. default - 0.
  40207. * @returns the created async loop object
  40208. */
  40209. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40210. }
  40211. }
  40212. declare module "babylonjs/Misc/stringDictionary" {
  40213. import { Nullable } from "babylonjs/types";
  40214. /**
  40215. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40216. * The underlying implementation relies on an associative array to ensure the best performances.
  40217. * The value can be anything including 'null' but except 'undefined'
  40218. */
  40219. export class StringDictionary<T> {
  40220. /**
  40221. * This will clear this dictionary and copy the content from the 'source' one.
  40222. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40223. * @param source the dictionary to take the content from and copy to this dictionary
  40224. */
  40225. copyFrom(source: StringDictionary<T>): void;
  40226. /**
  40227. * Get a value based from its key
  40228. * @param key the given key to get the matching value from
  40229. * @return the value if found, otherwise undefined is returned
  40230. */
  40231. get(key: string): T | undefined;
  40232. /**
  40233. * Get a value from its key or add it if it doesn't exist.
  40234. * This method will ensure you that a given key/data will be present in the dictionary.
  40235. * @param key the given key to get the matching value from
  40236. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40237. * The factory will only be invoked if there's no data for the given key.
  40238. * @return the value corresponding to the key.
  40239. */
  40240. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40241. /**
  40242. * Get a value from its key if present in the dictionary otherwise add it
  40243. * @param key the key to get the value from
  40244. * @param val if there's no such key/value pair in the dictionary add it with this value
  40245. * @return the value corresponding to the key
  40246. */
  40247. getOrAdd(key: string, val: T): T;
  40248. /**
  40249. * Check if there's a given key in the dictionary
  40250. * @param key the key to check for
  40251. * @return true if the key is present, false otherwise
  40252. */
  40253. contains(key: string): boolean;
  40254. /**
  40255. * Add a new key and its corresponding value
  40256. * @param key the key to add
  40257. * @param value the value corresponding to the key
  40258. * @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
  40259. */
  40260. add(key: string, value: T): boolean;
  40261. /**
  40262. * Update a specific value associated to a key
  40263. * @param key defines the key to use
  40264. * @param value defines the value to store
  40265. * @returns true if the value was updated (or false if the key was not found)
  40266. */
  40267. set(key: string, value: T): boolean;
  40268. /**
  40269. * Get the element of the given key and remove it from the dictionary
  40270. * @param key defines the key to search
  40271. * @returns the value associated with the key or null if not found
  40272. */
  40273. getAndRemove(key: string): Nullable<T>;
  40274. /**
  40275. * Remove a key/value from the dictionary.
  40276. * @param key the key to remove
  40277. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40278. */
  40279. remove(key: string): boolean;
  40280. /**
  40281. * Clear the whole content of the dictionary
  40282. */
  40283. clear(): void;
  40284. /**
  40285. * Gets the current count
  40286. */
  40287. get count(): number;
  40288. /**
  40289. * Execute a callback on each key/val of the dictionary.
  40290. * Note that you can remove any element in this dictionary in the callback implementation
  40291. * @param callback the callback to execute on a given key/value pair
  40292. */
  40293. forEach(callback: (key: string, val: T) => void): void;
  40294. /**
  40295. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40296. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40297. * Note that you can remove any element in this dictionary in the callback implementation
  40298. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40299. * @returns the first item
  40300. */
  40301. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40302. private _count;
  40303. private _data;
  40304. }
  40305. }
  40306. declare module "babylonjs/Collisions/collisionCoordinator" {
  40307. import { Nullable } from "babylonjs/types";
  40308. import { Scene } from "babylonjs/scene";
  40309. import { Vector3 } from "babylonjs/Maths/math.vector";
  40310. import { Collider } from "babylonjs/Collisions/collider";
  40311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40312. /** @hidden */
  40313. export interface ICollisionCoordinator {
  40314. createCollider(): Collider;
  40315. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40316. init(scene: Scene): void;
  40317. }
  40318. /** @hidden */
  40319. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40320. private _scene;
  40321. private _scaledPosition;
  40322. private _scaledVelocity;
  40323. private _finalPosition;
  40324. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40325. createCollider(): Collider;
  40326. init(scene: Scene): void;
  40327. private _collideWithWorld;
  40328. }
  40329. }
  40330. declare module "babylonjs/Inputs/scene.inputManager" {
  40331. import { Nullable } from "babylonjs/types";
  40332. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40333. import { Vector2 } from "babylonjs/Maths/math.vector";
  40334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40335. import { Scene } from "babylonjs/scene";
  40336. /**
  40337. * Class used to manage all inputs for the scene.
  40338. */
  40339. export class InputManager {
  40340. /** The distance in pixel that you have to move to prevent some events */
  40341. static DragMovementThreshold: number;
  40342. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40343. static LongPressDelay: number;
  40344. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40345. static DoubleClickDelay: number;
  40346. /** If you need to check double click without raising a single click at first click, enable this flag */
  40347. static ExclusiveDoubleClickMode: boolean;
  40348. /** 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. */
  40349. private _alreadyAttached;
  40350. private _wheelEventName;
  40351. private _onPointerMove;
  40352. private _onPointerDown;
  40353. private _onPointerUp;
  40354. private _initClickEvent;
  40355. private _initActionManager;
  40356. private _delayedSimpleClick;
  40357. private _delayedSimpleClickTimeout;
  40358. private _previousDelayedSimpleClickTimeout;
  40359. private _meshPickProceed;
  40360. private _previousButtonPressed;
  40361. private _currentPickResult;
  40362. private _previousPickResult;
  40363. private _totalPointersPressed;
  40364. private _doubleClickOccured;
  40365. private _pointerOverMesh;
  40366. private _pickedDownMesh;
  40367. private _pickedUpMesh;
  40368. private _pointerX;
  40369. private _pointerY;
  40370. private _unTranslatedPointerX;
  40371. private _unTranslatedPointerY;
  40372. private _startingPointerPosition;
  40373. private _previousStartingPointerPosition;
  40374. private _startingPointerTime;
  40375. private _previousStartingPointerTime;
  40376. private _pointerCaptures;
  40377. private _meshUnderPointerId;
  40378. private _onKeyDown;
  40379. private _onKeyUp;
  40380. private _onCanvasFocusObserver;
  40381. private _onCanvasBlurObserver;
  40382. private _scene;
  40383. /**
  40384. * Creates a new InputManager
  40385. * @param scene defines the hosting scene
  40386. */
  40387. constructor(scene: Scene);
  40388. /**
  40389. * Gets the mesh that is currently under the pointer
  40390. */
  40391. get meshUnderPointer(): Nullable<AbstractMesh>;
  40392. /**
  40393. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40394. * @param pointerId the pointer id to use
  40395. * @returns The mesh under this pointer id or null if not found
  40396. */
  40397. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40398. /**
  40399. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40400. */
  40401. get unTranslatedPointer(): Vector2;
  40402. /**
  40403. * Gets or sets the current on-screen X position of the pointer
  40404. */
  40405. get pointerX(): number;
  40406. set pointerX(value: number);
  40407. /**
  40408. * Gets or sets the current on-screen Y position of the pointer
  40409. */
  40410. get pointerY(): number;
  40411. set pointerY(value: number);
  40412. private _updatePointerPosition;
  40413. private _processPointerMove;
  40414. private _setRayOnPointerInfo;
  40415. private _checkPrePointerObservable;
  40416. /**
  40417. * Use this method to simulate a pointer move on a mesh
  40418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40421. */
  40422. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40423. /**
  40424. * Use this method to simulate a pointer down on a mesh
  40425. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40426. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40427. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40428. */
  40429. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40430. private _processPointerDown;
  40431. /** @hidden */
  40432. _isPointerSwiping(): boolean;
  40433. /**
  40434. * Use this method to simulate a pointer up on a mesh
  40435. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40436. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40437. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40438. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40439. */
  40440. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40441. private _processPointerUp;
  40442. /**
  40443. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40444. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40445. * @returns true if the pointer was captured
  40446. */
  40447. isPointerCaptured(pointerId?: number): boolean;
  40448. /**
  40449. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40450. * @param attachUp defines if you want to attach events to pointerup
  40451. * @param attachDown defines if you want to attach events to pointerdown
  40452. * @param attachMove defines if you want to attach events to pointermove
  40453. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40454. */
  40455. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40456. /**
  40457. * Detaches all event handlers
  40458. */
  40459. detachControl(): void;
  40460. /**
  40461. * Force the value of meshUnderPointer
  40462. * @param mesh defines the mesh to use
  40463. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40464. */
  40465. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40466. /**
  40467. * Gets the mesh under the pointer
  40468. * @returns a Mesh or null if no mesh is under the pointer
  40469. */
  40470. getPointerOverMesh(): Nullable<AbstractMesh>;
  40471. }
  40472. }
  40473. declare module "babylonjs/Animations/animationGroup" {
  40474. import { Animatable } from "babylonjs/Animations/animatable";
  40475. import { Animation } from "babylonjs/Animations/animation";
  40476. import { Scene, IDisposable } from "babylonjs/scene";
  40477. import { Observable } from "babylonjs/Misc/observable";
  40478. import { Nullable } from "babylonjs/types";
  40479. import "babylonjs/Animations/animatable";
  40480. /**
  40481. * This class defines the direct association between an animation and a target
  40482. */
  40483. export class TargetedAnimation {
  40484. /**
  40485. * Animation to perform
  40486. */
  40487. animation: Animation;
  40488. /**
  40489. * Target to animate
  40490. */
  40491. target: any;
  40492. /**
  40493. * Returns the string "TargetedAnimation"
  40494. * @returns "TargetedAnimation"
  40495. */
  40496. getClassName(): string;
  40497. /**
  40498. * Serialize the object
  40499. * @returns the JSON object representing the current entity
  40500. */
  40501. serialize(): any;
  40502. }
  40503. /**
  40504. * Use this class to create coordinated animations on multiple targets
  40505. */
  40506. export class AnimationGroup implements IDisposable {
  40507. /** The name of the animation group */
  40508. name: string;
  40509. private _scene;
  40510. private _targetedAnimations;
  40511. private _animatables;
  40512. private _from;
  40513. private _to;
  40514. private _isStarted;
  40515. private _isPaused;
  40516. private _speedRatio;
  40517. private _loopAnimation;
  40518. private _isAdditive;
  40519. /**
  40520. * Gets or sets the unique id of the node
  40521. */
  40522. uniqueId: number;
  40523. /**
  40524. * This observable will notify when one animation have ended
  40525. */
  40526. onAnimationEndObservable: Observable<TargetedAnimation>;
  40527. /**
  40528. * Observer raised when one animation loops
  40529. */
  40530. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40531. /**
  40532. * Observer raised when all animations have looped
  40533. */
  40534. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40535. /**
  40536. * This observable will notify when all animations have ended.
  40537. */
  40538. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40539. /**
  40540. * This observable will notify when all animations have paused.
  40541. */
  40542. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40543. /**
  40544. * This observable will notify when all animations are playing.
  40545. */
  40546. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40547. /**
  40548. * Gets the first frame
  40549. */
  40550. get from(): number;
  40551. /**
  40552. * Gets the last frame
  40553. */
  40554. get to(): number;
  40555. /**
  40556. * Define if the animations are started
  40557. */
  40558. get isStarted(): boolean;
  40559. /**
  40560. * Gets a value indicating that the current group is playing
  40561. */
  40562. get isPlaying(): boolean;
  40563. /**
  40564. * Gets or sets the speed ratio to use for all animations
  40565. */
  40566. get speedRatio(): number;
  40567. /**
  40568. * Gets or sets the speed ratio to use for all animations
  40569. */
  40570. set speedRatio(value: number);
  40571. /**
  40572. * Gets or sets if all animations should loop or not
  40573. */
  40574. get loopAnimation(): boolean;
  40575. set loopAnimation(value: boolean);
  40576. /**
  40577. * Gets or sets if all animations should be evaluated additively
  40578. */
  40579. get isAdditive(): boolean;
  40580. set isAdditive(value: boolean);
  40581. /**
  40582. * Gets the targeted animations for this animation group
  40583. */
  40584. get targetedAnimations(): Array<TargetedAnimation>;
  40585. /**
  40586. * returning the list of animatables controlled by this animation group.
  40587. */
  40588. get animatables(): Array<Animatable>;
  40589. /**
  40590. * Gets the list of target animations
  40591. */
  40592. get children(): TargetedAnimation[];
  40593. /**
  40594. * Instantiates a new Animation Group.
  40595. * This helps managing several animations at once.
  40596. * @see https://doc.babylonjs.com/how_to/group
  40597. * @param name Defines the name of the group
  40598. * @param scene Defines the scene the group belongs to
  40599. */
  40600. constructor(
  40601. /** The name of the animation group */
  40602. name: string, scene?: Nullable<Scene>);
  40603. /**
  40604. * Add an animation (with its target) in the group
  40605. * @param animation defines the animation we want to add
  40606. * @param target defines the target of the animation
  40607. * @returns the TargetedAnimation object
  40608. */
  40609. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40610. /**
  40611. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40612. * It can add constant keys at begin or end
  40613. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40614. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40615. * @returns the animation group
  40616. */
  40617. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40618. private _animationLoopCount;
  40619. private _animationLoopFlags;
  40620. private _processLoop;
  40621. /**
  40622. * Start all animations on given targets
  40623. * @param loop defines if animations must loop
  40624. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40625. * @param from defines the from key (optional)
  40626. * @param to defines the to key (optional)
  40627. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40628. * @returns the current animation group
  40629. */
  40630. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40631. /**
  40632. * Pause all animations
  40633. * @returns the animation group
  40634. */
  40635. pause(): AnimationGroup;
  40636. /**
  40637. * Play all animations to initial state
  40638. * This function will start() the animations if they were not started or will restart() them if they were paused
  40639. * @param loop defines if animations must loop
  40640. * @returns the animation group
  40641. */
  40642. play(loop?: boolean): AnimationGroup;
  40643. /**
  40644. * Reset all animations to initial state
  40645. * @returns the animation group
  40646. */
  40647. reset(): AnimationGroup;
  40648. /**
  40649. * Restart animations from key 0
  40650. * @returns the animation group
  40651. */
  40652. restart(): AnimationGroup;
  40653. /**
  40654. * Stop all animations
  40655. * @returns the animation group
  40656. */
  40657. stop(): AnimationGroup;
  40658. /**
  40659. * Set animation weight for all animatables
  40660. * @param weight defines the weight to use
  40661. * @return the animationGroup
  40662. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40663. */
  40664. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40665. /**
  40666. * Synchronize and normalize all animatables with a source animatable
  40667. * @param root defines the root animatable to synchronize with
  40668. * @return the animationGroup
  40669. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40670. */
  40671. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40672. /**
  40673. * Goes to a specific frame in this animation group
  40674. * @param frame the frame number to go to
  40675. * @return the animationGroup
  40676. */
  40677. goToFrame(frame: number): AnimationGroup;
  40678. /**
  40679. * Dispose all associated resources
  40680. */
  40681. dispose(): void;
  40682. private _checkAnimationGroupEnded;
  40683. /**
  40684. * Clone the current animation group and returns a copy
  40685. * @param newName defines the name of the new group
  40686. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40687. * @returns the new aniamtion group
  40688. */
  40689. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40690. /**
  40691. * Serializes the animationGroup to an object
  40692. * @returns Serialized object
  40693. */
  40694. serialize(): any;
  40695. /**
  40696. * Returns a new AnimationGroup object parsed from the source provided.
  40697. * @param parsedAnimationGroup defines the source
  40698. * @param scene defines the scene that will receive the animationGroup
  40699. * @returns a new AnimationGroup
  40700. */
  40701. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40702. /**
  40703. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40704. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40705. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40706. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40707. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40708. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40709. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40710. */
  40711. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40712. /**
  40713. * Returns the string "AnimationGroup"
  40714. * @returns "AnimationGroup"
  40715. */
  40716. getClassName(): string;
  40717. /**
  40718. * Creates a detailled string about the object
  40719. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40720. * @returns a string representing the object
  40721. */
  40722. toString(fullDetails?: boolean): string;
  40723. }
  40724. }
  40725. declare module "babylonjs/scene" {
  40726. import { Nullable } from "babylonjs/types";
  40727. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40728. import { Observable } from "babylonjs/Misc/observable";
  40729. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40730. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40731. import { Geometry } from "babylonjs/Meshes/geometry";
  40732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40735. import { Mesh } from "babylonjs/Meshes/mesh";
  40736. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40737. import { Bone } from "babylonjs/Bones/bone";
  40738. import { Skeleton } from "babylonjs/Bones/skeleton";
  40739. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40740. import { Camera } from "babylonjs/Cameras/camera";
  40741. import { AbstractScene } from "babylonjs/abstractScene";
  40742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40744. import { Material } from "babylonjs/Materials/material";
  40745. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40746. import { Effect } from "babylonjs/Materials/effect";
  40747. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40748. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40749. import { Light } from "babylonjs/Lights/light";
  40750. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40751. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40752. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40753. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40754. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40756. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40757. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40758. import { Engine } from "babylonjs/Engines/engine";
  40759. import { Node } from "babylonjs/node";
  40760. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40761. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40762. import { WebRequest } from "babylonjs/Misc/webRequest";
  40763. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40764. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40765. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40766. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40767. import { Plane } from "babylonjs/Maths/math.plane";
  40768. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40769. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40770. import { Ray } from "babylonjs/Culling/ray";
  40771. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40772. import { Animation } from "babylonjs/Animations/animation";
  40773. import { Animatable } from "babylonjs/Animations/animatable";
  40774. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40775. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40776. import { Collider } from "babylonjs/Collisions/collider";
  40777. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40778. /**
  40779. * Define an interface for all classes that will hold resources
  40780. */
  40781. export interface IDisposable {
  40782. /**
  40783. * Releases all held resources
  40784. */
  40785. dispose(): void;
  40786. }
  40787. /** Interface defining initialization parameters for Scene class */
  40788. export interface SceneOptions {
  40789. /**
  40790. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40791. * It will improve performance when the number of geometries becomes important.
  40792. */
  40793. useGeometryUniqueIdsMap?: boolean;
  40794. /**
  40795. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40796. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40797. */
  40798. useMaterialMeshMap?: boolean;
  40799. /**
  40800. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40801. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40802. */
  40803. useClonedMeshMap?: boolean;
  40804. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40805. virtual?: boolean;
  40806. }
  40807. /**
  40808. * Represents a scene to be rendered by the engine.
  40809. * @see https://doc.babylonjs.com/features/scene
  40810. */
  40811. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40812. /** The fog is deactivated */
  40813. static readonly FOGMODE_NONE: number;
  40814. /** The fog density is following an exponential function */
  40815. static readonly FOGMODE_EXP: number;
  40816. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40817. static readonly FOGMODE_EXP2: number;
  40818. /** The fog density is following a linear function. */
  40819. static readonly FOGMODE_LINEAR: number;
  40820. /**
  40821. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40822. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40823. */
  40824. static MinDeltaTime: number;
  40825. /**
  40826. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40827. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40828. */
  40829. static MaxDeltaTime: number;
  40830. /**
  40831. * Factory used to create the default material.
  40832. * @param name The name of the material to create
  40833. * @param scene The scene to create the material for
  40834. * @returns The default material
  40835. */
  40836. static DefaultMaterialFactory(scene: Scene): Material;
  40837. /**
  40838. * Factory used to create the a collision coordinator.
  40839. * @returns The collision coordinator
  40840. */
  40841. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40842. /** @hidden */
  40843. _inputManager: InputManager;
  40844. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40845. cameraToUseForPointers: Nullable<Camera>;
  40846. /** @hidden */
  40847. readonly _isScene: boolean;
  40848. /** @hidden */
  40849. _blockEntityCollection: boolean;
  40850. /**
  40851. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40852. */
  40853. autoClear: boolean;
  40854. /**
  40855. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40856. */
  40857. autoClearDepthAndStencil: boolean;
  40858. /**
  40859. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40860. */
  40861. clearColor: Color4;
  40862. /**
  40863. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40864. */
  40865. ambientColor: Color3;
  40866. /**
  40867. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40868. * It should only be one of the following (if not the default embedded one):
  40869. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40870. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40871. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40872. * The material properties need to be setup according to the type of texture in use.
  40873. */
  40874. environmentBRDFTexture: BaseTexture;
  40875. /**
  40876. * Texture used in all pbr material as the reflection texture.
  40877. * As in the majority of the scene they are the same (exception for multi room and so on),
  40878. * this is easier to reference from here than from all the materials.
  40879. */
  40880. get environmentTexture(): Nullable<BaseTexture>;
  40881. /**
  40882. * Texture used in all pbr material as the reflection texture.
  40883. * As in the majority of the scene they are the same (exception for multi room and so on),
  40884. * this is easier to set here than in all the materials.
  40885. */
  40886. set environmentTexture(value: Nullable<BaseTexture>);
  40887. /** @hidden */
  40888. protected _environmentIntensity: number;
  40889. /**
  40890. * Intensity of the environment in all pbr material.
  40891. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40892. * As in the majority of the scene they are the same (exception for multi room and so on),
  40893. * this is easier to reference from here than from all the materials.
  40894. */
  40895. get environmentIntensity(): number;
  40896. /**
  40897. * Intensity of the environment in all pbr material.
  40898. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40899. * As in the majority of the scene they are the same (exception for multi room and so on),
  40900. * this is easier to set here than in all the materials.
  40901. */
  40902. set environmentIntensity(value: number);
  40903. /** @hidden */
  40904. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40905. /**
  40906. * Default image processing configuration used either in the rendering
  40907. * Forward main pass or through the imageProcessingPostProcess if present.
  40908. * As in the majority of the scene they are the same (exception for multi camera),
  40909. * this is easier to reference from here than from all the materials and post process.
  40910. *
  40911. * No setter as we it is a shared configuration, you can set the values instead.
  40912. */
  40913. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40914. private _forceWireframe;
  40915. /**
  40916. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40917. */
  40918. set forceWireframe(value: boolean);
  40919. get forceWireframe(): boolean;
  40920. private _skipFrustumClipping;
  40921. /**
  40922. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40923. */
  40924. set skipFrustumClipping(value: boolean);
  40925. get skipFrustumClipping(): boolean;
  40926. private _forcePointsCloud;
  40927. /**
  40928. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40929. */
  40930. set forcePointsCloud(value: boolean);
  40931. get forcePointsCloud(): boolean;
  40932. /**
  40933. * Gets or sets the active clipplane 1
  40934. */
  40935. clipPlane: Nullable<Plane>;
  40936. /**
  40937. * Gets or sets the active clipplane 2
  40938. */
  40939. clipPlane2: Nullable<Plane>;
  40940. /**
  40941. * Gets or sets the active clipplane 3
  40942. */
  40943. clipPlane3: Nullable<Plane>;
  40944. /**
  40945. * Gets or sets the active clipplane 4
  40946. */
  40947. clipPlane4: Nullable<Plane>;
  40948. /**
  40949. * Gets or sets the active clipplane 5
  40950. */
  40951. clipPlane5: Nullable<Plane>;
  40952. /**
  40953. * Gets or sets the active clipplane 6
  40954. */
  40955. clipPlane6: Nullable<Plane>;
  40956. /**
  40957. * Gets or sets a boolean indicating if animations are enabled
  40958. */
  40959. animationsEnabled: boolean;
  40960. private _animationPropertiesOverride;
  40961. /**
  40962. * Gets or sets the animation properties override
  40963. */
  40964. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40965. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40966. /**
  40967. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40968. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40969. */
  40970. useConstantAnimationDeltaTime: boolean;
  40971. /**
  40972. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40973. * Please note that it requires to run a ray cast through the scene on every frame
  40974. */
  40975. constantlyUpdateMeshUnderPointer: boolean;
  40976. /**
  40977. * Defines the HTML cursor to use when hovering over interactive elements
  40978. */
  40979. hoverCursor: string;
  40980. /**
  40981. * Defines the HTML default cursor to use (empty by default)
  40982. */
  40983. defaultCursor: string;
  40984. /**
  40985. * Defines whether cursors are handled by the scene.
  40986. */
  40987. doNotHandleCursors: boolean;
  40988. /**
  40989. * This is used to call preventDefault() on pointer down
  40990. * in order to block unwanted artifacts like system double clicks
  40991. */
  40992. preventDefaultOnPointerDown: boolean;
  40993. /**
  40994. * This is used to call preventDefault() on pointer up
  40995. * in order to block unwanted artifacts like system double clicks
  40996. */
  40997. preventDefaultOnPointerUp: boolean;
  40998. /**
  40999. * Gets or sets user defined metadata
  41000. */
  41001. metadata: any;
  41002. /**
  41003. * For internal use only. Please do not use.
  41004. */
  41005. reservedDataStore: any;
  41006. /**
  41007. * Gets the name of the plugin used to load this scene (null by default)
  41008. */
  41009. loadingPluginName: string;
  41010. /**
  41011. * Use this array to add regular expressions used to disable offline support for specific urls
  41012. */
  41013. disableOfflineSupportExceptionRules: RegExp[];
  41014. /**
  41015. * An event triggered when the scene is disposed.
  41016. */
  41017. onDisposeObservable: Observable<Scene>;
  41018. private _onDisposeObserver;
  41019. /** Sets a function to be executed when this scene is disposed. */
  41020. set onDispose(callback: () => void);
  41021. /**
  41022. * An event triggered before rendering the scene (right after animations and physics)
  41023. */
  41024. onBeforeRenderObservable: Observable<Scene>;
  41025. private _onBeforeRenderObserver;
  41026. /** Sets a function to be executed before rendering this scene */
  41027. set beforeRender(callback: Nullable<() => void>);
  41028. /**
  41029. * An event triggered after rendering the scene
  41030. */
  41031. onAfterRenderObservable: Observable<Scene>;
  41032. /**
  41033. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41034. */
  41035. onAfterRenderCameraObservable: Observable<Camera>;
  41036. private _onAfterRenderObserver;
  41037. /** Sets a function to be executed after rendering this scene */
  41038. set afterRender(callback: Nullable<() => void>);
  41039. /**
  41040. * An event triggered before animating the scene
  41041. */
  41042. onBeforeAnimationsObservable: Observable<Scene>;
  41043. /**
  41044. * An event triggered after animations processing
  41045. */
  41046. onAfterAnimationsObservable: Observable<Scene>;
  41047. /**
  41048. * An event triggered before draw calls are ready to be sent
  41049. */
  41050. onBeforeDrawPhaseObservable: Observable<Scene>;
  41051. /**
  41052. * An event triggered after draw calls have been sent
  41053. */
  41054. onAfterDrawPhaseObservable: Observable<Scene>;
  41055. /**
  41056. * An event triggered when the scene is ready
  41057. */
  41058. onReadyObservable: Observable<Scene>;
  41059. /**
  41060. * An event triggered before rendering a camera
  41061. */
  41062. onBeforeCameraRenderObservable: Observable<Camera>;
  41063. private _onBeforeCameraRenderObserver;
  41064. /** Sets a function to be executed before rendering a camera*/
  41065. set beforeCameraRender(callback: () => void);
  41066. /**
  41067. * An event triggered after rendering a camera
  41068. */
  41069. onAfterCameraRenderObservable: Observable<Camera>;
  41070. private _onAfterCameraRenderObserver;
  41071. /** Sets a function to be executed after rendering a camera*/
  41072. set afterCameraRender(callback: () => void);
  41073. /**
  41074. * An event triggered when active meshes evaluation is about to start
  41075. */
  41076. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41077. /**
  41078. * An event triggered when active meshes evaluation is done
  41079. */
  41080. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41081. /**
  41082. * An event triggered when particles rendering is about to start
  41083. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41084. */
  41085. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41086. /**
  41087. * An event triggered when particles rendering is done
  41088. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41089. */
  41090. onAfterParticlesRenderingObservable: Observable<Scene>;
  41091. /**
  41092. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41093. */
  41094. onDataLoadedObservable: Observable<Scene>;
  41095. /**
  41096. * An event triggered when a camera is created
  41097. */
  41098. onNewCameraAddedObservable: Observable<Camera>;
  41099. /**
  41100. * An event triggered when a camera is removed
  41101. */
  41102. onCameraRemovedObservable: Observable<Camera>;
  41103. /**
  41104. * An event triggered when a light is created
  41105. */
  41106. onNewLightAddedObservable: Observable<Light>;
  41107. /**
  41108. * An event triggered when a light is removed
  41109. */
  41110. onLightRemovedObservable: Observable<Light>;
  41111. /**
  41112. * An event triggered when a geometry is created
  41113. */
  41114. onNewGeometryAddedObservable: Observable<Geometry>;
  41115. /**
  41116. * An event triggered when a geometry is removed
  41117. */
  41118. onGeometryRemovedObservable: Observable<Geometry>;
  41119. /**
  41120. * An event triggered when a transform node is created
  41121. */
  41122. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41123. /**
  41124. * An event triggered when a transform node is removed
  41125. */
  41126. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41127. /**
  41128. * An event triggered when a mesh is created
  41129. */
  41130. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41131. /**
  41132. * An event triggered when a mesh is removed
  41133. */
  41134. onMeshRemovedObservable: Observable<AbstractMesh>;
  41135. /**
  41136. * An event triggered when a skeleton is created
  41137. */
  41138. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41139. /**
  41140. * An event triggered when a skeleton is removed
  41141. */
  41142. onSkeletonRemovedObservable: Observable<Skeleton>;
  41143. /**
  41144. * An event triggered when a material is created
  41145. */
  41146. onNewMaterialAddedObservable: Observable<Material>;
  41147. /**
  41148. * An event triggered when a material is removed
  41149. */
  41150. onMaterialRemovedObservable: Observable<Material>;
  41151. /**
  41152. * An event triggered when a texture is created
  41153. */
  41154. onNewTextureAddedObservable: Observable<BaseTexture>;
  41155. /**
  41156. * An event triggered when a texture is removed
  41157. */
  41158. onTextureRemovedObservable: Observable<BaseTexture>;
  41159. /**
  41160. * An event triggered when render targets are about to be rendered
  41161. * Can happen multiple times per frame.
  41162. */
  41163. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41164. /**
  41165. * An event triggered when render targets were rendered.
  41166. * Can happen multiple times per frame.
  41167. */
  41168. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41169. /**
  41170. * An event triggered before calculating deterministic simulation step
  41171. */
  41172. onBeforeStepObservable: Observable<Scene>;
  41173. /**
  41174. * An event triggered after calculating deterministic simulation step
  41175. */
  41176. onAfterStepObservable: Observable<Scene>;
  41177. /**
  41178. * An event triggered when the activeCamera property is updated
  41179. */
  41180. onActiveCameraChanged: Observable<Scene>;
  41181. /**
  41182. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41183. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41184. * 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)
  41185. */
  41186. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41187. /**
  41188. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41189. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41190. * 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)
  41191. */
  41192. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41193. /**
  41194. * This Observable will when a mesh has been imported into the scene.
  41195. */
  41196. onMeshImportedObservable: Observable<AbstractMesh>;
  41197. /**
  41198. * This Observable will when an animation file has been imported into the scene.
  41199. */
  41200. onAnimationFileImportedObservable: Observable<Scene>;
  41201. /**
  41202. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41203. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41204. */
  41205. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41206. /** @hidden */
  41207. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41208. /**
  41209. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41210. */
  41211. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41212. /**
  41213. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41214. */
  41215. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41216. /**
  41217. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41218. */
  41219. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41220. /** Callback called when a pointer move is detected */
  41221. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41222. /** Callback called when a pointer down is detected */
  41223. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41224. /** Callback called when a pointer up is detected */
  41225. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41226. /** Callback called when a pointer pick is detected */
  41227. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41228. /**
  41229. * 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).
  41230. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41231. */
  41232. onPrePointerObservable: Observable<PointerInfoPre>;
  41233. /**
  41234. * Observable event triggered each time an input event is received from the rendering canvas
  41235. */
  41236. onPointerObservable: Observable<PointerInfo>;
  41237. /**
  41238. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41239. */
  41240. get unTranslatedPointer(): Vector2;
  41241. /**
  41242. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41243. */
  41244. static get DragMovementThreshold(): number;
  41245. static set DragMovementThreshold(value: number);
  41246. /**
  41247. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41248. */
  41249. static get LongPressDelay(): number;
  41250. static set LongPressDelay(value: number);
  41251. /**
  41252. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41253. */
  41254. static get DoubleClickDelay(): number;
  41255. static set DoubleClickDelay(value: number);
  41256. /** If you need to check double click without raising a single click at first click, enable this flag */
  41257. static get ExclusiveDoubleClickMode(): boolean;
  41258. static set ExclusiveDoubleClickMode(value: boolean);
  41259. /** @hidden */
  41260. _mirroredCameraPosition: Nullable<Vector3>;
  41261. /**
  41262. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41263. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41264. */
  41265. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41266. /**
  41267. * Observable event triggered each time an keyboard event is received from the hosting window
  41268. */
  41269. onKeyboardObservable: Observable<KeyboardInfo>;
  41270. private _useRightHandedSystem;
  41271. /**
  41272. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41273. */
  41274. set useRightHandedSystem(value: boolean);
  41275. get useRightHandedSystem(): boolean;
  41276. private _timeAccumulator;
  41277. private _currentStepId;
  41278. private _currentInternalStep;
  41279. /**
  41280. * Sets the step Id used by deterministic lock step
  41281. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41282. * @param newStepId defines the step Id
  41283. */
  41284. setStepId(newStepId: number): void;
  41285. /**
  41286. * Gets the step Id used by deterministic lock step
  41287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41288. * @returns the step Id
  41289. */
  41290. getStepId(): number;
  41291. /**
  41292. * Gets the internal step used by deterministic lock step
  41293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41294. * @returns the internal step
  41295. */
  41296. getInternalStep(): number;
  41297. private _fogEnabled;
  41298. /**
  41299. * Gets or sets a boolean indicating if fog is enabled on this scene
  41300. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41301. * (Default is true)
  41302. */
  41303. set fogEnabled(value: boolean);
  41304. get fogEnabled(): boolean;
  41305. private _fogMode;
  41306. /**
  41307. * Gets or sets the fog mode to use
  41308. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41309. * | mode | value |
  41310. * | --- | --- |
  41311. * | FOGMODE_NONE | 0 |
  41312. * | FOGMODE_EXP | 1 |
  41313. * | FOGMODE_EXP2 | 2 |
  41314. * | FOGMODE_LINEAR | 3 |
  41315. */
  41316. set fogMode(value: number);
  41317. get fogMode(): number;
  41318. /**
  41319. * Gets or sets the fog color to use
  41320. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41321. * (Default is Color3(0.2, 0.2, 0.3))
  41322. */
  41323. fogColor: Color3;
  41324. /**
  41325. * Gets or sets the fog density to use
  41326. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41327. * (Default is 0.1)
  41328. */
  41329. fogDensity: number;
  41330. /**
  41331. * Gets or sets the fog start distance to use
  41332. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41333. * (Default is 0)
  41334. */
  41335. fogStart: number;
  41336. /**
  41337. * Gets or sets the fog end distance to use
  41338. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41339. * (Default is 1000)
  41340. */
  41341. fogEnd: number;
  41342. /**
  41343. * Flag indicating that the frame buffer binding is handled by another component
  41344. */
  41345. prePass: boolean;
  41346. private _shadowsEnabled;
  41347. /**
  41348. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41349. */
  41350. set shadowsEnabled(value: boolean);
  41351. get shadowsEnabled(): boolean;
  41352. private _lightsEnabled;
  41353. /**
  41354. * Gets or sets a boolean indicating if lights are enabled on this scene
  41355. */
  41356. set lightsEnabled(value: boolean);
  41357. get lightsEnabled(): boolean;
  41358. /** All of the active cameras added to this scene. */
  41359. activeCameras: Camera[];
  41360. /** @hidden */
  41361. _activeCamera: Nullable<Camera>;
  41362. /** Gets or sets the current active camera */
  41363. get activeCamera(): Nullable<Camera>;
  41364. set activeCamera(value: Nullable<Camera>);
  41365. private _defaultMaterial;
  41366. /** The default material used on meshes when no material is affected */
  41367. get defaultMaterial(): Material;
  41368. /** The default material used on meshes when no material is affected */
  41369. set defaultMaterial(value: Material);
  41370. private _texturesEnabled;
  41371. /**
  41372. * Gets or sets a boolean indicating if textures are enabled on this scene
  41373. */
  41374. set texturesEnabled(value: boolean);
  41375. get texturesEnabled(): boolean;
  41376. /**
  41377. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41378. */
  41379. physicsEnabled: boolean;
  41380. /**
  41381. * Gets or sets a boolean indicating if particles are enabled on this scene
  41382. */
  41383. particlesEnabled: boolean;
  41384. /**
  41385. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41386. */
  41387. spritesEnabled: boolean;
  41388. private _skeletonsEnabled;
  41389. /**
  41390. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41391. */
  41392. set skeletonsEnabled(value: boolean);
  41393. get skeletonsEnabled(): boolean;
  41394. /**
  41395. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41396. */
  41397. lensFlaresEnabled: boolean;
  41398. /**
  41399. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41400. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41401. */
  41402. collisionsEnabled: boolean;
  41403. private _collisionCoordinator;
  41404. /** @hidden */
  41405. get collisionCoordinator(): ICollisionCoordinator;
  41406. /**
  41407. * Defines the gravity applied to this scene (used only for collisions)
  41408. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41409. */
  41410. gravity: Vector3;
  41411. /**
  41412. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41413. */
  41414. postProcessesEnabled: boolean;
  41415. /**
  41416. * Gets the current postprocess manager
  41417. */
  41418. postProcessManager: PostProcessManager;
  41419. /**
  41420. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41421. */
  41422. renderTargetsEnabled: boolean;
  41423. /**
  41424. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41425. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41426. */
  41427. dumpNextRenderTargets: boolean;
  41428. /**
  41429. * The list of user defined render targets added to the scene
  41430. */
  41431. customRenderTargets: RenderTargetTexture[];
  41432. /**
  41433. * Defines if texture loading must be delayed
  41434. * If true, textures will only be loaded when they need to be rendered
  41435. */
  41436. useDelayedTextureLoading: boolean;
  41437. /**
  41438. * Gets the list of meshes imported to the scene through SceneLoader
  41439. */
  41440. importedMeshesFiles: String[];
  41441. /**
  41442. * Gets or sets a boolean indicating if probes are enabled on this scene
  41443. */
  41444. probesEnabled: boolean;
  41445. /**
  41446. * Gets or sets the current offline provider to use to store scene data
  41447. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41448. */
  41449. offlineProvider: IOfflineProvider;
  41450. /**
  41451. * Gets or sets the action manager associated with the scene
  41452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41453. */
  41454. actionManager: AbstractActionManager;
  41455. private _meshesForIntersections;
  41456. /**
  41457. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41458. */
  41459. proceduralTexturesEnabled: boolean;
  41460. private _engine;
  41461. private _totalVertices;
  41462. /** @hidden */
  41463. _activeIndices: PerfCounter;
  41464. /** @hidden */
  41465. _activeParticles: PerfCounter;
  41466. /** @hidden */
  41467. _activeBones: PerfCounter;
  41468. private _animationRatio;
  41469. /** @hidden */
  41470. _animationTimeLast: number;
  41471. /** @hidden */
  41472. _animationTime: number;
  41473. /**
  41474. * Gets or sets a general scale for animation speed
  41475. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41476. */
  41477. animationTimeScale: number;
  41478. /** @hidden */
  41479. _cachedMaterial: Nullable<Material>;
  41480. /** @hidden */
  41481. _cachedEffect: Nullable<Effect>;
  41482. /** @hidden */
  41483. _cachedVisibility: Nullable<number>;
  41484. private _renderId;
  41485. private _frameId;
  41486. private _executeWhenReadyTimeoutId;
  41487. private _intermediateRendering;
  41488. private _viewUpdateFlag;
  41489. private _projectionUpdateFlag;
  41490. /** @hidden */
  41491. _toBeDisposed: Nullable<IDisposable>[];
  41492. private _activeRequests;
  41493. /** @hidden */
  41494. _pendingData: any[];
  41495. private _isDisposed;
  41496. /**
  41497. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41498. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41499. */
  41500. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41501. private _activeMeshes;
  41502. private _processedMaterials;
  41503. private _renderTargets;
  41504. /** @hidden */
  41505. _activeParticleSystems: SmartArray<IParticleSystem>;
  41506. private _activeSkeletons;
  41507. private _softwareSkinnedMeshes;
  41508. private _renderingManager;
  41509. /** @hidden */
  41510. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41511. private _transformMatrix;
  41512. private _sceneUbo;
  41513. /** @hidden */
  41514. _viewMatrix: Matrix;
  41515. private _projectionMatrix;
  41516. /** @hidden */
  41517. _forcedViewPosition: Nullable<Vector3>;
  41518. /** @hidden */
  41519. _frustumPlanes: Plane[];
  41520. /**
  41521. * Gets the list of frustum planes (built from the active camera)
  41522. */
  41523. get frustumPlanes(): Plane[];
  41524. /**
  41525. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41526. * This is useful if there are more lights that the maximum simulteanous authorized
  41527. */
  41528. requireLightSorting: boolean;
  41529. /** @hidden */
  41530. readonly useMaterialMeshMap: boolean;
  41531. /** @hidden */
  41532. readonly useClonedMeshMap: boolean;
  41533. private _externalData;
  41534. private _uid;
  41535. /**
  41536. * @hidden
  41537. * Backing store of defined scene components.
  41538. */
  41539. _components: ISceneComponent[];
  41540. /**
  41541. * @hidden
  41542. * Backing store of defined scene components.
  41543. */
  41544. _serializableComponents: ISceneSerializableComponent[];
  41545. /**
  41546. * List of components to register on the next registration step.
  41547. */
  41548. private _transientComponents;
  41549. /**
  41550. * Registers the transient components if needed.
  41551. */
  41552. private _registerTransientComponents;
  41553. /**
  41554. * @hidden
  41555. * Add a component to the scene.
  41556. * Note that the ccomponent could be registered on th next frame if this is called after
  41557. * the register component stage.
  41558. * @param component Defines the component to add to the scene
  41559. */
  41560. _addComponent(component: ISceneComponent): void;
  41561. /**
  41562. * @hidden
  41563. * Gets a component from the scene.
  41564. * @param name defines the name of the component to retrieve
  41565. * @returns the component or null if not present
  41566. */
  41567. _getComponent(name: string): Nullable<ISceneComponent>;
  41568. /**
  41569. * @hidden
  41570. * Defines the actions happening before camera updates.
  41571. */
  41572. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41573. /**
  41574. * @hidden
  41575. * Defines the actions happening before clear the canvas.
  41576. */
  41577. _beforeClearStage: Stage<SimpleStageAction>;
  41578. /**
  41579. * @hidden
  41580. * Defines the actions when collecting render targets for the frame.
  41581. */
  41582. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41583. /**
  41584. * @hidden
  41585. * Defines the actions happening for one camera in the frame.
  41586. */
  41587. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41588. /**
  41589. * @hidden
  41590. * Defines the actions happening during the per mesh ready checks.
  41591. */
  41592. _isReadyForMeshStage: Stage<MeshStageAction>;
  41593. /**
  41594. * @hidden
  41595. * Defines the actions happening before evaluate active mesh checks.
  41596. */
  41597. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41598. /**
  41599. * @hidden
  41600. * Defines the actions happening during the evaluate sub mesh checks.
  41601. */
  41602. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41603. /**
  41604. * @hidden
  41605. * Defines the actions happening during the active mesh stage.
  41606. */
  41607. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41608. /**
  41609. * @hidden
  41610. * Defines the actions happening during the per camera render target step.
  41611. */
  41612. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41613. /**
  41614. * @hidden
  41615. * Defines the actions happening just before the active camera is drawing.
  41616. */
  41617. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41618. /**
  41619. * @hidden
  41620. * Defines the actions happening just before a render target is drawing.
  41621. */
  41622. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41623. /**
  41624. * @hidden
  41625. * Defines the actions happening just before a rendering group is drawing.
  41626. */
  41627. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41628. /**
  41629. * @hidden
  41630. * Defines the actions happening just before a mesh is drawing.
  41631. */
  41632. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41633. /**
  41634. * @hidden
  41635. * Defines the actions happening just after a mesh has been drawn.
  41636. */
  41637. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41638. /**
  41639. * @hidden
  41640. * Defines the actions happening just after a rendering group has been drawn.
  41641. */
  41642. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41643. /**
  41644. * @hidden
  41645. * Defines the actions happening just after the active camera has been drawn.
  41646. */
  41647. _afterCameraDrawStage: Stage<CameraStageAction>;
  41648. /**
  41649. * @hidden
  41650. * Defines the actions happening just after a render target has been drawn.
  41651. */
  41652. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41653. /**
  41654. * @hidden
  41655. * Defines the actions happening just after rendering all cameras and computing intersections.
  41656. */
  41657. _afterRenderStage: Stage<SimpleStageAction>;
  41658. /**
  41659. * @hidden
  41660. * Defines the actions happening when a pointer move event happens.
  41661. */
  41662. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41663. /**
  41664. * @hidden
  41665. * Defines the actions happening when a pointer down event happens.
  41666. */
  41667. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41668. /**
  41669. * @hidden
  41670. * Defines the actions happening when a pointer up event happens.
  41671. */
  41672. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41673. /**
  41674. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41675. */
  41676. private geometriesByUniqueId;
  41677. /**
  41678. * Creates a new Scene
  41679. * @param engine defines the engine to use to render this scene
  41680. * @param options defines the scene options
  41681. */
  41682. constructor(engine: Engine, options?: SceneOptions);
  41683. /**
  41684. * Gets a string identifying the name of the class
  41685. * @returns "Scene" string
  41686. */
  41687. getClassName(): string;
  41688. private _defaultMeshCandidates;
  41689. /**
  41690. * @hidden
  41691. */
  41692. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41693. private _defaultSubMeshCandidates;
  41694. /**
  41695. * @hidden
  41696. */
  41697. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41698. /**
  41699. * Sets the default candidate providers for the scene.
  41700. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41701. * and getCollidingSubMeshCandidates to their default function
  41702. */
  41703. setDefaultCandidateProviders(): void;
  41704. /**
  41705. * Gets the mesh that is currently under the pointer
  41706. */
  41707. get meshUnderPointer(): Nullable<AbstractMesh>;
  41708. /**
  41709. * Gets or sets the current on-screen X position of the pointer
  41710. */
  41711. get pointerX(): number;
  41712. set pointerX(value: number);
  41713. /**
  41714. * Gets or sets the current on-screen Y position of the pointer
  41715. */
  41716. get pointerY(): number;
  41717. set pointerY(value: number);
  41718. /**
  41719. * Gets the cached material (ie. the latest rendered one)
  41720. * @returns the cached material
  41721. */
  41722. getCachedMaterial(): Nullable<Material>;
  41723. /**
  41724. * Gets the cached effect (ie. the latest rendered one)
  41725. * @returns the cached effect
  41726. */
  41727. getCachedEffect(): Nullable<Effect>;
  41728. /**
  41729. * Gets the cached visibility state (ie. the latest rendered one)
  41730. * @returns the cached visibility state
  41731. */
  41732. getCachedVisibility(): Nullable<number>;
  41733. /**
  41734. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41735. * @param material defines the current material
  41736. * @param effect defines the current effect
  41737. * @param visibility defines the current visibility state
  41738. * @returns true if one parameter is not cached
  41739. */
  41740. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41741. /**
  41742. * Gets the engine associated with the scene
  41743. * @returns an Engine
  41744. */
  41745. getEngine(): Engine;
  41746. /**
  41747. * Gets the total number of vertices rendered per frame
  41748. * @returns the total number of vertices rendered per frame
  41749. */
  41750. getTotalVertices(): number;
  41751. /**
  41752. * Gets the performance counter for total vertices
  41753. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41754. */
  41755. get totalVerticesPerfCounter(): PerfCounter;
  41756. /**
  41757. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41758. * @returns the total number of active indices rendered per frame
  41759. */
  41760. getActiveIndices(): number;
  41761. /**
  41762. * Gets the performance counter for active indices
  41763. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41764. */
  41765. get totalActiveIndicesPerfCounter(): PerfCounter;
  41766. /**
  41767. * Gets the total number of active particles rendered per frame
  41768. * @returns the total number of active particles rendered per frame
  41769. */
  41770. getActiveParticles(): number;
  41771. /**
  41772. * Gets the performance counter for active particles
  41773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41774. */
  41775. get activeParticlesPerfCounter(): PerfCounter;
  41776. /**
  41777. * Gets the total number of active bones rendered per frame
  41778. * @returns the total number of active bones rendered per frame
  41779. */
  41780. getActiveBones(): number;
  41781. /**
  41782. * Gets the performance counter for active bones
  41783. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41784. */
  41785. get activeBonesPerfCounter(): PerfCounter;
  41786. /**
  41787. * Gets the array of active meshes
  41788. * @returns an array of AbstractMesh
  41789. */
  41790. getActiveMeshes(): SmartArray<AbstractMesh>;
  41791. /**
  41792. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41793. * @returns a number
  41794. */
  41795. getAnimationRatio(): number;
  41796. /**
  41797. * Gets an unique Id for the current render phase
  41798. * @returns a number
  41799. */
  41800. getRenderId(): number;
  41801. /**
  41802. * Gets an unique Id for the current frame
  41803. * @returns a number
  41804. */
  41805. getFrameId(): number;
  41806. /** Call this function if you want to manually increment the render Id*/
  41807. incrementRenderId(): void;
  41808. private _createUbo;
  41809. /**
  41810. * Use this method to simulate a pointer move on a mesh
  41811. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41812. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41813. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41814. * @returns the current scene
  41815. */
  41816. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41817. /**
  41818. * Use this method to simulate a pointer down on a mesh
  41819. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41820. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41821. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41822. * @returns the current scene
  41823. */
  41824. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41825. /**
  41826. * Use this method to simulate a pointer up on a mesh
  41827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41830. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41831. * @returns the current scene
  41832. */
  41833. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41834. /**
  41835. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41836. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41837. * @returns true if the pointer was captured
  41838. */
  41839. isPointerCaptured(pointerId?: number): boolean;
  41840. /**
  41841. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41842. * @param attachUp defines if you want to attach events to pointerup
  41843. * @param attachDown defines if you want to attach events to pointerdown
  41844. * @param attachMove defines if you want to attach events to pointermove
  41845. */
  41846. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41847. /** Detaches all event handlers*/
  41848. detachControl(): void;
  41849. /**
  41850. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41851. * Delay loaded resources are not taking in account
  41852. * @return true if all required resources are ready
  41853. */
  41854. isReady(): boolean;
  41855. /** Resets all cached information relative to material (including effect and visibility) */
  41856. resetCachedMaterial(): void;
  41857. /**
  41858. * Registers a function to be called before every frame render
  41859. * @param func defines the function to register
  41860. */
  41861. registerBeforeRender(func: () => void): void;
  41862. /**
  41863. * Unregisters a function called before every frame render
  41864. * @param func defines the function to unregister
  41865. */
  41866. unregisterBeforeRender(func: () => void): void;
  41867. /**
  41868. * Registers a function to be called after every frame render
  41869. * @param func defines the function to register
  41870. */
  41871. registerAfterRender(func: () => void): void;
  41872. /**
  41873. * Unregisters a function called after every frame render
  41874. * @param func defines the function to unregister
  41875. */
  41876. unregisterAfterRender(func: () => void): void;
  41877. private _executeOnceBeforeRender;
  41878. /**
  41879. * The provided function will run before render once and will be disposed afterwards.
  41880. * A timeout delay can be provided so that the function will be executed in N ms.
  41881. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41882. * @param func The function to be executed.
  41883. * @param timeout optional delay in ms
  41884. */
  41885. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41886. /** @hidden */
  41887. _addPendingData(data: any): void;
  41888. /** @hidden */
  41889. _removePendingData(data: any): void;
  41890. /**
  41891. * Returns the number of items waiting to be loaded
  41892. * @returns the number of items waiting to be loaded
  41893. */
  41894. getWaitingItemsCount(): number;
  41895. /**
  41896. * Returns a boolean indicating if the scene is still loading data
  41897. */
  41898. get isLoading(): boolean;
  41899. /**
  41900. * Registers a function to be executed when the scene is ready
  41901. * @param {Function} func - the function to be executed
  41902. */
  41903. executeWhenReady(func: () => void): void;
  41904. /**
  41905. * Returns a promise that resolves when the scene is ready
  41906. * @returns A promise that resolves when the scene is ready
  41907. */
  41908. whenReadyAsync(): Promise<void>;
  41909. /** @hidden */
  41910. _checkIsReady(): void;
  41911. /**
  41912. * Gets all animatable attached to the scene
  41913. */
  41914. get animatables(): Animatable[];
  41915. /**
  41916. * Resets the last animation time frame.
  41917. * Useful to override when animations start running when loading a scene for the first time.
  41918. */
  41919. resetLastAnimationTimeFrame(): void;
  41920. /**
  41921. * Gets the current view matrix
  41922. * @returns a Matrix
  41923. */
  41924. getViewMatrix(): Matrix;
  41925. /**
  41926. * Gets the current projection matrix
  41927. * @returns a Matrix
  41928. */
  41929. getProjectionMatrix(): Matrix;
  41930. /**
  41931. * Gets the current transform matrix
  41932. * @returns a Matrix made of View * Projection
  41933. */
  41934. getTransformMatrix(): Matrix;
  41935. /**
  41936. * Sets the current transform matrix
  41937. * @param viewL defines the View matrix to use
  41938. * @param projectionL defines the Projection matrix to use
  41939. * @param viewR defines the right View matrix to use (if provided)
  41940. * @param projectionR defines the right Projection matrix to use (if provided)
  41941. */
  41942. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41943. /**
  41944. * Gets the uniform buffer used to store scene data
  41945. * @returns a UniformBuffer
  41946. */
  41947. getSceneUniformBuffer(): UniformBuffer;
  41948. /**
  41949. * Gets an unique (relatively to the current scene) Id
  41950. * @returns an unique number for the scene
  41951. */
  41952. getUniqueId(): number;
  41953. /**
  41954. * Add a mesh to the list of scene's meshes
  41955. * @param newMesh defines the mesh to add
  41956. * @param recursive if all child meshes should also be added to the scene
  41957. */
  41958. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41959. /**
  41960. * Remove a mesh for the list of scene's meshes
  41961. * @param toRemove defines the mesh to remove
  41962. * @param recursive if all child meshes should also be removed from the scene
  41963. * @returns the index where the mesh was in the mesh list
  41964. */
  41965. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41966. /**
  41967. * Add a transform node to the list of scene's transform nodes
  41968. * @param newTransformNode defines the transform node to add
  41969. */
  41970. addTransformNode(newTransformNode: TransformNode): void;
  41971. /**
  41972. * Remove a transform node for the list of scene's transform nodes
  41973. * @param toRemove defines the transform node to remove
  41974. * @returns the index where the transform node was in the transform node list
  41975. */
  41976. removeTransformNode(toRemove: TransformNode): number;
  41977. /**
  41978. * Remove a skeleton for the list of scene's skeletons
  41979. * @param toRemove defines the skeleton to remove
  41980. * @returns the index where the skeleton was in the skeleton list
  41981. */
  41982. removeSkeleton(toRemove: Skeleton): number;
  41983. /**
  41984. * Remove a morph target for the list of scene's morph targets
  41985. * @param toRemove defines the morph target to remove
  41986. * @returns the index where the morph target was in the morph target list
  41987. */
  41988. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41989. /**
  41990. * Remove a light for the list of scene's lights
  41991. * @param toRemove defines the light to remove
  41992. * @returns the index where the light was in the light list
  41993. */
  41994. removeLight(toRemove: Light): number;
  41995. /**
  41996. * Remove a camera for the list of scene's cameras
  41997. * @param toRemove defines the camera to remove
  41998. * @returns the index where the camera was in the camera list
  41999. */
  42000. removeCamera(toRemove: Camera): number;
  42001. /**
  42002. * Remove a particle system for the list of scene's particle systems
  42003. * @param toRemove defines the particle system to remove
  42004. * @returns the index where the particle system was in the particle system list
  42005. */
  42006. removeParticleSystem(toRemove: IParticleSystem): number;
  42007. /**
  42008. * Remove a animation for the list of scene's animations
  42009. * @param toRemove defines the animation to remove
  42010. * @returns the index where the animation was in the animation list
  42011. */
  42012. removeAnimation(toRemove: Animation): number;
  42013. /**
  42014. * Will stop the animation of the given target
  42015. * @param target - the target
  42016. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42017. * @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)
  42018. */
  42019. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42020. /**
  42021. * Removes the given animation group from this scene.
  42022. * @param toRemove The animation group to remove
  42023. * @returns The index of the removed animation group
  42024. */
  42025. removeAnimationGroup(toRemove: AnimationGroup): number;
  42026. /**
  42027. * Removes the given multi-material from this scene.
  42028. * @param toRemove The multi-material to remove
  42029. * @returns The index of the removed multi-material
  42030. */
  42031. removeMultiMaterial(toRemove: MultiMaterial): number;
  42032. /**
  42033. * Removes the given material from this scene.
  42034. * @param toRemove The material to remove
  42035. * @returns The index of the removed material
  42036. */
  42037. removeMaterial(toRemove: Material): number;
  42038. /**
  42039. * Removes the given action manager from this scene.
  42040. * @param toRemove The action manager to remove
  42041. * @returns The index of the removed action manager
  42042. */
  42043. removeActionManager(toRemove: AbstractActionManager): number;
  42044. /**
  42045. * Removes the given texture from this scene.
  42046. * @param toRemove The texture to remove
  42047. * @returns The index of the removed texture
  42048. */
  42049. removeTexture(toRemove: BaseTexture): number;
  42050. /**
  42051. * Adds the given light to this scene
  42052. * @param newLight The light to add
  42053. */
  42054. addLight(newLight: Light): void;
  42055. /**
  42056. * Sorts the list list based on light priorities
  42057. */
  42058. sortLightsByPriority(): void;
  42059. /**
  42060. * Adds the given camera to this scene
  42061. * @param newCamera The camera to add
  42062. */
  42063. addCamera(newCamera: Camera): void;
  42064. /**
  42065. * Adds the given skeleton to this scene
  42066. * @param newSkeleton The skeleton to add
  42067. */
  42068. addSkeleton(newSkeleton: Skeleton): void;
  42069. /**
  42070. * Adds the given particle system to this scene
  42071. * @param newParticleSystem The particle system to add
  42072. */
  42073. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42074. /**
  42075. * Adds the given animation to this scene
  42076. * @param newAnimation The animation to add
  42077. */
  42078. addAnimation(newAnimation: Animation): void;
  42079. /**
  42080. * Adds the given animation group to this scene.
  42081. * @param newAnimationGroup The animation group to add
  42082. */
  42083. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42084. /**
  42085. * Adds the given multi-material to this scene
  42086. * @param newMultiMaterial The multi-material to add
  42087. */
  42088. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42089. /**
  42090. * Adds the given material to this scene
  42091. * @param newMaterial The material to add
  42092. */
  42093. addMaterial(newMaterial: Material): void;
  42094. /**
  42095. * Adds the given morph target to this scene
  42096. * @param newMorphTargetManager The morph target to add
  42097. */
  42098. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42099. /**
  42100. * Adds the given geometry to this scene
  42101. * @param newGeometry The geometry to add
  42102. */
  42103. addGeometry(newGeometry: Geometry): void;
  42104. /**
  42105. * Adds the given action manager to this scene
  42106. * @param newActionManager The action manager to add
  42107. */
  42108. addActionManager(newActionManager: AbstractActionManager): void;
  42109. /**
  42110. * Adds the given texture to this scene.
  42111. * @param newTexture The texture to add
  42112. */
  42113. addTexture(newTexture: BaseTexture): void;
  42114. /**
  42115. * Switch active camera
  42116. * @param newCamera defines the new active camera
  42117. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42118. */
  42119. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42120. /**
  42121. * sets the active camera of the scene using its ID
  42122. * @param id defines the camera's ID
  42123. * @return the new active camera or null if none found.
  42124. */
  42125. setActiveCameraByID(id: string): Nullable<Camera>;
  42126. /**
  42127. * sets the active camera of the scene using its name
  42128. * @param name defines the camera's name
  42129. * @returns the new active camera or null if none found.
  42130. */
  42131. setActiveCameraByName(name: string): Nullable<Camera>;
  42132. /**
  42133. * get an animation group using its name
  42134. * @param name defines the material's name
  42135. * @return the animation group or null if none found.
  42136. */
  42137. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42138. /**
  42139. * Get a material using its unique id
  42140. * @param uniqueId defines the material's unique id
  42141. * @return the material or null if none found.
  42142. */
  42143. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42144. /**
  42145. * get a material using its id
  42146. * @param id defines the material's ID
  42147. * @return the material or null if none found.
  42148. */
  42149. getMaterialByID(id: string): Nullable<Material>;
  42150. /**
  42151. * Gets a the last added material using a given id
  42152. * @param id defines the material's ID
  42153. * @return the last material with the given id or null if none found.
  42154. */
  42155. getLastMaterialByID(id: string): Nullable<Material>;
  42156. /**
  42157. * Gets a material using its name
  42158. * @param name defines the material's name
  42159. * @return the material or null if none found.
  42160. */
  42161. getMaterialByName(name: string): Nullable<Material>;
  42162. /**
  42163. * Get a texture using its unique id
  42164. * @param uniqueId defines the texture's unique id
  42165. * @return the texture or null if none found.
  42166. */
  42167. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42168. /**
  42169. * Gets a camera using its id
  42170. * @param id defines the id to look for
  42171. * @returns the camera or null if not found
  42172. */
  42173. getCameraByID(id: string): Nullable<Camera>;
  42174. /**
  42175. * Gets a camera using its unique id
  42176. * @param uniqueId defines the unique id to look for
  42177. * @returns the camera or null if not found
  42178. */
  42179. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42180. /**
  42181. * Gets a camera using its name
  42182. * @param name defines the camera's name
  42183. * @return the camera or null if none found.
  42184. */
  42185. getCameraByName(name: string): Nullable<Camera>;
  42186. /**
  42187. * Gets a bone using its id
  42188. * @param id defines the bone's id
  42189. * @return the bone or null if not found
  42190. */
  42191. getBoneByID(id: string): Nullable<Bone>;
  42192. /**
  42193. * Gets a bone using its id
  42194. * @param name defines the bone's name
  42195. * @return the bone or null if not found
  42196. */
  42197. getBoneByName(name: string): Nullable<Bone>;
  42198. /**
  42199. * Gets a light node using its name
  42200. * @param name defines the the light's name
  42201. * @return the light or null if none found.
  42202. */
  42203. getLightByName(name: string): Nullable<Light>;
  42204. /**
  42205. * Gets a light node using its id
  42206. * @param id defines the light's id
  42207. * @return the light or null if none found.
  42208. */
  42209. getLightByID(id: string): Nullable<Light>;
  42210. /**
  42211. * Gets a light node using its scene-generated unique ID
  42212. * @param uniqueId defines the light's unique id
  42213. * @return the light or null if none found.
  42214. */
  42215. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42216. /**
  42217. * Gets a particle system by id
  42218. * @param id defines the particle system id
  42219. * @return the corresponding system or null if none found
  42220. */
  42221. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42222. /**
  42223. * Gets a geometry using its ID
  42224. * @param id defines the geometry's id
  42225. * @return the geometry or null if none found.
  42226. */
  42227. getGeometryByID(id: string): Nullable<Geometry>;
  42228. private _getGeometryByUniqueID;
  42229. /**
  42230. * Add a new geometry to this scene
  42231. * @param geometry defines the geometry to be added to the scene.
  42232. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42233. * @return a boolean defining if the geometry was added or not
  42234. */
  42235. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42236. /**
  42237. * Removes an existing geometry
  42238. * @param geometry defines the geometry to be removed from the scene
  42239. * @return a boolean defining if the geometry was removed or not
  42240. */
  42241. removeGeometry(geometry: Geometry): boolean;
  42242. /**
  42243. * Gets the list of geometries attached to the scene
  42244. * @returns an array of Geometry
  42245. */
  42246. getGeometries(): Geometry[];
  42247. /**
  42248. * Gets the first added mesh found of a given ID
  42249. * @param id defines the id to search for
  42250. * @return the mesh found or null if not found at all
  42251. */
  42252. getMeshByID(id: string): Nullable<AbstractMesh>;
  42253. /**
  42254. * Gets a list of meshes using their id
  42255. * @param id defines the id to search for
  42256. * @returns a list of meshes
  42257. */
  42258. getMeshesByID(id: string): Array<AbstractMesh>;
  42259. /**
  42260. * Gets the first added transform node found of a given ID
  42261. * @param id defines the id to search for
  42262. * @return the found transform node or null if not found at all.
  42263. */
  42264. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42265. /**
  42266. * Gets a transform node with its auto-generated unique id
  42267. * @param uniqueId efines the unique id to search for
  42268. * @return the found transform node or null if not found at all.
  42269. */
  42270. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42271. /**
  42272. * Gets a list of transform nodes using their id
  42273. * @param id defines the id to search for
  42274. * @returns a list of transform nodes
  42275. */
  42276. getTransformNodesByID(id: string): Array<TransformNode>;
  42277. /**
  42278. * Gets a mesh with its auto-generated unique id
  42279. * @param uniqueId defines the unique id to search for
  42280. * @return the found mesh or null if not found at all.
  42281. */
  42282. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42283. /**
  42284. * Gets a the last added mesh using a given id
  42285. * @param id defines the id to search for
  42286. * @return the found mesh or null if not found at all.
  42287. */
  42288. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42289. /**
  42290. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42291. * @param id defines the id to search for
  42292. * @return the found node or null if not found at all
  42293. */
  42294. getLastEntryByID(id: string): Nullable<Node>;
  42295. /**
  42296. * Gets a node (Mesh, Camera, Light) using a given id
  42297. * @param id defines the id to search for
  42298. * @return the found node or null if not found at all
  42299. */
  42300. getNodeByID(id: string): Nullable<Node>;
  42301. /**
  42302. * Gets a node (Mesh, Camera, Light) using a given name
  42303. * @param name defines the name to search for
  42304. * @return the found node or null if not found at all.
  42305. */
  42306. getNodeByName(name: string): Nullable<Node>;
  42307. /**
  42308. * Gets a mesh using a given name
  42309. * @param name defines the name to search for
  42310. * @return the found mesh or null if not found at all.
  42311. */
  42312. getMeshByName(name: string): Nullable<AbstractMesh>;
  42313. /**
  42314. * Gets a transform node using a given name
  42315. * @param name defines the name to search for
  42316. * @return the found transform node or null if not found at all.
  42317. */
  42318. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42319. /**
  42320. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42321. * @param id defines the id to search for
  42322. * @return the found skeleton or null if not found at all.
  42323. */
  42324. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42325. /**
  42326. * Gets a skeleton using a given auto generated unique id
  42327. * @param uniqueId defines the unique id to search for
  42328. * @return the found skeleton or null if not found at all.
  42329. */
  42330. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42331. /**
  42332. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42333. * @param id defines the id to search for
  42334. * @return the found skeleton or null if not found at all.
  42335. */
  42336. getSkeletonById(id: string): Nullable<Skeleton>;
  42337. /**
  42338. * Gets a skeleton using a given name
  42339. * @param name defines the name to search for
  42340. * @return the found skeleton or null if not found at all.
  42341. */
  42342. getSkeletonByName(name: string): Nullable<Skeleton>;
  42343. /**
  42344. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42345. * @param id defines the id to search for
  42346. * @return the found morph target manager or null if not found at all.
  42347. */
  42348. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42349. /**
  42350. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42351. * @param id defines the id to search for
  42352. * @return the found morph target or null if not found at all.
  42353. */
  42354. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42355. /**
  42356. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42357. * @param name defines the name to search for
  42358. * @return the found morph target or null if not found at all.
  42359. */
  42360. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42361. /**
  42362. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42363. * @param name defines the name to search for
  42364. * @return the found post process or null if not found at all.
  42365. */
  42366. getPostProcessByName(name: string): Nullable<PostProcess>;
  42367. /**
  42368. * Gets a boolean indicating if the given mesh is active
  42369. * @param mesh defines the mesh to look for
  42370. * @returns true if the mesh is in the active list
  42371. */
  42372. isActiveMesh(mesh: AbstractMesh): boolean;
  42373. /**
  42374. * Return a unique id as a string which can serve as an identifier for the scene
  42375. */
  42376. get uid(): string;
  42377. /**
  42378. * Add an externaly attached data from its key.
  42379. * This method call will fail and return false, if such key already exists.
  42380. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42381. * @param key the unique key that identifies the data
  42382. * @param data the data object to associate to the key for this Engine instance
  42383. * @return true if no such key were already present and the data was added successfully, false otherwise
  42384. */
  42385. addExternalData<T>(key: string, data: T): boolean;
  42386. /**
  42387. * Get an externaly attached data from its key
  42388. * @param key the unique key that identifies the data
  42389. * @return the associated data, if present (can be null), or undefined if not present
  42390. */
  42391. getExternalData<T>(key: string): Nullable<T>;
  42392. /**
  42393. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42394. * @param key the unique key that identifies the data
  42395. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42396. * @return the associated data, can be null if the factory returned null.
  42397. */
  42398. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42399. /**
  42400. * Remove an externaly attached data from the Engine instance
  42401. * @param key the unique key that identifies the data
  42402. * @return true if the data was successfully removed, false if it doesn't exist
  42403. */
  42404. removeExternalData(key: string): boolean;
  42405. private _evaluateSubMesh;
  42406. /**
  42407. * Clear the processed materials smart array preventing retention point in material dispose.
  42408. */
  42409. freeProcessedMaterials(): void;
  42410. private _preventFreeActiveMeshesAndRenderingGroups;
  42411. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42412. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42413. * when disposing several meshes in a row or a hierarchy of meshes.
  42414. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42415. */
  42416. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42417. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42418. /**
  42419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42420. */
  42421. freeActiveMeshes(): void;
  42422. /**
  42423. * Clear the info related to rendering groups preventing retention points during dispose.
  42424. */
  42425. freeRenderingGroups(): void;
  42426. /** @hidden */
  42427. _isInIntermediateRendering(): boolean;
  42428. /**
  42429. * Lambda returning the list of potentially active meshes.
  42430. */
  42431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42432. /**
  42433. * Lambda returning the list of potentially active sub meshes.
  42434. */
  42435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42436. /**
  42437. * Lambda returning the list of potentially intersecting sub meshes.
  42438. */
  42439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42440. /**
  42441. * Lambda returning the list of potentially colliding sub meshes.
  42442. */
  42443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42444. private _activeMeshesFrozen;
  42445. private _skipEvaluateActiveMeshesCompletely;
  42446. /**
  42447. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42448. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42449. * @returns the current scene
  42450. */
  42451. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42452. /**
  42453. * Use this function to restart evaluating active meshes on every frame
  42454. * @returns the current scene
  42455. */
  42456. unfreezeActiveMeshes(): Scene;
  42457. private _evaluateActiveMeshes;
  42458. private _activeMesh;
  42459. /**
  42460. * Update the transform matrix to update from the current active camera
  42461. * @param force defines a boolean used to force the update even if cache is up to date
  42462. */
  42463. updateTransformMatrix(force?: boolean): void;
  42464. private _bindFrameBuffer;
  42465. /** @hidden */
  42466. _allowPostProcessClearColor: boolean;
  42467. /** @hidden */
  42468. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42469. private _processSubCameras;
  42470. private _checkIntersections;
  42471. /** @hidden */
  42472. _advancePhysicsEngineStep(step: number): void;
  42473. /**
  42474. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42475. */
  42476. getDeterministicFrameTime: () => number;
  42477. /** @hidden */
  42478. _animate(): void;
  42479. /** Execute all animations (for a frame) */
  42480. animate(): void;
  42481. /**
  42482. * Render the scene
  42483. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42484. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42485. */
  42486. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42487. /**
  42488. * Freeze all materials
  42489. * A frozen material will not be updatable but should be faster to render
  42490. */
  42491. freezeMaterials(): void;
  42492. /**
  42493. * Unfreeze all materials
  42494. * A frozen material will not be updatable but should be faster to render
  42495. */
  42496. unfreezeMaterials(): void;
  42497. /**
  42498. * Releases all held ressources
  42499. */
  42500. dispose(): void;
  42501. /**
  42502. * Gets if the scene is already disposed
  42503. */
  42504. get isDisposed(): boolean;
  42505. /**
  42506. * Call this function to reduce memory footprint of the scene.
  42507. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42508. */
  42509. clearCachedVertexData(): void;
  42510. /**
  42511. * This function will remove the local cached buffer data from texture.
  42512. * It will save memory but will prevent the texture from being rebuilt
  42513. */
  42514. cleanCachedTextureBuffer(): void;
  42515. /**
  42516. * Get the world extend vectors with an optional filter
  42517. *
  42518. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42519. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42520. */
  42521. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42522. min: Vector3;
  42523. max: Vector3;
  42524. };
  42525. /**
  42526. * Creates a ray that can be used to pick in the scene
  42527. * @param x defines the x coordinate of the origin (on-screen)
  42528. * @param y defines the y coordinate of the origin (on-screen)
  42529. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42530. * @param camera defines the camera to use for the picking
  42531. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42532. * @returns a Ray
  42533. */
  42534. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42535. /**
  42536. * Creates a ray that can be used to pick in the scene
  42537. * @param x defines the x coordinate of the origin (on-screen)
  42538. * @param y defines the y coordinate of the origin (on-screen)
  42539. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42540. * @param result defines the ray where to store the picking ray
  42541. * @param camera defines the camera to use for the picking
  42542. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42543. * @returns the current scene
  42544. */
  42545. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42546. /**
  42547. * Creates a ray that can be used to pick in the scene
  42548. * @param x defines the x coordinate of the origin (on-screen)
  42549. * @param y defines the y coordinate of the origin (on-screen)
  42550. * @param camera defines the camera to use for the picking
  42551. * @returns a Ray
  42552. */
  42553. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42554. /**
  42555. * Creates a ray that can be used to pick in the scene
  42556. * @param x defines the x coordinate of the origin (on-screen)
  42557. * @param y defines the y coordinate of the origin (on-screen)
  42558. * @param result defines the ray where to store the picking ray
  42559. * @param camera defines the camera to use for the picking
  42560. * @returns the current scene
  42561. */
  42562. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42563. /** Launch a ray to try to pick a mesh in the scene
  42564. * @param x position on screen
  42565. * @param y position on screen
  42566. * @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
  42567. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42568. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42569. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42570. * @returns a PickingInfo
  42571. */
  42572. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42573. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42574. * @param x position on screen
  42575. * @param y position on screen
  42576. * @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
  42577. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42578. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42579. * @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)
  42580. */
  42581. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42582. /** Use the given ray to pick a mesh in the scene
  42583. * @param ray The ray to use to pick meshes
  42584. * @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
  42585. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42587. * @returns a PickingInfo
  42588. */
  42589. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42590. /**
  42591. * Launch a ray to try to pick a mesh in the scene
  42592. * @param x X position on screen
  42593. * @param y Y position on screen
  42594. * @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
  42595. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42596. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42597. * @returns an array of PickingInfo
  42598. */
  42599. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42600. /**
  42601. * Launch a ray to try to pick a mesh in the scene
  42602. * @param ray Ray to use
  42603. * @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
  42604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42605. * @returns an array of PickingInfo
  42606. */
  42607. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42608. /**
  42609. * Force the value of meshUnderPointer
  42610. * @param mesh defines the mesh to use
  42611. * @param pointerId optional pointer id when using more than one pointer
  42612. */
  42613. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42614. /**
  42615. * Gets the mesh under the pointer
  42616. * @returns a Mesh or null if no mesh is under the pointer
  42617. */
  42618. getPointerOverMesh(): Nullable<AbstractMesh>;
  42619. /** @hidden */
  42620. _rebuildGeometries(): void;
  42621. /** @hidden */
  42622. _rebuildTextures(): void;
  42623. private _getByTags;
  42624. /**
  42625. * Get a list of meshes by tags
  42626. * @param tagsQuery defines the tags query to use
  42627. * @param forEach defines a predicate used to filter results
  42628. * @returns an array of Mesh
  42629. */
  42630. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42631. /**
  42632. * Get a list of cameras by tags
  42633. * @param tagsQuery defines the tags query to use
  42634. * @param forEach defines a predicate used to filter results
  42635. * @returns an array of Camera
  42636. */
  42637. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42638. /**
  42639. * Get a list of lights by tags
  42640. * @param tagsQuery defines the tags query to use
  42641. * @param forEach defines a predicate used to filter results
  42642. * @returns an array of Light
  42643. */
  42644. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42645. /**
  42646. * Get a list of materials by tags
  42647. * @param tagsQuery defines the tags query to use
  42648. * @param forEach defines a predicate used to filter results
  42649. * @returns an array of Material
  42650. */
  42651. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42652. /**
  42653. * Get a list of transform nodes by tags
  42654. * @param tagsQuery defines the tags query to use
  42655. * @param forEach defines a predicate used to filter results
  42656. * @returns an array of TransformNode
  42657. */
  42658. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42659. /**
  42660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42661. * This allowed control for front to back rendering or reversly depending of the special needs.
  42662. *
  42663. * @param renderingGroupId The rendering group id corresponding to its index
  42664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42667. */
  42668. 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;
  42669. /**
  42670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42671. *
  42672. * @param renderingGroupId The rendering group id corresponding to its index
  42673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42674. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42675. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42676. */
  42677. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42678. /**
  42679. * Gets the current auto clear configuration for one rendering group of the rendering
  42680. * manager.
  42681. * @param index the rendering group index to get the information for
  42682. * @returns The auto clear setup for the requested rendering group
  42683. */
  42684. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42685. private _blockMaterialDirtyMechanism;
  42686. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42687. get blockMaterialDirtyMechanism(): boolean;
  42688. set blockMaterialDirtyMechanism(value: boolean);
  42689. /**
  42690. * Will flag all materials as dirty to trigger new shader compilation
  42691. * @param flag defines the flag used to specify which material part must be marked as dirty
  42692. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42693. */
  42694. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42695. /** @hidden */
  42696. _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;
  42697. /** @hidden */
  42698. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42699. /** @hidden */
  42700. _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;
  42701. /** @hidden */
  42702. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42703. /** @hidden */
  42704. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42705. /** @hidden */
  42706. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42707. }
  42708. }
  42709. declare module "babylonjs/assetContainer" {
  42710. import { AbstractScene } from "babylonjs/abstractScene";
  42711. import { Scene } from "babylonjs/scene";
  42712. import { Mesh } from "babylonjs/Meshes/mesh";
  42713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42714. import { Skeleton } from "babylonjs/Bones/skeleton";
  42715. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42716. import { Animatable } from "babylonjs/Animations/animatable";
  42717. import { Nullable } from "babylonjs/types";
  42718. import { Node } from "babylonjs/node";
  42719. /**
  42720. * Set of assets to keep when moving a scene into an asset container.
  42721. */
  42722. export class KeepAssets extends AbstractScene {
  42723. }
  42724. /**
  42725. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42726. */
  42727. export class InstantiatedEntries {
  42728. /**
  42729. * List of new root nodes (eg. nodes with no parent)
  42730. */
  42731. rootNodes: TransformNode[];
  42732. /**
  42733. * List of new skeletons
  42734. */
  42735. skeletons: Skeleton[];
  42736. /**
  42737. * List of new animation groups
  42738. */
  42739. animationGroups: AnimationGroup[];
  42740. }
  42741. /**
  42742. * Container with a set of assets that can be added or removed from a scene.
  42743. */
  42744. export class AssetContainer extends AbstractScene {
  42745. private _wasAddedToScene;
  42746. /**
  42747. * The scene the AssetContainer belongs to.
  42748. */
  42749. scene: Scene;
  42750. /**
  42751. * Instantiates an AssetContainer.
  42752. * @param scene The scene the AssetContainer belongs to.
  42753. */
  42754. constructor(scene: Scene);
  42755. /**
  42756. * Instantiate or clone all meshes and add the new ones to the scene.
  42757. * Skeletons and animation groups will all be cloned
  42758. * @param nameFunction defines an optional function used to get new names for clones
  42759. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42760. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42761. */
  42762. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42763. /**
  42764. * Adds all the assets from the container to the scene.
  42765. */
  42766. addAllToScene(): void;
  42767. /**
  42768. * Removes all the assets in the container from the scene
  42769. */
  42770. removeAllFromScene(): void;
  42771. /**
  42772. * Disposes all the assets in the container
  42773. */
  42774. dispose(): void;
  42775. private _moveAssets;
  42776. /**
  42777. * Removes all the assets contained in the scene and adds them to the container.
  42778. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42779. */
  42780. moveAllFromScene(keepAssets?: KeepAssets): void;
  42781. /**
  42782. * 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.
  42783. * @returns the root mesh
  42784. */
  42785. createRootMesh(): Mesh;
  42786. /**
  42787. * Merge animations (direct and animation groups) from this asset container into a scene
  42788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42789. * @param animatables set of animatables to retarget to a node from the scene
  42790. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42791. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42792. */
  42793. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42794. }
  42795. }
  42796. declare module "babylonjs/abstractScene" {
  42797. import { Scene } from "babylonjs/scene";
  42798. import { Nullable } from "babylonjs/types";
  42799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42801. import { Geometry } from "babylonjs/Meshes/geometry";
  42802. import { Skeleton } from "babylonjs/Bones/skeleton";
  42803. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42804. import { AssetContainer } from "babylonjs/assetContainer";
  42805. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42806. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42808. import { Material } from "babylonjs/Materials/material";
  42809. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42810. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42811. import { Camera } from "babylonjs/Cameras/camera";
  42812. import { Light } from "babylonjs/Lights/light";
  42813. import { Node } from "babylonjs/node";
  42814. import { Animation } from "babylonjs/Animations/animation";
  42815. /**
  42816. * Defines how the parser contract is defined.
  42817. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42818. */
  42819. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42820. /**
  42821. * Defines how the individual parser contract is defined.
  42822. * These parser can parse an individual asset
  42823. */
  42824. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42825. /**
  42826. * Base class of the scene acting as a container for the different elements composing a scene.
  42827. * This class is dynamically extended by the different components of the scene increasing
  42828. * flexibility and reducing coupling
  42829. */
  42830. export abstract class AbstractScene {
  42831. /**
  42832. * Stores the list of available parsers in the application.
  42833. */
  42834. private static _BabylonFileParsers;
  42835. /**
  42836. * Stores the list of available individual parsers in the application.
  42837. */
  42838. private static _IndividualBabylonFileParsers;
  42839. /**
  42840. * Adds a parser in the list of available ones
  42841. * @param name Defines the name of the parser
  42842. * @param parser Defines the parser to add
  42843. */
  42844. static AddParser(name: string, parser: BabylonFileParser): void;
  42845. /**
  42846. * Gets a general parser from the list of avaialble ones
  42847. * @param name Defines the name of the parser
  42848. * @returns the requested parser or null
  42849. */
  42850. static GetParser(name: string): Nullable<BabylonFileParser>;
  42851. /**
  42852. * Adds n individual parser in the list of available ones
  42853. * @param name Defines the name of the parser
  42854. * @param parser Defines the parser to add
  42855. */
  42856. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42857. /**
  42858. * Gets an individual parser from the list of avaialble ones
  42859. * @param name Defines the name of the parser
  42860. * @returns the requested parser or null
  42861. */
  42862. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42863. /**
  42864. * Parser json data and populate both a scene and its associated container object
  42865. * @param jsonData Defines the data to parse
  42866. * @param scene Defines the scene to parse the data for
  42867. * @param container Defines the container attached to the parsing sequence
  42868. * @param rootUrl Defines the root url of the data
  42869. */
  42870. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42871. /**
  42872. * Gets the list of root nodes (ie. nodes with no parent)
  42873. */
  42874. rootNodes: Node[];
  42875. /** All of the cameras added to this scene
  42876. * @see https://doc.babylonjs.com/babylon101/cameras
  42877. */
  42878. cameras: Camera[];
  42879. /**
  42880. * All of the lights added to this scene
  42881. * @see https://doc.babylonjs.com/babylon101/lights
  42882. */
  42883. lights: Light[];
  42884. /**
  42885. * All of the (abstract) meshes added to this scene
  42886. */
  42887. meshes: AbstractMesh[];
  42888. /**
  42889. * The list of skeletons added to the scene
  42890. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42891. */
  42892. skeletons: Skeleton[];
  42893. /**
  42894. * All of the particle systems added to this scene
  42895. * @see https://doc.babylonjs.com/babylon101/particles
  42896. */
  42897. particleSystems: IParticleSystem[];
  42898. /**
  42899. * Gets a list of Animations associated with the scene
  42900. */
  42901. animations: Animation[];
  42902. /**
  42903. * All of the animation groups added to this scene
  42904. * @see https://doc.babylonjs.com/how_to/group
  42905. */
  42906. animationGroups: AnimationGroup[];
  42907. /**
  42908. * All of the multi-materials added to this scene
  42909. * @see https://doc.babylonjs.com/how_to/multi_materials
  42910. */
  42911. multiMaterials: MultiMaterial[];
  42912. /**
  42913. * All of the materials added to this scene
  42914. * In the context of a Scene, it is not supposed to be modified manually.
  42915. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42916. * Note also that the order of the Material within the array is not significant and might change.
  42917. * @see https://doc.babylonjs.com/babylon101/materials
  42918. */
  42919. materials: Material[];
  42920. /**
  42921. * The list of morph target managers added to the scene
  42922. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42923. */
  42924. morphTargetManagers: MorphTargetManager[];
  42925. /**
  42926. * The list of geometries used in the scene.
  42927. */
  42928. geometries: Geometry[];
  42929. /**
  42930. * All of the tranform nodes added to this scene
  42931. * In the context of a Scene, it is not supposed to be modified manually.
  42932. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42933. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42934. * @see https://doc.babylonjs.com/how_to/transformnode
  42935. */
  42936. transformNodes: TransformNode[];
  42937. /**
  42938. * ActionManagers available on the scene.
  42939. */
  42940. actionManagers: AbstractActionManager[];
  42941. /**
  42942. * Textures to keep.
  42943. */
  42944. textures: BaseTexture[];
  42945. /** @hidden */
  42946. protected _environmentTexture: Nullable<BaseTexture>;
  42947. /**
  42948. * Texture used in all pbr material as the reflection texture.
  42949. * As in the majority of the scene they are the same (exception for multi room and so on),
  42950. * this is easier to reference from here than from all the materials.
  42951. */
  42952. get environmentTexture(): Nullable<BaseTexture>;
  42953. set environmentTexture(value: Nullable<BaseTexture>);
  42954. /**
  42955. * The list of postprocesses added to the scene
  42956. */
  42957. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42958. /**
  42959. * @returns all meshes, lights, cameras, transformNodes and bones
  42960. */
  42961. getNodes(): Array<Node>;
  42962. }
  42963. }
  42964. declare module "babylonjs/Audio/sound" {
  42965. import { Observable } from "babylonjs/Misc/observable";
  42966. import { Vector3 } from "babylonjs/Maths/math.vector";
  42967. import { Nullable } from "babylonjs/types";
  42968. import { Scene } from "babylonjs/scene";
  42969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42970. /**
  42971. * Interface used to define options for Sound class
  42972. */
  42973. export interface ISoundOptions {
  42974. /**
  42975. * Does the sound autoplay once loaded.
  42976. */
  42977. autoplay?: boolean;
  42978. /**
  42979. * Does the sound loop after it finishes playing once.
  42980. */
  42981. loop?: boolean;
  42982. /**
  42983. * Sound's volume
  42984. */
  42985. volume?: number;
  42986. /**
  42987. * Is it a spatial sound?
  42988. */
  42989. spatialSound?: boolean;
  42990. /**
  42991. * Maximum distance to hear that sound
  42992. */
  42993. maxDistance?: number;
  42994. /**
  42995. * Uses user defined attenuation function
  42996. */
  42997. useCustomAttenuation?: boolean;
  42998. /**
  42999. * Define the roll off factor of spatial sounds.
  43000. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43001. */
  43002. rolloffFactor?: number;
  43003. /**
  43004. * Define the reference distance the sound should be heard perfectly.
  43005. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43006. */
  43007. refDistance?: number;
  43008. /**
  43009. * Define the distance attenuation model the sound will follow.
  43010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43011. */
  43012. distanceModel?: string;
  43013. /**
  43014. * Defines the playback speed (1 by default)
  43015. */
  43016. playbackRate?: number;
  43017. /**
  43018. * Defines if the sound is from a streaming source
  43019. */
  43020. streaming?: boolean;
  43021. /**
  43022. * Defines an optional length (in seconds) inside the sound file
  43023. */
  43024. length?: number;
  43025. /**
  43026. * Defines an optional offset (in seconds) inside the sound file
  43027. */
  43028. offset?: number;
  43029. /**
  43030. * If true, URLs will not be required to state the audio file codec to use.
  43031. */
  43032. skipCodecCheck?: boolean;
  43033. }
  43034. /**
  43035. * Defines a sound that can be played in the application.
  43036. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43038. */
  43039. export class Sound {
  43040. /**
  43041. * The name of the sound in the scene.
  43042. */
  43043. name: string;
  43044. /**
  43045. * Does the sound autoplay once loaded.
  43046. */
  43047. autoplay: boolean;
  43048. /**
  43049. * Does the sound loop after it finishes playing once.
  43050. */
  43051. loop: boolean;
  43052. /**
  43053. * Does the sound use a custom attenuation curve to simulate the falloff
  43054. * happening when the source gets further away from the camera.
  43055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43056. */
  43057. useCustomAttenuation: boolean;
  43058. /**
  43059. * The sound track id this sound belongs to.
  43060. */
  43061. soundTrackId: number;
  43062. /**
  43063. * Is this sound currently played.
  43064. */
  43065. isPlaying: boolean;
  43066. /**
  43067. * Is this sound currently paused.
  43068. */
  43069. isPaused: boolean;
  43070. /**
  43071. * Does this sound enables spatial sound.
  43072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43073. */
  43074. spatialSound: boolean;
  43075. /**
  43076. * Define the reference distance the sound should be heard perfectly.
  43077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43078. */
  43079. refDistance: number;
  43080. /**
  43081. * Define the roll off factor of spatial sounds.
  43082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43083. */
  43084. rolloffFactor: number;
  43085. /**
  43086. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43088. */
  43089. maxDistance: number;
  43090. /**
  43091. * Define the distance attenuation model the sound will follow.
  43092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43093. */
  43094. distanceModel: string;
  43095. /**
  43096. * @hidden
  43097. * Back Compat
  43098. **/
  43099. onended: () => any;
  43100. /**
  43101. * Gets or sets an object used to store user defined information for the sound.
  43102. */
  43103. metadata: any;
  43104. /**
  43105. * Observable event when the current playing sound finishes.
  43106. */
  43107. onEndedObservable: Observable<Sound>;
  43108. private _panningModel;
  43109. private _playbackRate;
  43110. private _streaming;
  43111. private _startTime;
  43112. private _startOffset;
  43113. private _position;
  43114. /** @hidden */
  43115. _positionInEmitterSpace: boolean;
  43116. private _localDirection;
  43117. private _volume;
  43118. private _isReadyToPlay;
  43119. private _isDirectional;
  43120. private _readyToPlayCallback;
  43121. private _audioBuffer;
  43122. private _soundSource;
  43123. private _streamingSource;
  43124. private _soundPanner;
  43125. private _soundGain;
  43126. private _inputAudioNode;
  43127. private _outputAudioNode;
  43128. private _coneInnerAngle;
  43129. private _coneOuterAngle;
  43130. private _coneOuterGain;
  43131. private _scene;
  43132. private _connectedTransformNode;
  43133. private _customAttenuationFunction;
  43134. private _registerFunc;
  43135. private _isOutputConnected;
  43136. private _htmlAudioElement;
  43137. private _urlType;
  43138. private _length?;
  43139. private _offset?;
  43140. /** @hidden */
  43141. static _SceneComponentInitialization: (scene: Scene) => void;
  43142. /**
  43143. * Create a sound and attach it to a scene
  43144. * @param name Name of your sound
  43145. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43146. * @param scene defines the scene the sound belongs to
  43147. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43148. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43149. */
  43150. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43151. /**
  43152. * Release the sound and its associated resources
  43153. */
  43154. dispose(): void;
  43155. /**
  43156. * Gets if the sounds is ready to be played or not.
  43157. * @returns true if ready, otherwise false
  43158. */
  43159. isReady(): boolean;
  43160. private _soundLoaded;
  43161. /**
  43162. * Sets the data of the sound from an audiobuffer
  43163. * @param audioBuffer The audioBuffer containing the data
  43164. */
  43165. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43166. /**
  43167. * Updates the current sounds options such as maxdistance, loop...
  43168. * @param options A JSON object containing values named as the object properties
  43169. */
  43170. updateOptions(options: ISoundOptions): void;
  43171. private _createSpatialParameters;
  43172. private _updateSpatialParameters;
  43173. /**
  43174. * Switch the panning model to HRTF:
  43175. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43176. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43177. */
  43178. switchPanningModelToHRTF(): void;
  43179. /**
  43180. * Switch the panning model to Equal Power:
  43181. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43183. */
  43184. switchPanningModelToEqualPower(): void;
  43185. private _switchPanningModel;
  43186. /**
  43187. * Connect this sound to a sound track audio node like gain...
  43188. * @param soundTrackAudioNode the sound track audio node to connect to
  43189. */
  43190. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43191. /**
  43192. * Transform this sound into a directional source
  43193. * @param coneInnerAngle Size of the inner cone in degree
  43194. * @param coneOuterAngle Size of the outer cone in degree
  43195. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43196. */
  43197. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43198. /**
  43199. * Gets or sets the inner angle for the directional cone.
  43200. */
  43201. get directionalConeInnerAngle(): number;
  43202. /**
  43203. * Gets or sets the inner angle for the directional cone.
  43204. */
  43205. set directionalConeInnerAngle(value: number);
  43206. /**
  43207. * Gets or sets the outer angle for the directional cone.
  43208. */
  43209. get directionalConeOuterAngle(): number;
  43210. /**
  43211. * Gets or sets the outer angle for the directional cone.
  43212. */
  43213. set directionalConeOuterAngle(value: number);
  43214. /**
  43215. * Sets the position of the emitter if spatial sound is enabled
  43216. * @param newPosition Defines the new posisiton
  43217. */
  43218. setPosition(newPosition: Vector3): void;
  43219. /**
  43220. * Sets the local direction of the emitter if spatial sound is enabled
  43221. * @param newLocalDirection Defines the new local direction
  43222. */
  43223. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43224. private _updateDirection;
  43225. /** @hidden */
  43226. updateDistanceFromListener(): void;
  43227. /**
  43228. * Sets a new custom attenuation function for the sound.
  43229. * @param callback Defines the function used for the attenuation
  43230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43231. */
  43232. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43233. /**
  43234. * Play the sound
  43235. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43236. * @param offset (optional) Start the sound at a specific time in seconds
  43237. * @param length (optional) Sound duration (in seconds)
  43238. */
  43239. play(time?: number, offset?: number, length?: number): void;
  43240. private _onended;
  43241. /**
  43242. * Stop the sound
  43243. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43244. */
  43245. stop(time?: number): void;
  43246. /**
  43247. * Put the sound in pause
  43248. */
  43249. pause(): void;
  43250. /**
  43251. * Sets a dedicated volume for this sounds
  43252. * @param newVolume Define the new volume of the sound
  43253. * @param time Define time for gradual change to new volume
  43254. */
  43255. setVolume(newVolume: number, time?: number): void;
  43256. /**
  43257. * Set the sound play back rate
  43258. * @param newPlaybackRate Define the playback rate the sound should be played at
  43259. */
  43260. setPlaybackRate(newPlaybackRate: number): void;
  43261. /**
  43262. * Gets the volume of the sound.
  43263. * @returns the volume of the sound
  43264. */
  43265. getVolume(): number;
  43266. /**
  43267. * Attach the sound to a dedicated mesh
  43268. * @param transformNode The transform node to connect the sound with
  43269. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43270. */
  43271. attachToMesh(transformNode: TransformNode): void;
  43272. /**
  43273. * Detach the sound from the previously attached mesh
  43274. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43275. */
  43276. detachFromMesh(): void;
  43277. private _onRegisterAfterWorldMatrixUpdate;
  43278. /**
  43279. * Clone the current sound in the scene.
  43280. * @returns the new sound clone
  43281. */
  43282. clone(): Nullable<Sound>;
  43283. /**
  43284. * Gets the current underlying audio buffer containing the data
  43285. * @returns the audio buffer
  43286. */
  43287. getAudioBuffer(): Nullable<AudioBuffer>;
  43288. /**
  43289. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43290. * @returns the source node
  43291. */
  43292. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43293. /**
  43294. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43295. * @returns the gain node
  43296. */
  43297. getSoundGain(): Nullable<GainNode>;
  43298. /**
  43299. * Serializes the Sound in a JSON representation
  43300. * @returns the JSON representation of the sound
  43301. */
  43302. serialize(): any;
  43303. /**
  43304. * Parse a JSON representation of a sound to innstantiate in a given scene
  43305. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43306. * @param scene Define the scene the new parsed sound should be created in
  43307. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43308. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43309. * @returns the newly parsed sound
  43310. */
  43311. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43312. }
  43313. }
  43314. declare module "babylonjs/Actions/directAudioActions" {
  43315. import { Action } from "babylonjs/Actions/action";
  43316. import { Condition } from "babylonjs/Actions/condition";
  43317. import { Sound } from "babylonjs/Audio/sound";
  43318. /**
  43319. * This defines an action helpful to play a defined sound on a triggered action.
  43320. */
  43321. export class PlaySoundAction extends Action {
  43322. private _sound;
  43323. /**
  43324. * Instantiate the action
  43325. * @param triggerOptions defines the trigger options
  43326. * @param sound defines the sound to play
  43327. * @param condition defines the trigger related conditions
  43328. */
  43329. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43330. /** @hidden */
  43331. _prepare(): void;
  43332. /**
  43333. * Execute the action and play the sound.
  43334. */
  43335. execute(): void;
  43336. /**
  43337. * Serializes the actions and its related information.
  43338. * @param parent defines the object to serialize in
  43339. * @returns the serialized object
  43340. */
  43341. serialize(parent: any): any;
  43342. }
  43343. /**
  43344. * This defines an action helpful to stop a defined sound on a triggered action.
  43345. */
  43346. export class StopSoundAction extends Action {
  43347. private _sound;
  43348. /**
  43349. * Instantiate the action
  43350. * @param triggerOptions defines the trigger options
  43351. * @param sound defines the sound to stop
  43352. * @param condition defines the trigger related conditions
  43353. */
  43354. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43355. /** @hidden */
  43356. _prepare(): void;
  43357. /**
  43358. * Execute the action and stop the sound.
  43359. */
  43360. execute(): void;
  43361. /**
  43362. * Serializes the actions and its related information.
  43363. * @param parent defines the object to serialize in
  43364. * @returns the serialized object
  43365. */
  43366. serialize(parent: any): any;
  43367. }
  43368. }
  43369. declare module "babylonjs/Actions/interpolateValueAction" {
  43370. import { Action } from "babylonjs/Actions/action";
  43371. import { Condition } from "babylonjs/Actions/condition";
  43372. import { Observable } from "babylonjs/Misc/observable";
  43373. /**
  43374. * This defines an action responsible to change the value of a property
  43375. * by interpolating between its current value and the newly set one once triggered.
  43376. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43377. */
  43378. export class InterpolateValueAction extends Action {
  43379. /**
  43380. * Defines the path of the property where the value should be interpolated
  43381. */
  43382. propertyPath: string;
  43383. /**
  43384. * Defines the target value at the end of the interpolation.
  43385. */
  43386. value: any;
  43387. /**
  43388. * Defines the time it will take for the property to interpolate to the value.
  43389. */
  43390. duration: number;
  43391. /**
  43392. * Defines if the other scene animations should be stopped when the action has been triggered
  43393. */
  43394. stopOtherAnimations?: boolean;
  43395. /**
  43396. * Defines a callback raised once the interpolation animation has been done.
  43397. */
  43398. onInterpolationDone?: () => void;
  43399. /**
  43400. * Observable triggered once the interpolation animation has been done.
  43401. */
  43402. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43403. private _target;
  43404. private _effectiveTarget;
  43405. private _property;
  43406. /**
  43407. * Instantiate the action
  43408. * @param triggerOptions defines the trigger options
  43409. * @param target defines the object containing the value to interpolate
  43410. * @param propertyPath defines the path to the property in the target object
  43411. * @param value defines the target value at the end of the interpolation
  43412. * @param duration deines the time it will take for the property to interpolate to the value.
  43413. * @param condition defines the trigger related conditions
  43414. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43415. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43416. */
  43417. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43418. /** @hidden */
  43419. _prepare(): void;
  43420. /**
  43421. * Execute the action starts the value interpolation.
  43422. */
  43423. execute(): void;
  43424. /**
  43425. * Serializes the actions and its related information.
  43426. * @param parent defines the object to serialize in
  43427. * @returns the serialized object
  43428. */
  43429. serialize(parent: any): any;
  43430. }
  43431. }
  43432. declare module "babylonjs/Actions/index" {
  43433. export * from "babylonjs/Actions/abstractActionManager";
  43434. export * from "babylonjs/Actions/action";
  43435. export * from "babylonjs/Actions/actionEvent";
  43436. export * from "babylonjs/Actions/actionManager";
  43437. export * from "babylonjs/Actions/condition";
  43438. export * from "babylonjs/Actions/directActions";
  43439. export * from "babylonjs/Actions/directAudioActions";
  43440. export * from "babylonjs/Actions/interpolateValueAction";
  43441. }
  43442. declare module "babylonjs/Animations/index" {
  43443. export * from "babylonjs/Animations/animatable";
  43444. export * from "babylonjs/Animations/animation";
  43445. export * from "babylonjs/Animations/animationGroup";
  43446. export * from "babylonjs/Animations/animationPropertiesOverride";
  43447. export * from "babylonjs/Animations/easing";
  43448. export * from "babylonjs/Animations/runtimeAnimation";
  43449. export * from "babylonjs/Animations/animationEvent";
  43450. export * from "babylonjs/Animations/animationGroup";
  43451. export * from "babylonjs/Animations/animationKey";
  43452. export * from "babylonjs/Animations/animationRange";
  43453. export * from "babylonjs/Animations/animatable.interface";
  43454. }
  43455. declare module "babylonjs/Audio/soundTrack" {
  43456. import { Sound } from "babylonjs/Audio/sound";
  43457. import { Analyser } from "babylonjs/Audio/analyser";
  43458. import { Scene } from "babylonjs/scene";
  43459. /**
  43460. * Options allowed during the creation of a sound track.
  43461. */
  43462. export interface ISoundTrackOptions {
  43463. /**
  43464. * The volume the sound track should take during creation
  43465. */
  43466. volume?: number;
  43467. /**
  43468. * Define if the sound track is the main sound track of the scene
  43469. */
  43470. mainTrack?: boolean;
  43471. }
  43472. /**
  43473. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43474. * It will be also used in a future release to apply effects on a specific track.
  43475. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43476. */
  43477. export class SoundTrack {
  43478. /**
  43479. * The unique identifier of the sound track in the scene.
  43480. */
  43481. id: number;
  43482. /**
  43483. * The list of sounds included in the sound track.
  43484. */
  43485. soundCollection: Array<Sound>;
  43486. private _outputAudioNode;
  43487. private _scene;
  43488. private _connectedAnalyser;
  43489. private _options;
  43490. private _isInitialized;
  43491. /**
  43492. * Creates a new sound track.
  43493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43494. * @param scene Define the scene the sound track belongs to
  43495. * @param options
  43496. */
  43497. constructor(scene: Scene, options?: ISoundTrackOptions);
  43498. private _initializeSoundTrackAudioGraph;
  43499. /**
  43500. * Release the sound track and its associated resources
  43501. */
  43502. dispose(): void;
  43503. /**
  43504. * Adds a sound to this sound track
  43505. * @param sound define the cound to add
  43506. * @ignoreNaming
  43507. */
  43508. AddSound(sound: Sound): void;
  43509. /**
  43510. * Removes a sound to this sound track
  43511. * @param sound define the cound to remove
  43512. * @ignoreNaming
  43513. */
  43514. RemoveSound(sound: Sound): void;
  43515. /**
  43516. * Set a global volume for the full sound track.
  43517. * @param newVolume Define the new volume of the sound track
  43518. */
  43519. setVolume(newVolume: number): void;
  43520. /**
  43521. * Switch the panning model to HRTF:
  43522. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43523. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43524. */
  43525. switchPanningModelToHRTF(): void;
  43526. /**
  43527. * Switch the panning model to Equal Power:
  43528. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43530. */
  43531. switchPanningModelToEqualPower(): void;
  43532. /**
  43533. * Connect the sound track to an audio analyser allowing some amazing
  43534. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43536. * @param analyser The analyser to connect to the engine
  43537. */
  43538. connectToAnalyser(analyser: Analyser): void;
  43539. }
  43540. }
  43541. declare module "babylonjs/Audio/audioSceneComponent" {
  43542. import { Sound } from "babylonjs/Audio/sound";
  43543. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43544. import { Nullable } from "babylonjs/types";
  43545. import { Vector3 } from "babylonjs/Maths/math.vector";
  43546. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43547. import { Scene } from "babylonjs/scene";
  43548. import { AbstractScene } from "babylonjs/abstractScene";
  43549. import "babylonjs/Audio/audioEngine";
  43550. module "babylonjs/abstractScene" {
  43551. interface AbstractScene {
  43552. /**
  43553. * The list of sounds used in the scene.
  43554. */
  43555. sounds: Nullable<Array<Sound>>;
  43556. }
  43557. }
  43558. module "babylonjs/scene" {
  43559. interface Scene {
  43560. /**
  43561. * @hidden
  43562. * Backing field
  43563. */
  43564. _mainSoundTrack: SoundTrack;
  43565. /**
  43566. * The main sound track played by the scene.
  43567. * It cotains your primary collection of sounds.
  43568. */
  43569. mainSoundTrack: SoundTrack;
  43570. /**
  43571. * The list of sound tracks added to the scene
  43572. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43573. */
  43574. soundTracks: Nullable<Array<SoundTrack>>;
  43575. /**
  43576. * Gets a sound using a given name
  43577. * @param name defines the name to search for
  43578. * @return the found sound or null if not found at all.
  43579. */
  43580. getSoundByName(name: string): Nullable<Sound>;
  43581. /**
  43582. * Gets or sets if audio support is enabled
  43583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43584. */
  43585. audioEnabled: boolean;
  43586. /**
  43587. * Gets or sets if audio will be output to headphones
  43588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43589. */
  43590. headphone: boolean;
  43591. /**
  43592. * Gets or sets custom audio listener position provider
  43593. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43594. */
  43595. audioListenerPositionProvider: Nullable<() => Vector3>;
  43596. /**
  43597. * Gets or sets a refresh rate when using 3D audio positioning
  43598. */
  43599. audioPositioningRefreshRate: number;
  43600. }
  43601. }
  43602. /**
  43603. * Defines the sound scene component responsible to manage any sounds
  43604. * in a given scene.
  43605. */
  43606. export class AudioSceneComponent implements ISceneSerializableComponent {
  43607. private static _CameraDirectionLH;
  43608. private static _CameraDirectionRH;
  43609. /**
  43610. * The component name helpfull to identify the component in the list of scene components.
  43611. */
  43612. readonly name: string;
  43613. /**
  43614. * The scene the component belongs to.
  43615. */
  43616. scene: Scene;
  43617. private _audioEnabled;
  43618. /**
  43619. * Gets whether audio is enabled or not.
  43620. * Please use related enable/disable method to switch state.
  43621. */
  43622. get audioEnabled(): boolean;
  43623. private _headphone;
  43624. /**
  43625. * Gets whether audio is outputing to headphone or not.
  43626. * Please use the according Switch methods to change output.
  43627. */
  43628. get headphone(): boolean;
  43629. /**
  43630. * Gets or sets a refresh rate when using 3D audio positioning
  43631. */
  43632. audioPositioningRefreshRate: number;
  43633. private _audioListenerPositionProvider;
  43634. /**
  43635. * Gets the current audio listener position provider
  43636. */
  43637. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43638. /**
  43639. * Sets a custom listener position for all sounds in the scene
  43640. * By default, this is the position of the first active camera
  43641. */
  43642. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43643. /**
  43644. * Creates a new instance of the component for the given scene
  43645. * @param scene Defines the scene to register the component in
  43646. */
  43647. constructor(scene: Scene);
  43648. /**
  43649. * Registers the component in a given scene
  43650. */
  43651. register(): void;
  43652. /**
  43653. * Rebuilds the elements related to this component in case of
  43654. * context lost for instance.
  43655. */
  43656. rebuild(): void;
  43657. /**
  43658. * Serializes the component data to the specified json object
  43659. * @param serializationObject The object to serialize to
  43660. */
  43661. serialize(serializationObject: any): void;
  43662. /**
  43663. * Adds all the elements from the container to the scene
  43664. * @param container the container holding the elements
  43665. */
  43666. addFromContainer(container: AbstractScene): void;
  43667. /**
  43668. * Removes all the elements in the container from the scene
  43669. * @param container contains the elements to remove
  43670. * @param dispose if the removed element should be disposed (default: false)
  43671. */
  43672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43673. /**
  43674. * Disposes the component and the associated ressources.
  43675. */
  43676. dispose(): void;
  43677. /**
  43678. * Disables audio in the associated scene.
  43679. */
  43680. disableAudio(): void;
  43681. /**
  43682. * Enables audio in the associated scene.
  43683. */
  43684. enableAudio(): void;
  43685. /**
  43686. * Switch audio to headphone output.
  43687. */
  43688. switchAudioModeForHeadphones(): void;
  43689. /**
  43690. * Switch audio to normal speakers.
  43691. */
  43692. switchAudioModeForNormalSpeakers(): void;
  43693. private _cachedCameraDirection;
  43694. private _cachedCameraPosition;
  43695. private _lastCheck;
  43696. private _afterRender;
  43697. }
  43698. }
  43699. declare module "babylonjs/Audio/weightedsound" {
  43700. import { Sound } from "babylonjs/Audio/sound";
  43701. /**
  43702. * Wraps one or more Sound objects and selects one with random weight for playback.
  43703. */
  43704. export class WeightedSound {
  43705. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43706. loop: boolean;
  43707. private _coneInnerAngle;
  43708. private _coneOuterAngle;
  43709. private _volume;
  43710. /** A Sound is currently playing. */
  43711. isPlaying: boolean;
  43712. /** A Sound is currently paused. */
  43713. isPaused: boolean;
  43714. private _sounds;
  43715. private _weights;
  43716. private _currentIndex?;
  43717. /**
  43718. * Creates a new WeightedSound from the list of sounds given.
  43719. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43720. * @param sounds Array of Sounds that will be selected from.
  43721. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43722. */
  43723. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43724. /**
  43725. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43726. */
  43727. get directionalConeInnerAngle(): number;
  43728. /**
  43729. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43730. */
  43731. set directionalConeInnerAngle(value: number);
  43732. /**
  43733. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43734. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43735. */
  43736. get directionalConeOuterAngle(): number;
  43737. /**
  43738. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43739. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43740. */
  43741. set directionalConeOuterAngle(value: number);
  43742. /**
  43743. * Playback volume.
  43744. */
  43745. get volume(): number;
  43746. /**
  43747. * Playback volume.
  43748. */
  43749. set volume(value: number);
  43750. private _onended;
  43751. /**
  43752. * Suspend playback
  43753. */
  43754. pause(): void;
  43755. /**
  43756. * Stop playback
  43757. */
  43758. stop(): void;
  43759. /**
  43760. * Start playback.
  43761. * @param startOffset Position the clip head at a specific time in seconds.
  43762. */
  43763. play(startOffset?: number): void;
  43764. }
  43765. }
  43766. declare module "babylonjs/Audio/index" {
  43767. export * from "babylonjs/Audio/analyser";
  43768. export * from "babylonjs/Audio/audioEngine";
  43769. export * from "babylonjs/Audio/audioSceneComponent";
  43770. export * from "babylonjs/Audio/sound";
  43771. export * from "babylonjs/Audio/soundTrack";
  43772. export * from "babylonjs/Audio/weightedsound";
  43773. }
  43774. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43775. import { Behavior } from "babylonjs/Behaviors/behavior";
  43776. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43777. import { BackEase } from "babylonjs/Animations/easing";
  43778. /**
  43779. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43780. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43781. */
  43782. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43783. /**
  43784. * Gets the name of the behavior.
  43785. */
  43786. get name(): string;
  43787. /**
  43788. * The easing function used by animations
  43789. */
  43790. static EasingFunction: BackEase;
  43791. /**
  43792. * The easing mode used by animations
  43793. */
  43794. static EasingMode: number;
  43795. /**
  43796. * The duration of the animation, in milliseconds
  43797. */
  43798. transitionDuration: number;
  43799. /**
  43800. * Length of the distance animated by the transition when lower radius is reached
  43801. */
  43802. lowerRadiusTransitionRange: number;
  43803. /**
  43804. * Length of the distance animated by the transition when upper radius is reached
  43805. */
  43806. upperRadiusTransitionRange: number;
  43807. private _autoTransitionRange;
  43808. /**
  43809. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43810. */
  43811. get autoTransitionRange(): boolean;
  43812. /**
  43813. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43814. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43815. */
  43816. set autoTransitionRange(value: boolean);
  43817. private _attachedCamera;
  43818. private _onAfterCheckInputsObserver;
  43819. private _onMeshTargetChangedObserver;
  43820. /**
  43821. * Initializes the behavior.
  43822. */
  43823. init(): void;
  43824. /**
  43825. * Attaches the behavior to its arc rotate camera.
  43826. * @param camera Defines the camera to attach the behavior to
  43827. */
  43828. attach(camera: ArcRotateCamera): void;
  43829. /**
  43830. * Detaches the behavior from its current arc rotate camera.
  43831. */
  43832. detach(): void;
  43833. private _radiusIsAnimating;
  43834. private _radiusBounceTransition;
  43835. private _animatables;
  43836. private _cachedWheelPrecision;
  43837. /**
  43838. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43839. * @param radiusLimit The limit to check against.
  43840. * @return Bool to indicate if at limit.
  43841. */
  43842. private _isRadiusAtLimit;
  43843. /**
  43844. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43845. * @param radiusDelta The delta by which to animate to. Can be negative.
  43846. */
  43847. private _applyBoundRadiusAnimation;
  43848. /**
  43849. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43850. */
  43851. protected _clearAnimationLocks(): void;
  43852. /**
  43853. * Stops and removes all animations that have been applied to the camera
  43854. */
  43855. stopAllAnimations(): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43859. import { Behavior } from "babylonjs/Behaviors/behavior";
  43860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43861. import { ExponentialEase } from "babylonjs/Animations/easing";
  43862. import { Nullable } from "babylonjs/types";
  43863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43864. import { Vector3 } from "babylonjs/Maths/math.vector";
  43865. /**
  43866. * 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.
  43867. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43868. */
  43869. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43870. /**
  43871. * Gets the name of the behavior.
  43872. */
  43873. get name(): string;
  43874. private _mode;
  43875. private _radiusScale;
  43876. private _positionScale;
  43877. private _defaultElevation;
  43878. private _elevationReturnTime;
  43879. private _elevationReturnWaitTime;
  43880. private _zoomStopsAnimation;
  43881. private _framingTime;
  43882. /**
  43883. * The easing function used by animations
  43884. */
  43885. static EasingFunction: ExponentialEase;
  43886. /**
  43887. * The easing mode used by animations
  43888. */
  43889. static EasingMode: number;
  43890. /**
  43891. * Sets the current mode used by the behavior
  43892. */
  43893. set mode(mode: number);
  43894. /**
  43895. * Gets current mode used by the behavior.
  43896. */
  43897. get mode(): number;
  43898. /**
  43899. * Sets the scale applied to the radius (1 by default)
  43900. */
  43901. set radiusScale(radius: number);
  43902. /**
  43903. * Gets the scale applied to the radius
  43904. */
  43905. get radiusScale(): number;
  43906. /**
  43907. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43908. */
  43909. set positionScale(scale: number);
  43910. /**
  43911. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43912. */
  43913. get positionScale(): number;
  43914. /**
  43915. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43916. * behaviour is triggered, in radians.
  43917. */
  43918. set defaultElevation(elevation: number);
  43919. /**
  43920. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43921. * behaviour is triggered, in radians.
  43922. */
  43923. get defaultElevation(): number;
  43924. /**
  43925. * Sets the time (in milliseconds) taken to return to the default beta position.
  43926. * Negative value indicates camera should not return to default.
  43927. */
  43928. set elevationReturnTime(speed: number);
  43929. /**
  43930. * Gets the time (in milliseconds) taken to return to the default beta position.
  43931. * Negative value indicates camera should not return to default.
  43932. */
  43933. get elevationReturnTime(): number;
  43934. /**
  43935. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43936. */
  43937. set elevationReturnWaitTime(time: number);
  43938. /**
  43939. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43940. */
  43941. get elevationReturnWaitTime(): number;
  43942. /**
  43943. * Sets the flag that indicates if user zooming should stop animation.
  43944. */
  43945. set zoomStopsAnimation(flag: boolean);
  43946. /**
  43947. * Gets the flag that indicates if user zooming should stop animation.
  43948. */
  43949. get zoomStopsAnimation(): boolean;
  43950. /**
  43951. * Sets the transition time when framing the mesh, in milliseconds
  43952. */
  43953. set framingTime(time: number);
  43954. /**
  43955. * Gets the transition time when framing the mesh, in milliseconds
  43956. */
  43957. get framingTime(): number;
  43958. /**
  43959. * Define if the behavior should automatically change the configured
  43960. * camera limits and sensibilities.
  43961. */
  43962. autoCorrectCameraLimitsAndSensibility: boolean;
  43963. private _onPrePointerObservableObserver;
  43964. private _onAfterCheckInputsObserver;
  43965. private _onMeshTargetChangedObserver;
  43966. private _attachedCamera;
  43967. private _isPointerDown;
  43968. private _lastInteractionTime;
  43969. /**
  43970. * Initializes the behavior.
  43971. */
  43972. init(): void;
  43973. /**
  43974. * Attaches the behavior to its arc rotate camera.
  43975. * @param camera Defines the camera to attach the behavior to
  43976. */
  43977. attach(camera: ArcRotateCamera): void;
  43978. /**
  43979. * Detaches the behavior from its current arc rotate camera.
  43980. */
  43981. detach(): void;
  43982. private _animatables;
  43983. private _betaIsAnimating;
  43984. private _betaTransition;
  43985. private _radiusTransition;
  43986. private _vectorTransition;
  43987. /**
  43988. * Targets the given mesh and updates zoom level accordingly.
  43989. * @param mesh The mesh to target.
  43990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43992. */
  43993. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43994. /**
  43995. * Targets the given mesh with its children and updates zoom level accordingly.
  43996. * @param mesh The mesh to target.
  43997. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43998. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43999. */
  44000. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44001. /**
  44002. * Targets the given meshes with their children and updates zoom level accordingly.
  44003. * @param meshes The mesh to target.
  44004. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44005. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44006. */
  44007. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44008. /**
  44009. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44010. * @param minimumWorld Determines the smaller position of the bounding box extend
  44011. * @param maximumWorld Determines the bigger position of the bounding box extend
  44012. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44013. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44014. */
  44015. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44016. /**
  44017. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44018. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44019. * frustum width.
  44020. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44021. * to fully enclose the mesh in the viewing frustum.
  44022. */
  44023. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44024. /**
  44025. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44026. * is automatically returned to its default position (expected to be above ground plane).
  44027. */
  44028. private _maintainCameraAboveGround;
  44029. /**
  44030. * Returns the frustum slope based on the canvas ratio and camera FOV
  44031. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44032. */
  44033. private _getFrustumSlope;
  44034. /**
  44035. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44036. */
  44037. private _clearAnimationLocks;
  44038. /**
  44039. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44040. */
  44041. private _applyUserInteraction;
  44042. /**
  44043. * Stops and removes all animations that have been applied to the camera
  44044. */
  44045. stopAllAnimations(): void;
  44046. /**
  44047. * Gets a value indicating if the user is moving the camera
  44048. */
  44049. get isUserIsMoving(): boolean;
  44050. /**
  44051. * The camera can move all the way towards the mesh.
  44052. */
  44053. static IgnoreBoundsSizeMode: number;
  44054. /**
  44055. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44056. */
  44057. static FitFrustumSidesMode: number;
  44058. }
  44059. }
  44060. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44061. import { Nullable } from "babylonjs/types";
  44062. import { Camera } from "babylonjs/Cameras/camera";
  44063. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44064. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44065. /**
  44066. * Base class for Camera Pointer Inputs.
  44067. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44068. * for example usage.
  44069. */
  44070. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44071. /**
  44072. * Defines the camera the input is attached to.
  44073. */
  44074. abstract camera: Camera;
  44075. /**
  44076. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44077. */
  44078. protected _altKey: boolean;
  44079. protected _ctrlKey: boolean;
  44080. protected _metaKey: boolean;
  44081. protected _shiftKey: boolean;
  44082. /**
  44083. * Which mouse buttons were pressed at time of last mouse event.
  44084. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44085. */
  44086. protected _buttonsPressed: number;
  44087. /**
  44088. * Defines the buttons associated with the input to handle camera move.
  44089. */
  44090. buttons: number[];
  44091. /**
  44092. * Attach the input controls to a specific dom element to get the input from.
  44093. * @param element Defines the element the controls should be listened from
  44094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44095. */
  44096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44097. /**
  44098. * Detach the current controls from the specified dom element.
  44099. * @param element Defines the element to stop listening the inputs from
  44100. */
  44101. detachControl(element: Nullable<HTMLElement>): void;
  44102. /**
  44103. * Gets the class name of the current input.
  44104. * @returns the class name
  44105. */
  44106. getClassName(): string;
  44107. /**
  44108. * Get the friendly name associated with the input class.
  44109. * @returns the input friendly name
  44110. */
  44111. getSimpleName(): string;
  44112. /**
  44113. * Called on pointer POINTERDOUBLETAP event.
  44114. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44115. */
  44116. protected onDoubleTap(type: string): void;
  44117. /**
  44118. * Called on pointer POINTERMOVE event if only a single touch is active.
  44119. * Override this method to provide functionality.
  44120. */
  44121. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44122. /**
  44123. * Called on pointer POINTERMOVE event if multiple touches are active.
  44124. * Override this method to provide functionality.
  44125. */
  44126. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44127. /**
  44128. * Called on JS contextmenu event.
  44129. * Override this method to provide functionality.
  44130. */
  44131. protected onContextMenu(evt: PointerEvent): void;
  44132. /**
  44133. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44134. * press.
  44135. * Override this method to provide functionality.
  44136. */
  44137. protected onButtonDown(evt: PointerEvent): void;
  44138. /**
  44139. * Called each time a new POINTERUP event occurs. Ie, for each button
  44140. * release.
  44141. * Override this method to provide functionality.
  44142. */
  44143. protected onButtonUp(evt: PointerEvent): void;
  44144. /**
  44145. * Called when window becomes inactive.
  44146. * Override this method to provide functionality.
  44147. */
  44148. protected onLostFocus(): void;
  44149. private _pointerInput;
  44150. private _observer;
  44151. private _onLostFocus;
  44152. private pointA;
  44153. private pointB;
  44154. }
  44155. }
  44156. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44157. import { Nullable } from "babylonjs/types";
  44158. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44159. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44160. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44161. /**
  44162. * Manage the pointers inputs to control an arc rotate camera.
  44163. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44164. */
  44165. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44166. /**
  44167. * Defines the camera the input is attached to.
  44168. */
  44169. camera: ArcRotateCamera;
  44170. /**
  44171. * Gets the class name of the current input.
  44172. * @returns the class name
  44173. */
  44174. getClassName(): string;
  44175. /**
  44176. * Defines the buttons associated with the input to handle camera move.
  44177. */
  44178. buttons: number[];
  44179. /**
  44180. * Defines the pointer angular sensibility along the X axis or how fast is
  44181. * the camera rotating.
  44182. */
  44183. angularSensibilityX: number;
  44184. /**
  44185. * Defines the pointer angular sensibility along the Y axis or how fast is
  44186. * the camera rotating.
  44187. */
  44188. angularSensibilityY: number;
  44189. /**
  44190. * Defines the pointer pinch precision or how fast is the camera zooming.
  44191. */
  44192. pinchPrecision: number;
  44193. /**
  44194. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44195. * from 0.
  44196. * It defines the percentage of current camera.radius to use as delta when
  44197. * pinch zoom is used.
  44198. */
  44199. pinchDeltaPercentage: number;
  44200. /**
  44201. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44202. * that any object in the plane at the camera's target point will scale
  44203. * perfectly with finger motion.
  44204. * Overrides pinchDeltaPercentage and pinchPrecision.
  44205. */
  44206. useNaturalPinchZoom: boolean;
  44207. /**
  44208. * Defines the pointer panning sensibility or how fast is the camera moving.
  44209. */
  44210. panningSensibility: number;
  44211. /**
  44212. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44213. */
  44214. multiTouchPanning: boolean;
  44215. /**
  44216. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44217. * zoom (pinch) through multitouch.
  44218. */
  44219. multiTouchPanAndZoom: boolean;
  44220. /**
  44221. * Revers pinch action direction.
  44222. */
  44223. pinchInwards: boolean;
  44224. private _isPanClick;
  44225. private _twoFingerActivityCount;
  44226. private _isPinching;
  44227. /**
  44228. * Called on pointer POINTERMOVE event if only a single touch is active.
  44229. */
  44230. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44231. /**
  44232. * Called on pointer POINTERDOUBLETAP event.
  44233. */
  44234. protected onDoubleTap(type: string): void;
  44235. /**
  44236. * Called on pointer POINTERMOVE event if multiple touches are active.
  44237. */
  44238. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44239. /**
  44240. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44241. * press.
  44242. */
  44243. protected onButtonDown(evt: PointerEvent): void;
  44244. /**
  44245. * Called each time a new POINTERUP event occurs. Ie, for each button
  44246. * release.
  44247. */
  44248. protected onButtonUp(evt: PointerEvent): void;
  44249. /**
  44250. * Called when window becomes inactive.
  44251. */
  44252. protected onLostFocus(): void;
  44253. }
  44254. }
  44255. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44256. import { Nullable } from "babylonjs/types";
  44257. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44259. /**
  44260. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44262. */
  44263. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44264. /**
  44265. * Defines the camera the input is attached to.
  44266. */
  44267. camera: ArcRotateCamera;
  44268. /**
  44269. * Defines the list of key codes associated with the up action (increase alpha)
  44270. */
  44271. keysUp: number[];
  44272. /**
  44273. * Defines the list of key codes associated with the down action (decrease alpha)
  44274. */
  44275. keysDown: number[];
  44276. /**
  44277. * Defines the list of key codes associated with the left action (increase beta)
  44278. */
  44279. keysLeft: number[];
  44280. /**
  44281. * Defines the list of key codes associated with the right action (decrease beta)
  44282. */
  44283. keysRight: number[];
  44284. /**
  44285. * Defines the list of key codes associated with the reset action.
  44286. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44287. */
  44288. keysReset: number[];
  44289. /**
  44290. * Defines the panning sensibility of the inputs.
  44291. * (How fast is the camera panning)
  44292. */
  44293. panningSensibility: number;
  44294. /**
  44295. * Defines the zooming sensibility of the inputs.
  44296. * (How fast is the camera zooming)
  44297. */
  44298. zoomingSensibility: number;
  44299. /**
  44300. * Defines whether maintaining the alt key down switch the movement mode from
  44301. * orientation to zoom.
  44302. */
  44303. useAltToZoom: boolean;
  44304. /**
  44305. * Rotation speed of the camera
  44306. */
  44307. angularSpeed: number;
  44308. private _keys;
  44309. private _ctrlPressed;
  44310. private _altPressed;
  44311. private _onCanvasBlurObserver;
  44312. private _onKeyboardObserver;
  44313. private _engine;
  44314. private _scene;
  44315. /**
  44316. * Attach the input controls to a specific dom element to get the input from.
  44317. * @param element Defines the element the controls should be listened from
  44318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44319. */
  44320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44321. /**
  44322. * Detach the current controls from the specified dom element.
  44323. * @param element Defines the element to stop listening the inputs from
  44324. */
  44325. detachControl(element: Nullable<HTMLElement>): void;
  44326. /**
  44327. * Update the current camera state depending on the inputs that have been used this frame.
  44328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44329. */
  44330. checkInputs(): void;
  44331. /**
  44332. * Gets the class name of the current intput.
  44333. * @returns the class name
  44334. */
  44335. getClassName(): string;
  44336. /**
  44337. * Get the friendly name associated with the input class.
  44338. * @returns the input friendly name
  44339. */
  44340. getSimpleName(): string;
  44341. }
  44342. }
  44343. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44344. import { Nullable } from "babylonjs/types";
  44345. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44346. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44347. /**
  44348. * Manage the mouse wheel inputs to control an arc rotate camera.
  44349. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44350. */
  44351. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44352. /**
  44353. * Defines the camera the input is attached to.
  44354. */
  44355. camera: ArcRotateCamera;
  44356. /**
  44357. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44358. */
  44359. wheelPrecision: number;
  44360. /**
  44361. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44362. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44363. */
  44364. wheelDeltaPercentage: number;
  44365. private _wheel;
  44366. private _observer;
  44367. private computeDeltaFromMouseWheelLegacyEvent;
  44368. /**
  44369. * Attach the input controls to a specific dom element to get the input from.
  44370. * @param element Defines the element the controls should be listened from
  44371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44372. */
  44373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44374. /**
  44375. * Detach the current controls from the specified dom element.
  44376. * @param element Defines the element to stop listening the inputs from
  44377. */
  44378. detachControl(element: Nullable<HTMLElement>): void;
  44379. /**
  44380. * Gets the class name of the current intput.
  44381. * @returns the class name
  44382. */
  44383. getClassName(): string;
  44384. /**
  44385. * Get the friendly name associated with the input class.
  44386. * @returns the input friendly name
  44387. */
  44388. getSimpleName(): string;
  44389. }
  44390. }
  44391. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44393. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44394. /**
  44395. * Default Inputs manager for the ArcRotateCamera.
  44396. * It groups all the default supported inputs for ease of use.
  44397. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44398. */
  44399. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44400. /**
  44401. * Instantiates a new ArcRotateCameraInputsManager.
  44402. * @param camera Defines the camera the inputs belong to
  44403. */
  44404. constructor(camera: ArcRotateCamera);
  44405. /**
  44406. * Add mouse wheel input support to the input manager.
  44407. * @returns the current input manager
  44408. */
  44409. addMouseWheel(): ArcRotateCameraInputsManager;
  44410. /**
  44411. * Add pointers input support to the input manager.
  44412. * @returns the current input manager
  44413. */
  44414. addPointers(): ArcRotateCameraInputsManager;
  44415. /**
  44416. * Add keyboard input support to the input manager.
  44417. * @returns the current input manager
  44418. */
  44419. addKeyboard(): ArcRotateCameraInputsManager;
  44420. }
  44421. }
  44422. declare module "babylonjs/Cameras/arcRotateCamera" {
  44423. import { Observable } from "babylonjs/Misc/observable";
  44424. import { Nullable } from "babylonjs/types";
  44425. import { Scene } from "babylonjs/scene";
  44426. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44428. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44429. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44430. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44431. import { Camera } from "babylonjs/Cameras/camera";
  44432. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44433. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44434. import { Collider } from "babylonjs/Collisions/collider";
  44435. /**
  44436. * This represents an orbital type of camera.
  44437. *
  44438. * 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.
  44439. * 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.
  44440. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44441. */
  44442. export class ArcRotateCamera extends TargetCamera {
  44443. /**
  44444. * Defines the rotation angle of the camera along the longitudinal axis.
  44445. */
  44446. alpha: number;
  44447. /**
  44448. * Defines the rotation angle of the camera along the latitudinal axis.
  44449. */
  44450. beta: number;
  44451. /**
  44452. * Defines the radius of the camera from it s target point.
  44453. */
  44454. radius: number;
  44455. protected _target: Vector3;
  44456. protected _targetHost: Nullable<AbstractMesh>;
  44457. /**
  44458. * Defines the target point of the camera.
  44459. * The camera looks towards it form the radius distance.
  44460. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44461. */
  44462. get target(): Vector3;
  44463. set target(value: Vector3);
  44464. /**
  44465. * Define the current local position of the camera in the scene
  44466. */
  44467. get position(): Vector3;
  44468. set position(newPosition: Vector3);
  44469. protected _upToYMatrix: Matrix;
  44470. protected _YToUpMatrix: Matrix;
  44471. /**
  44472. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44473. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44474. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44475. */
  44476. set upVector(vec: Vector3);
  44477. get upVector(): Vector3;
  44478. /**
  44479. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44480. */
  44481. setMatUp(): void;
  44482. /**
  44483. * Current inertia value on the longitudinal axis.
  44484. * The bigger this number the longer it will take for the camera to stop.
  44485. */
  44486. inertialAlphaOffset: number;
  44487. /**
  44488. * Current inertia value on the latitudinal axis.
  44489. * The bigger this number the longer it will take for the camera to stop.
  44490. */
  44491. inertialBetaOffset: number;
  44492. /**
  44493. * Current inertia value on the radius axis.
  44494. * The bigger this number the longer it will take for the camera to stop.
  44495. */
  44496. inertialRadiusOffset: number;
  44497. /**
  44498. * Minimum allowed angle on the longitudinal axis.
  44499. * This can help limiting how the Camera is able to move in the scene.
  44500. */
  44501. lowerAlphaLimit: Nullable<number>;
  44502. /**
  44503. * Maximum allowed angle on the longitudinal axis.
  44504. * This can help limiting how the Camera is able to move in the scene.
  44505. */
  44506. upperAlphaLimit: Nullable<number>;
  44507. /**
  44508. * Minimum allowed angle on the latitudinal axis.
  44509. * This can help limiting how the Camera is able to move in the scene.
  44510. */
  44511. lowerBetaLimit: number;
  44512. /**
  44513. * Maximum allowed angle on the latitudinal axis.
  44514. * This can help limiting how the Camera is able to move in the scene.
  44515. */
  44516. upperBetaLimit: number;
  44517. /**
  44518. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44519. * This can help limiting how the Camera is able to move in the scene.
  44520. */
  44521. lowerRadiusLimit: Nullable<number>;
  44522. /**
  44523. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44524. * This can help limiting how the Camera is able to move in the scene.
  44525. */
  44526. upperRadiusLimit: Nullable<number>;
  44527. /**
  44528. * Defines the current inertia value used during panning of the camera along the X axis.
  44529. */
  44530. inertialPanningX: number;
  44531. /**
  44532. * Defines the current inertia value used during panning of the camera along the Y axis.
  44533. */
  44534. inertialPanningY: number;
  44535. /**
  44536. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44537. * Basically if your fingers moves away from more than this distance you will be considered
  44538. * in pinch mode.
  44539. */
  44540. pinchToPanMaxDistance: number;
  44541. /**
  44542. * Defines the maximum distance the camera can pan.
  44543. * This could help keeping the cammera always in your scene.
  44544. */
  44545. panningDistanceLimit: Nullable<number>;
  44546. /**
  44547. * Defines the target of the camera before paning.
  44548. */
  44549. panningOriginTarget: Vector3;
  44550. /**
  44551. * Defines the value of the inertia used during panning.
  44552. * 0 would mean stop inertia and one would mean no decelleration at all.
  44553. */
  44554. panningInertia: number;
  44555. /**
  44556. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44557. */
  44558. get angularSensibilityX(): number;
  44559. set angularSensibilityX(value: number);
  44560. /**
  44561. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44562. */
  44563. get angularSensibilityY(): number;
  44564. set angularSensibilityY(value: number);
  44565. /**
  44566. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44567. */
  44568. get pinchPrecision(): number;
  44569. set pinchPrecision(value: number);
  44570. /**
  44571. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44572. * It will be used instead of pinchDeltaPrecision if different from 0.
  44573. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44574. */
  44575. get pinchDeltaPercentage(): number;
  44576. set pinchDeltaPercentage(value: number);
  44577. /**
  44578. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44579. * and pinch delta percentage.
  44580. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44581. * that any object in the plane at the camera's target point will scale
  44582. * perfectly with finger motion.
  44583. */
  44584. get useNaturalPinchZoom(): boolean;
  44585. set useNaturalPinchZoom(value: boolean);
  44586. /**
  44587. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44588. */
  44589. get panningSensibility(): number;
  44590. set panningSensibility(value: number);
  44591. /**
  44592. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44593. */
  44594. get keysUp(): number[];
  44595. set keysUp(value: number[]);
  44596. /**
  44597. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44598. */
  44599. get keysDown(): number[];
  44600. set keysDown(value: number[]);
  44601. /**
  44602. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44603. */
  44604. get keysLeft(): number[];
  44605. set keysLeft(value: number[]);
  44606. /**
  44607. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44608. */
  44609. get keysRight(): number[];
  44610. set keysRight(value: number[]);
  44611. /**
  44612. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44613. */
  44614. get wheelPrecision(): number;
  44615. set wheelPrecision(value: number);
  44616. /**
  44617. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44618. * It will be used instead of pinchDeltaPrecision if different from 0.
  44619. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44620. */
  44621. get wheelDeltaPercentage(): number;
  44622. set wheelDeltaPercentage(value: number);
  44623. /**
  44624. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44625. */
  44626. zoomOnFactor: number;
  44627. /**
  44628. * Defines a screen offset for the camera position.
  44629. */
  44630. targetScreenOffset: Vector2;
  44631. /**
  44632. * Allows the camera to be completely reversed.
  44633. * If false the camera can not arrive upside down.
  44634. */
  44635. allowUpsideDown: boolean;
  44636. /**
  44637. * Define if double tap/click is used to restore the previously saved state of the camera.
  44638. */
  44639. useInputToRestoreState: boolean;
  44640. /** @hidden */
  44641. _viewMatrix: Matrix;
  44642. /** @hidden */
  44643. _useCtrlForPanning: boolean;
  44644. /** @hidden */
  44645. _panningMouseButton: number;
  44646. /**
  44647. * Defines the input associated to the camera.
  44648. */
  44649. inputs: ArcRotateCameraInputsManager;
  44650. /** @hidden */
  44651. _reset: () => void;
  44652. /**
  44653. * Defines the allowed panning axis.
  44654. */
  44655. panningAxis: Vector3;
  44656. protected _localDirection: Vector3;
  44657. protected _transformedDirection: Vector3;
  44658. private _bouncingBehavior;
  44659. /**
  44660. * Gets the bouncing behavior of the camera if it has been enabled.
  44661. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44662. */
  44663. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44664. /**
  44665. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44666. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44667. */
  44668. get useBouncingBehavior(): boolean;
  44669. set useBouncingBehavior(value: boolean);
  44670. private _framingBehavior;
  44671. /**
  44672. * Gets the framing behavior of the camera if it has been enabled.
  44673. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44674. */
  44675. get framingBehavior(): Nullable<FramingBehavior>;
  44676. /**
  44677. * Defines if the framing behavior of the camera is enabled on the camera.
  44678. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44679. */
  44680. get useFramingBehavior(): boolean;
  44681. set useFramingBehavior(value: boolean);
  44682. private _autoRotationBehavior;
  44683. /**
  44684. * Gets the auto rotation behavior of the camera if it has been enabled.
  44685. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44686. */
  44687. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44688. /**
  44689. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44690. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44691. */
  44692. get useAutoRotationBehavior(): boolean;
  44693. set useAutoRotationBehavior(value: boolean);
  44694. /**
  44695. * Observable triggered when the mesh target has been changed on the camera.
  44696. */
  44697. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44698. /**
  44699. * Event raised when the camera is colliding with a mesh.
  44700. */
  44701. onCollide: (collidedMesh: AbstractMesh) => void;
  44702. /**
  44703. * Defines whether the camera should check collision with the objects oh the scene.
  44704. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44705. */
  44706. checkCollisions: boolean;
  44707. /**
  44708. * Defines the collision radius of the camera.
  44709. * This simulates a sphere around the camera.
  44710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44711. */
  44712. collisionRadius: Vector3;
  44713. protected _collider: Collider;
  44714. protected _previousPosition: Vector3;
  44715. protected _collisionVelocity: Vector3;
  44716. protected _newPosition: Vector3;
  44717. protected _previousAlpha: number;
  44718. protected _previousBeta: number;
  44719. protected _previousRadius: number;
  44720. protected _collisionTriggered: boolean;
  44721. protected _targetBoundingCenter: Nullable<Vector3>;
  44722. private _computationVector;
  44723. /**
  44724. * Instantiates a new ArcRotateCamera in a given scene
  44725. * @param name Defines the name of the camera
  44726. * @param alpha Defines the camera rotation along the logitudinal axis
  44727. * @param beta Defines the camera rotation along the latitudinal axis
  44728. * @param radius Defines the camera distance from its target
  44729. * @param target Defines the camera target
  44730. * @param scene Defines the scene the camera belongs to
  44731. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44732. */
  44733. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44734. /** @hidden */
  44735. _initCache(): void;
  44736. /** @hidden */
  44737. _updateCache(ignoreParentClass?: boolean): void;
  44738. protected _getTargetPosition(): Vector3;
  44739. private _storedAlpha;
  44740. private _storedBeta;
  44741. private _storedRadius;
  44742. private _storedTarget;
  44743. private _storedTargetScreenOffset;
  44744. /**
  44745. * Stores the current state of the camera (alpha, beta, radius and target)
  44746. * @returns the camera itself
  44747. */
  44748. storeState(): Camera;
  44749. /**
  44750. * @hidden
  44751. * Restored camera state. You must call storeState() first
  44752. */
  44753. _restoreStateValues(): boolean;
  44754. /** @hidden */
  44755. _isSynchronizedViewMatrix(): boolean;
  44756. /**
  44757. * Attached controls to the current camera.
  44758. * @param element Defines the element the controls should be listened from
  44759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44760. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44761. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44762. */
  44763. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44764. /**
  44765. * Detach the current controls from the camera.
  44766. * The camera will stop reacting to inputs.
  44767. * @param element Defines the element to stop listening the inputs from
  44768. */
  44769. detachControl(element: HTMLElement): void;
  44770. /** @hidden */
  44771. _checkInputs(): void;
  44772. protected _checkLimits(): void;
  44773. /**
  44774. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44775. */
  44776. rebuildAnglesAndRadius(): void;
  44777. /**
  44778. * Use a position to define the current camera related information like alpha, beta and radius
  44779. * @param position Defines the position to set the camera at
  44780. */
  44781. setPosition(position: Vector3): void;
  44782. /**
  44783. * Defines the target the camera should look at.
  44784. * This will automatically adapt alpha beta and radius to fit within the new target.
  44785. * @param target Defines the new target as a Vector or a mesh
  44786. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44787. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44788. */
  44789. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44790. /** @hidden */
  44791. _getViewMatrix(): Matrix;
  44792. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44793. /**
  44794. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44795. * @param meshes Defines the mesh to zoom on
  44796. * @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)
  44797. */
  44798. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44799. /**
  44800. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44801. * The target will be changed but the radius
  44802. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44803. * @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)
  44804. */
  44805. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44806. min: Vector3;
  44807. max: Vector3;
  44808. distance: number;
  44809. }, doNotUpdateMaxZ?: boolean): void;
  44810. /**
  44811. * @override
  44812. * Override Camera.createRigCamera
  44813. */
  44814. createRigCamera(name: string, cameraIndex: number): Camera;
  44815. /**
  44816. * @hidden
  44817. * @override
  44818. * Override Camera._updateRigCameras
  44819. */
  44820. _updateRigCameras(): void;
  44821. /**
  44822. * Destroy the camera and release the current resources hold by it.
  44823. */
  44824. dispose(): void;
  44825. /**
  44826. * Gets the current object class name.
  44827. * @return the class name
  44828. */
  44829. getClassName(): string;
  44830. }
  44831. }
  44832. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44833. import { Behavior } from "babylonjs/Behaviors/behavior";
  44834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44835. /**
  44836. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44837. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44838. */
  44839. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44840. /**
  44841. * Gets the name of the behavior.
  44842. */
  44843. get name(): string;
  44844. private _zoomStopsAnimation;
  44845. private _idleRotationSpeed;
  44846. private _idleRotationWaitTime;
  44847. private _idleRotationSpinupTime;
  44848. /**
  44849. * Sets the flag that indicates if user zooming should stop animation.
  44850. */
  44851. set zoomStopsAnimation(flag: boolean);
  44852. /**
  44853. * Gets the flag that indicates if user zooming should stop animation.
  44854. */
  44855. get zoomStopsAnimation(): boolean;
  44856. /**
  44857. * Sets the default speed at which the camera rotates around the model.
  44858. */
  44859. set idleRotationSpeed(speed: number);
  44860. /**
  44861. * Gets the default speed at which the camera rotates around the model.
  44862. */
  44863. get idleRotationSpeed(): number;
  44864. /**
  44865. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44866. */
  44867. set idleRotationWaitTime(time: number);
  44868. /**
  44869. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44870. */
  44871. get idleRotationWaitTime(): number;
  44872. /**
  44873. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44874. */
  44875. set idleRotationSpinupTime(time: number);
  44876. /**
  44877. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44878. */
  44879. get idleRotationSpinupTime(): number;
  44880. /**
  44881. * Gets a value indicating if the camera is currently rotating because of this behavior
  44882. */
  44883. get rotationInProgress(): boolean;
  44884. private _onPrePointerObservableObserver;
  44885. private _onAfterCheckInputsObserver;
  44886. private _attachedCamera;
  44887. private _isPointerDown;
  44888. private _lastFrameTime;
  44889. private _lastInteractionTime;
  44890. private _cameraRotationSpeed;
  44891. /**
  44892. * Initializes the behavior.
  44893. */
  44894. init(): void;
  44895. /**
  44896. * Attaches the behavior to its arc rotate camera.
  44897. * @param camera Defines the camera to attach the behavior to
  44898. */
  44899. attach(camera: ArcRotateCamera): void;
  44900. /**
  44901. * Detaches the behavior from its current arc rotate camera.
  44902. */
  44903. detach(): void;
  44904. /**
  44905. * Returns true if user is scrolling.
  44906. * @return true if user is scrolling.
  44907. */
  44908. private _userIsZooming;
  44909. private _lastFrameRadius;
  44910. private _shouldAnimationStopForInteraction;
  44911. /**
  44912. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44913. */
  44914. private _applyUserInteraction;
  44915. private _userIsMoving;
  44916. }
  44917. }
  44918. declare module "babylonjs/Behaviors/Cameras/index" {
  44919. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44920. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44921. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44922. }
  44923. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44924. import { Mesh } from "babylonjs/Meshes/mesh";
  44925. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44926. import { Behavior } from "babylonjs/Behaviors/behavior";
  44927. /**
  44928. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44929. */
  44930. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44931. private ui;
  44932. /**
  44933. * The name of the behavior
  44934. */
  44935. name: string;
  44936. /**
  44937. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44938. */
  44939. distanceAwayFromFace: number;
  44940. /**
  44941. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44942. */
  44943. distanceAwayFromBottomOfFace: number;
  44944. private _faceVectors;
  44945. private _target;
  44946. private _scene;
  44947. private _onRenderObserver;
  44948. private _tmpMatrix;
  44949. private _tmpVector;
  44950. /**
  44951. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44952. * @param ui The transform node that should be attched to the mesh
  44953. */
  44954. constructor(ui: TransformNode);
  44955. /**
  44956. * Initializes the behavior
  44957. */
  44958. init(): void;
  44959. private _closestFace;
  44960. private _zeroVector;
  44961. private _lookAtTmpMatrix;
  44962. private _lookAtToRef;
  44963. /**
  44964. * Attaches the AttachToBoxBehavior to the passed in mesh
  44965. * @param target The mesh that the specified node will be attached to
  44966. */
  44967. attach(target: Mesh): void;
  44968. /**
  44969. * Detaches the behavior from the mesh
  44970. */
  44971. detach(): void;
  44972. }
  44973. }
  44974. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44975. import { Behavior } from "babylonjs/Behaviors/behavior";
  44976. import { Mesh } from "babylonjs/Meshes/mesh";
  44977. /**
  44978. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44979. */
  44980. export class FadeInOutBehavior implements Behavior<Mesh> {
  44981. /**
  44982. * Time in milliseconds to delay before fading in (Default: 0)
  44983. */
  44984. delay: number;
  44985. /**
  44986. * Time in milliseconds for the mesh to fade in (Default: 300)
  44987. */
  44988. fadeInTime: number;
  44989. private _millisecondsPerFrame;
  44990. private _hovered;
  44991. private _hoverValue;
  44992. private _ownerNode;
  44993. /**
  44994. * Instatiates the FadeInOutBehavior
  44995. */
  44996. constructor();
  44997. /**
  44998. * The name of the behavior
  44999. */
  45000. get name(): string;
  45001. /**
  45002. * Initializes the behavior
  45003. */
  45004. init(): void;
  45005. /**
  45006. * Attaches the fade behavior on the passed in mesh
  45007. * @param ownerNode The mesh that will be faded in/out once attached
  45008. */
  45009. attach(ownerNode: Mesh): void;
  45010. /**
  45011. * Detaches the behavior from the mesh
  45012. */
  45013. detach(): void;
  45014. /**
  45015. * Triggers the mesh to begin fading in or out
  45016. * @param value if the object should fade in or out (true to fade in)
  45017. */
  45018. fadeIn(value: boolean): void;
  45019. private _update;
  45020. private _setAllVisibility;
  45021. }
  45022. }
  45023. declare module "babylonjs/Misc/pivotTools" {
  45024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45025. /**
  45026. * Class containing a set of static utilities functions for managing Pivots
  45027. * @hidden
  45028. */
  45029. export class PivotTools {
  45030. private static _PivotCached;
  45031. private static _OldPivotPoint;
  45032. private static _PivotTranslation;
  45033. private static _PivotTmpVector;
  45034. private static _PivotPostMultiplyPivotMatrix;
  45035. /** @hidden */
  45036. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45037. /** @hidden */
  45038. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45039. }
  45040. }
  45041. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45042. import { Scene } from "babylonjs/scene";
  45043. import { Vector4 } from "babylonjs/Maths/math.vector";
  45044. import { Mesh } from "babylonjs/Meshes/mesh";
  45045. import { Nullable } from "babylonjs/types";
  45046. import { Plane } from "babylonjs/Maths/math.plane";
  45047. /**
  45048. * Class containing static functions to help procedurally build meshes
  45049. */
  45050. export class PlaneBuilder {
  45051. /**
  45052. * Creates a plane mesh
  45053. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45054. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45055. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45059. * @param name defines the name of the mesh
  45060. * @param options defines the options used to create the mesh
  45061. * @param scene defines the hosting scene
  45062. * @returns the plane mesh
  45063. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45064. */
  45065. static CreatePlane(name: string, options: {
  45066. size?: number;
  45067. width?: number;
  45068. height?: number;
  45069. sideOrientation?: number;
  45070. frontUVs?: Vector4;
  45071. backUVs?: Vector4;
  45072. updatable?: boolean;
  45073. sourcePlane?: Plane;
  45074. }, scene?: Nullable<Scene>): Mesh;
  45075. }
  45076. }
  45077. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45078. import { Behavior } from "babylonjs/Behaviors/behavior";
  45079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45080. import { Observable } from "babylonjs/Misc/observable";
  45081. import { Vector3 } from "babylonjs/Maths/math.vector";
  45082. import { Ray } from "babylonjs/Culling/ray";
  45083. import "babylonjs/Meshes/Builders/planeBuilder";
  45084. /**
  45085. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45086. */
  45087. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45088. private static _AnyMouseID;
  45089. /**
  45090. * Abstract mesh the behavior is set on
  45091. */
  45092. attachedNode: AbstractMesh;
  45093. private _dragPlane;
  45094. private _scene;
  45095. private _pointerObserver;
  45096. private _beforeRenderObserver;
  45097. private static _planeScene;
  45098. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45099. /**
  45100. * 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)
  45101. */
  45102. maxDragAngle: number;
  45103. /**
  45104. * @hidden
  45105. */
  45106. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45107. /**
  45108. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45109. */
  45110. currentDraggingPointerID: number;
  45111. /**
  45112. * The last position where the pointer hit the drag plane in world space
  45113. */
  45114. lastDragPosition: Vector3;
  45115. /**
  45116. * If the behavior is currently in a dragging state
  45117. */
  45118. dragging: boolean;
  45119. /**
  45120. * 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)
  45121. */
  45122. dragDeltaRatio: number;
  45123. /**
  45124. * If the drag plane orientation should be updated during the dragging (Default: true)
  45125. */
  45126. updateDragPlane: boolean;
  45127. private _debugMode;
  45128. private _moving;
  45129. /**
  45130. * Fires each time the attached mesh is dragged with the pointer
  45131. * * delta between last drag position and current drag position in world space
  45132. * * dragDistance along the drag axis
  45133. * * dragPlaneNormal normal of the current drag plane used during the drag
  45134. * * dragPlanePoint in world space where the drag intersects the drag plane
  45135. */
  45136. onDragObservable: Observable<{
  45137. delta: Vector3;
  45138. dragPlanePoint: Vector3;
  45139. dragPlaneNormal: Vector3;
  45140. dragDistance: number;
  45141. pointerId: number;
  45142. }>;
  45143. /**
  45144. * Fires each time a drag begins (eg. mouse down on mesh)
  45145. */
  45146. onDragStartObservable: Observable<{
  45147. dragPlanePoint: Vector3;
  45148. pointerId: number;
  45149. }>;
  45150. /**
  45151. * Fires each time a drag ends (eg. mouse release after drag)
  45152. */
  45153. onDragEndObservable: Observable<{
  45154. dragPlanePoint: Vector3;
  45155. pointerId: number;
  45156. }>;
  45157. /**
  45158. * If the attached mesh should be moved when dragged
  45159. */
  45160. moveAttached: boolean;
  45161. /**
  45162. * If the drag behavior will react to drag events (Default: true)
  45163. */
  45164. enabled: boolean;
  45165. /**
  45166. * If pointer events should start and release the drag (Default: true)
  45167. */
  45168. startAndReleaseDragOnPointerEvents: boolean;
  45169. /**
  45170. * If camera controls should be detached during the drag
  45171. */
  45172. detachCameraControls: boolean;
  45173. /**
  45174. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45175. */
  45176. useObjectOrientationForDragging: boolean;
  45177. private _options;
  45178. /**
  45179. * Gets the options used by the behavior
  45180. */
  45181. get options(): {
  45182. dragAxis?: Vector3;
  45183. dragPlaneNormal?: Vector3;
  45184. };
  45185. /**
  45186. * Sets the options used by the behavior
  45187. */
  45188. set options(options: {
  45189. dragAxis?: Vector3;
  45190. dragPlaneNormal?: Vector3;
  45191. });
  45192. /**
  45193. * Creates a pointer drag behavior that can be attached to a mesh
  45194. * @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)
  45195. */
  45196. constructor(options?: {
  45197. dragAxis?: Vector3;
  45198. dragPlaneNormal?: Vector3;
  45199. });
  45200. /**
  45201. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45202. */
  45203. validateDrag: (targetPosition: Vector3) => boolean;
  45204. /**
  45205. * The name of the behavior
  45206. */
  45207. get name(): string;
  45208. /**
  45209. * Initializes the behavior
  45210. */
  45211. init(): void;
  45212. private _tmpVector;
  45213. private _alternatePickedPoint;
  45214. private _worldDragAxis;
  45215. private _targetPosition;
  45216. private _attachedElement;
  45217. /**
  45218. * Attaches the drag behavior the passed in mesh
  45219. * @param ownerNode The mesh that will be dragged around once attached
  45220. * @param predicate Predicate to use for pick filtering
  45221. */
  45222. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45223. /**
  45224. * Force relase the drag action by code.
  45225. */
  45226. releaseDrag(): void;
  45227. private _startDragRay;
  45228. private _lastPointerRay;
  45229. /**
  45230. * Simulates the start of a pointer drag event on the behavior
  45231. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45232. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45233. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45234. */
  45235. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45236. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45237. private _dragDelta;
  45238. protected _moveDrag(ray: Ray): void;
  45239. private _pickWithRayOnDragPlane;
  45240. private _pointA;
  45241. private _pointC;
  45242. private _localAxis;
  45243. private _lookAt;
  45244. private _updateDragPlanePosition;
  45245. /**
  45246. * Detaches the behavior from the mesh
  45247. */
  45248. detach(): void;
  45249. }
  45250. }
  45251. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45252. import { Mesh } from "babylonjs/Meshes/mesh";
  45253. import { Behavior } from "babylonjs/Behaviors/behavior";
  45254. /**
  45255. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45256. */
  45257. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45258. private _dragBehaviorA;
  45259. private _dragBehaviorB;
  45260. private _startDistance;
  45261. private _initialScale;
  45262. private _targetScale;
  45263. private _ownerNode;
  45264. private _sceneRenderObserver;
  45265. /**
  45266. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45267. */
  45268. constructor();
  45269. /**
  45270. * The name of the behavior
  45271. */
  45272. get name(): string;
  45273. /**
  45274. * Initializes the behavior
  45275. */
  45276. init(): void;
  45277. private _getCurrentDistance;
  45278. /**
  45279. * Attaches the scale behavior the passed in mesh
  45280. * @param ownerNode The mesh that will be scaled around once attached
  45281. */
  45282. attach(ownerNode: Mesh): void;
  45283. /**
  45284. * Detaches the behavior from the mesh
  45285. */
  45286. detach(): void;
  45287. }
  45288. }
  45289. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45290. import { Behavior } from "babylonjs/Behaviors/behavior";
  45291. import { Mesh } from "babylonjs/Meshes/mesh";
  45292. import { Observable } from "babylonjs/Misc/observable";
  45293. /**
  45294. * 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
  45295. */
  45296. export class SixDofDragBehavior implements Behavior<Mesh> {
  45297. private static _virtualScene;
  45298. private _ownerNode;
  45299. private _sceneRenderObserver;
  45300. private _scene;
  45301. private _targetPosition;
  45302. private _virtualOriginMesh;
  45303. private _virtualDragMesh;
  45304. private _pointerObserver;
  45305. private _moving;
  45306. private _startingOrientation;
  45307. private _attachedElement;
  45308. /**
  45309. * 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)
  45310. */
  45311. private zDragFactor;
  45312. /**
  45313. * If the object should rotate to face the drag origin
  45314. */
  45315. rotateDraggedObject: boolean;
  45316. /**
  45317. * If the behavior is currently in a dragging state
  45318. */
  45319. dragging: boolean;
  45320. /**
  45321. * 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)
  45322. */
  45323. dragDeltaRatio: number;
  45324. /**
  45325. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45326. */
  45327. currentDraggingPointerID: number;
  45328. /**
  45329. * If camera controls should be detached during the drag
  45330. */
  45331. detachCameraControls: boolean;
  45332. /**
  45333. * Fires each time a drag starts
  45334. */
  45335. onDragStartObservable: Observable<{}>;
  45336. /**
  45337. * Fires each time a drag ends (eg. mouse release after drag)
  45338. */
  45339. onDragEndObservable: Observable<{}>;
  45340. /**
  45341. * 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
  45342. */
  45343. constructor();
  45344. /**
  45345. * The name of the behavior
  45346. */
  45347. get name(): string;
  45348. /**
  45349. * Initializes the behavior
  45350. */
  45351. init(): void;
  45352. /**
  45353. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45354. */
  45355. private get _pointerCamera();
  45356. /**
  45357. * Attaches the scale behavior the passed in mesh
  45358. * @param ownerNode The mesh that will be scaled around once attached
  45359. */
  45360. attach(ownerNode: Mesh): void;
  45361. /**
  45362. * Detaches the behavior from the mesh
  45363. */
  45364. detach(): void;
  45365. }
  45366. }
  45367. declare module "babylonjs/Behaviors/Meshes/index" {
  45368. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45369. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45370. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45371. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45372. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45373. }
  45374. declare module "babylonjs/Behaviors/index" {
  45375. export * from "babylonjs/Behaviors/behavior";
  45376. export * from "babylonjs/Behaviors/Cameras/index";
  45377. export * from "babylonjs/Behaviors/Meshes/index";
  45378. }
  45379. declare module "babylonjs/Bones/boneIKController" {
  45380. import { Bone } from "babylonjs/Bones/bone";
  45381. import { Vector3 } from "babylonjs/Maths/math.vector";
  45382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45383. import { Nullable } from "babylonjs/types";
  45384. /**
  45385. * Class used to apply inverse kinematics to bones
  45386. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45387. */
  45388. export class BoneIKController {
  45389. private static _tmpVecs;
  45390. private static _tmpQuat;
  45391. private static _tmpMats;
  45392. /**
  45393. * Gets or sets the target mesh
  45394. */
  45395. targetMesh: AbstractMesh;
  45396. /** Gets or sets the mesh used as pole */
  45397. poleTargetMesh: AbstractMesh;
  45398. /**
  45399. * Gets or sets the bone used as pole
  45400. */
  45401. poleTargetBone: Nullable<Bone>;
  45402. /**
  45403. * Gets or sets the target position
  45404. */
  45405. targetPosition: Vector3;
  45406. /**
  45407. * Gets or sets the pole target position
  45408. */
  45409. poleTargetPosition: Vector3;
  45410. /**
  45411. * Gets or sets the pole target local offset
  45412. */
  45413. poleTargetLocalOffset: Vector3;
  45414. /**
  45415. * Gets or sets the pole angle
  45416. */
  45417. poleAngle: number;
  45418. /**
  45419. * Gets or sets the mesh associated with the controller
  45420. */
  45421. mesh: AbstractMesh;
  45422. /**
  45423. * 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)
  45424. */
  45425. slerpAmount: number;
  45426. private _bone1Quat;
  45427. private _bone1Mat;
  45428. private _bone2Ang;
  45429. private _bone1;
  45430. private _bone2;
  45431. private _bone1Length;
  45432. private _bone2Length;
  45433. private _maxAngle;
  45434. private _maxReach;
  45435. private _rightHandedSystem;
  45436. private _bendAxis;
  45437. private _slerping;
  45438. private _adjustRoll;
  45439. /**
  45440. * Gets or sets maximum allowed angle
  45441. */
  45442. get maxAngle(): number;
  45443. set maxAngle(value: number);
  45444. /**
  45445. * Creates a new BoneIKController
  45446. * @param mesh defines the mesh to control
  45447. * @param bone defines the bone to control
  45448. * @param options defines options to set up the controller
  45449. */
  45450. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45451. targetMesh?: AbstractMesh;
  45452. poleTargetMesh?: AbstractMesh;
  45453. poleTargetBone?: Bone;
  45454. poleTargetLocalOffset?: Vector3;
  45455. poleAngle?: number;
  45456. bendAxis?: Vector3;
  45457. maxAngle?: number;
  45458. slerpAmount?: number;
  45459. });
  45460. private _setMaxAngle;
  45461. /**
  45462. * Force the controller to update the bones
  45463. */
  45464. update(): void;
  45465. }
  45466. }
  45467. declare module "babylonjs/Bones/boneLookController" {
  45468. import { Vector3 } from "babylonjs/Maths/math.vector";
  45469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45470. import { Bone } from "babylonjs/Bones/bone";
  45471. import { Space } from "babylonjs/Maths/math.axis";
  45472. /**
  45473. * Class used to make a bone look toward a point in space
  45474. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45475. */
  45476. export class BoneLookController {
  45477. private static _tmpVecs;
  45478. private static _tmpQuat;
  45479. private static _tmpMats;
  45480. /**
  45481. * The target Vector3 that the bone will look at
  45482. */
  45483. target: Vector3;
  45484. /**
  45485. * The mesh that the bone is attached to
  45486. */
  45487. mesh: AbstractMesh;
  45488. /**
  45489. * The bone that will be looking to the target
  45490. */
  45491. bone: Bone;
  45492. /**
  45493. * The up axis of the coordinate system that is used when the bone is rotated
  45494. */
  45495. upAxis: Vector3;
  45496. /**
  45497. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45498. */
  45499. upAxisSpace: Space;
  45500. /**
  45501. * Used to make an adjustment to the yaw of the bone
  45502. */
  45503. adjustYaw: number;
  45504. /**
  45505. * Used to make an adjustment to the pitch of the bone
  45506. */
  45507. adjustPitch: number;
  45508. /**
  45509. * Used to make an adjustment to the roll of the bone
  45510. */
  45511. adjustRoll: number;
  45512. /**
  45513. * 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)
  45514. */
  45515. slerpAmount: number;
  45516. private _minYaw;
  45517. private _maxYaw;
  45518. private _minPitch;
  45519. private _maxPitch;
  45520. private _minYawSin;
  45521. private _minYawCos;
  45522. private _maxYawSin;
  45523. private _maxYawCos;
  45524. private _midYawConstraint;
  45525. private _minPitchTan;
  45526. private _maxPitchTan;
  45527. private _boneQuat;
  45528. private _slerping;
  45529. private _transformYawPitch;
  45530. private _transformYawPitchInv;
  45531. private _firstFrameSkipped;
  45532. private _yawRange;
  45533. private _fowardAxis;
  45534. /**
  45535. * Gets or sets the minimum yaw angle that the bone can look to
  45536. */
  45537. get minYaw(): number;
  45538. set minYaw(value: number);
  45539. /**
  45540. * Gets or sets the maximum yaw angle that the bone can look to
  45541. */
  45542. get maxYaw(): number;
  45543. set maxYaw(value: number);
  45544. /**
  45545. * Gets or sets the minimum pitch angle that the bone can look to
  45546. */
  45547. get minPitch(): number;
  45548. set minPitch(value: number);
  45549. /**
  45550. * Gets or sets the maximum pitch angle that the bone can look to
  45551. */
  45552. get maxPitch(): number;
  45553. set maxPitch(value: number);
  45554. /**
  45555. * Create a BoneLookController
  45556. * @param mesh the mesh that the bone belongs to
  45557. * @param bone the bone that will be looking to the target
  45558. * @param target the target Vector3 to look at
  45559. * @param options optional settings:
  45560. * * maxYaw: the maximum angle the bone will yaw to
  45561. * * minYaw: the minimum angle the bone will yaw to
  45562. * * maxPitch: the maximum angle the bone will pitch to
  45563. * * minPitch: the minimum angle the bone will yaw to
  45564. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45565. * * upAxis: the up axis of the coordinate system
  45566. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45567. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45568. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45569. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45570. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45571. * * adjustRoll: used to make an adjustment to the roll of the bone
  45572. **/
  45573. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45574. maxYaw?: number;
  45575. minYaw?: number;
  45576. maxPitch?: number;
  45577. minPitch?: number;
  45578. slerpAmount?: number;
  45579. upAxis?: Vector3;
  45580. upAxisSpace?: Space;
  45581. yawAxis?: Vector3;
  45582. pitchAxis?: Vector3;
  45583. adjustYaw?: number;
  45584. adjustPitch?: number;
  45585. adjustRoll?: number;
  45586. });
  45587. /**
  45588. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45589. */
  45590. update(): void;
  45591. private _getAngleDiff;
  45592. private _getAngleBetween;
  45593. private _isAngleBetween;
  45594. }
  45595. }
  45596. declare module "babylonjs/Bones/index" {
  45597. export * from "babylonjs/Bones/bone";
  45598. export * from "babylonjs/Bones/boneIKController";
  45599. export * from "babylonjs/Bones/boneLookController";
  45600. export * from "babylonjs/Bones/skeleton";
  45601. }
  45602. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45603. import { Nullable } from "babylonjs/types";
  45604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45605. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45606. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45607. /**
  45608. * Manage the gamepad inputs to control an arc rotate camera.
  45609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45610. */
  45611. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45612. /**
  45613. * Defines the camera the input is attached to.
  45614. */
  45615. camera: ArcRotateCamera;
  45616. /**
  45617. * Defines the gamepad the input is gathering event from.
  45618. */
  45619. gamepad: Nullable<Gamepad>;
  45620. /**
  45621. * Defines the gamepad rotation sensiblity.
  45622. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45623. */
  45624. gamepadRotationSensibility: number;
  45625. /**
  45626. * Defines the gamepad move sensiblity.
  45627. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45628. */
  45629. gamepadMoveSensibility: number;
  45630. private _yAxisScale;
  45631. /**
  45632. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45633. */
  45634. get invertYAxis(): boolean;
  45635. set invertYAxis(value: boolean);
  45636. private _onGamepadConnectedObserver;
  45637. private _onGamepadDisconnectedObserver;
  45638. /**
  45639. * Attach the input controls to a specific dom element to get the input from.
  45640. * @param element Defines the element the controls should be listened from
  45641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45642. */
  45643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45644. /**
  45645. * Detach the current controls from the specified dom element.
  45646. * @param element Defines the element to stop listening the inputs from
  45647. */
  45648. detachControl(element: Nullable<HTMLElement>): void;
  45649. /**
  45650. * Update the current camera state depending on the inputs that have been used this frame.
  45651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45652. */
  45653. checkInputs(): void;
  45654. /**
  45655. * Gets the class name of the current intput.
  45656. * @returns the class name
  45657. */
  45658. getClassName(): string;
  45659. /**
  45660. * Get the friendly name associated with the input class.
  45661. * @returns the input friendly name
  45662. */
  45663. getSimpleName(): string;
  45664. }
  45665. }
  45666. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45667. import { Nullable } from "babylonjs/types";
  45668. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45669. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45670. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45671. interface ArcRotateCameraInputsManager {
  45672. /**
  45673. * Add orientation input support to the input manager.
  45674. * @returns the current input manager
  45675. */
  45676. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45677. }
  45678. }
  45679. /**
  45680. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45681. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45682. */
  45683. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45684. /**
  45685. * Defines the camera the input is attached to.
  45686. */
  45687. camera: ArcRotateCamera;
  45688. /**
  45689. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45690. */
  45691. alphaCorrection: number;
  45692. /**
  45693. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45694. */
  45695. gammaCorrection: number;
  45696. private _alpha;
  45697. private _gamma;
  45698. private _dirty;
  45699. private _deviceOrientationHandler;
  45700. /**
  45701. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45702. */
  45703. constructor();
  45704. /**
  45705. * Attach the input controls to a specific dom element to get the input from.
  45706. * @param element Defines the element the controls should be listened from
  45707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45708. */
  45709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45710. /** @hidden */
  45711. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45712. /**
  45713. * Update the current camera state depending on the inputs that have been used this frame.
  45714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45715. */
  45716. checkInputs(): void;
  45717. /**
  45718. * Detach the current controls from the specified dom element.
  45719. * @param element Defines the element to stop listening the inputs from
  45720. */
  45721. detachControl(element: Nullable<HTMLElement>): void;
  45722. /**
  45723. * Gets the class name of the current intput.
  45724. * @returns the class name
  45725. */
  45726. getClassName(): string;
  45727. /**
  45728. * Get the friendly name associated with the input class.
  45729. * @returns the input friendly name
  45730. */
  45731. getSimpleName(): string;
  45732. }
  45733. }
  45734. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45735. import { Nullable } from "babylonjs/types";
  45736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45737. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45738. /**
  45739. * Listen to mouse events to control the camera.
  45740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45741. */
  45742. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45743. /**
  45744. * Defines the camera the input is attached to.
  45745. */
  45746. camera: FlyCamera;
  45747. /**
  45748. * Defines if touch is enabled. (Default is true.)
  45749. */
  45750. touchEnabled: boolean;
  45751. /**
  45752. * Defines the buttons associated with the input to handle camera rotation.
  45753. */
  45754. buttons: number[];
  45755. /**
  45756. * Assign buttons for Yaw control.
  45757. */
  45758. buttonsYaw: number[];
  45759. /**
  45760. * Assign buttons for Pitch control.
  45761. */
  45762. buttonsPitch: number[];
  45763. /**
  45764. * Assign buttons for Roll control.
  45765. */
  45766. buttonsRoll: number[];
  45767. /**
  45768. * Detect if any button is being pressed while mouse is moved.
  45769. * -1 = Mouse locked.
  45770. * 0 = Left button.
  45771. * 1 = Middle Button.
  45772. * 2 = Right Button.
  45773. */
  45774. activeButton: number;
  45775. /**
  45776. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45777. * Higher values reduce its sensitivity.
  45778. */
  45779. angularSensibility: number;
  45780. private _mousemoveCallback;
  45781. private _observer;
  45782. private _rollObserver;
  45783. private previousPosition;
  45784. private noPreventDefault;
  45785. private element;
  45786. /**
  45787. * Listen to mouse events to control the camera.
  45788. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45789. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45790. */
  45791. constructor(touchEnabled?: boolean);
  45792. /**
  45793. * Attach the mouse control to the HTML DOM element.
  45794. * @param element Defines the element that listens to the input events.
  45795. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45796. */
  45797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45798. /**
  45799. * Detach the current controls from the specified dom element.
  45800. * @param element Defines the element to stop listening the inputs from
  45801. */
  45802. detachControl(element: Nullable<HTMLElement>): void;
  45803. /**
  45804. * Gets the class name of the current input.
  45805. * @returns the class name.
  45806. */
  45807. getClassName(): string;
  45808. /**
  45809. * Get the friendly name associated with the input class.
  45810. * @returns the input's friendly name.
  45811. */
  45812. getSimpleName(): string;
  45813. private _pointerInput;
  45814. private _onMouseMove;
  45815. /**
  45816. * Rotate camera by mouse offset.
  45817. */
  45818. private rotateCamera;
  45819. }
  45820. }
  45821. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45822. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45823. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45824. /**
  45825. * Default Inputs manager for the FlyCamera.
  45826. * It groups all the default supported inputs for ease of use.
  45827. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45828. */
  45829. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45830. /**
  45831. * Instantiates a new FlyCameraInputsManager.
  45832. * @param camera Defines the camera the inputs belong to.
  45833. */
  45834. constructor(camera: FlyCamera);
  45835. /**
  45836. * Add keyboard input support to the input manager.
  45837. * @returns the new FlyCameraKeyboardMoveInput().
  45838. */
  45839. addKeyboard(): FlyCameraInputsManager;
  45840. /**
  45841. * Add mouse input support to the input manager.
  45842. * @param touchEnabled Enable touch screen support.
  45843. * @returns the new FlyCameraMouseInput().
  45844. */
  45845. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45846. }
  45847. }
  45848. declare module "babylonjs/Cameras/flyCamera" {
  45849. import { Scene } from "babylonjs/scene";
  45850. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45852. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45853. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45854. /**
  45855. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45856. * such as in a 3D Space Shooter or a Flight Simulator.
  45857. */
  45858. export class FlyCamera extends TargetCamera {
  45859. /**
  45860. * Define the collision ellipsoid of the camera.
  45861. * This is helpful for simulating a camera body, like a player's body.
  45862. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45863. */
  45864. ellipsoid: Vector3;
  45865. /**
  45866. * Define an offset for the position of the ellipsoid around the camera.
  45867. * This can be helpful if the camera is attached away from the player's body center,
  45868. * such as at its head.
  45869. */
  45870. ellipsoidOffset: Vector3;
  45871. /**
  45872. * Enable or disable collisions of the camera with the rest of the scene objects.
  45873. */
  45874. checkCollisions: boolean;
  45875. /**
  45876. * Enable or disable gravity on the camera.
  45877. */
  45878. applyGravity: boolean;
  45879. /**
  45880. * Define the current direction the camera is moving to.
  45881. */
  45882. cameraDirection: Vector3;
  45883. /**
  45884. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45885. * This overrides and empties cameraRotation.
  45886. */
  45887. rotationQuaternion: Quaternion;
  45888. /**
  45889. * Track Roll to maintain the wanted Rolling when looking around.
  45890. */
  45891. _trackRoll: number;
  45892. /**
  45893. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45894. */
  45895. rollCorrect: number;
  45896. /**
  45897. * Mimic a banked turn, Rolling the camera when Yawing.
  45898. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45899. */
  45900. bankedTurn: boolean;
  45901. /**
  45902. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45903. */
  45904. bankedTurnLimit: number;
  45905. /**
  45906. * Value of 0 disables the banked Roll.
  45907. * Value of 1 is equal to the Yaw angle in radians.
  45908. */
  45909. bankedTurnMultiplier: number;
  45910. /**
  45911. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45912. */
  45913. inputs: FlyCameraInputsManager;
  45914. /**
  45915. * Gets the input sensibility for mouse input.
  45916. * Higher values reduce sensitivity.
  45917. */
  45918. get angularSensibility(): number;
  45919. /**
  45920. * Sets the input sensibility for a mouse input.
  45921. * Higher values reduce sensitivity.
  45922. */
  45923. set angularSensibility(value: number);
  45924. /**
  45925. * Get the keys for camera movement forward.
  45926. */
  45927. get keysForward(): number[];
  45928. /**
  45929. * Set the keys for camera movement forward.
  45930. */
  45931. set keysForward(value: number[]);
  45932. /**
  45933. * Get the keys for camera movement backward.
  45934. */
  45935. get keysBackward(): number[];
  45936. set keysBackward(value: number[]);
  45937. /**
  45938. * Get the keys for camera movement up.
  45939. */
  45940. get keysUp(): number[];
  45941. /**
  45942. * Set the keys for camera movement up.
  45943. */
  45944. set keysUp(value: number[]);
  45945. /**
  45946. * Get the keys for camera movement down.
  45947. */
  45948. get keysDown(): number[];
  45949. /**
  45950. * Set the keys for camera movement down.
  45951. */
  45952. set keysDown(value: number[]);
  45953. /**
  45954. * Get the keys for camera movement left.
  45955. */
  45956. get keysLeft(): number[];
  45957. /**
  45958. * Set the keys for camera movement left.
  45959. */
  45960. set keysLeft(value: number[]);
  45961. /**
  45962. * Set the keys for camera movement right.
  45963. */
  45964. get keysRight(): number[];
  45965. /**
  45966. * Set the keys for camera movement right.
  45967. */
  45968. set keysRight(value: number[]);
  45969. /**
  45970. * Event raised when the camera collides with a mesh in the scene.
  45971. */
  45972. onCollide: (collidedMesh: AbstractMesh) => void;
  45973. private _collider;
  45974. private _needMoveForGravity;
  45975. private _oldPosition;
  45976. private _diffPosition;
  45977. private _newPosition;
  45978. /** @hidden */
  45979. _localDirection: Vector3;
  45980. /** @hidden */
  45981. _transformedDirection: Vector3;
  45982. /**
  45983. * Instantiates a FlyCamera.
  45984. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45985. * such as in a 3D Space Shooter or a Flight Simulator.
  45986. * @param name Define the name of the camera in the scene.
  45987. * @param position Define the starting position of the camera in the scene.
  45988. * @param scene Define the scene the camera belongs to.
  45989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45990. */
  45991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45992. /**
  45993. * Attach a control to the HTML DOM element.
  45994. * @param element Defines the element that listens to the input events.
  45995. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45996. */
  45997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45998. /**
  45999. * Detach a control from the HTML DOM element.
  46000. * The camera will stop reacting to that input.
  46001. * @param element Defines the element that listens to the input events.
  46002. */
  46003. detachControl(element: HTMLElement): void;
  46004. private _collisionMask;
  46005. /**
  46006. * Get the mask that the camera ignores in collision events.
  46007. */
  46008. get collisionMask(): number;
  46009. /**
  46010. * Set the mask that the camera ignores in collision events.
  46011. */
  46012. set collisionMask(mask: number);
  46013. /** @hidden */
  46014. _collideWithWorld(displacement: Vector3): void;
  46015. /** @hidden */
  46016. private _onCollisionPositionChange;
  46017. /** @hidden */
  46018. _checkInputs(): void;
  46019. /** @hidden */
  46020. _decideIfNeedsToMove(): boolean;
  46021. /** @hidden */
  46022. _updatePosition(): void;
  46023. /**
  46024. * Restore the Roll to its target value at the rate specified.
  46025. * @param rate - Higher means slower restoring.
  46026. * @hidden
  46027. */
  46028. restoreRoll(rate: number): void;
  46029. /**
  46030. * Destroy the camera and release the current resources held by it.
  46031. */
  46032. dispose(): void;
  46033. /**
  46034. * Get the current object class name.
  46035. * @returns the class name.
  46036. */
  46037. getClassName(): string;
  46038. }
  46039. }
  46040. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46041. import { Nullable } from "babylonjs/types";
  46042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46043. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46044. /**
  46045. * Listen to keyboard events to control the camera.
  46046. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46047. */
  46048. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46049. /**
  46050. * Defines the camera the input is attached to.
  46051. */
  46052. camera: FlyCamera;
  46053. /**
  46054. * The list of keyboard keys used to control the forward move of the camera.
  46055. */
  46056. keysForward: number[];
  46057. /**
  46058. * The list of keyboard keys used to control the backward move of the camera.
  46059. */
  46060. keysBackward: number[];
  46061. /**
  46062. * The list of keyboard keys used to control the forward move of the camera.
  46063. */
  46064. keysUp: number[];
  46065. /**
  46066. * The list of keyboard keys used to control the backward move of the camera.
  46067. */
  46068. keysDown: number[];
  46069. /**
  46070. * The list of keyboard keys used to control the right strafe move of the camera.
  46071. */
  46072. keysRight: number[];
  46073. /**
  46074. * The list of keyboard keys used to control the left strafe move of the camera.
  46075. */
  46076. keysLeft: number[];
  46077. private _keys;
  46078. private _onCanvasBlurObserver;
  46079. private _onKeyboardObserver;
  46080. private _engine;
  46081. private _scene;
  46082. /**
  46083. * Attach the input controls to a specific dom element to get the input from.
  46084. * @param element Defines the element the controls should be listened from
  46085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46086. */
  46087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46088. /**
  46089. * Detach the current controls from the specified dom element.
  46090. * @param element Defines the element to stop listening the inputs from
  46091. */
  46092. detachControl(element: Nullable<HTMLElement>): void;
  46093. /**
  46094. * Gets the class name of the current intput.
  46095. * @returns the class name
  46096. */
  46097. getClassName(): string;
  46098. /** @hidden */
  46099. _onLostFocus(e: FocusEvent): void;
  46100. /**
  46101. * Get the friendly name associated with the input class.
  46102. * @returns the input friendly name
  46103. */
  46104. getSimpleName(): string;
  46105. /**
  46106. * Update the current camera state depending on the inputs that have been used this frame.
  46107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46108. */
  46109. checkInputs(): void;
  46110. }
  46111. }
  46112. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46113. import { Nullable } from "babylonjs/types";
  46114. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46115. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46116. /**
  46117. * Manage the mouse wheel inputs to control a follow camera.
  46118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46119. */
  46120. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46121. /**
  46122. * Defines the camera the input is attached to.
  46123. */
  46124. camera: FollowCamera;
  46125. /**
  46126. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46127. */
  46128. axisControlRadius: boolean;
  46129. /**
  46130. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46131. */
  46132. axisControlHeight: boolean;
  46133. /**
  46134. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46135. */
  46136. axisControlRotation: boolean;
  46137. /**
  46138. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46139. * relation to mouseWheel events.
  46140. */
  46141. wheelPrecision: number;
  46142. /**
  46143. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46144. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46145. */
  46146. wheelDeltaPercentage: number;
  46147. private _wheel;
  46148. private _observer;
  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. /**
  46166. * Get the friendly name associated with the input class.
  46167. * @returns the input friendly name
  46168. */
  46169. getSimpleName(): string;
  46170. }
  46171. }
  46172. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46173. import { Nullable } from "babylonjs/types";
  46174. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46175. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46176. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46177. /**
  46178. * Manage the pointers inputs to control an follow camera.
  46179. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46180. */
  46181. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46182. /**
  46183. * Defines the camera the input is attached to.
  46184. */
  46185. camera: FollowCamera;
  46186. /**
  46187. * Gets the class name of the current input.
  46188. * @returns the class name
  46189. */
  46190. getClassName(): string;
  46191. /**
  46192. * Defines the pointer angular sensibility along the X axis or how fast is
  46193. * the camera rotating.
  46194. * A negative number will reverse the axis direction.
  46195. */
  46196. angularSensibilityX: number;
  46197. /**
  46198. * Defines the pointer angular sensibility along the Y axis or how fast is
  46199. * the camera rotating.
  46200. * A negative number will reverse the axis direction.
  46201. */
  46202. angularSensibilityY: number;
  46203. /**
  46204. * Defines the pointer pinch precision or how fast is the camera zooming.
  46205. * A negative number will reverse the axis direction.
  46206. */
  46207. pinchPrecision: number;
  46208. /**
  46209. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46210. * from 0.
  46211. * It defines the percentage of current camera.radius to use as delta when
  46212. * pinch zoom is used.
  46213. */
  46214. pinchDeltaPercentage: number;
  46215. /**
  46216. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46217. */
  46218. axisXControlRadius: boolean;
  46219. /**
  46220. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46221. */
  46222. axisXControlHeight: boolean;
  46223. /**
  46224. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46225. */
  46226. axisXControlRotation: boolean;
  46227. /**
  46228. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46229. */
  46230. axisYControlRadius: boolean;
  46231. /**
  46232. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46233. */
  46234. axisYControlHeight: boolean;
  46235. /**
  46236. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46237. */
  46238. axisYControlRotation: boolean;
  46239. /**
  46240. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46241. */
  46242. axisPinchControlRadius: boolean;
  46243. /**
  46244. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46245. */
  46246. axisPinchControlHeight: boolean;
  46247. /**
  46248. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46249. */
  46250. axisPinchControlRotation: boolean;
  46251. /**
  46252. * Log error messages if basic misconfiguration has occurred.
  46253. */
  46254. warningEnable: boolean;
  46255. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46256. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46257. private _warningCounter;
  46258. private _warning;
  46259. }
  46260. }
  46261. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46262. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46263. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46264. /**
  46265. * Default Inputs manager for the FollowCamera.
  46266. * It groups all the default supported inputs for ease of use.
  46267. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46268. */
  46269. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46270. /**
  46271. * Instantiates a new FollowCameraInputsManager.
  46272. * @param camera Defines the camera the inputs belong to
  46273. */
  46274. constructor(camera: FollowCamera);
  46275. /**
  46276. * Add keyboard input support to the input manager.
  46277. * @returns the current input manager
  46278. */
  46279. addKeyboard(): FollowCameraInputsManager;
  46280. /**
  46281. * Add mouse wheel input support to the input manager.
  46282. * @returns the current input manager
  46283. */
  46284. addMouseWheel(): FollowCameraInputsManager;
  46285. /**
  46286. * Add pointers input support to the input manager.
  46287. * @returns the current input manager
  46288. */
  46289. addPointers(): FollowCameraInputsManager;
  46290. /**
  46291. * Add orientation input support to the input manager.
  46292. * @returns the current input manager
  46293. */
  46294. addVRDeviceOrientation(): FollowCameraInputsManager;
  46295. }
  46296. }
  46297. declare module "babylonjs/Cameras/followCamera" {
  46298. import { Nullable } from "babylonjs/types";
  46299. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46300. import { Scene } from "babylonjs/scene";
  46301. import { Vector3 } from "babylonjs/Maths/math.vector";
  46302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46303. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46304. /**
  46305. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46306. * an arc rotate version arcFollowCamera are available.
  46307. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46308. */
  46309. export class FollowCamera extends TargetCamera {
  46310. /**
  46311. * Distance the follow camera should follow an object at
  46312. */
  46313. radius: number;
  46314. /**
  46315. * Minimum allowed distance of the camera to the axis of rotation
  46316. * (The camera can not get closer).
  46317. * This can help limiting how the Camera is able to move in the scene.
  46318. */
  46319. lowerRadiusLimit: Nullable<number>;
  46320. /**
  46321. * Maximum allowed distance of the camera to the axis of rotation
  46322. * (The camera can not get further).
  46323. * This can help limiting how the Camera is able to move in the scene.
  46324. */
  46325. upperRadiusLimit: Nullable<number>;
  46326. /**
  46327. * Define a rotation offset between the camera and the object it follows
  46328. */
  46329. rotationOffset: number;
  46330. /**
  46331. * Minimum allowed angle to camera position relative to target object.
  46332. * This can help limiting how the Camera is able to move in the scene.
  46333. */
  46334. lowerRotationOffsetLimit: Nullable<number>;
  46335. /**
  46336. * Maximum allowed angle to camera position relative to target object.
  46337. * This can help limiting how the Camera is able to move in the scene.
  46338. */
  46339. upperRotationOffsetLimit: Nullable<number>;
  46340. /**
  46341. * Define a height offset between the camera and the object it follows.
  46342. * It can help following an object from the top (like a car chaing a plane)
  46343. */
  46344. heightOffset: number;
  46345. /**
  46346. * Minimum allowed height of camera position relative to target object.
  46347. * This can help limiting how the Camera is able to move in the scene.
  46348. */
  46349. lowerHeightOffsetLimit: Nullable<number>;
  46350. /**
  46351. * Maximum allowed height of camera position relative to target object.
  46352. * This can help limiting how the Camera is able to move in the scene.
  46353. */
  46354. upperHeightOffsetLimit: Nullable<number>;
  46355. /**
  46356. * Define how fast the camera can accelerate to follow it s target.
  46357. */
  46358. cameraAcceleration: number;
  46359. /**
  46360. * Define the speed limit of the camera following an object.
  46361. */
  46362. maxCameraSpeed: number;
  46363. /**
  46364. * Define the target of the camera.
  46365. */
  46366. lockedTarget: Nullable<AbstractMesh>;
  46367. /**
  46368. * Defines the input associated with the camera.
  46369. */
  46370. inputs: FollowCameraInputsManager;
  46371. /**
  46372. * Instantiates the follow camera.
  46373. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46374. * @param name Define the name of the camera in the scene
  46375. * @param position Define the position of the camera
  46376. * @param scene Define the scene the camera belong to
  46377. * @param lockedTarget Define the target of the camera
  46378. */
  46379. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46380. private _follow;
  46381. /**
  46382. * Attached controls to the current camera.
  46383. * @param element Defines the element the controls should be listened from
  46384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46385. */
  46386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46387. /**
  46388. * Detach the current controls from the camera.
  46389. * The camera will stop reacting to inputs.
  46390. * @param element Defines the element to stop listening the inputs from
  46391. */
  46392. detachControl(element: HTMLElement): void;
  46393. /** @hidden */
  46394. _checkInputs(): void;
  46395. private _checkLimits;
  46396. /**
  46397. * Gets the camera class name.
  46398. * @returns the class name
  46399. */
  46400. getClassName(): string;
  46401. }
  46402. /**
  46403. * Arc Rotate version of the follow camera.
  46404. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46405. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46406. */
  46407. export class ArcFollowCamera extends TargetCamera {
  46408. /** The longitudinal angle of the camera */
  46409. alpha: number;
  46410. /** The latitudinal angle of the camera */
  46411. beta: number;
  46412. /** The radius of the camera from its target */
  46413. radius: number;
  46414. private _cartesianCoordinates;
  46415. /** Define the camera target (the mesh it should follow) */
  46416. private _meshTarget;
  46417. /**
  46418. * Instantiates a new ArcFollowCamera
  46419. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46420. * @param name Define the name of the camera
  46421. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46422. * @param beta Define the rotation angle of the camera around the elevation axis
  46423. * @param radius Define the radius of the camera from its target point
  46424. * @param target Define the target of the camera
  46425. * @param scene Define the scene the camera belongs to
  46426. */
  46427. constructor(name: string,
  46428. /** The longitudinal angle of the camera */
  46429. alpha: number,
  46430. /** The latitudinal angle of the camera */
  46431. beta: number,
  46432. /** The radius of the camera from its target */
  46433. radius: number,
  46434. /** Define the camera target (the mesh it should follow) */
  46435. target: Nullable<AbstractMesh>, scene: Scene);
  46436. private _follow;
  46437. /** @hidden */
  46438. _checkInputs(): void;
  46439. /**
  46440. * Returns the class name of the object.
  46441. * It is mostly used internally for serialization purposes.
  46442. */
  46443. getClassName(): string;
  46444. }
  46445. }
  46446. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46447. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46448. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46449. import { Nullable } from "babylonjs/types";
  46450. /**
  46451. * Manage the keyboard inputs to control the movement of a follow camera.
  46452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46453. */
  46454. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46455. /**
  46456. * Defines the camera the input is attached to.
  46457. */
  46458. camera: FollowCamera;
  46459. /**
  46460. * Defines the list of key codes associated with the up action (increase heightOffset)
  46461. */
  46462. keysHeightOffsetIncr: number[];
  46463. /**
  46464. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46465. */
  46466. keysHeightOffsetDecr: number[];
  46467. /**
  46468. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46469. */
  46470. keysHeightOffsetModifierAlt: boolean;
  46471. /**
  46472. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46473. */
  46474. keysHeightOffsetModifierCtrl: boolean;
  46475. /**
  46476. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46477. */
  46478. keysHeightOffsetModifierShift: boolean;
  46479. /**
  46480. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46481. */
  46482. keysRotationOffsetIncr: number[];
  46483. /**
  46484. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46485. */
  46486. keysRotationOffsetDecr: number[];
  46487. /**
  46488. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46489. */
  46490. keysRotationOffsetModifierAlt: boolean;
  46491. /**
  46492. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46493. */
  46494. keysRotationOffsetModifierCtrl: boolean;
  46495. /**
  46496. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46497. */
  46498. keysRotationOffsetModifierShift: boolean;
  46499. /**
  46500. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46501. */
  46502. keysRadiusIncr: number[];
  46503. /**
  46504. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46505. */
  46506. keysRadiusDecr: number[];
  46507. /**
  46508. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46509. */
  46510. keysRadiusModifierAlt: boolean;
  46511. /**
  46512. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46513. */
  46514. keysRadiusModifierCtrl: boolean;
  46515. /**
  46516. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46517. */
  46518. keysRadiusModifierShift: boolean;
  46519. /**
  46520. * Defines the rate of change of heightOffset.
  46521. */
  46522. heightSensibility: number;
  46523. /**
  46524. * Defines the rate of change of rotationOffset.
  46525. */
  46526. rotationSensibility: number;
  46527. /**
  46528. * Defines the rate of change of radius.
  46529. */
  46530. radiusSensibility: number;
  46531. private _keys;
  46532. private _ctrlPressed;
  46533. private _altPressed;
  46534. private _shiftPressed;
  46535. private _onCanvasBlurObserver;
  46536. private _onKeyboardObserver;
  46537. private _engine;
  46538. private _scene;
  46539. /**
  46540. * Attach the input controls to a specific dom element to get the input from.
  46541. * @param element Defines the element the controls should be listened from
  46542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46543. */
  46544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46545. /**
  46546. * Detach the current controls from the specified dom element.
  46547. * @param element Defines the element to stop listening the inputs from
  46548. */
  46549. detachControl(element: Nullable<HTMLElement>): void;
  46550. /**
  46551. * Update the current camera state depending on the inputs that have been used this frame.
  46552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46553. */
  46554. checkInputs(): void;
  46555. /**
  46556. * Gets the class name of the current input.
  46557. * @returns the class name
  46558. */
  46559. getClassName(): string;
  46560. /**
  46561. * Get the friendly name associated with the input class.
  46562. * @returns the input friendly name
  46563. */
  46564. getSimpleName(): string;
  46565. /**
  46566. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46567. * allow modification of the heightOffset value.
  46568. */
  46569. private _modifierHeightOffset;
  46570. /**
  46571. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46572. * allow modification of the rotationOffset value.
  46573. */
  46574. private _modifierRotationOffset;
  46575. /**
  46576. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46577. * allow modification of the radius value.
  46578. */
  46579. private _modifierRadius;
  46580. }
  46581. }
  46582. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46583. import { Nullable } from "babylonjs/types";
  46584. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46585. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46586. import { Observable } from "babylonjs/Misc/observable";
  46587. module "babylonjs/Cameras/freeCameraInputsManager" {
  46588. interface FreeCameraInputsManager {
  46589. /**
  46590. * @hidden
  46591. */
  46592. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46593. /**
  46594. * Add orientation input support to the input manager.
  46595. * @returns the current input manager
  46596. */
  46597. addDeviceOrientation(): FreeCameraInputsManager;
  46598. }
  46599. }
  46600. /**
  46601. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46602. * Screen rotation is taken into account.
  46603. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46604. */
  46605. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46606. private _camera;
  46607. private _screenOrientationAngle;
  46608. private _constantTranform;
  46609. private _screenQuaternion;
  46610. private _alpha;
  46611. private _beta;
  46612. private _gamma;
  46613. /**
  46614. * Can be used to detect if a device orientation sensor is available on a device
  46615. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46616. * @returns a promise that will resolve on orientation change
  46617. */
  46618. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46619. /**
  46620. * @hidden
  46621. */
  46622. _onDeviceOrientationChangedObservable: Observable<void>;
  46623. /**
  46624. * Instantiates a new input
  46625. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46626. */
  46627. constructor();
  46628. /**
  46629. * Define the camera controlled by the input.
  46630. */
  46631. get camera(): FreeCamera;
  46632. set camera(camera: FreeCamera);
  46633. /**
  46634. * Attach the input controls to a specific dom element to get the input from.
  46635. * @param element Defines the element the controls should be listened from
  46636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46637. */
  46638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46639. private _orientationChanged;
  46640. private _deviceOrientation;
  46641. /**
  46642. * Detach the current controls from the specified dom element.
  46643. * @param element Defines the element to stop listening the inputs from
  46644. */
  46645. detachControl(element: Nullable<HTMLElement>): void;
  46646. /**
  46647. * Update the current camera state depending on the inputs that have been used this frame.
  46648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46649. */
  46650. checkInputs(): void;
  46651. /**
  46652. * Gets the class name of the current intput.
  46653. * @returns the class name
  46654. */
  46655. getClassName(): string;
  46656. /**
  46657. * Get the friendly name associated with the input class.
  46658. * @returns the input friendly name
  46659. */
  46660. getSimpleName(): string;
  46661. }
  46662. }
  46663. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46664. import { Nullable } from "babylonjs/types";
  46665. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46667. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46668. /**
  46669. * Manage the gamepad inputs to control a free camera.
  46670. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46671. */
  46672. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46673. /**
  46674. * Define the camera the input is attached to.
  46675. */
  46676. camera: FreeCamera;
  46677. /**
  46678. * Define the Gamepad controlling the input
  46679. */
  46680. gamepad: Nullable<Gamepad>;
  46681. /**
  46682. * Defines the gamepad rotation sensiblity.
  46683. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46684. */
  46685. gamepadAngularSensibility: number;
  46686. /**
  46687. * Defines the gamepad move sensiblity.
  46688. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46689. */
  46690. gamepadMoveSensibility: number;
  46691. private _yAxisScale;
  46692. /**
  46693. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46694. */
  46695. get invertYAxis(): boolean;
  46696. set invertYAxis(value: boolean);
  46697. private _onGamepadConnectedObserver;
  46698. private _onGamepadDisconnectedObserver;
  46699. private _cameraTransform;
  46700. private _deltaTransform;
  46701. private _vector3;
  46702. private _vector2;
  46703. /**
  46704. * Attach the input controls to a specific dom element to get the input from.
  46705. * @param element Defines the element the controls should be listened from
  46706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46707. */
  46708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46709. /**
  46710. * Detach the current controls from the specified dom element.
  46711. * @param element Defines the element to stop listening the inputs from
  46712. */
  46713. detachControl(element: Nullable<HTMLElement>): void;
  46714. /**
  46715. * Update the current camera state depending on the inputs that have been used this frame.
  46716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46717. */
  46718. checkInputs(): void;
  46719. /**
  46720. * Gets the class name of the current intput.
  46721. * @returns the class name
  46722. */
  46723. getClassName(): string;
  46724. /**
  46725. * Get the friendly name associated with the input class.
  46726. * @returns the input friendly name
  46727. */
  46728. getSimpleName(): string;
  46729. }
  46730. }
  46731. declare module "babylonjs/Misc/virtualJoystick" {
  46732. import { Nullable } from "babylonjs/types";
  46733. import { Vector3 } from "babylonjs/Maths/math.vector";
  46734. /**
  46735. * Defines the potential axis of a Joystick
  46736. */
  46737. export enum JoystickAxis {
  46738. /** X axis */
  46739. X = 0,
  46740. /** Y axis */
  46741. Y = 1,
  46742. /** Z axis */
  46743. Z = 2
  46744. }
  46745. /**
  46746. * Represents the different customization options available
  46747. * for VirtualJoystick
  46748. */
  46749. interface VirtualJoystickCustomizations {
  46750. /**
  46751. * Size of the joystick's puck
  46752. */
  46753. puckSize: number;
  46754. /**
  46755. * Size of the joystick's container
  46756. */
  46757. containerSize: number;
  46758. /**
  46759. * Color of the joystick && puck
  46760. */
  46761. color: string;
  46762. /**
  46763. * Image URL for the joystick's puck
  46764. */
  46765. puckImage?: string;
  46766. /**
  46767. * Image URL for the joystick's container
  46768. */
  46769. containerImage?: string;
  46770. /**
  46771. * Defines the unmoving position of the joystick container
  46772. */
  46773. position?: {
  46774. x: number;
  46775. y: number;
  46776. };
  46777. /**
  46778. * Defines whether or not the joystick container is always visible
  46779. */
  46780. alwaysVisible: boolean;
  46781. /**
  46782. * Defines whether or not to limit the movement of the puck to the joystick's container
  46783. */
  46784. limitToContainer: boolean;
  46785. }
  46786. /**
  46787. * Class used to define virtual joystick (used in touch mode)
  46788. */
  46789. export class VirtualJoystick {
  46790. /**
  46791. * Gets or sets a boolean indicating that left and right values must be inverted
  46792. */
  46793. reverseLeftRight: boolean;
  46794. /**
  46795. * Gets or sets a boolean indicating that up and down values must be inverted
  46796. */
  46797. reverseUpDown: boolean;
  46798. /**
  46799. * Gets the offset value for the position (ie. the change of the position value)
  46800. */
  46801. deltaPosition: Vector3;
  46802. /**
  46803. * Gets a boolean indicating if the virtual joystick was pressed
  46804. */
  46805. pressed: boolean;
  46806. /**
  46807. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46808. */
  46809. static Canvas: Nullable<HTMLCanvasElement>;
  46810. /**
  46811. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46812. */
  46813. limitToContainer: boolean;
  46814. private static _globalJoystickIndex;
  46815. private static _alwaysVisibleSticks;
  46816. private static vjCanvasContext;
  46817. private static vjCanvasWidth;
  46818. private static vjCanvasHeight;
  46819. private static halfWidth;
  46820. private static _GetDefaultOptions;
  46821. private _action;
  46822. private _axisTargetedByLeftAndRight;
  46823. private _axisTargetedByUpAndDown;
  46824. private _joystickSensibility;
  46825. private _inversedSensibility;
  46826. private _joystickPointerID;
  46827. private _joystickColor;
  46828. private _joystickPointerPos;
  46829. private _joystickPreviousPointerPos;
  46830. private _joystickPointerStartPos;
  46831. private _deltaJoystickVector;
  46832. private _leftJoystick;
  46833. private _touches;
  46834. private _joystickPosition;
  46835. private _alwaysVisible;
  46836. private _puckImage;
  46837. private _containerImage;
  46838. private _joystickPuckSize;
  46839. private _joystickContainerSize;
  46840. private _clearPuckSize;
  46841. private _clearContainerSize;
  46842. private _clearPuckSizeOffset;
  46843. private _clearContainerSizeOffset;
  46844. private _onPointerDownHandlerRef;
  46845. private _onPointerMoveHandlerRef;
  46846. private _onPointerUpHandlerRef;
  46847. private _onResize;
  46848. /**
  46849. * Creates a new virtual joystick
  46850. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46851. * @param customizations Defines the options we want to customize the VirtualJoystick
  46852. */
  46853. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46854. /**
  46855. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46856. * @param newJoystickSensibility defines the new sensibility
  46857. */
  46858. setJoystickSensibility(newJoystickSensibility: number): void;
  46859. private _onPointerDown;
  46860. private _onPointerMove;
  46861. private _onPointerUp;
  46862. /**
  46863. * Change the color of the virtual joystick
  46864. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46865. */
  46866. setJoystickColor(newColor: string): void;
  46867. /**
  46868. * Size of the joystick's container
  46869. */
  46870. set containerSize(newSize: number);
  46871. get containerSize(): number;
  46872. /**
  46873. * Size of the joystick's puck
  46874. */
  46875. set puckSize(newSize: number);
  46876. get puckSize(): number;
  46877. /**
  46878. * Clears the set position of the joystick
  46879. */
  46880. clearPosition(): void;
  46881. /**
  46882. * Defines whether or not the joystick container is always visible
  46883. */
  46884. set alwaysVisible(value: boolean);
  46885. get alwaysVisible(): boolean;
  46886. /**
  46887. * Sets the constant position of the Joystick container
  46888. * @param x X axis coordinate
  46889. * @param y Y axis coordinate
  46890. */
  46891. setPosition(x: number, y: number): void;
  46892. /**
  46893. * Defines a callback to call when the joystick is touched
  46894. * @param action defines the callback
  46895. */
  46896. setActionOnTouch(action: () => any): void;
  46897. /**
  46898. * Defines which axis you'd like to control for left & right
  46899. * @param axis defines the axis to use
  46900. */
  46901. setAxisForLeftRight(axis: JoystickAxis): void;
  46902. /**
  46903. * Defines which axis you'd like to control for up & down
  46904. * @param axis defines the axis to use
  46905. */
  46906. setAxisForUpDown(axis: JoystickAxis): void;
  46907. /**
  46908. * Clears the canvas from the previous puck / container draw
  46909. */
  46910. private _clearPreviousDraw;
  46911. /**
  46912. * Loads `urlPath` to be used for the container's image
  46913. * @param urlPath defines the urlPath of an image to use
  46914. */
  46915. setContainerImage(urlPath: string): void;
  46916. /**
  46917. * Loads `urlPath` to be used for the puck's image
  46918. * @param urlPath defines the urlPath of an image to use
  46919. */
  46920. setPuckImage(urlPath: string): void;
  46921. /**
  46922. * Draws the Virtual Joystick's container
  46923. */
  46924. private _drawContainer;
  46925. /**
  46926. * Draws the Virtual Joystick's puck
  46927. */
  46928. private _drawPuck;
  46929. private _drawVirtualJoystick;
  46930. /**
  46931. * Release internal HTML canvas
  46932. */
  46933. releaseCanvas(): void;
  46934. }
  46935. }
  46936. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46937. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46938. import { Nullable } from "babylonjs/types";
  46939. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46940. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46941. module "babylonjs/Cameras/freeCameraInputsManager" {
  46942. interface FreeCameraInputsManager {
  46943. /**
  46944. * Add virtual joystick input support to the input manager.
  46945. * @returns the current input manager
  46946. */
  46947. addVirtualJoystick(): FreeCameraInputsManager;
  46948. }
  46949. }
  46950. /**
  46951. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46952. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46953. */
  46954. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46955. /**
  46956. * Defines the camera the input is attached to.
  46957. */
  46958. camera: FreeCamera;
  46959. private _leftjoystick;
  46960. private _rightjoystick;
  46961. /**
  46962. * Gets the left stick of the virtual joystick.
  46963. * @returns The virtual Joystick
  46964. */
  46965. getLeftJoystick(): VirtualJoystick;
  46966. /**
  46967. * Gets the right stick of the virtual joystick.
  46968. * @returns The virtual Joystick
  46969. */
  46970. getRightJoystick(): VirtualJoystick;
  46971. /**
  46972. * Update the current camera state depending on the inputs that have been used this frame.
  46973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46974. */
  46975. checkInputs(): void;
  46976. /**
  46977. * Attach the input controls to a specific dom element to get the input from.
  46978. * @param element Defines the element the controls should be listened from
  46979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46980. */
  46981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46982. /**
  46983. * Detach the current controls from the specified dom element.
  46984. * @param element Defines the element to stop listening the inputs from
  46985. */
  46986. detachControl(element: Nullable<HTMLElement>): void;
  46987. /**
  46988. * Gets the class name of the current intput.
  46989. * @returns the class name
  46990. */
  46991. getClassName(): string;
  46992. /**
  46993. * Get the friendly name associated with the input class.
  46994. * @returns the input friendly name
  46995. */
  46996. getSimpleName(): string;
  46997. }
  46998. }
  46999. declare module "babylonjs/Cameras/Inputs/index" {
  47000. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47001. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47002. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47003. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47004. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47005. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47006. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47007. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47008. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47009. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47010. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47011. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47012. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47013. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47014. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47015. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47016. }
  47017. declare module "babylonjs/Cameras/touchCamera" {
  47018. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47019. import { Scene } from "babylonjs/scene";
  47020. import { Vector3 } from "babylonjs/Maths/math.vector";
  47021. /**
  47022. * This represents a FPS type of camera controlled by touch.
  47023. * This is like a universal camera minus the Gamepad controls.
  47024. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47025. */
  47026. export class TouchCamera extends FreeCamera {
  47027. /**
  47028. * Defines the touch sensibility for rotation.
  47029. * The higher the faster.
  47030. */
  47031. get touchAngularSensibility(): number;
  47032. set touchAngularSensibility(value: number);
  47033. /**
  47034. * Defines the touch sensibility for move.
  47035. * The higher the faster.
  47036. */
  47037. get touchMoveSensibility(): number;
  47038. set touchMoveSensibility(value: number);
  47039. /**
  47040. * Instantiates a new touch camera.
  47041. * This represents a FPS type of camera controlled by touch.
  47042. * This is like a universal camera minus the Gamepad controls.
  47043. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47044. * @param name Define the name of the camera in the scene
  47045. * @param position Define the start position of the camera in the scene
  47046. * @param scene Define the scene the camera belongs to
  47047. */
  47048. constructor(name: string, position: Vector3, scene: Scene);
  47049. /**
  47050. * Gets the current object class name.
  47051. * @return the class name
  47052. */
  47053. getClassName(): string;
  47054. /** @hidden */
  47055. _setupInputs(): void;
  47056. }
  47057. }
  47058. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47059. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47060. import { Scene } from "babylonjs/scene";
  47061. import { Vector3 } from "babylonjs/Maths/math.vector";
  47062. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47063. import { Axis } from "babylonjs/Maths/math.axis";
  47064. /**
  47065. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47066. * being tilted forward or back and left or right.
  47067. */
  47068. export class DeviceOrientationCamera extends FreeCamera {
  47069. private _initialQuaternion;
  47070. private _quaternionCache;
  47071. private _tmpDragQuaternion;
  47072. private _disablePointerInputWhenUsingDeviceOrientation;
  47073. /**
  47074. * Creates a new device orientation camera
  47075. * @param name The name of the camera
  47076. * @param position The start position camera
  47077. * @param scene The scene the camera belongs to
  47078. */
  47079. constructor(name: string, position: Vector3, scene: Scene);
  47080. /**
  47081. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47082. */
  47083. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47084. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47085. private _dragFactor;
  47086. /**
  47087. * Enabled turning on the y axis when the orientation sensor is active
  47088. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47089. */
  47090. enableHorizontalDragging(dragFactor?: number): void;
  47091. /**
  47092. * Gets the current instance class name ("DeviceOrientationCamera").
  47093. * This helps avoiding instanceof at run time.
  47094. * @returns the class name
  47095. */
  47096. getClassName(): string;
  47097. /**
  47098. * @hidden
  47099. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47100. */
  47101. _checkInputs(): void;
  47102. /**
  47103. * Reset the camera to its default orientation on the specified axis only.
  47104. * @param axis The axis to reset
  47105. */
  47106. resetToCurrentRotation(axis?: Axis): void;
  47107. }
  47108. }
  47109. declare module "babylonjs/Gamepads/xboxGamepad" {
  47110. import { Observable } from "babylonjs/Misc/observable";
  47111. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47112. /**
  47113. * Defines supported buttons for XBox360 compatible gamepads
  47114. */
  47115. export enum Xbox360Button {
  47116. /** A */
  47117. A = 0,
  47118. /** B */
  47119. B = 1,
  47120. /** X */
  47121. X = 2,
  47122. /** Y */
  47123. Y = 3,
  47124. /** Left button */
  47125. LB = 4,
  47126. /** Right button */
  47127. RB = 5,
  47128. /** Back */
  47129. Back = 8,
  47130. /** Start */
  47131. Start = 9,
  47132. /** Left stick */
  47133. LeftStick = 10,
  47134. /** Right stick */
  47135. RightStick = 11
  47136. }
  47137. /** Defines values for XBox360 DPad */
  47138. export enum Xbox360Dpad {
  47139. /** Up */
  47140. Up = 12,
  47141. /** Down */
  47142. Down = 13,
  47143. /** Left */
  47144. Left = 14,
  47145. /** Right */
  47146. Right = 15
  47147. }
  47148. /**
  47149. * Defines a XBox360 gamepad
  47150. */
  47151. export class Xbox360Pad extends Gamepad {
  47152. private _leftTrigger;
  47153. private _rightTrigger;
  47154. private _onlefttriggerchanged;
  47155. private _onrighttriggerchanged;
  47156. private _onbuttondown;
  47157. private _onbuttonup;
  47158. private _ondpaddown;
  47159. private _ondpadup;
  47160. /** Observable raised when a button is pressed */
  47161. onButtonDownObservable: Observable<Xbox360Button>;
  47162. /** Observable raised when a button is released */
  47163. onButtonUpObservable: Observable<Xbox360Button>;
  47164. /** Observable raised when a pad is pressed */
  47165. onPadDownObservable: Observable<Xbox360Dpad>;
  47166. /** Observable raised when a pad is released */
  47167. onPadUpObservable: Observable<Xbox360Dpad>;
  47168. private _buttonA;
  47169. private _buttonB;
  47170. private _buttonX;
  47171. private _buttonY;
  47172. private _buttonBack;
  47173. private _buttonStart;
  47174. private _buttonLB;
  47175. private _buttonRB;
  47176. private _buttonLeftStick;
  47177. private _buttonRightStick;
  47178. private _dPadUp;
  47179. private _dPadDown;
  47180. private _dPadLeft;
  47181. private _dPadRight;
  47182. private _isXboxOnePad;
  47183. /**
  47184. * Creates a new XBox360 gamepad object
  47185. * @param id defines the id of this gamepad
  47186. * @param index defines its index
  47187. * @param gamepad defines the internal HTML gamepad object
  47188. * @param xboxOne defines if it is a XBox One gamepad
  47189. */
  47190. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47191. /**
  47192. * Defines the callback to call when left trigger is pressed
  47193. * @param callback defines the callback to use
  47194. */
  47195. onlefttriggerchanged(callback: (value: number) => void): void;
  47196. /**
  47197. * Defines the callback to call when right trigger is pressed
  47198. * @param callback defines the callback to use
  47199. */
  47200. onrighttriggerchanged(callback: (value: number) => void): void;
  47201. /**
  47202. * Gets the left trigger value
  47203. */
  47204. get leftTrigger(): number;
  47205. /**
  47206. * Sets the left trigger value
  47207. */
  47208. set leftTrigger(newValue: number);
  47209. /**
  47210. * Gets the right trigger value
  47211. */
  47212. get rightTrigger(): number;
  47213. /**
  47214. * Sets the right trigger value
  47215. */
  47216. set rightTrigger(newValue: number);
  47217. /**
  47218. * Defines the callback to call when a button is pressed
  47219. * @param callback defines the callback to use
  47220. */
  47221. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47222. /**
  47223. * Defines the callback to call when a button is released
  47224. * @param callback defines the callback to use
  47225. */
  47226. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47227. /**
  47228. * Defines the callback to call when a pad is pressed
  47229. * @param callback defines the callback to use
  47230. */
  47231. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47232. /**
  47233. * Defines the callback to call when a pad is released
  47234. * @param callback defines the callback to use
  47235. */
  47236. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47237. private _setButtonValue;
  47238. private _setDPadValue;
  47239. /**
  47240. * Gets the value of the `A` button
  47241. */
  47242. get buttonA(): number;
  47243. /**
  47244. * Sets the value of the `A` button
  47245. */
  47246. set buttonA(value: number);
  47247. /**
  47248. * Gets the value of the `B` button
  47249. */
  47250. get buttonB(): number;
  47251. /**
  47252. * Sets the value of the `B` button
  47253. */
  47254. set buttonB(value: number);
  47255. /**
  47256. * Gets the value of the `X` button
  47257. */
  47258. get buttonX(): number;
  47259. /**
  47260. * Sets the value of the `X` button
  47261. */
  47262. set buttonX(value: number);
  47263. /**
  47264. * Gets the value of the `Y` button
  47265. */
  47266. get buttonY(): number;
  47267. /**
  47268. * Sets the value of the `Y` button
  47269. */
  47270. set buttonY(value: number);
  47271. /**
  47272. * Gets the value of the `Start` button
  47273. */
  47274. get buttonStart(): number;
  47275. /**
  47276. * Sets the value of the `Start` button
  47277. */
  47278. set buttonStart(value: number);
  47279. /**
  47280. * Gets the value of the `Back` button
  47281. */
  47282. get buttonBack(): number;
  47283. /**
  47284. * Sets the value of the `Back` button
  47285. */
  47286. set buttonBack(value: number);
  47287. /**
  47288. * Gets the value of the `Left` button
  47289. */
  47290. get buttonLB(): number;
  47291. /**
  47292. * Sets the value of the `Left` button
  47293. */
  47294. set buttonLB(value: number);
  47295. /**
  47296. * Gets the value of the `Right` button
  47297. */
  47298. get buttonRB(): number;
  47299. /**
  47300. * Sets the value of the `Right` button
  47301. */
  47302. set buttonRB(value: number);
  47303. /**
  47304. * Gets the value of the Left joystick
  47305. */
  47306. get buttonLeftStick(): number;
  47307. /**
  47308. * Sets the value of the Left joystick
  47309. */
  47310. set buttonLeftStick(value: number);
  47311. /**
  47312. * Gets the value of the Right joystick
  47313. */
  47314. get buttonRightStick(): number;
  47315. /**
  47316. * Sets the value of the Right joystick
  47317. */
  47318. set buttonRightStick(value: number);
  47319. /**
  47320. * Gets the value of D-pad up
  47321. */
  47322. get dPadUp(): number;
  47323. /**
  47324. * Sets the value of D-pad up
  47325. */
  47326. set dPadUp(value: number);
  47327. /**
  47328. * Gets the value of D-pad down
  47329. */
  47330. get dPadDown(): number;
  47331. /**
  47332. * Sets the value of D-pad down
  47333. */
  47334. set dPadDown(value: number);
  47335. /**
  47336. * Gets the value of D-pad left
  47337. */
  47338. get dPadLeft(): number;
  47339. /**
  47340. * Sets the value of D-pad left
  47341. */
  47342. set dPadLeft(value: number);
  47343. /**
  47344. * Gets the value of D-pad right
  47345. */
  47346. get dPadRight(): number;
  47347. /**
  47348. * Sets the value of D-pad right
  47349. */
  47350. set dPadRight(value: number);
  47351. /**
  47352. * Force the gamepad to synchronize with device values
  47353. */
  47354. update(): void;
  47355. /**
  47356. * Disposes the gamepad
  47357. */
  47358. dispose(): void;
  47359. }
  47360. }
  47361. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47362. import { Observable } from "babylonjs/Misc/observable";
  47363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47364. /**
  47365. * Defines supported buttons for DualShock compatible gamepads
  47366. */
  47367. export enum DualShockButton {
  47368. /** Cross */
  47369. Cross = 0,
  47370. /** Circle */
  47371. Circle = 1,
  47372. /** Square */
  47373. Square = 2,
  47374. /** Triangle */
  47375. Triangle = 3,
  47376. /** L1 */
  47377. L1 = 4,
  47378. /** R1 */
  47379. R1 = 5,
  47380. /** Share */
  47381. Share = 8,
  47382. /** Options */
  47383. Options = 9,
  47384. /** Left stick */
  47385. LeftStick = 10,
  47386. /** Right stick */
  47387. RightStick = 11
  47388. }
  47389. /** Defines values for DualShock DPad */
  47390. export enum DualShockDpad {
  47391. /** Up */
  47392. Up = 12,
  47393. /** Down */
  47394. Down = 13,
  47395. /** Left */
  47396. Left = 14,
  47397. /** Right */
  47398. Right = 15
  47399. }
  47400. /**
  47401. * Defines a DualShock gamepad
  47402. */
  47403. export class DualShockPad extends Gamepad {
  47404. private _leftTrigger;
  47405. private _rightTrigger;
  47406. private _onlefttriggerchanged;
  47407. private _onrighttriggerchanged;
  47408. private _onbuttondown;
  47409. private _onbuttonup;
  47410. private _ondpaddown;
  47411. private _ondpadup;
  47412. /** Observable raised when a button is pressed */
  47413. onButtonDownObservable: Observable<DualShockButton>;
  47414. /** Observable raised when a button is released */
  47415. onButtonUpObservable: Observable<DualShockButton>;
  47416. /** Observable raised when a pad is pressed */
  47417. onPadDownObservable: Observable<DualShockDpad>;
  47418. /** Observable raised when a pad is released */
  47419. onPadUpObservable: Observable<DualShockDpad>;
  47420. private _buttonCross;
  47421. private _buttonCircle;
  47422. private _buttonSquare;
  47423. private _buttonTriangle;
  47424. private _buttonShare;
  47425. private _buttonOptions;
  47426. private _buttonL1;
  47427. private _buttonR1;
  47428. private _buttonLeftStick;
  47429. private _buttonRightStick;
  47430. private _dPadUp;
  47431. private _dPadDown;
  47432. private _dPadLeft;
  47433. private _dPadRight;
  47434. /**
  47435. * Creates a new DualShock gamepad object
  47436. * @param id defines the id of this gamepad
  47437. * @param index defines its index
  47438. * @param gamepad defines the internal HTML gamepad object
  47439. */
  47440. constructor(id: string, index: number, gamepad: any);
  47441. /**
  47442. * Defines the callback to call when left trigger is pressed
  47443. * @param callback defines the callback to use
  47444. */
  47445. onlefttriggerchanged(callback: (value: number) => void): void;
  47446. /**
  47447. * Defines the callback to call when right trigger is pressed
  47448. * @param callback defines the callback to use
  47449. */
  47450. onrighttriggerchanged(callback: (value: number) => void): void;
  47451. /**
  47452. * Gets the left trigger value
  47453. */
  47454. get leftTrigger(): number;
  47455. /**
  47456. * Sets the left trigger value
  47457. */
  47458. set leftTrigger(newValue: number);
  47459. /**
  47460. * Gets the right trigger value
  47461. */
  47462. get rightTrigger(): number;
  47463. /**
  47464. * Sets the right trigger value
  47465. */
  47466. set rightTrigger(newValue: number);
  47467. /**
  47468. * Defines the callback to call when a button is pressed
  47469. * @param callback defines the callback to use
  47470. */
  47471. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47472. /**
  47473. * Defines the callback to call when a button is released
  47474. * @param callback defines the callback to use
  47475. */
  47476. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47477. /**
  47478. * Defines the callback to call when a pad is pressed
  47479. * @param callback defines the callback to use
  47480. */
  47481. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47482. /**
  47483. * Defines the callback to call when a pad is released
  47484. * @param callback defines the callback to use
  47485. */
  47486. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47487. private _setButtonValue;
  47488. private _setDPadValue;
  47489. /**
  47490. * Gets the value of the `Cross` button
  47491. */
  47492. get buttonCross(): number;
  47493. /**
  47494. * Sets the value of the `Cross` button
  47495. */
  47496. set buttonCross(value: number);
  47497. /**
  47498. * Gets the value of the `Circle` button
  47499. */
  47500. get buttonCircle(): number;
  47501. /**
  47502. * Sets the value of the `Circle` button
  47503. */
  47504. set buttonCircle(value: number);
  47505. /**
  47506. * Gets the value of the `Square` button
  47507. */
  47508. get buttonSquare(): number;
  47509. /**
  47510. * Sets the value of the `Square` button
  47511. */
  47512. set buttonSquare(value: number);
  47513. /**
  47514. * Gets the value of the `Triangle` button
  47515. */
  47516. get buttonTriangle(): number;
  47517. /**
  47518. * Sets the value of the `Triangle` button
  47519. */
  47520. set buttonTriangle(value: number);
  47521. /**
  47522. * Gets the value of the `Options` button
  47523. */
  47524. get buttonOptions(): number;
  47525. /**
  47526. * Sets the value of the `Options` button
  47527. */
  47528. set buttonOptions(value: number);
  47529. /**
  47530. * Gets the value of the `Share` button
  47531. */
  47532. get buttonShare(): number;
  47533. /**
  47534. * Sets the value of the `Share` button
  47535. */
  47536. set buttonShare(value: number);
  47537. /**
  47538. * Gets the value of the `L1` button
  47539. */
  47540. get buttonL1(): number;
  47541. /**
  47542. * Sets the value of the `L1` button
  47543. */
  47544. set buttonL1(value: number);
  47545. /**
  47546. * Gets the value of the `R1` button
  47547. */
  47548. get buttonR1(): number;
  47549. /**
  47550. * Sets the value of the `R1` button
  47551. */
  47552. set buttonR1(value: number);
  47553. /**
  47554. * Gets the value of the Left joystick
  47555. */
  47556. get buttonLeftStick(): number;
  47557. /**
  47558. * Sets the value of the Left joystick
  47559. */
  47560. set buttonLeftStick(value: number);
  47561. /**
  47562. * Gets the value of the Right joystick
  47563. */
  47564. get buttonRightStick(): number;
  47565. /**
  47566. * Sets the value of the Right joystick
  47567. */
  47568. set buttonRightStick(value: number);
  47569. /**
  47570. * Gets the value of D-pad up
  47571. */
  47572. get dPadUp(): number;
  47573. /**
  47574. * Sets the value of D-pad up
  47575. */
  47576. set dPadUp(value: number);
  47577. /**
  47578. * Gets the value of D-pad down
  47579. */
  47580. get dPadDown(): number;
  47581. /**
  47582. * Sets the value of D-pad down
  47583. */
  47584. set dPadDown(value: number);
  47585. /**
  47586. * Gets the value of D-pad left
  47587. */
  47588. get dPadLeft(): number;
  47589. /**
  47590. * Sets the value of D-pad left
  47591. */
  47592. set dPadLeft(value: number);
  47593. /**
  47594. * Gets the value of D-pad right
  47595. */
  47596. get dPadRight(): number;
  47597. /**
  47598. * Sets the value of D-pad right
  47599. */
  47600. set dPadRight(value: number);
  47601. /**
  47602. * Force the gamepad to synchronize with device values
  47603. */
  47604. update(): void;
  47605. /**
  47606. * Disposes the gamepad
  47607. */
  47608. dispose(): void;
  47609. }
  47610. }
  47611. declare module "babylonjs/Gamepads/gamepadManager" {
  47612. import { Observable } from "babylonjs/Misc/observable";
  47613. import { Nullable } from "babylonjs/types";
  47614. import { Scene } from "babylonjs/scene";
  47615. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47616. /**
  47617. * Manager for handling gamepads
  47618. */
  47619. export class GamepadManager {
  47620. private _scene?;
  47621. private _babylonGamepads;
  47622. private _oneGamepadConnected;
  47623. /** @hidden */
  47624. _isMonitoring: boolean;
  47625. private _gamepadEventSupported;
  47626. private _gamepadSupport?;
  47627. /**
  47628. * observable to be triggered when the gamepad controller has been connected
  47629. */
  47630. onGamepadConnectedObservable: Observable<Gamepad>;
  47631. /**
  47632. * observable to be triggered when the gamepad controller has been disconnected
  47633. */
  47634. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47635. private _onGamepadConnectedEvent;
  47636. private _onGamepadDisconnectedEvent;
  47637. /**
  47638. * Initializes the gamepad manager
  47639. * @param _scene BabylonJS scene
  47640. */
  47641. constructor(_scene?: Scene | undefined);
  47642. /**
  47643. * The gamepads in the game pad manager
  47644. */
  47645. get gamepads(): Gamepad[];
  47646. /**
  47647. * Get the gamepad controllers based on type
  47648. * @param type The type of gamepad controller
  47649. * @returns Nullable gamepad
  47650. */
  47651. getGamepadByType(type?: number): Nullable<Gamepad>;
  47652. /**
  47653. * Disposes the gamepad manager
  47654. */
  47655. dispose(): void;
  47656. private _addNewGamepad;
  47657. private _startMonitoringGamepads;
  47658. private _stopMonitoringGamepads;
  47659. /** @hidden */
  47660. _checkGamepadsStatus(): void;
  47661. private _updateGamepadObjects;
  47662. }
  47663. }
  47664. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47665. import { Nullable } from "babylonjs/types";
  47666. import { Scene } from "babylonjs/scene";
  47667. import { ISceneComponent } from "babylonjs/sceneComponent";
  47668. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47669. module "babylonjs/scene" {
  47670. interface Scene {
  47671. /** @hidden */
  47672. _gamepadManager: Nullable<GamepadManager>;
  47673. /**
  47674. * Gets the gamepad manager associated with the scene
  47675. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47676. */
  47677. gamepadManager: GamepadManager;
  47678. }
  47679. }
  47680. module "babylonjs/Cameras/freeCameraInputsManager" {
  47681. /**
  47682. * Interface representing a free camera inputs manager
  47683. */
  47684. interface FreeCameraInputsManager {
  47685. /**
  47686. * Adds gamepad input support to the FreeCameraInputsManager.
  47687. * @returns the FreeCameraInputsManager
  47688. */
  47689. addGamepad(): FreeCameraInputsManager;
  47690. }
  47691. }
  47692. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47693. /**
  47694. * Interface representing an arc rotate camera inputs manager
  47695. */
  47696. interface ArcRotateCameraInputsManager {
  47697. /**
  47698. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47699. * @returns the camera inputs manager
  47700. */
  47701. addGamepad(): ArcRotateCameraInputsManager;
  47702. }
  47703. }
  47704. /**
  47705. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47706. */
  47707. export class GamepadSystemSceneComponent implements ISceneComponent {
  47708. /**
  47709. * The component name helpfull to identify the component in the list of scene components.
  47710. */
  47711. readonly name: string;
  47712. /**
  47713. * The scene the component belongs to.
  47714. */
  47715. scene: Scene;
  47716. /**
  47717. * Creates a new instance of the component for the given scene
  47718. * @param scene Defines the scene to register the component in
  47719. */
  47720. constructor(scene: Scene);
  47721. /**
  47722. * Registers the component in a given scene
  47723. */
  47724. register(): void;
  47725. /**
  47726. * Rebuilds the elements related to this component in case of
  47727. * context lost for instance.
  47728. */
  47729. rebuild(): void;
  47730. /**
  47731. * Disposes the component and the associated ressources
  47732. */
  47733. dispose(): void;
  47734. private _beforeCameraUpdate;
  47735. }
  47736. }
  47737. declare module "babylonjs/Cameras/universalCamera" {
  47738. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47739. import { Scene } from "babylonjs/scene";
  47740. import { Vector3 } from "babylonjs/Maths/math.vector";
  47741. import "babylonjs/Gamepads/gamepadSceneComponent";
  47742. /**
  47743. * 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,
  47744. * which still works and will still be found in many Playgrounds.
  47745. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47746. */
  47747. export class UniversalCamera extends TouchCamera {
  47748. /**
  47749. * Defines the gamepad rotation sensiblity.
  47750. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47751. */
  47752. get gamepadAngularSensibility(): number;
  47753. set gamepadAngularSensibility(value: number);
  47754. /**
  47755. * Defines the gamepad move sensiblity.
  47756. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47757. */
  47758. get gamepadMoveSensibility(): number;
  47759. set gamepadMoveSensibility(value: number);
  47760. /**
  47761. * 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,
  47762. * which still works and will still be found in many Playgrounds.
  47763. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47764. * @param name Define the name of the camera in the scene
  47765. * @param position Define the start position of the camera in the scene
  47766. * @param scene Define the scene the camera belongs to
  47767. */
  47768. constructor(name: string, position: Vector3, scene: Scene);
  47769. /**
  47770. * Gets the current object class name.
  47771. * @return the class name
  47772. */
  47773. getClassName(): string;
  47774. }
  47775. }
  47776. declare module "babylonjs/Cameras/gamepadCamera" {
  47777. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47778. import { Scene } from "babylonjs/scene";
  47779. import { Vector3 } from "babylonjs/Maths/math.vector";
  47780. /**
  47781. * This represents a FPS type of camera. This is only here for back compat purpose.
  47782. * Please use the UniversalCamera instead as both are identical.
  47783. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47784. */
  47785. export class GamepadCamera extends UniversalCamera {
  47786. /**
  47787. * Instantiates a new Gamepad Camera
  47788. * This represents a FPS type of camera. This is only here for back compat purpose.
  47789. * Please use the UniversalCamera instead as both are identical.
  47790. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47791. * @param name Define the name of the camera in the scene
  47792. * @param position Define the start position of the camera in the scene
  47793. * @param scene Define the scene the camera belongs to
  47794. */
  47795. constructor(name: string, position: Vector3, scene: Scene);
  47796. /**
  47797. * Gets the current object class name.
  47798. * @return the class name
  47799. */
  47800. getClassName(): string;
  47801. }
  47802. }
  47803. declare module "babylonjs/Shaders/pass.fragment" {
  47804. /** @hidden */
  47805. export var passPixelShader: {
  47806. name: string;
  47807. shader: string;
  47808. };
  47809. }
  47810. declare module "babylonjs/Shaders/passCube.fragment" {
  47811. /** @hidden */
  47812. export var passCubePixelShader: {
  47813. name: string;
  47814. shader: string;
  47815. };
  47816. }
  47817. declare module "babylonjs/PostProcesses/passPostProcess" {
  47818. import { Nullable } from "babylonjs/types";
  47819. import { Camera } from "babylonjs/Cameras/camera";
  47820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47821. import { Engine } from "babylonjs/Engines/engine";
  47822. import "babylonjs/Shaders/pass.fragment";
  47823. import "babylonjs/Shaders/passCube.fragment";
  47824. import { Scene } from "babylonjs/scene";
  47825. /**
  47826. * PassPostProcess which produces an output the same as it's input
  47827. */
  47828. export class PassPostProcess extends PostProcess {
  47829. /**
  47830. * Gets a string identifying the name of the class
  47831. * @returns "PassPostProcess" string
  47832. */
  47833. getClassName(): string;
  47834. /**
  47835. * Creates the PassPostProcess
  47836. * @param name The name of the effect.
  47837. * @param options The required width/height ratio to downsize to before computing the render pass.
  47838. * @param camera The camera to apply the render pass to.
  47839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47840. * @param engine The engine which the post process will be applied. (default: current engine)
  47841. * @param reusable If the post process can be reused on the same frame. (default: false)
  47842. * @param textureType The type of texture to be used when performing the post processing.
  47843. * @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)
  47844. */
  47845. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47846. /** @hidden */
  47847. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47848. }
  47849. /**
  47850. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47851. */
  47852. export class PassCubePostProcess extends PostProcess {
  47853. private _face;
  47854. /**
  47855. * Gets or sets the cube face to display.
  47856. * * 0 is +X
  47857. * * 1 is -X
  47858. * * 2 is +Y
  47859. * * 3 is -Y
  47860. * * 4 is +Z
  47861. * * 5 is -Z
  47862. */
  47863. get face(): number;
  47864. set face(value: number);
  47865. /**
  47866. * Gets a string identifying the name of the class
  47867. * @returns "PassCubePostProcess" string
  47868. */
  47869. getClassName(): string;
  47870. /**
  47871. * Creates the PassCubePostProcess
  47872. * @param name The name of the effect.
  47873. * @param options The required width/height ratio to downsize to before computing the render pass.
  47874. * @param camera The camera to apply the render pass to.
  47875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47876. * @param engine The engine which the post process will be applied. (default: current engine)
  47877. * @param reusable If the post process can be reused on the same frame. (default: false)
  47878. * @param textureType The type of texture to be used when performing the post processing.
  47879. * @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)
  47880. */
  47881. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47882. /** @hidden */
  47883. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47884. }
  47885. }
  47886. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47887. /** @hidden */
  47888. export var anaglyphPixelShader: {
  47889. name: string;
  47890. shader: string;
  47891. };
  47892. }
  47893. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47894. import { Engine } from "babylonjs/Engines/engine";
  47895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47896. import { Camera } from "babylonjs/Cameras/camera";
  47897. import "babylonjs/Shaders/anaglyph.fragment";
  47898. /**
  47899. * Postprocess used to generate anaglyphic rendering
  47900. */
  47901. export class AnaglyphPostProcess extends PostProcess {
  47902. private _passedProcess;
  47903. /**
  47904. * Gets a string identifying the name of the class
  47905. * @returns "AnaglyphPostProcess" string
  47906. */
  47907. getClassName(): string;
  47908. /**
  47909. * Creates a new AnaglyphPostProcess
  47910. * @param name defines postprocess name
  47911. * @param options defines creation options or target ratio scale
  47912. * @param rigCameras defines cameras using this postprocess
  47913. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47914. * @param engine defines hosting engine
  47915. * @param reusable defines if the postprocess will be reused multiple times per frame
  47916. */
  47917. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47918. }
  47919. }
  47920. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47921. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47922. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47923. import { Scene } from "babylonjs/scene";
  47924. import { Vector3 } from "babylonjs/Maths/math.vector";
  47925. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47926. /**
  47927. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47928. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47929. */
  47930. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47931. /**
  47932. * Creates a new AnaglyphArcRotateCamera
  47933. * @param name defines camera name
  47934. * @param alpha defines alpha angle (in radians)
  47935. * @param beta defines beta angle (in radians)
  47936. * @param radius defines radius
  47937. * @param target defines camera target
  47938. * @param interaxialDistance defines distance between each color axis
  47939. * @param scene defines the hosting scene
  47940. */
  47941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47942. /**
  47943. * Gets camera class name
  47944. * @returns AnaglyphArcRotateCamera
  47945. */
  47946. getClassName(): string;
  47947. }
  47948. }
  47949. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47950. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47951. import { Scene } from "babylonjs/scene";
  47952. import { Vector3 } from "babylonjs/Maths/math.vector";
  47953. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47954. /**
  47955. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47956. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47957. */
  47958. export class AnaglyphFreeCamera extends FreeCamera {
  47959. /**
  47960. * Creates a new AnaglyphFreeCamera
  47961. * @param name defines camera name
  47962. * @param position defines initial position
  47963. * @param interaxialDistance defines distance between each color axis
  47964. * @param scene defines the hosting scene
  47965. */
  47966. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47967. /**
  47968. * Gets camera class name
  47969. * @returns AnaglyphFreeCamera
  47970. */
  47971. getClassName(): string;
  47972. }
  47973. }
  47974. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47975. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47976. import { Scene } from "babylonjs/scene";
  47977. import { Vector3 } from "babylonjs/Maths/math.vector";
  47978. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47979. /**
  47980. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47981. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47982. */
  47983. export class AnaglyphGamepadCamera extends GamepadCamera {
  47984. /**
  47985. * Creates a new AnaglyphGamepadCamera
  47986. * @param name defines camera name
  47987. * @param position defines initial position
  47988. * @param interaxialDistance defines distance between each color axis
  47989. * @param scene defines the hosting scene
  47990. */
  47991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47992. /**
  47993. * Gets camera class name
  47994. * @returns AnaglyphGamepadCamera
  47995. */
  47996. getClassName(): string;
  47997. }
  47998. }
  47999. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48000. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48001. import { Scene } from "babylonjs/scene";
  48002. import { Vector3 } from "babylonjs/Maths/math.vector";
  48003. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48004. /**
  48005. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48006. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48007. */
  48008. export class AnaglyphUniversalCamera extends UniversalCamera {
  48009. /**
  48010. * Creates a new AnaglyphUniversalCamera
  48011. * @param name defines camera name
  48012. * @param position defines initial position
  48013. * @param interaxialDistance defines distance between each color axis
  48014. * @param scene defines the hosting scene
  48015. */
  48016. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48017. /**
  48018. * Gets camera class name
  48019. * @returns AnaglyphUniversalCamera
  48020. */
  48021. getClassName(): string;
  48022. }
  48023. }
  48024. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48025. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48026. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48027. import { Scene } from "babylonjs/scene";
  48028. import { Vector3 } from "babylonjs/Maths/math.vector";
  48029. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48030. /**
  48031. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48032. * @see https://doc.babylonjs.com/features/cameras
  48033. */
  48034. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48035. /**
  48036. * Creates a new StereoscopicArcRotateCamera
  48037. * @param name defines camera name
  48038. * @param alpha defines alpha angle (in radians)
  48039. * @param beta defines beta angle (in radians)
  48040. * @param radius defines radius
  48041. * @param target defines camera target
  48042. * @param interaxialDistance defines distance between each color axis
  48043. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48044. * @param scene defines the hosting scene
  48045. */
  48046. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48047. /**
  48048. * Gets camera class name
  48049. * @returns StereoscopicArcRotateCamera
  48050. */
  48051. getClassName(): string;
  48052. }
  48053. }
  48054. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48055. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48056. import { Scene } from "babylonjs/scene";
  48057. import { Vector3 } from "babylonjs/Maths/math.vector";
  48058. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48059. /**
  48060. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48061. * @see https://doc.babylonjs.com/features/cameras
  48062. */
  48063. export class StereoscopicFreeCamera extends FreeCamera {
  48064. /**
  48065. * Creates a new StereoscopicFreeCamera
  48066. * @param name defines camera name
  48067. * @param position defines initial position
  48068. * @param interaxialDistance defines distance between each color axis
  48069. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48070. * @param scene defines the hosting scene
  48071. */
  48072. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48073. /**
  48074. * Gets camera class name
  48075. * @returns StereoscopicFreeCamera
  48076. */
  48077. getClassName(): string;
  48078. }
  48079. }
  48080. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48081. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48082. import { Scene } from "babylonjs/scene";
  48083. import { Vector3 } from "babylonjs/Maths/math.vector";
  48084. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48085. /**
  48086. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48087. * @see https://doc.babylonjs.com/features/cameras
  48088. */
  48089. export class StereoscopicGamepadCamera extends GamepadCamera {
  48090. /**
  48091. * Creates a new StereoscopicGamepadCamera
  48092. * @param name defines camera name
  48093. * @param position defines initial position
  48094. * @param interaxialDistance defines distance between each color axis
  48095. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48096. * @param scene defines the hosting scene
  48097. */
  48098. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48099. /**
  48100. * Gets camera class name
  48101. * @returns StereoscopicGamepadCamera
  48102. */
  48103. getClassName(): string;
  48104. }
  48105. }
  48106. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48107. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48108. import { Scene } from "babylonjs/scene";
  48109. import { Vector3 } from "babylonjs/Maths/math.vector";
  48110. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48111. /**
  48112. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48113. * @see https://doc.babylonjs.com/features/cameras
  48114. */
  48115. export class StereoscopicUniversalCamera extends UniversalCamera {
  48116. /**
  48117. * Creates a new StereoscopicUniversalCamera
  48118. * @param name defines camera name
  48119. * @param position defines initial position
  48120. * @param interaxialDistance defines distance between each color axis
  48121. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48122. * @param scene defines the hosting scene
  48123. */
  48124. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48125. /**
  48126. * Gets camera class name
  48127. * @returns StereoscopicUniversalCamera
  48128. */
  48129. getClassName(): string;
  48130. }
  48131. }
  48132. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48133. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48134. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48135. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48136. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48137. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48138. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48139. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48140. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48141. }
  48142. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48143. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48144. import { Scene } from "babylonjs/scene";
  48145. import { Vector3 } from "babylonjs/Maths/math.vector";
  48146. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48147. /**
  48148. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48149. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48150. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48151. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48152. */
  48153. export class VirtualJoysticksCamera extends FreeCamera {
  48154. /**
  48155. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48156. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48157. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48158. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48159. * @param name Define the name of the camera in the scene
  48160. * @param position Define the start position of the camera in the scene
  48161. * @param scene Define the scene the camera belongs to
  48162. */
  48163. constructor(name: string, position: Vector3, scene: Scene);
  48164. /**
  48165. * Gets the current object class name.
  48166. * @return the class name
  48167. */
  48168. getClassName(): string;
  48169. }
  48170. }
  48171. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48172. import { Matrix } from "babylonjs/Maths/math.vector";
  48173. /**
  48174. * This represents all the required metrics to create a VR camera.
  48175. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48176. */
  48177. export class VRCameraMetrics {
  48178. /**
  48179. * Define the horizontal resolution off the screen.
  48180. */
  48181. hResolution: number;
  48182. /**
  48183. * Define the vertical resolution off the screen.
  48184. */
  48185. vResolution: number;
  48186. /**
  48187. * Define the horizontal screen size.
  48188. */
  48189. hScreenSize: number;
  48190. /**
  48191. * Define the vertical screen size.
  48192. */
  48193. vScreenSize: number;
  48194. /**
  48195. * Define the vertical screen center position.
  48196. */
  48197. vScreenCenter: number;
  48198. /**
  48199. * Define the distance of the eyes to the screen.
  48200. */
  48201. eyeToScreenDistance: number;
  48202. /**
  48203. * Define the distance between both lenses
  48204. */
  48205. lensSeparationDistance: number;
  48206. /**
  48207. * Define the distance between both viewer's eyes.
  48208. */
  48209. interpupillaryDistance: number;
  48210. /**
  48211. * Define the distortion factor of the VR postprocess.
  48212. * Please, touch with care.
  48213. */
  48214. distortionK: number[];
  48215. /**
  48216. * Define the chromatic aberration correction factors for the VR post process.
  48217. */
  48218. chromaAbCorrection: number[];
  48219. /**
  48220. * Define the scale factor of the post process.
  48221. * The smaller the better but the slower.
  48222. */
  48223. postProcessScaleFactor: number;
  48224. /**
  48225. * Define an offset for the lens center.
  48226. */
  48227. lensCenterOffset: number;
  48228. /**
  48229. * Define if the current vr camera should compensate the distortion of the lense or not.
  48230. */
  48231. compensateDistortion: boolean;
  48232. /**
  48233. * Defines if multiview should be enabled when rendering (Default: false)
  48234. */
  48235. multiviewEnabled: boolean;
  48236. /**
  48237. * Gets the rendering aspect ratio based on the provided resolutions.
  48238. */
  48239. get aspectRatio(): number;
  48240. /**
  48241. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48242. */
  48243. get aspectRatioFov(): number;
  48244. /**
  48245. * @hidden
  48246. */
  48247. get leftHMatrix(): Matrix;
  48248. /**
  48249. * @hidden
  48250. */
  48251. get rightHMatrix(): Matrix;
  48252. /**
  48253. * @hidden
  48254. */
  48255. get leftPreViewMatrix(): Matrix;
  48256. /**
  48257. * @hidden
  48258. */
  48259. get rightPreViewMatrix(): Matrix;
  48260. /**
  48261. * Get the default VRMetrics based on the most generic setup.
  48262. * @returns the default vr metrics
  48263. */
  48264. static GetDefault(): VRCameraMetrics;
  48265. }
  48266. }
  48267. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48268. /** @hidden */
  48269. export var vrDistortionCorrectionPixelShader: {
  48270. name: string;
  48271. shader: string;
  48272. };
  48273. }
  48274. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48275. import { Camera } from "babylonjs/Cameras/camera";
  48276. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48278. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48279. /**
  48280. * VRDistortionCorrectionPostProcess used for mobile VR
  48281. */
  48282. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48283. private _isRightEye;
  48284. private _distortionFactors;
  48285. private _postProcessScaleFactor;
  48286. private _lensCenterOffset;
  48287. private _scaleIn;
  48288. private _scaleFactor;
  48289. private _lensCenter;
  48290. /**
  48291. * Gets a string identifying the name of the class
  48292. * @returns "VRDistortionCorrectionPostProcess" string
  48293. */
  48294. getClassName(): string;
  48295. /**
  48296. * Initializes the VRDistortionCorrectionPostProcess
  48297. * @param name The name of the effect.
  48298. * @param camera The camera to apply the render pass to.
  48299. * @param isRightEye If this is for the right eye distortion
  48300. * @param vrMetrics All the required metrics for the VR camera
  48301. */
  48302. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48303. }
  48304. }
  48305. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48306. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48307. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48308. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48309. import { Scene } from "babylonjs/scene";
  48310. import { Vector3 } from "babylonjs/Maths/math.vector";
  48311. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48312. import "babylonjs/Cameras/RigModes/vrRigMode";
  48313. /**
  48314. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48315. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48316. */
  48317. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48318. /**
  48319. * Creates a new VRDeviceOrientationArcRotateCamera
  48320. * @param name defines camera name
  48321. * @param alpha defines the camera rotation along the logitudinal axis
  48322. * @param beta defines the camera rotation along the latitudinal axis
  48323. * @param radius defines the camera distance from its target
  48324. * @param target defines the camera target
  48325. * @param scene defines the scene the camera belongs to
  48326. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48327. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48328. */
  48329. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48330. /**
  48331. * Gets camera class name
  48332. * @returns VRDeviceOrientationArcRotateCamera
  48333. */
  48334. getClassName(): string;
  48335. }
  48336. }
  48337. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48338. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48339. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48340. import { Scene } from "babylonjs/scene";
  48341. import { Vector3 } from "babylonjs/Maths/math.vector";
  48342. import "babylonjs/Cameras/RigModes/vrRigMode";
  48343. /**
  48344. * Camera used to simulate VR rendering (based on FreeCamera)
  48345. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48346. */
  48347. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48348. /**
  48349. * Creates a new VRDeviceOrientationFreeCamera
  48350. * @param name defines camera name
  48351. * @param position defines the start position of the camera
  48352. * @param scene defines the scene the camera belongs to
  48353. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48354. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48355. */
  48356. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48357. /**
  48358. * Gets camera class name
  48359. * @returns VRDeviceOrientationFreeCamera
  48360. */
  48361. getClassName(): string;
  48362. }
  48363. }
  48364. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48365. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48366. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48367. import { Scene } from "babylonjs/scene";
  48368. import { Vector3 } from "babylonjs/Maths/math.vector";
  48369. import "babylonjs/Gamepads/gamepadSceneComponent";
  48370. /**
  48371. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48372. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48373. */
  48374. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48375. /**
  48376. * Creates a new VRDeviceOrientationGamepadCamera
  48377. * @param name defines camera name
  48378. * @param position defines the start position of the camera
  48379. * @param scene defines the scene the camera belongs to
  48380. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48381. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48382. */
  48383. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48384. /**
  48385. * Gets camera class name
  48386. * @returns VRDeviceOrientationGamepadCamera
  48387. */
  48388. getClassName(): string;
  48389. }
  48390. }
  48391. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48392. import { Scene } from "babylonjs/scene";
  48393. import { Texture } from "babylonjs/Materials/Textures/texture";
  48394. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48395. /**
  48396. * A class extending Texture allowing drawing on a texture
  48397. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48398. */
  48399. export class DynamicTexture extends Texture {
  48400. private _generateMipMaps;
  48401. private _canvas;
  48402. private _context;
  48403. /**
  48404. * Creates a DynamicTexture
  48405. * @param name defines the name of the texture
  48406. * @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
  48407. * @param scene defines the scene where you want the texture
  48408. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48409. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48410. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48411. */
  48412. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48413. /**
  48414. * Get the current class name of the texture useful for serialization or dynamic coding.
  48415. * @returns "DynamicTexture"
  48416. */
  48417. getClassName(): string;
  48418. /**
  48419. * Gets the current state of canRescale
  48420. */
  48421. get canRescale(): boolean;
  48422. private _recreate;
  48423. /**
  48424. * Scales the texture
  48425. * @param ratio the scale factor to apply to both width and height
  48426. */
  48427. scale(ratio: number): void;
  48428. /**
  48429. * Resizes the texture
  48430. * @param width the new width
  48431. * @param height the new height
  48432. */
  48433. scaleTo(width: number, height: number): void;
  48434. /**
  48435. * Gets the context of the canvas used by the texture
  48436. * @returns the canvas context of the dynamic texture
  48437. */
  48438. getContext(): CanvasRenderingContext2D;
  48439. /**
  48440. * Clears the texture
  48441. */
  48442. clear(): void;
  48443. /**
  48444. * Updates the texture
  48445. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48446. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48447. */
  48448. update(invertY?: boolean, premulAlpha?: boolean): void;
  48449. /**
  48450. * Draws text onto the texture
  48451. * @param text defines the text to be drawn
  48452. * @param x defines the placement of the text from the left
  48453. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48454. * @param font defines the font to be used with font-style, font-size, font-name
  48455. * @param color defines the color used for the text
  48456. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48458. * @param update defines whether texture is immediately update (default is true)
  48459. */
  48460. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48461. /**
  48462. * Clones the texture
  48463. * @returns the clone of the texture.
  48464. */
  48465. clone(): DynamicTexture;
  48466. /**
  48467. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48468. * @returns a serialized dynamic texture object
  48469. */
  48470. serialize(): any;
  48471. private _IsCanvasElement;
  48472. /** @hidden */
  48473. _rebuild(): void;
  48474. }
  48475. }
  48476. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48477. import { Scene } from "babylonjs/scene";
  48478. import { Color3 } from "babylonjs/Maths/math.color";
  48479. import { Mesh } from "babylonjs/Meshes/mesh";
  48480. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48481. import { Nullable } from "babylonjs/types";
  48482. /**
  48483. * Class containing static functions to help procedurally build meshes
  48484. */
  48485. export class GroundBuilder {
  48486. /**
  48487. * Creates a ground mesh
  48488. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48489. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48491. * @param name defines the name of the mesh
  48492. * @param options defines the options used to create the mesh
  48493. * @param scene defines the hosting scene
  48494. * @returns the ground mesh
  48495. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48496. */
  48497. static CreateGround(name: string, options: {
  48498. width?: number;
  48499. height?: number;
  48500. subdivisions?: number;
  48501. subdivisionsX?: number;
  48502. subdivisionsY?: number;
  48503. updatable?: boolean;
  48504. }, scene: any): Mesh;
  48505. /**
  48506. * Creates a tiled ground mesh
  48507. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48508. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48509. * * 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
  48510. * * 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
  48511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48512. * @param name defines the name of the mesh
  48513. * @param options defines the options used to create the mesh
  48514. * @param scene defines the hosting scene
  48515. * @returns the tiled ground mesh
  48516. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48517. */
  48518. static CreateTiledGround(name: string, options: {
  48519. xmin: number;
  48520. zmin: number;
  48521. xmax: number;
  48522. zmax: number;
  48523. subdivisions?: {
  48524. w: number;
  48525. h: number;
  48526. };
  48527. precision?: {
  48528. w: number;
  48529. h: number;
  48530. };
  48531. updatable?: boolean;
  48532. }, scene?: Nullable<Scene>): Mesh;
  48533. /**
  48534. * Creates a ground mesh from a height map
  48535. * * The parameter `url` sets the URL of the height map image resource.
  48536. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48537. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48538. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48539. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48540. * * 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.
  48541. * * 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).
  48542. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48544. * @param name defines the name of the mesh
  48545. * @param url defines the url to the height map
  48546. * @param options defines the options used to create the mesh
  48547. * @param scene defines the hosting scene
  48548. * @returns the ground mesh
  48549. * @see https://doc.babylonjs.com/babylon101/height_map
  48550. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48551. */
  48552. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48553. width?: number;
  48554. height?: number;
  48555. subdivisions?: number;
  48556. minHeight?: number;
  48557. maxHeight?: number;
  48558. colorFilter?: Color3;
  48559. alphaFilter?: number;
  48560. updatable?: boolean;
  48561. onReady?: (mesh: GroundMesh) => void;
  48562. }, scene?: Nullable<Scene>): GroundMesh;
  48563. }
  48564. }
  48565. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48566. import { Vector4 } from "babylonjs/Maths/math.vector";
  48567. import { Mesh } from "babylonjs/Meshes/mesh";
  48568. /**
  48569. * Class containing static functions to help procedurally build meshes
  48570. */
  48571. export class TorusBuilder {
  48572. /**
  48573. * Creates a torus mesh
  48574. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48575. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48576. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48580. * @param name defines the name of the mesh
  48581. * @param options defines the options used to create the mesh
  48582. * @param scene defines the hosting scene
  48583. * @returns the torus mesh
  48584. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48585. */
  48586. static CreateTorus(name: string, options: {
  48587. diameter?: number;
  48588. thickness?: number;
  48589. tessellation?: number;
  48590. updatable?: boolean;
  48591. sideOrientation?: number;
  48592. frontUVs?: Vector4;
  48593. backUVs?: Vector4;
  48594. }, scene: any): Mesh;
  48595. }
  48596. }
  48597. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48598. import { Vector4 } from "babylonjs/Maths/math.vector";
  48599. import { Color4 } from "babylonjs/Maths/math.color";
  48600. import { Mesh } from "babylonjs/Meshes/mesh";
  48601. /**
  48602. * Class containing static functions to help procedurally build meshes
  48603. */
  48604. export class CylinderBuilder {
  48605. /**
  48606. * Creates a cylinder or a cone mesh
  48607. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48608. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48609. * * 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.
  48610. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48611. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48612. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48613. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48614. * * 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).
  48615. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48616. * * 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).
  48617. * * 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
  48618. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48619. * * 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
  48620. * * 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.
  48621. * * If `enclose` is false, a ring surface is one element.
  48622. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48623. * * 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
  48624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48627. * @param name defines the name of the mesh
  48628. * @param options defines the options used to create the mesh
  48629. * @param scene defines the hosting scene
  48630. * @returns the cylinder mesh
  48631. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48632. */
  48633. static CreateCylinder(name: string, options: {
  48634. height?: number;
  48635. diameterTop?: number;
  48636. diameterBottom?: number;
  48637. diameter?: number;
  48638. tessellation?: number;
  48639. subdivisions?: number;
  48640. arc?: number;
  48641. faceColors?: Color4[];
  48642. faceUV?: Vector4[];
  48643. updatable?: boolean;
  48644. hasRings?: boolean;
  48645. enclose?: boolean;
  48646. cap?: number;
  48647. sideOrientation?: number;
  48648. frontUVs?: Vector4;
  48649. backUVs?: Vector4;
  48650. }, scene: any): Mesh;
  48651. }
  48652. }
  48653. declare module "babylonjs/XR/webXRTypes" {
  48654. import { Nullable } from "babylonjs/types";
  48655. import { IDisposable } from "babylonjs/scene";
  48656. /**
  48657. * States of the webXR experience
  48658. */
  48659. export enum WebXRState {
  48660. /**
  48661. * Transitioning to being in XR mode
  48662. */
  48663. ENTERING_XR = 0,
  48664. /**
  48665. * Transitioning to non XR mode
  48666. */
  48667. EXITING_XR = 1,
  48668. /**
  48669. * In XR mode and presenting
  48670. */
  48671. IN_XR = 2,
  48672. /**
  48673. * Not entered XR mode
  48674. */
  48675. NOT_IN_XR = 3
  48676. }
  48677. /**
  48678. * Abstraction of the XR render target
  48679. */
  48680. export interface WebXRRenderTarget extends IDisposable {
  48681. /**
  48682. * xrpresent context of the canvas which can be used to display/mirror xr content
  48683. */
  48684. canvasContext: WebGLRenderingContext;
  48685. /**
  48686. * xr layer for the canvas
  48687. */
  48688. xrLayer: Nullable<XRWebGLLayer>;
  48689. /**
  48690. * Initializes the xr layer for the session
  48691. * @param xrSession xr session
  48692. * @returns a promise that will resolve once the XR Layer has been created
  48693. */
  48694. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48695. }
  48696. }
  48697. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48698. import { Nullable } from "babylonjs/types";
  48699. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48700. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48701. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48702. import { Observable } from "babylonjs/Misc/observable";
  48703. /**
  48704. * COnfiguration object for WebXR output canvas
  48705. */
  48706. export class WebXRManagedOutputCanvasOptions {
  48707. /**
  48708. * An optional canvas in case you wish to create it yourself and provide it here.
  48709. * If not provided, a new canvas will be created
  48710. */
  48711. canvasElement?: HTMLCanvasElement;
  48712. /**
  48713. * Options for this XR Layer output
  48714. */
  48715. canvasOptions?: XRWebGLLayerOptions;
  48716. /**
  48717. * CSS styling for a newly created canvas (if not provided)
  48718. */
  48719. newCanvasCssStyle?: string;
  48720. /**
  48721. * Get the default values of the configuration object
  48722. * @param engine defines the engine to use (can be null)
  48723. * @returns default values of this configuration object
  48724. */
  48725. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48726. }
  48727. /**
  48728. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48729. */
  48730. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48731. private _options;
  48732. private _canvas;
  48733. private _engine;
  48734. private _originalCanvasSize;
  48735. /**
  48736. * Rendering context of the canvas which can be used to display/mirror xr content
  48737. */
  48738. canvasContext: WebGLRenderingContext;
  48739. /**
  48740. * xr layer for the canvas
  48741. */
  48742. xrLayer: Nullable<XRWebGLLayer>;
  48743. /**
  48744. * Obseervers registered here will be triggered when the xr layer was initialized
  48745. */
  48746. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48747. /**
  48748. * Initializes the canvas to be added/removed upon entering/exiting xr
  48749. * @param _xrSessionManager The XR Session manager
  48750. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48751. */
  48752. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48753. /**
  48754. * Disposes of the object
  48755. */
  48756. dispose(): void;
  48757. /**
  48758. * Initializes the xr layer for the session
  48759. * @param xrSession xr session
  48760. * @returns a promise that will resolve once the XR Layer has been created
  48761. */
  48762. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48763. private _addCanvas;
  48764. private _removeCanvas;
  48765. private _setCanvasSize;
  48766. private _setManagedOutputCanvas;
  48767. }
  48768. }
  48769. declare module "babylonjs/XR/webXRSessionManager" {
  48770. import { Observable } from "babylonjs/Misc/observable";
  48771. import { Nullable } from "babylonjs/types";
  48772. import { IDisposable, Scene } from "babylonjs/scene";
  48773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48774. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48775. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48776. /**
  48777. * Manages an XRSession to work with Babylon's engine
  48778. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48779. */
  48780. export class WebXRSessionManager implements IDisposable {
  48781. /** The scene which the session should be created for */
  48782. scene: Scene;
  48783. private _referenceSpace;
  48784. private _rttProvider;
  48785. private _sessionEnded;
  48786. private _xrNavigator;
  48787. private baseLayer;
  48788. /**
  48789. * The base reference space from which the session started. good if you want to reset your
  48790. * reference space
  48791. */
  48792. baseReferenceSpace: XRReferenceSpace;
  48793. /**
  48794. * Current XR frame
  48795. */
  48796. currentFrame: Nullable<XRFrame>;
  48797. /** WebXR timestamp updated every frame */
  48798. currentTimestamp: number;
  48799. /**
  48800. * Used just in case of a failure to initialize an immersive session.
  48801. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48802. */
  48803. defaultHeightCompensation: number;
  48804. /**
  48805. * Fires every time a new xrFrame arrives which can be used to update the camera
  48806. */
  48807. onXRFrameObservable: Observable<XRFrame>;
  48808. /**
  48809. * Fires when the reference space changed
  48810. */
  48811. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48812. /**
  48813. * Fires when the xr session is ended either by the device or manually done
  48814. */
  48815. onXRSessionEnded: Observable<any>;
  48816. /**
  48817. * Fires when the xr session is ended either by the device or manually done
  48818. */
  48819. onXRSessionInit: Observable<XRSession>;
  48820. /**
  48821. * Underlying xr session
  48822. */
  48823. session: XRSession;
  48824. /**
  48825. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48826. * or get the offset the player is currently at.
  48827. */
  48828. viewerReferenceSpace: XRReferenceSpace;
  48829. /**
  48830. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48831. * @param scene The scene which the session should be created for
  48832. */
  48833. constructor(
  48834. /** The scene which the session should be created for */
  48835. scene: Scene);
  48836. /**
  48837. * The current reference space used in this session. This reference space can constantly change!
  48838. * It is mainly used to offset the camera's position.
  48839. */
  48840. get referenceSpace(): XRReferenceSpace;
  48841. /**
  48842. * Set a new reference space and triggers the observable
  48843. */
  48844. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48845. /**
  48846. * Disposes of the session manager
  48847. */
  48848. dispose(): void;
  48849. /**
  48850. * Stops the xrSession and restores the render loop
  48851. * @returns Promise which resolves after it exits XR
  48852. */
  48853. exitXRAsync(): Promise<void>;
  48854. /**
  48855. * Gets the correct render target texture to be rendered this frame for this eye
  48856. * @param eye the eye for which to get the render target
  48857. * @returns the render target for the specified eye
  48858. */
  48859. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48860. /**
  48861. * Creates a WebXRRenderTarget object for the XR session
  48862. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48863. * @param options optional options to provide when creating a new render target
  48864. * @returns a WebXR render target to which the session can render
  48865. */
  48866. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48867. /**
  48868. * Initializes the manager
  48869. * After initialization enterXR can be called to start an XR session
  48870. * @returns Promise which resolves after it is initialized
  48871. */
  48872. initializeAsync(): Promise<void>;
  48873. /**
  48874. * Initializes an xr session
  48875. * @param xrSessionMode mode to initialize
  48876. * @param xrSessionInit defines optional and required values to pass to the session builder
  48877. * @returns a promise which will resolve once the session has been initialized
  48878. */
  48879. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48880. /**
  48881. * Checks if a session would be supported for the creation options specified
  48882. * @param sessionMode session mode to check if supported eg. immersive-vr
  48883. * @returns A Promise that resolves to true if supported and false if not
  48884. */
  48885. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48886. /**
  48887. * Resets the reference space to the one started the session
  48888. */
  48889. resetReferenceSpace(): void;
  48890. /**
  48891. * Starts rendering to the xr layer
  48892. */
  48893. runXRRenderLoop(): void;
  48894. /**
  48895. * Sets the reference space on the xr session
  48896. * @param referenceSpaceType space to set
  48897. * @returns a promise that will resolve once the reference space has been set
  48898. */
  48899. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48900. /**
  48901. * Updates the render state of the session
  48902. * @param state state to set
  48903. * @returns a promise that resolves once the render state has been updated
  48904. */
  48905. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48906. /**
  48907. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48908. * @param sessionMode defines the session to test
  48909. * @returns a promise with boolean as final value
  48910. */
  48911. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48912. private _createRenderTargetTexture;
  48913. }
  48914. }
  48915. declare module "babylonjs/XR/webXRCamera" {
  48916. import { Vector3 } from "babylonjs/Maths/math.vector";
  48917. import { Scene } from "babylonjs/scene";
  48918. import { Camera } from "babylonjs/Cameras/camera";
  48919. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48920. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48921. import { Observable } from "babylonjs/Misc/observable";
  48922. /**
  48923. * WebXR Camera which holds the views for the xrSession
  48924. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48925. */
  48926. export class WebXRCamera extends FreeCamera {
  48927. private _xrSessionManager;
  48928. private _firstFrame;
  48929. private _referenceQuaternion;
  48930. private _referencedPosition;
  48931. private _xrInvPositionCache;
  48932. private _xrInvQuaternionCache;
  48933. /**
  48934. * Observable raised before camera teleportation
  48935. */
  48936. onBeforeCameraTeleport: Observable<Vector3>;
  48937. /**
  48938. * Observable raised after camera teleportation
  48939. */
  48940. onAfterCameraTeleport: Observable<Vector3>;
  48941. /**
  48942. * Should position compensation execute on first frame.
  48943. * This is used when copying the position from a native (non XR) camera
  48944. */
  48945. compensateOnFirstFrame: boolean;
  48946. /**
  48947. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48948. * @param name the name of the camera
  48949. * @param scene the scene to add the camera to
  48950. * @param _xrSessionManager a constructed xr session manager
  48951. */
  48952. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48953. /**
  48954. * Return the user's height, unrelated to the current ground.
  48955. * This will be the y position of this camera, when ground level is 0.
  48956. */
  48957. get realWorldHeight(): number;
  48958. /** @hidden */
  48959. _updateForDualEyeDebugging(): void;
  48960. /**
  48961. * Sets this camera's transformation based on a non-vr camera
  48962. * @param otherCamera the non-vr camera to copy the transformation from
  48963. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48964. */
  48965. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48966. /**
  48967. * Gets the current instance class name ("WebXRCamera").
  48968. * @returns the class name
  48969. */
  48970. getClassName(): string;
  48971. private _rotate180;
  48972. private _updateFromXRSession;
  48973. private _updateNumberOfRigCameras;
  48974. private _updateReferenceSpace;
  48975. private _updateReferenceSpaceOffset;
  48976. }
  48977. }
  48978. declare module "babylonjs/XR/webXRFeaturesManager" {
  48979. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48980. import { IDisposable } from "babylonjs/scene";
  48981. /**
  48982. * Defining the interface required for a (webxr) feature
  48983. */
  48984. export interface IWebXRFeature extends IDisposable {
  48985. /**
  48986. * Is this feature attached
  48987. */
  48988. attached: boolean;
  48989. /**
  48990. * Should auto-attach be disabled?
  48991. */
  48992. disableAutoAttach: boolean;
  48993. /**
  48994. * Attach the feature to the session
  48995. * Will usually be called by the features manager
  48996. *
  48997. * @param force should attachment be forced (even when already attached)
  48998. * @returns true if successful.
  48999. */
  49000. attach(force?: boolean): boolean;
  49001. /**
  49002. * Detach the feature from the session
  49003. * Will usually be called by the features manager
  49004. *
  49005. * @returns true if successful.
  49006. */
  49007. detach(): boolean;
  49008. /**
  49009. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49010. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49011. *
  49012. * @returns whether or not the feature is compatible in this environment
  49013. */
  49014. isCompatible(): boolean;
  49015. /**
  49016. * Was this feature disposed;
  49017. */
  49018. isDisposed: boolean;
  49019. /**
  49020. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49021. */
  49022. xrNativeFeatureName?: string;
  49023. /**
  49024. * A list of (Babylon WebXR) features this feature depends on
  49025. */
  49026. dependsOn?: string[];
  49027. }
  49028. /**
  49029. * A list of the currently available features without referencing them
  49030. */
  49031. export class WebXRFeatureName {
  49032. /**
  49033. * The name of the anchor system feature
  49034. */
  49035. static readonly ANCHOR_SYSTEM: string;
  49036. /**
  49037. * The name of the background remover feature
  49038. */
  49039. static readonly BACKGROUND_REMOVER: string;
  49040. /**
  49041. * The name of the hit test feature
  49042. */
  49043. static readonly HIT_TEST: string;
  49044. /**
  49045. * physics impostors for xr controllers feature
  49046. */
  49047. static readonly PHYSICS_CONTROLLERS: string;
  49048. /**
  49049. * The name of the plane detection feature
  49050. */
  49051. static readonly PLANE_DETECTION: string;
  49052. /**
  49053. * The name of the pointer selection feature
  49054. */
  49055. static readonly POINTER_SELECTION: string;
  49056. /**
  49057. * The name of the teleportation feature
  49058. */
  49059. static readonly TELEPORTATION: string;
  49060. /**
  49061. * The name of the feature points feature.
  49062. */
  49063. static readonly FEATURE_POINTS: string;
  49064. /**
  49065. * The name of the hand tracking feature.
  49066. */
  49067. static readonly HAND_TRACKING: string;
  49068. }
  49069. /**
  49070. * Defining the constructor of a feature. Used to register the modules.
  49071. */
  49072. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49073. /**
  49074. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49075. * It is mainly used in AR sessions.
  49076. *
  49077. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49078. */
  49079. export class WebXRFeaturesManager implements IDisposable {
  49080. private _xrSessionManager;
  49081. private static readonly _AvailableFeatures;
  49082. private _features;
  49083. /**
  49084. * constructs a new features manages.
  49085. *
  49086. * @param _xrSessionManager an instance of WebXRSessionManager
  49087. */
  49088. constructor(_xrSessionManager: WebXRSessionManager);
  49089. /**
  49090. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49091. * Mainly used internally.
  49092. *
  49093. * @param featureName the name of the feature to register
  49094. * @param constructorFunction the function used to construct the module
  49095. * @param version the (babylon) version of the module
  49096. * @param stable is that a stable version of this module
  49097. */
  49098. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49099. /**
  49100. * Returns a constructor of a specific feature.
  49101. *
  49102. * @param featureName the name of the feature to construct
  49103. * @param version the version of the feature to load
  49104. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49105. * @param options optional options provided to the module.
  49106. * @returns a function that, when called, will return a new instance of this feature
  49107. */
  49108. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49109. /**
  49110. * Can be used to return the list of features currently registered
  49111. *
  49112. * @returns an Array of available features
  49113. */
  49114. static GetAvailableFeatures(): string[];
  49115. /**
  49116. * Gets the versions available for a specific feature
  49117. * @param featureName the name of the feature
  49118. * @returns an array with the available versions
  49119. */
  49120. static GetAvailableVersions(featureName: string): string[];
  49121. /**
  49122. * Return the latest unstable version of this feature
  49123. * @param featureName the name of the feature to search
  49124. * @returns the version number. if not found will return -1
  49125. */
  49126. static GetLatestVersionOfFeature(featureName: string): number;
  49127. /**
  49128. * Return the latest stable version of this feature
  49129. * @param featureName the name of the feature to search
  49130. * @returns the version number. if not found will return -1
  49131. */
  49132. static GetStableVersionOfFeature(featureName: string): number;
  49133. /**
  49134. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49135. * Can be used during a session to start a feature
  49136. * @param featureName the name of feature to attach
  49137. */
  49138. attachFeature(featureName: string): void;
  49139. /**
  49140. * Can be used inside a session or when the session ends to detach a specific feature
  49141. * @param featureName the name of the feature to detach
  49142. */
  49143. detachFeature(featureName: string): void;
  49144. /**
  49145. * Used to disable an already-enabled feature
  49146. * The feature will be disposed and will be recreated once enabled.
  49147. * @param featureName the feature to disable
  49148. * @returns true if disable was successful
  49149. */
  49150. disableFeature(featureName: string | {
  49151. Name: string;
  49152. }): boolean;
  49153. /**
  49154. * dispose this features manager
  49155. */
  49156. dispose(): void;
  49157. /**
  49158. * 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.
  49159. * 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.
  49160. *
  49161. * @param featureName the name of the feature to load or the class of the feature
  49162. * @param version optional version to load. if not provided the latest version will be enabled
  49163. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49164. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49165. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49166. * @returns a new constructed feature or throws an error if feature not found.
  49167. */
  49168. enableFeature(featureName: string | {
  49169. Name: string;
  49170. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49171. /**
  49172. * get the implementation of an enabled feature.
  49173. * @param featureName the name of the feature to load
  49174. * @returns the feature class, if found
  49175. */
  49176. getEnabledFeature(featureName: string): IWebXRFeature;
  49177. /**
  49178. * Get the list of enabled features
  49179. * @returns an array of enabled features
  49180. */
  49181. getEnabledFeatures(): string[];
  49182. /**
  49183. * This function will exten the session creation configuration object with enabled features.
  49184. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49185. * according to the defined "required" variable, provided during enableFeature call
  49186. * @param xrSessionInit the xr Session init object to extend
  49187. *
  49188. * @returns an extended XRSessionInit object
  49189. */
  49190. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49191. }
  49192. }
  49193. declare module "babylonjs/XR/webXRExperienceHelper" {
  49194. import { Observable } from "babylonjs/Misc/observable";
  49195. import { IDisposable, Scene } from "babylonjs/scene";
  49196. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49197. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49198. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49199. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49200. /**
  49201. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49202. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49203. */
  49204. export class WebXRExperienceHelper implements IDisposable {
  49205. private scene;
  49206. private _nonVRCamera;
  49207. private _originalSceneAutoClear;
  49208. private _supported;
  49209. /**
  49210. * Camera used to render xr content
  49211. */
  49212. camera: WebXRCamera;
  49213. /** A features manager for this xr session */
  49214. featuresManager: WebXRFeaturesManager;
  49215. /**
  49216. * Observers registered here will be triggered after the camera's initial transformation is set
  49217. * This can be used to set a different ground level or an extra rotation.
  49218. *
  49219. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49220. * to the position set after this observable is done executing.
  49221. */
  49222. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49223. /**
  49224. * Fires when the state of the experience helper has changed
  49225. */
  49226. onStateChangedObservable: Observable<WebXRState>;
  49227. /** Session manager used to keep track of xr session */
  49228. sessionManager: WebXRSessionManager;
  49229. /**
  49230. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49231. */
  49232. state: WebXRState;
  49233. /**
  49234. * Creates a WebXRExperienceHelper
  49235. * @param scene The scene the helper should be created in
  49236. */
  49237. private constructor();
  49238. /**
  49239. * Creates the experience helper
  49240. * @param scene the scene to attach the experience helper to
  49241. * @returns a promise for the experience helper
  49242. */
  49243. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49244. /**
  49245. * Disposes of the experience helper
  49246. */
  49247. dispose(): void;
  49248. /**
  49249. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49250. * @param sessionMode options for the XR session
  49251. * @param referenceSpaceType frame of reference of the XR session
  49252. * @param renderTarget the output canvas that will be used to enter XR mode
  49253. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49254. * @returns promise that resolves after xr mode has entered
  49255. */
  49256. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49257. /**
  49258. * Exits XR mode and returns the scene to its original state
  49259. * @returns promise that resolves after xr mode has exited
  49260. */
  49261. exitXRAsync(): Promise<void>;
  49262. private _nonXRToXRCamera;
  49263. private _setState;
  49264. }
  49265. }
  49266. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49267. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49268. import { Observable } from "babylonjs/Misc/observable";
  49269. import { IDisposable } from "babylonjs/scene";
  49270. /**
  49271. * X-Y values for axes in WebXR
  49272. */
  49273. export interface IWebXRMotionControllerAxesValue {
  49274. /**
  49275. * The value of the x axis
  49276. */
  49277. x: number;
  49278. /**
  49279. * The value of the y-axis
  49280. */
  49281. y: number;
  49282. }
  49283. /**
  49284. * changed / previous values for the values of this component
  49285. */
  49286. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49287. /**
  49288. * current (this frame) value
  49289. */
  49290. current: T;
  49291. /**
  49292. * previous (last change) value
  49293. */
  49294. previous: T;
  49295. }
  49296. /**
  49297. * Represents changes in the component between current frame and last values recorded
  49298. */
  49299. export interface IWebXRMotionControllerComponentChanges {
  49300. /**
  49301. * will be populated with previous and current values if axes changed
  49302. */
  49303. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49304. /**
  49305. * will be populated with previous and current values if pressed changed
  49306. */
  49307. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49308. /**
  49309. * will be populated with previous and current values if touched changed
  49310. */
  49311. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49312. /**
  49313. * will be populated with previous and current values if value changed
  49314. */
  49315. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49316. }
  49317. /**
  49318. * This class represents a single component (for example button or thumbstick) of a motion controller
  49319. */
  49320. export class WebXRControllerComponent implements IDisposable {
  49321. /**
  49322. * the id of this component
  49323. */
  49324. id: string;
  49325. /**
  49326. * the type of the component
  49327. */
  49328. type: MotionControllerComponentType;
  49329. private _buttonIndex;
  49330. private _axesIndices;
  49331. private _axes;
  49332. private _changes;
  49333. private _currentValue;
  49334. private _hasChanges;
  49335. private _pressed;
  49336. private _touched;
  49337. /**
  49338. * button component type
  49339. */
  49340. static BUTTON_TYPE: MotionControllerComponentType;
  49341. /**
  49342. * squeeze component type
  49343. */
  49344. static SQUEEZE_TYPE: MotionControllerComponentType;
  49345. /**
  49346. * Thumbstick component type
  49347. */
  49348. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49349. /**
  49350. * Touchpad component type
  49351. */
  49352. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49353. /**
  49354. * trigger component type
  49355. */
  49356. static TRIGGER_TYPE: MotionControllerComponentType;
  49357. /**
  49358. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49359. * the axes data changes
  49360. */
  49361. onAxisValueChangedObservable: Observable<{
  49362. x: number;
  49363. y: number;
  49364. }>;
  49365. /**
  49366. * Observers registered here will be triggered when the state of a button changes
  49367. * State change is either pressed / touched / value
  49368. */
  49369. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49370. /**
  49371. * Creates a new component for a motion controller.
  49372. * It is created by the motion controller itself
  49373. *
  49374. * @param id the id of this component
  49375. * @param type the type of the component
  49376. * @param _buttonIndex index in the buttons array of the gamepad
  49377. * @param _axesIndices indices of the values in the axes array of the gamepad
  49378. */
  49379. constructor(
  49380. /**
  49381. * the id of this component
  49382. */
  49383. id: string,
  49384. /**
  49385. * the type of the component
  49386. */
  49387. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49388. /**
  49389. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49390. */
  49391. get axes(): IWebXRMotionControllerAxesValue;
  49392. /**
  49393. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49394. */
  49395. get changes(): IWebXRMotionControllerComponentChanges;
  49396. /**
  49397. * Return whether or not the component changed the last frame
  49398. */
  49399. get hasChanges(): boolean;
  49400. /**
  49401. * is the button currently pressed
  49402. */
  49403. get pressed(): boolean;
  49404. /**
  49405. * is the button currently touched
  49406. */
  49407. get touched(): boolean;
  49408. /**
  49409. * Get the current value of this component
  49410. */
  49411. get value(): number;
  49412. /**
  49413. * Dispose this component
  49414. */
  49415. dispose(): void;
  49416. /**
  49417. * Are there axes correlating to this component
  49418. * @return true is axes data is available
  49419. */
  49420. isAxes(): boolean;
  49421. /**
  49422. * Is this component a button (hence - pressable)
  49423. * @returns true if can be pressed
  49424. */
  49425. isButton(): boolean;
  49426. /**
  49427. * update this component using the gamepad object it is in. Called on every frame
  49428. * @param nativeController the native gamepad controller object
  49429. */
  49430. update(nativeController: IMinimalMotionControllerObject): void;
  49431. }
  49432. }
  49433. declare module "babylonjs/Loading/sceneLoader" {
  49434. import { Observable } from "babylonjs/Misc/observable";
  49435. import { Nullable } from "babylonjs/types";
  49436. import { Scene } from "babylonjs/scene";
  49437. import { Engine } from "babylonjs/Engines/engine";
  49438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49439. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49440. import { AssetContainer } from "babylonjs/assetContainer";
  49441. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49442. import { Skeleton } from "babylonjs/Bones/skeleton";
  49443. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49444. import { WebRequest } from "babylonjs/Misc/webRequest";
  49445. /**
  49446. * Interface used to represent data loading progression
  49447. */
  49448. export interface ISceneLoaderProgressEvent {
  49449. /**
  49450. * Defines if data length to load can be evaluated
  49451. */
  49452. readonly lengthComputable: boolean;
  49453. /**
  49454. * Defines the loaded data length
  49455. */
  49456. readonly loaded: number;
  49457. /**
  49458. * Defines the data length to load
  49459. */
  49460. readonly total: number;
  49461. }
  49462. /**
  49463. * Interface used by SceneLoader plugins to define supported file extensions
  49464. */
  49465. export interface ISceneLoaderPluginExtensions {
  49466. /**
  49467. * Defines the list of supported extensions
  49468. */
  49469. [extension: string]: {
  49470. isBinary: boolean;
  49471. };
  49472. }
  49473. /**
  49474. * Interface used by SceneLoader plugin factory
  49475. */
  49476. export interface ISceneLoaderPluginFactory {
  49477. /**
  49478. * Defines the name of the factory
  49479. */
  49480. name: string;
  49481. /**
  49482. * Function called to create a new plugin
  49483. * @return the new plugin
  49484. */
  49485. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49486. /**
  49487. * The callback that returns true if the data can be directly loaded.
  49488. * @param data string containing the file data
  49489. * @returns if the data can be loaded directly
  49490. */
  49491. canDirectLoad?(data: string): boolean;
  49492. }
  49493. /**
  49494. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49495. */
  49496. export interface ISceneLoaderPluginBase {
  49497. /**
  49498. * The friendly name of this plugin.
  49499. */
  49500. name: string;
  49501. /**
  49502. * The file extensions supported by this plugin.
  49503. */
  49504. extensions: string | ISceneLoaderPluginExtensions;
  49505. /**
  49506. * The callback called when loading from a url.
  49507. * @param scene scene loading this url
  49508. * @param url url to load
  49509. * @param onSuccess callback called when the file successfully loads
  49510. * @param onProgress callback called while file is loading (if the server supports this mode)
  49511. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49512. * @param onError callback called when the file fails to load
  49513. * @returns a file request object
  49514. */
  49515. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49516. /**
  49517. * The callback called when loading from a file object.
  49518. * @param scene scene loading this file
  49519. * @param file defines the file to load
  49520. * @param onSuccess defines the callback to call when data is loaded
  49521. * @param onProgress defines the callback to call during loading process
  49522. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49523. * @param onError defines the callback to call when an error occurs
  49524. * @returns a file request object
  49525. */
  49526. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49527. /**
  49528. * The callback that returns true if the data can be directly loaded.
  49529. * @param data string containing the file data
  49530. * @returns if the data can be loaded directly
  49531. */
  49532. canDirectLoad?(data: string): boolean;
  49533. /**
  49534. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49535. * @param scene scene loading this data
  49536. * @param data string containing the data
  49537. * @returns data to pass to the plugin
  49538. */
  49539. directLoad?(scene: Scene, data: string): any;
  49540. /**
  49541. * The callback that allows custom handling of the root url based on the response url.
  49542. * @param rootUrl the original root url
  49543. * @param responseURL the response url if available
  49544. * @returns the new root url
  49545. */
  49546. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49547. }
  49548. /**
  49549. * Interface used to define a SceneLoader plugin
  49550. */
  49551. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49552. /**
  49553. * Import meshes into a scene.
  49554. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49555. * @param scene The scene to import into
  49556. * @param data The data to import
  49557. * @param rootUrl The root url for scene and resources
  49558. * @param meshes The meshes array to import into
  49559. * @param particleSystems The particle systems array to import into
  49560. * @param skeletons The skeletons array to import into
  49561. * @param onError The callback when import fails
  49562. * @returns True if successful or false otherwise
  49563. */
  49564. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49565. /**
  49566. * Load into a scene.
  49567. * @param scene The scene to load into
  49568. * @param data The data to import
  49569. * @param rootUrl The root url for scene and resources
  49570. * @param onError The callback when import fails
  49571. * @returns True if successful or false otherwise
  49572. */
  49573. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49574. /**
  49575. * Load into an asset container.
  49576. * @param scene The scene to load into
  49577. * @param data The data to import
  49578. * @param rootUrl The root url for scene and resources
  49579. * @param onError The callback when import fails
  49580. * @returns The loaded asset container
  49581. */
  49582. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49583. }
  49584. /**
  49585. * Interface used to define an async SceneLoader plugin
  49586. */
  49587. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49588. /**
  49589. * Import meshes into a scene.
  49590. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49591. * @param scene The scene to import into
  49592. * @param data The data to import
  49593. * @param rootUrl The root url for scene and resources
  49594. * @param onProgress The callback when the load progresses
  49595. * @param fileName Defines the name of the file to load
  49596. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49597. */
  49598. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49599. meshes: AbstractMesh[];
  49600. particleSystems: IParticleSystem[];
  49601. skeletons: Skeleton[];
  49602. animationGroups: AnimationGroup[];
  49603. }>;
  49604. /**
  49605. * Load into a scene.
  49606. * @param scene The scene to load into
  49607. * @param data The data to import
  49608. * @param rootUrl The root url for scene and resources
  49609. * @param onProgress The callback when the load progresses
  49610. * @param fileName Defines the name of the file to load
  49611. * @returns Nothing
  49612. */
  49613. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49614. /**
  49615. * Load into an asset container.
  49616. * @param scene The scene to load into
  49617. * @param data The data to import
  49618. * @param rootUrl The root url for scene and resources
  49619. * @param onProgress The callback when the load progresses
  49620. * @param fileName Defines the name of the file to load
  49621. * @returns The loaded asset container
  49622. */
  49623. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49624. }
  49625. /**
  49626. * Mode that determines how to handle old animation groups before loading new ones.
  49627. */
  49628. export enum SceneLoaderAnimationGroupLoadingMode {
  49629. /**
  49630. * Reset all old animations to initial state then dispose them.
  49631. */
  49632. Clean = 0,
  49633. /**
  49634. * Stop all old animations.
  49635. */
  49636. Stop = 1,
  49637. /**
  49638. * Restart old animations from first frame.
  49639. */
  49640. Sync = 2,
  49641. /**
  49642. * Old animations remains untouched.
  49643. */
  49644. NoSync = 3
  49645. }
  49646. /**
  49647. * Defines a plugin registered by the SceneLoader
  49648. */
  49649. interface IRegisteredPlugin {
  49650. /**
  49651. * Defines the plugin to use
  49652. */
  49653. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49654. /**
  49655. * Defines if the plugin supports binary data
  49656. */
  49657. isBinary: boolean;
  49658. }
  49659. /**
  49660. * Class used to load scene from various file formats using registered plugins
  49661. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49662. */
  49663. export class SceneLoader {
  49664. /**
  49665. * No logging while loading
  49666. */
  49667. static readonly NO_LOGGING: number;
  49668. /**
  49669. * Minimal logging while loading
  49670. */
  49671. static readonly MINIMAL_LOGGING: number;
  49672. /**
  49673. * Summary logging while loading
  49674. */
  49675. static readonly SUMMARY_LOGGING: number;
  49676. /**
  49677. * Detailled logging while loading
  49678. */
  49679. static readonly DETAILED_LOGGING: number;
  49680. /**
  49681. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49682. */
  49683. static get ForceFullSceneLoadingForIncremental(): boolean;
  49684. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49685. /**
  49686. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49687. */
  49688. static get ShowLoadingScreen(): boolean;
  49689. static set ShowLoadingScreen(value: boolean);
  49690. /**
  49691. * Defines the current logging level (while loading the scene)
  49692. * @ignorenaming
  49693. */
  49694. static get loggingLevel(): number;
  49695. static set loggingLevel(value: number);
  49696. /**
  49697. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49698. */
  49699. static get CleanBoneMatrixWeights(): boolean;
  49700. static set CleanBoneMatrixWeights(value: boolean);
  49701. /**
  49702. * Event raised when a plugin is used to load a scene
  49703. */
  49704. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49705. private static _registeredPlugins;
  49706. private static _showingLoadingScreen;
  49707. /**
  49708. * Gets the default plugin (used to load Babylon files)
  49709. * @returns the .babylon plugin
  49710. */
  49711. static GetDefaultPlugin(): IRegisteredPlugin;
  49712. private static _GetPluginForExtension;
  49713. private static _GetPluginForDirectLoad;
  49714. private static _GetPluginForFilename;
  49715. private static _GetDirectLoad;
  49716. private static _LoadData;
  49717. private static _GetFileInfo;
  49718. /**
  49719. * Gets a plugin that can load the given extension
  49720. * @param extension defines the extension to load
  49721. * @returns a plugin or null if none works
  49722. */
  49723. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49724. /**
  49725. * Gets a boolean indicating that the given extension can be loaded
  49726. * @param extension defines the extension to load
  49727. * @returns true if the extension is supported
  49728. */
  49729. static IsPluginForExtensionAvailable(extension: string): boolean;
  49730. /**
  49731. * Adds a new plugin to the list of registered plugins
  49732. * @param plugin defines the plugin to add
  49733. */
  49734. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49735. /**
  49736. * Import meshes into a scene
  49737. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49738. * @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)
  49739. * @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)
  49740. * @param scene the instance of BABYLON.Scene to append to
  49741. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49742. * @param onProgress a callback with a progress event for each file being loaded
  49743. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49744. * @param pluginExtension the extension used to determine the plugin
  49745. * @returns The loaded plugin
  49746. */
  49747. 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>;
  49748. /**
  49749. * Import meshes into a scene
  49750. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49751. * @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)
  49752. * @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)
  49753. * @param scene the instance of BABYLON.Scene to append to
  49754. * @param onProgress a callback with a progress event for each file being loaded
  49755. * @param pluginExtension the extension used to determine the plugin
  49756. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49757. */
  49758. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49759. meshes: AbstractMesh[];
  49760. particleSystems: IParticleSystem[];
  49761. skeletons: Skeleton[];
  49762. animationGroups: AnimationGroup[];
  49763. }>;
  49764. /**
  49765. * Load a scene
  49766. * @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)
  49767. * @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)
  49768. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49769. * @param onSuccess a callback with the scene when import succeeds
  49770. * @param onProgress a callback with a progress event for each file being loaded
  49771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49772. * @param pluginExtension the extension used to determine the plugin
  49773. * @returns The loaded plugin
  49774. */
  49775. 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>;
  49776. /**
  49777. * Load a scene
  49778. * @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)
  49779. * @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)
  49780. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49781. * @param onProgress a callback with a progress event for each file being loaded
  49782. * @param pluginExtension the extension used to determine the plugin
  49783. * @returns The loaded scene
  49784. */
  49785. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49786. /**
  49787. * Append a scene
  49788. * @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)
  49789. * @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)
  49790. * @param scene is the instance of BABYLON.Scene to append to
  49791. * @param onSuccess a callback with the scene when import succeeds
  49792. * @param onProgress a callback with a progress event for each file being loaded
  49793. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49794. * @param pluginExtension the extension used to determine the plugin
  49795. * @returns The loaded plugin
  49796. */
  49797. 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>;
  49798. /**
  49799. * Append a scene
  49800. * @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)
  49801. * @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)
  49802. * @param scene is the instance of BABYLON.Scene to append to
  49803. * @param onProgress a callback with a progress event for each file being loaded
  49804. * @param pluginExtension the extension used to determine the plugin
  49805. * @returns The given scene
  49806. */
  49807. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49808. /**
  49809. * Load a scene into an asset container
  49810. * @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)
  49811. * @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)
  49812. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49813. * @param onSuccess a callback with the scene when import succeeds
  49814. * @param onProgress a callback with a progress event for each file being loaded
  49815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49816. * @param pluginExtension the extension used to determine the plugin
  49817. * @returns The loaded plugin
  49818. */
  49819. 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>;
  49820. /**
  49821. * Load a scene into an asset container
  49822. * @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)
  49823. * @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)
  49824. * @param scene is the instance of Scene to append to
  49825. * @param onProgress a callback with a progress event for each file being loaded
  49826. * @param pluginExtension the extension used to determine the plugin
  49827. * @returns The loaded asset container
  49828. */
  49829. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49830. /**
  49831. * Import animations from a file into a scene
  49832. * @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)
  49833. * @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)
  49834. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49835. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49836. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49837. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49838. * @param onSuccess a callback with the scene when import succeeds
  49839. * @param onProgress a callback with a progress event for each file being loaded
  49840. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49841. * @param pluginExtension the extension used to determine the plugin
  49842. */
  49843. 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;
  49844. /**
  49845. * Import animations from a file into a scene
  49846. * @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)
  49847. * @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)
  49848. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49849. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49850. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49851. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49852. * @param onSuccess a callback with the scene when import succeeds
  49853. * @param onProgress a callback with a progress event for each file being loaded
  49854. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49855. * @param pluginExtension the extension used to determine the plugin
  49856. * @returns the updated scene with imported animations
  49857. */
  49858. 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>;
  49859. }
  49860. }
  49861. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49862. import { IDisposable, Scene } from "babylonjs/scene";
  49863. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49864. import { Observable } from "babylonjs/Misc/observable";
  49865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49866. import { Nullable } from "babylonjs/types";
  49867. /**
  49868. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49869. */
  49870. export type MotionControllerHandedness = "none" | "left" | "right";
  49871. /**
  49872. * The type of components available in motion controllers.
  49873. * This is not the name of the component.
  49874. */
  49875. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49876. /**
  49877. * The state of a controller component
  49878. */
  49879. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49880. /**
  49881. * The schema of motion controller layout.
  49882. * No object will be initialized using this interface
  49883. * This is used just to define the profile.
  49884. */
  49885. export interface IMotionControllerLayout {
  49886. /**
  49887. * Path to load the assets. Usually relative to the base path
  49888. */
  49889. assetPath: string;
  49890. /**
  49891. * Available components (unsorted)
  49892. */
  49893. components: {
  49894. /**
  49895. * A map of component Ids
  49896. */
  49897. [componentId: string]: {
  49898. /**
  49899. * The type of input the component outputs
  49900. */
  49901. type: MotionControllerComponentType;
  49902. /**
  49903. * The indices of this component in the gamepad object
  49904. */
  49905. gamepadIndices: {
  49906. /**
  49907. * Index of button
  49908. */
  49909. button?: number;
  49910. /**
  49911. * If available, index of x-axis
  49912. */
  49913. xAxis?: number;
  49914. /**
  49915. * If available, index of y-axis
  49916. */
  49917. yAxis?: number;
  49918. };
  49919. /**
  49920. * The mesh's root node name
  49921. */
  49922. rootNodeName: string;
  49923. /**
  49924. * Animation definitions for this model
  49925. */
  49926. visualResponses: {
  49927. [stateKey: string]: {
  49928. /**
  49929. * What property will be animated
  49930. */
  49931. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49932. /**
  49933. * What states influence this visual response
  49934. */
  49935. states: MotionControllerComponentStateType[];
  49936. /**
  49937. * Type of animation - movement or visibility
  49938. */
  49939. valueNodeProperty: "transform" | "visibility";
  49940. /**
  49941. * Base node name to move. Its position will be calculated according to the min and max nodes
  49942. */
  49943. valueNodeName?: string;
  49944. /**
  49945. * Minimum movement node
  49946. */
  49947. minNodeName?: string;
  49948. /**
  49949. * Max movement node
  49950. */
  49951. maxNodeName?: string;
  49952. };
  49953. };
  49954. /**
  49955. * If touch enabled, what is the name of node to display user feedback
  49956. */
  49957. touchPointNodeName?: string;
  49958. };
  49959. };
  49960. /**
  49961. * Is it xr standard mapping or not
  49962. */
  49963. gamepadMapping: "" | "xr-standard";
  49964. /**
  49965. * Base root node of this entire model
  49966. */
  49967. rootNodeName: string;
  49968. /**
  49969. * Defines the main button component id
  49970. */
  49971. selectComponentId: string;
  49972. }
  49973. /**
  49974. * A definition for the layout map in the input profile
  49975. */
  49976. export interface IMotionControllerLayoutMap {
  49977. /**
  49978. * Layouts with handedness type as a key
  49979. */
  49980. [handedness: string]: IMotionControllerLayout;
  49981. }
  49982. /**
  49983. * The XR Input profile schema
  49984. * Profiles can be found here:
  49985. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49986. */
  49987. export interface IMotionControllerProfile {
  49988. /**
  49989. * fallback profiles for this profileId
  49990. */
  49991. fallbackProfileIds: string[];
  49992. /**
  49993. * The layout map, with handedness as key
  49994. */
  49995. layouts: IMotionControllerLayoutMap;
  49996. /**
  49997. * The id of this profile
  49998. * correlates to the profile(s) in the xrInput.profiles array
  49999. */
  50000. profileId: string;
  50001. }
  50002. /**
  50003. * A helper-interface for the 3 meshes needed for controller button animation
  50004. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50005. */
  50006. export interface IMotionControllerButtonMeshMap {
  50007. /**
  50008. * the mesh that defines the pressed value mesh position.
  50009. * This is used to find the max-position of this button
  50010. */
  50011. pressedMesh: AbstractMesh;
  50012. /**
  50013. * the mesh that defines the unpressed value mesh position.
  50014. * This is used to find the min (or initial) position of this button
  50015. */
  50016. unpressedMesh: AbstractMesh;
  50017. /**
  50018. * The mesh that will be changed when value changes
  50019. */
  50020. valueMesh: AbstractMesh;
  50021. }
  50022. /**
  50023. * A helper-interface for the 3 meshes needed for controller axis animation.
  50024. * This will be expanded when touchpad animations are fully supported
  50025. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50026. */
  50027. export interface IMotionControllerMeshMap {
  50028. /**
  50029. * the mesh that defines the maximum value mesh position.
  50030. */
  50031. maxMesh?: AbstractMesh;
  50032. /**
  50033. * the mesh that defines the minimum value mesh position.
  50034. */
  50035. minMesh?: AbstractMesh;
  50036. /**
  50037. * The mesh that will be changed when axis value changes
  50038. */
  50039. valueMesh?: AbstractMesh;
  50040. }
  50041. /**
  50042. * The elements needed for change-detection of the gamepad objects in motion controllers
  50043. */
  50044. export interface IMinimalMotionControllerObject {
  50045. /**
  50046. * Available axes of this controller
  50047. */
  50048. axes: number[];
  50049. /**
  50050. * An array of available buttons
  50051. */
  50052. buttons: Array<{
  50053. /**
  50054. * Value of the button/trigger
  50055. */
  50056. value: number;
  50057. /**
  50058. * If the button/trigger is currently touched
  50059. */
  50060. touched: boolean;
  50061. /**
  50062. * If the button/trigger is currently pressed
  50063. */
  50064. pressed: boolean;
  50065. }>;
  50066. /**
  50067. * EXPERIMENTAL haptic support.
  50068. */
  50069. hapticActuators?: Array<{
  50070. pulse: (value: number, duration: number) => Promise<boolean>;
  50071. }>;
  50072. }
  50073. /**
  50074. * An Abstract Motion controller
  50075. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50076. * Each component has an observable to check for changes in value and state
  50077. */
  50078. export abstract class WebXRAbstractMotionController implements IDisposable {
  50079. protected scene: Scene;
  50080. protected layout: IMotionControllerLayout;
  50081. /**
  50082. * The gamepad object correlating to this controller
  50083. */
  50084. gamepadObject: IMinimalMotionControllerObject;
  50085. /**
  50086. * handedness (left/right/none) of this controller
  50087. */
  50088. handedness: MotionControllerHandedness;
  50089. private _initComponent;
  50090. private _modelReady;
  50091. /**
  50092. * A map of components (WebXRControllerComponent) in this motion controller
  50093. * Components have a ComponentType and can also have both button and axis definitions
  50094. */
  50095. readonly components: {
  50096. [id: string]: WebXRControllerComponent;
  50097. };
  50098. /**
  50099. * Disable the model's animation. Can be set at any time.
  50100. */
  50101. disableAnimation: boolean;
  50102. /**
  50103. * Observers registered here will be triggered when the model of this controller is done loading
  50104. */
  50105. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50106. /**
  50107. * The profile id of this motion controller
  50108. */
  50109. abstract profileId: string;
  50110. /**
  50111. * The root mesh of the model. It is null if the model was not yet initialized
  50112. */
  50113. rootMesh: Nullable<AbstractMesh>;
  50114. /**
  50115. * constructs a new abstract motion controller
  50116. * @param scene the scene to which the model of the controller will be added
  50117. * @param layout The profile layout to load
  50118. * @param gamepadObject The gamepad object correlating to this controller
  50119. * @param handedness handedness (left/right/none) of this controller
  50120. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50121. */
  50122. constructor(scene: Scene, layout: IMotionControllerLayout,
  50123. /**
  50124. * The gamepad object correlating to this controller
  50125. */
  50126. gamepadObject: IMinimalMotionControllerObject,
  50127. /**
  50128. * handedness (left/right/none) of this controller
  50129. */
  50130. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50131. /**
  50132. * Dispose this controller, the model mesh and all its components
  50133. */
  50134. dispose(): void;
  50135. /**
  50136. * Returns all components of specific type
  50137. * @param type the type to search for
  50138. * @return an array of components with this type
  50139. */
  50140. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50141. /**
  50142. * get a component based an its component id as defined in layout.components
  50143. * @param id the id of the component
  50144. * @returns the component correlates to the id or undefined if not found
  50145. */
  50146. getComponent(id: string): WebXRControllerComponent;
  50147. /**
  50148. * Get the list of components available in this motion controller
  50149. * @returns an array of strings correlating to available components
  50150. */
  50151. getComponentIds(): string[];
  50152. /**
  50153. * Get the first component of specific type
  50154. * @param type type of component to find
  50155. * @return a controller component or null if not found
  50156. */
  50157. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50158. /**
  50159. * Get the main (Select) component of this controller as defined in the layout
  50160. * @returns the main component of this controller
  50161. */
  50162. getMainComponent(): WebXRControllerComponent;
  50163. /**
  50164. * Loads the model correlating to this controller
  50165. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50166. * @returns A promise fulfilled with the result of the model loading
  50167. */
  50168. loadModel(): Promise<boolean>;
  50169. /**
  50170. * Update this model using the current XRFrame
  50171. * @param xrFrame the current xr frame to use and update the model
  50172. */
  50173. updateFromXRFrame(xrFrame: XRFrame): void;
  50174. /**
  50175. * Backwards compatibility due to a deeply-integrated typo
  50176. */
  50177. get handness(): XREye;
  50178. /**
  50179. * Pulse (vibrate) this controller
  50180. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50181. * Consecutive calls to this function will cancel the last pulse call
  50182. *
  50183. * @param value the strength of the pulse in 0.0...1.0 range
  50184. * @param duration Duration of the pulse in milliseconds
  50185. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50186. * @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
  50187. */
  50188. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50189. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50190. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50191. /**
  50192. * Moves the axis on the controller mesh based on its current state
  50193. * @param axis the index of the axis
  50194. * @param axisValue the value of the axis which determines the meshes new position
  50195. * @hidden
  50196. */
  50197. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50198. /**
  50199. * Update the model itself with the current frame data
  50200. * @param xrFrame the frame to use for updating the model mesh
  50201. */
  50202. protected updateModel(xrFrame: XRFrame): void;
  50203. /**
  50204. * Get the filename and path for this controller's model
  50205. * @returns a map of filename and path
  50206. */
  50207. protected abstract _getFilenameAndPath(): {
  50208. filename: string;
  50209. path: string;
  50210. };
  50211. /**
  50212. * This function is called before the mesh is loaded. It checks for loading constraints.
  50213. * For example, this function can check if the GLB loader is available
  50214. * If this function returns false, the generic controller will be loaded instead
  50215. * @returns Is the client ready to load the mesh
  50216. */
  50217. protected abstract _getModelLoadingConstraints(): boolean;
  50218. /**
  50219. * This function will be called after the model was successfully loaded and can be used
  50220. * for mesh transformations before it is available for the user
  50221. * @param meshes the loaded meshes
  50222. */
  50223. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50224. /**
  50225. * Set the root mesh for this controller. Important for the WebXR controller class
  50226. * @param meshes the loaded meshes
  50227. */
  50228. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50229. /**
  50230. * A function executed each frame that updates the mesh (if needed)
  50231. * @param xrFrame the current xrFrame
  50232. */
  50233. protected abstract _updateModel(xrFrame: XRFrame): void;
  50234. private _getGenericFilenameAndPath;
  50235. private _getGenericParentMesh;
  50236. }
  50237. }
  50238. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50239. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50241. import { Scene } from "babylonjs/scene";
  50242. /**
  50243. * A generic trigger-only motion controller for WebXR
  50244. */
  50245. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50246. /**
  50247. * Static version of the profile id of this controller
  50248. */
  50249. static ProfileId: string;
  50250. profileId: string;
  50251. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50252. protected _getFilenameAndPath(): {
  50253. filename: string;
  50254. path: string;
  50255. };
  50256. protected _getModelLoadingConstraints(): boolean;
  50257. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50258. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50259. protected _updateModel(): void;
  50260. }
  50261. }
  50262. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50263. import { Vector4 } from "babylonjs/Maths/math.vector";
  50264. import { Mesh } from "babylonjs/Meshes/mesh";
  50265. import { Scene } from "babylonjs/scene";
  50266. import { Nullable } from "babylonjs/types";
  50267. /**
  50268. * Class containing static functions to help procedurally build meshes
  50269. */
  50270. export class SphereBuilder {
  50271. /**
  50272. * Creates a sphere mesh
  50273. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50274. * * 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`)
  50275. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50276. * * 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
  50277. * * 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)
  50278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50281. * @param name defines the name of the mesh
  50282. * @param options defines the options used to create the mesh
  50283. * @param scene defines the hosting scene
  50284. * @returns the sphere mesh
  50285. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50286. */
  50287. static CreateSphere(name: string, options: {
  50288. segments?: number;
  50289. diameter?: number;
  50290. diameterX?: number;
  50291. diameterY?: number;
  50292. diameterZ?: number;
  50293. arc?: number;
  50294. slice?: number;
  50295. sideOrientation?: number;
  50296. frontUVs?: Vector4;
  50297. backUVs?: Vector4;
  50298. updatable?: boolean;
  50299. }, scene?: Nullable<Scene>): Mesh;
  50300. }
  50301. }
  50302. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50304. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50305. import { Scene } from "babylonjs/scene";
  50306. /**
  50307. * A profiled motion controller has its profile loaded from an online repository.
  50308. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50309. */
  50310. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50311. private _repositoryUrl;
  50312. private _buttonMeshMapping;
  50313. private _touchDots;
  50314. /**
  50315. * The profile ID of this controller. Will be populated when the controller initializes.
  50316. */
  50317. profileId: string;
  50318. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50319. dispose(): void;
  50320. protected _getFilenameAndPath(): {
  50321. filename: string;
  50322. path: string;
  50323. };
  50324. protected _getModelLoadingConstraints(): boolean;
  50325. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50326. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50327. protected _updateModel(_xrFrame: XRFrame): void;
  50328. }
  50329. }
  50330. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50331. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50332. import { Scene } from "babylonjs/scene";
  50333. /**
  50334. * A construction function type to create a new controller based on an xrInput object
  50335. */
  50336. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50337. /**
  50338. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50339. *
  50340. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50341. * it should be replaced with auto-loaded controllers.
  50342. *
  50343. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50344. */
  50345. export class WebXRMotionControllerManager {
  50346. private static _AvailableControllers;
  50347. private static _Fallbacks;
  50348. private static _ProfileLoadingPromises;
  50349. private static _ProfilesList;
  50350. /**
  50351. * The base URL of the online controller repository. Can be changed at any time.
  50352. */
  50353. static BaseRepositoryUrl: string;
  50354. /**
  50355. * Which repository gets priority - local or online
  50356. */
  50357. static PrioritizeOnlineRepository: boolean;
  50358. /**
  50359. * Use the online repository, or use only locally-defined controllers
  50360. */
  50361. static UseOnlineRepository: boolean;
  50362. /**
  50363. * Clear the cache used for profile loading and reload when requested again
  50364. */
  50365. static ClearProfilesCache(): void;
  50366. /**
  50367. * Register the default fallbacks.
  50368. * This function is called automatically when this file is imported.
  50369. */
  50370. static DefaultFallbacks(): void;
  50371. /**
  50372. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50373. * @param profileId the profile to which a fallback needs to be found
  50374. * @return an array with corresponding fallback profiles
  50375. */
  50376. static FindFallbackWithProfileId(profileId: string): string[];
  50377. /**
  50378. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50379. * The order of search:
  50380. *
  50381. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50382. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50383. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50384. * 4) return the generic trigger controller if none were found
  50385. *
  50386. * @param xrInput the xrInput to which a new controller is initialized
  50387. * @param scene the scene to which the model will be added
  50388. * @param forceProfile force a certain profile for this controller
  50389. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50390. */
  50391. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50392. /**
  50393. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50394. *
  50395. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50396. *
  50397. * @param type the profile type to register
  50398. * @param constructFunction the function to be called when loading this profile
  50399. */
  50400. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50401. /**
  50402. * Register a fallback to a specific profile.
  50403. * @param profileId the profileId that will receive the fallbacks
  50404. * @param fallbacks A list of fallback profiles
  50405. */
  50406. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50407. /**
  50408. * Will update the list of profiles available in the repository
  50409. * @return a promise that resolves to a map of profiles available online
  50410. */
  50411. static UpdateProfilesList(): Promise<{
  50412. [profile: string]: string;
  50413. }>;
  50414. private static _LoadProfileFromRepository;
  50415. private static _LoadProfilesFromAvailableControllers;
  50416. }
  50417. }
  50418. declare module "babylonjs/XR/webXRInputSource" {
  50419. import { Observable } from "babylonjs/Misc/observable";
  50420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50421. import { Ray } from "babylonjs/Culling/ray";
  50422. import { Scene } from "babylonjs/scene";
  50423. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50424. /**
  50425. * Configuration options for the WebXR controller creation
  50426. */
  50427. export interface IWebXRControllerOptions {
  50428. /**
  50429. * Should the controller mesh be animated when a user interacts with it
  50430. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50431. */
  50432. disableMotionControllerAnimation?: boolean;
  50433. /**
  50434. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50435. */
  50436. doNotLoadControllerMesh?: boolean;
  50437. /**
  50438. * Force a specific controller type for this controller.
  50439. * This can be used when creating your own profile or when testing different controllers
  50440. */
  50441. forceControllerProfile?: string;
  50442. /**
  50443. * Defines a rendering group ID for meshes that will be loaded.
  50444. * This is for the default controllers only.
  50445. */
  50446. renderingGroupId?: number;
  50447. }
  50448. /**
  50449. * Represents an XR controller
  50450. */
  50451. export class WebXRInputSource {
  50452. private _scene;
  50453. /** The underlying input source for the controller */
  50454. inputSource: XRInputSource;
  50455. private _options;
  50456. private _tmpVector;
  50457. private _uniqueId;
  50458. private _disposed;
  50459. /**
  50460. * 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
  50461. */
  50462. grip?: AbstractMesh;
  50463. /**
  50464. * If available, this is the gamepad object related to this controller.
  50465. * Using this object it is possible to get click events and trackpad changes of the
  50466. * webxr controller that is currently being used.
  50467. */
  50468. motionController?: WebXRAbstractMotionController;
  50469. /**
  50470. * Event that fires when the controller is removed/disposed.
  50471. * The object provided as event data is this controller, after associated assets were disposed.
  50472. * uniqueId is still available.
  50473. */
  50474. onDisposeObservable: Observable<WebXRInputSource>;
  50475. /**
  50476. * Will be triggered when the mesh associated with the motion controller is done loading.
  50477. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50478. * A shortened version of controller -> motion controller -> on mesh loaded.
  50479. */
  50480. onMeshLoadedObservable: Observable<AbstractMesh>;
  50481. /**
  50482. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50483. */
  50484. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50485. /**
  50486. * Pointer which can be used to select objects or attach a visible laser to
  50487. */
  50488. pointer: AbstractMesh;
  50489. /**
  50490. * Creates the input source object
  50491. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50492. * @param _scene the scene which the controller should be associated to
  50493. * @param inputSource the underlying input source for the controller
  50494. * @param _options options for this controller creation
  50495. */
  50496. constructor(_scene: Scene,
  50497. /** The underlying input source for the controller */
  50498. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50499. /**
  50500. * Get this controllers unique id
  50501. */
  50502. get uniqueId(): string;
  50503. /**
  50504. * Disposes of the object
  50505. */
  50506. dispose(): void;
  50507. /**
  50508. * Gets a world space ray coming from the pointer or grip
  50509. * @param result the resulting ray
  50510. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50511. */
  50512. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50513. /**
  50514. * Updates the controller pose based on the given XRFrame
  50515. * @param xrFrame xr frame to update the pose with
  50516. * @param referenceSpace reference space to use
  50517. */
  50518. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50519. }
  50520. }
  50521. declare module "babylonjs/XR/webXRInput" {
  50522. import { Observable } from "babylonjs/Misc/observable";
  50523. import { IDisposable } from "babylonjs/scene";
  50524. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50525. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50526. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50527. /**
  50528. * The schema for initialization options of the XR Input class
  50529. */
  50530. export interface IWebXRInputOptions {
  50531. /**
  50532. * If set to true no model will be automatically loaded
  50533. */
  50534. doNotLoadControllerMeshes?: boolean;
  50535. /**
  50536. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50537. * If not found, the xr input profile data will be used.
  50538. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50539. */
  50540. forceInputProfile?: string;
  50541. /**
  50542. * Do not send a request to the controller repository to load the profile.
  50543. *
  50544. * Instead, use the controllers available in babylon itself.
  50545. */
  50546. disableOnlineControllerRepository?: boolean;
  50547. /**
  50548. * A custom URL for the controllers repository
  50549. */
  50550. customControllersRepositoryURL?: string;
  50551. /**
  50552. * Should the controller model's components not move according to the user input
  50553. */
  50554. disableControllerAnimation?: boolean;
  50555. /**
  50556. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50557. */
  50558. controllerOptions?: IWebXRControllerOptions;
  50559. }
  50560. /**
  50561. * XR input used to track XR inputs such as controllers/rays
  50562. */
  50563. export class WebXRInput implements IDisposable {
  50564. /**
  50565. * the xr session manager for this session
  50566. */
  50567. xrSessionManager: WebXRSessionManager;
  50568. /**
  50569. * the WebXR camera for this session. Mainly used for teleportation
  50570. */
  50571. xrCamera: WebXRCamera;
  50572. private readonly options;
  50573. /**
  50574. * XR controllers being tracked
  50575. */
  50576. controllers: Array<WebXRInputSource>;
  50577. private _frameObserver;
  50578. private _sessionEndedObserver;
  50579. private _sessionInitObserver;
  50580. /**
  50581. * Event when a controller has been connected/added
  50582. */
  50583. onControllerAddedObservable: Observable<WebXRInputSource>;
  50584. /**
  50585. * Event when a controller has been removed/disconnected
  50586. */
  50587. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50588. /**
  50589. * Initializes the WebXRInput
  50590. * @param xrSessionManager the xr session manager for this session
  50591. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50592. * @param options = initialization options for this xr input
  50593. */
  50594. constructor(
  50595. /**
  50596. * the xr session manager for this session
  50597. */
  50598. xrSessionManager: WebXRSessionManager,
  50599. /**
  50600. * the WebXR camera for this session. Mainly used for teleportation
  50601. */
  50602. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50603. private _onInputSourcesChange;
  50604. private _addAndRemoveControllers;
  50605. /**
  50606. * Disposes of the object
  50607. */
  50608. dispose(): void;
  50609. }
  50610. }
  50611. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50612. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50613. import { Observable, EventState } from "babylonjs/Misc/observable";
  50614. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50615. /**
  50616. * This is the base class for all WebXR features.
  50617. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50618. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50619. */
  50620. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50621. protected _xrSessionManager: WebXRSessionManager;
  50622. private _attached;
  50623. private _removeOnDetach;
  50624. /**
  50625. * Is this feature disposed?
  50626. */
  50627. isDisposed: boolean;
  50628. /**
  50629. * Should auto-attach be disabled?
  50630. */
  50631. disableAutoAttach: boolean;
  50632. /**
  50633. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50634. */
  50635. xrNativeFeatureName: string;
  50636. /**
  50637. * Construct a new (abstract) WebXR feature
  50638. * @param _xrSessionManager the xr session manager for this feature
  50639. */
  50640. constructor(_xrSessionManager: WebXRSessionManager);
  50641. /**
  50642. * Is this feature attached
  50643. */
  50644. get attached(): boolean;
  50645. /**
  50646. * attach this feature
  50647. *
  50648. * @param force should attachment be forced (even when already attached)
  50649. * @returns true if successful, false is failed or already attached
  50650. */
  50651. attach(force?: boolean): boolean;
  50652. /**
  50653. * detach this feature.
  50654. *
  50655. * @returns true if successful, false if failed or already detached
  50656. */
  50657. detach(): boolean;
  50658. /**
  50659. * Dispose this feature and all of the resources attached
  50660. */
  50661. dispose(): void;
  50662. /**
  50663. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50664. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50665. *
  50666. * @returns whether or not the feature is compatible in this environment
  50667. */
  50668. isCompatible(): boolean;
  50669. /**
  50670. * This is used to register callbacks that will automatically be removed when detach is called.
  50671. * @param observable the observable to which the observer will be attached
  50672. * @param callback the callback to register
  50673. */
  50674. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50675. /**
  50676. * Code in this function will be executed on each xrFrame received from the browser.
  50677. * This function will not execute after the feature is detached.
  50678. * @param _xrFrame the current frame
  50679. */
  50680. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50681. }
  50682. }
  50683. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50684. import { IDisposable, Scene } from "babylonjs/scene";
  50685. import { Nullable } from "babylonjs/types";
  50686. import { Observable } from "babylonjs/Misc/observable";
  50687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50688. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50689. import { Camera } from "babylonjs/Cameras/camera";
  50690. /**
  50691. * Renders a layer on top of an existing scene
  50692. */
  50693. export class UtilityLayerRenderer implements IDisposable {
  50694. /** the original scene that will be rendered on top of */
  50695. originalScene: Scene;
  50696. private _pointerCaptures;
  50697. private _lastPointerEvents;
  50698. private static _DefaultUtilityLayer;
  50699. private static _DefaultKeepDepthUtilityLayer;
  50700. private _sharedGizmoLight;
  50701. private _renderCamera;
  50702. /**
  50703. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50704. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50705. * @returns the camera that is used when rendering the utility layer
  50706. */
  50707. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50708. /**
  50709. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50710. * @param cam the camera that should be used when rendering the utility layer
  50711. */
  50712. setRenderCamera(cam: Nullable<Camera>): void;
  50713. /**
  50714. * @hidden
  50715. * Light which used by gizmos to get light shading
  50716. */
  50717. _getSharedGizmoLight(): HemisphericLight;
  50718. /**
  50719. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50720. */
  50721. pickUtilitySceneFirst: boolean;
  50722. /**
  50723. * 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)
  50724. */
  50725. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50726. /**
  50727. * 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)
  50728. */
  50729. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50730. /**
  50731. * The scene that is rendered on top of the original scene
  50732. */
  50733. utilityLayerScene: Scene;
  50734. /**
  50735. * If the utility layer should automatically be rendered on top of existing scene
  50736. */
  50737. shouldRender: boolean;
  50738. /**
  50739. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50740. */
  50741. onlyCheckPointerDownEvents: boolean;
  50742. /**
  50743. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50744. */
  50745. processAllEvents: boolean;
  50746. /**
  50747. * Observable raised when the pointer move from the utility layer scene to the main scene
  50748. */
  50749. onPointerOutObservable: Observable<number>;
  50750. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50751. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50752. private _afterRenderObserver;
  50753. private _sceneDisposeObserver;
  50754. private _originalPointerObserver;
  50755. /**
  50756. * Instantiates a UtilityLayerRenderer
  50757. * @param originalScene the original scene that will be rendered on top of
  50758. * @param handleEvents boolean indicating if the utility layer should handle events
  50759. */
  50760. constructor(
  50761. /** the original scene that will be rendered on top of */
  50762. originalScene: Scene, handleEvents?: boolean);
  50763. private _notifyObservers;
  50764. /**
  50765. * Renders the utility layers scene on top of the original scene
  50766. */
  50767. render(): void;
  50768. /**
  50769. * Disposes of the renderer
  50770. */
  50771. dispose(): void;
  50772. private _updateCamera;
  50773. }
  50774. }
  50775. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50776. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50778. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50779. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50780. import { Scene } from "babylonjs/scene";
  50781. import { Nullable } from "babylonjs/types";
  50782. import { Color3 } from "babylonjs/Maths/math.color";
  50783. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50784. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50785. /**
  50786. * Options interface for the pointer selection module
  50787. */
  50788. export interface IWebXRControllerPointerSelectionOptions {
  50789. /**
  50790. * if provided, this scene will be used to render meshes.
  50791. */
  50792. customUtilityLayerScene?: Scene;
  50793. /**
  50794. * 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)
  50795. * If not disabled, the last picked point will be used to execute a pointer up event
  50796. * If disabled, pointer up event will be triggered right after the pointer down event.
  50797. * Used in screen and gaze target ray mode only
  50798. */
  50799. disablePointerUpOnTouchOut: boolean;
  50800. /**
  50801. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50802. */
  50803. forceGazeMode: boolean;
  50804. /**
  50805. * 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
  50806. * to start a new countdown to the pointer down event.
  50807. * Defaults to 1.
  50808. */
  50809. gazeModePointerMovedFactor?: number;
  50810. /**
  50811. * Different button type to use instead of the main component
  50812. */
  50813. overrideButtonId?: string;
  50814. /**
  50815. * use this rendering group id for the meshes (optional)
  50816. */
  50817. renderingGroupId?: number;
  50818. /**
  50819. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50820. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50821. * 3000 means 3 seconds between pointing at something and selecting it
  50822. */
  50823. timeToSelect?: number;
  50824. /**
  50825. * Should meshes created here be added to a utility layer or the main scene
  50826. */
  50827. useUtilityLayer?: boolean;
  50828. /**
  50829. * Optional WebXR camera to be used for gaze selection
  50830. */
  50831. gazeCamera?: WebXRCamera;
  50832. /**
  50833. * the xr input to use with this pointer selection
  50834. */
  50835. xrInput: WebXRInput;
  50836. }
  50837. /**
  50838. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50839. */
  50840. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50841. private readonly _options;
  50842. private static _idCounter;
  50843. private _attachController;
  50844. private _controllers;
  50845. private _scene;
  50846. private _tmpVectorForPickCompare;
  50847. /**
  50848. * The module's name
  50849. */
  50850. static readonly Name: string;
  50851. /**
  50852. * The (Babylon) version of this module.
  50853. * This is an integer representing the implementation version.
  50854. * This number does not correspond to the WebXR specs version
  50855. */
  50856. static readonly Version: number;
  50857. /**
  50858. * Disable lighting on the laser pointer (so it will always be visible)
  50859. */
  50860. disablePointerLighting: boolean;
  50861. /**
  50862. * Disable lighting on the selection mesh (so it will always be visible)
  50863. */
  50864. disableSelectionMeshLighting: boolean;
  50865. /**
  50866. * Should the laser pointer be displayed
  50867. */
  50868. displayLaserPointer: boolean;
  50869. /**
  50870. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50871. */
  50872. displaySelectionMesh: boolean;
  50873. /**
  50874. * This color will be set to the laser pointer when selection is triggered
  50875. */
  50876. laserPointerPickedColor: Color3;
  50877. /**
  50878. * Default color of the laser pointer
  50879. */
  50880. laserPointerDefaultColor: Color3;
  50881. /**
  50882. * default color of the selection ring
  50883. */
  50884. selectionMeshDefaultColor: Color3;
  50885. /**
  50886. * This color will be applied to the selection ring when selection is triggered
  50887. */
  50888. selectionMeshPickedColor: Color3;
  50889. /**
  50890. * Optional filter to be used for ray selection. This predicate shares behavior with
  50891. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50892. */
  50893. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50894. /**
  50895. * constructs a new background remover module
  50896. * @param _xrSessionManager the session manager for this module
  50897. * @param _options read-only options to be used in this module
  50898. */
  50899. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50900. /**
  50901. * attach this feature
  50902. * Will usually be called by the features manager
  50903. *
  50904. * @returns true if successful.
  50905. */
  50906. attach(): boolean;
  50907. /**
  50908. * detach this feature.
  50909. * Will usually be called by the features manager
  50910. *
  50911. * @returns true if successful.
  50912. */
  50913. detach(): boolean;
  50914. /**
  50915. * Will get the mesh under a specific pointer.
  50916. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50917. * @param controllerId the controllerId to check
  50918. * @returns The mesh under pointer or null if no mesh is under the pointer
  50919. */
  50920. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50921. /**
  50922. * Get the xr controller that correlates to the pointer id in the pointer event
  50923. *
  50924. * @param id the pointer id to search for
  50925. * @returns the controller that correlates to this id or null if not found
  50926. */
  50927. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50928. protected _onXRFrame(_xrFrame: XRFrame): void;
  50929. private _attachGazeMode;
  50930. private _attachScreenRayMode;
  50931. private _attachTrackedPointerRayMode;
  50932. private _convertNormalToDirectionOfRay;
  50933. private _detachController;
  50934. private _generateNewMeshPair;
  50935. private _pickingMoved;
  50936. private _updatePointerDistance;
  50937. /** @hidden */
  50938. get lasterPointerDefaultColor(): Color3;
  50939. }
  50940. }
  50941. declare module "babylonjs/XR/webXREnterExitUI" {
  50942. import { Nullable } from "babylonjs/types";
  50943. import { Observable } from "babylonjs/Misc/observable";
  50944. import { IDisposable, Scene } from "babylonjs/scene";
  50945. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50946. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50947. /**
  50948. * Button which can be used to enter a different mode of XR
  50949. */
  50950. export class WebXREnterExitUIButton {
  50951. /** button element */
  50952. element: HTMLElement;
  50953. /** XR initialization options for the button */
  50954. sessionMode: XRSessionMode;
  50955. /** Reference space type */
  50956. referenceSpaceType: XRReferenceSpaceType;
  50957. /**
  50958. * Creates a WebXREnterExitUIButton
  50959. * @param element button element
  50960. * @param sessionMode XR initialization session mode
  50961. * @param referenceSpaceType the type of reference space to be used
  50962. */
  50963. constructor(
  50964. /** button element */
  50965. element: HTMLElement,
  50966. /** XR initialization options for the button */
  50967. sessionMode: XRSessionMode,
  50968. /** Reference space type */
  50969. referenceSpaceType: XRReferenceSpaceType);
  50970. /**
  50971. * Extendable function which can be used to update the button's visuals when the state changes
  50972. * @param activeButton the current active button in the UI
  50973. */
  50974. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50975. }
  50976. /**
  50977. * Options to create the webXR UI
  50978. */
  50979. export class WebXREnterExitUIOptions {
  50980. /**
  50981. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50982. */
  50983. customButtons?: Array<WebXREnterExitUIButton>;
  50984. /**
  50985. * A reference space type to use when creating the default button.
  50986. * Default is local-floor
  50987. */
  50988. referenceSpaceType?: XRReferenceSpaceType;
  50989. /**
  50990. * Context to enter xr with
  50991. */
  50992. renderTarget?: Nullable<WebXRRenderTarget>;
  50993. /**
  50994. * A session mode to use when creating the default button.
  50995. * Default is immersive-vr
  50996. */
  50997. sessionMode?: XRSessionMode;
  50998. /**
  50999. * A list of optional features to init the session with
  51000. */
  51001. optionalFeatures?: string[];
  51002. /**
  51003. * A list of optional features to init the session with
  51004. */
  51005. requiredFeatures?: string[];
  51006. }
  51007. /**
  51008. * UI to allow the user to enter/exit XR mode
  51009. */
  51010. export class WebXREnterExitUI implements IDisposable {
  51011. private scene;
  51012. /** version of the options passed to this UI */
  51013. options: WebXREnterExitUIOptions;
  51014. private _activeButton;
  51015. private _buttons;
  51016. /**
  51017. * The HTML Div Element to which buttons are added.
  51018. */
  51019. readonly overlay: HTMLDivElement;
  51020. /**
  51021. * Fired every time the active button is changed.
  51022. *
  51023. * When xr is entered via a button that launches xr that button will be the callback parameter
  51024. *
  51025. * When exiting xr the callback parameter will be null)
  51026. */
  51027. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51028. /**
  51029. *
  51030. * @param scene babylon scene object to use
  51031. * @param options (read-only) version of the options passed to this UI
  51032. */
  51033. private constructor();
  51034. /**
  51035. * Creates UI to allow the user to enter/exit XR mode
  51036. * @param scene the scene to add the ui to
  51037. * @param helper the xr experience helper to enter/exit xr with
  51038. * @param options options to configure the UI
  51039. * @returns the created ui
  51040. */
  51041. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51042. /**
  51043. * Disposes of the XR UI component
  51044. */
  51045. dispose(): void;
  51046. private _updateButtons;
  51047. }
  51048. }
  51049. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51050. import { Vector3 } from "babylonjs/Maths/math.vector";
  51051. import { Color4 } from "babylonjs/Maths/math.color";
  51052. import { Nullable } from "babylonjs/types";
  51053. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51054. import { Scene } from "babylonjs/scene";
  51055. /**
  51056. * Class containing static functions to help procedurally build meshes
  51057. */
  51058. export class LinesBuilder {
  51059. /**
  51060. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51061. * * 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
  51062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51063. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51064. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51065. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51066. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51067. * * 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
  51068. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51071. * @param name defines the name of the new line system
  51072. * @param options defines the options used to create the line system
  51073. * @param scene defines the hosting scene
  51074. * @returns a new line system mesh
  51075. */
  51076. static CreateLineSystem(name: string, options: {
  51077. lines: Vector3[][];
  51078. updatable?: boolean;
  51079. instance?: Nullable<LinesMesh>;
  51080. colors?: Nullable<Color4[][]>;
  51081. useVertexAlpha?: boolean;
  51082. }, scene: Nullable<Scene>): LinesMesh;
  51083. /**
  51084. * Creates a line mesh
  51085. * 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
  51086. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51087. * * The parameter `points` is an array successive Vector3
  51088. * * 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
  51089. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51090. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51091. * * When updating an instance, remember that only point positions can change, not the number of points
  51092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51094. * @param name defines the name of the new line system
  51095. * @param options defines the options used to create the line system
  51096. * @param scene defines the hosting scene
  51097. * @returns a new line mesh
  51098. */
  51099. static CreateLines(name: string, options: {
  51100. points: Vector3[];
  51101. updatable?: boolean;
  51102. instance?: Nullable<LinesMesh>;
  51103. colors?: Color4[];
  51104. useVertexAlpha?: boolean;
  51105. }, scene?: Nullable<Scene>): LinesMesh;
  51106. /**
  51107. * Creates a dashed line mesh
  51108. * * 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
  51109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51110. * * The parameter `points` is an array successive Vector3
  51111. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51112. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51113. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51114. * * 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
  51115. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51116. * * When updating an instance, remember that only point positions can change, not the number of points
  51117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51118. * @param name defines the name of the mesh
  51119. * @param options defines the options used to create the mesh
  51120. * @param scene defines the hosting scene
  51121. * @returns the dashed line mesh
  51122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51123. */
  51124. static CreateDashedLines(name: string, options: {
  51125. points: Vector3[];
  51126. dashSize?: number;
  51127. gapSize?: number;
  51128. dashNb?: number;
  51129. updatable?: boolean;
  51130. instance?: LinesMesh;
  51131. useVertexAlpha?: boolean;
  51132. }, scene?: Nullable<Scene>): LinesMesh;
  51133. }
  51134. }
  51135. declare module "babylonjs/Misc/timer" {
  51136. import { Observable, Observer } from "babylonjs/Misc/observable";
  51137. import { Nullable } from "babylonjs/types";
  51138. import { IDisposable } from "babylonjs/scene";
  51139. /**
  51140. * Construction options for a timer
  51141. */
  51142. export interface ITimerOptions<T> {
  51143. /**
  51144. * Time-to-end
  51145. */
  51146. timeout: number;
  51147. /**
  51148. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51149. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51150. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51151. */
  51152. contextObservable: Observable<T>;
  51153. /**
  51154. * Optional parameters when adding an observer to the observable
  51155. */
  51156. observableParameters?: {
  51157. mask?: number;
  51158. insertFirst?: boolean;
  51159. scope?: any;
  51160. };
  51161. /**
  51162. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51163. */
  51164. breakCondition?: (data?: ITimerData<T>) => boolean;
  51165. /**
  51166. * Will be triggered when the time condition has met
  51167. */
  51168. onEnded?: (data: ITimerData<any>) => void;
  51169. /**
  51170. * Will be triggered when the break condition has met (prematurely ended)
  51171. */
  51172. onAborted?: (data: ITimerData<any>) => void;
  51173. /**
  51174. * Optional function to execute on each tick (or count)
  51175. */
  51176. onTick?: (data: ITimerData<any>) => void;
  51177. }
  51178. /**
  51179. * An interface defining the data sent by the timer
  51180. */
  51181. export interface ITimerData<T> {
  51182. /**
  51183. * When did it start
  51184. */
  51185. startTime: number;
  51186. /**
  51187. * Time now
  51188. */
  51189. currentTime: number;
  51190. /**
  51191. * Time passed since started
  51192. */
  51193. deltaTime: number;
  51194. /**
  51195. * How much is completed, in [0.0...1.0].
  51196. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51197. */
  51198. completeRate: number;
  51199. /**
  51200. * What the registered observable sent in the last count
  51201. */
  51202. payload: T;
  51203. }
  51204. /**
  51205. * The current state of the timer
  51206. */
  51207. export enum TimerState {
  51208. /**
  51209. * Timer initialized, not yet started
  51210. */
  51211. INIT = 0,
  51212. /**
  51213. * Timer started and counting
  51214. */
  51215. STARTED = 1,
  51216. /**
  51217. * Timer ended (whether aborted or time reached)
  51218. */
  51219. ENDED = 2
  51220. }
  51221. /**
  51222. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51223. *
  51224. * @param options options with which to initialize this timer
  51225. */
  51226. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51227. /**
  51228. * An advanced implementation of a timer class
  51229. */
  51230. export class AdvancedTimer<T = any> implements IDisposable {
  51231. /**
  51232. * Will notify each time the timer calculates the remaining time
  51233. */
  51234. onEachCountObservable: Observable<ITimerData<T>>;
  51235. /**
  51236. * Will trigger when the timer was aborted due to the break condition
  51237. */
  51238. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51239. /**
  51240. * Will trigger when the timer ended successfully
  51241. */
  51242. onTimerEndedObservable: Observable<ITimerData<T>>;
  51243. /**
  51244. * Will trigger when the timer state has changed
  51245. */
  51246. onStateChangedObservable: Observable<TimerState>;
  51247. private _observer;
  51248. private _contextObservable;
  51249. private _observableParameters;
  51250. private _startTime;
  51251. private _timer;
  51252. private _state;
  51253. private _breakCondition;
  51254. private _timeToEnd;
  51255. private _breakOnNextTick;
  51256. /**
  51257. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51258. * @param options construction options for this advanced timer
  51259. */
  51260. constructor(options: ITimerOptions<T>);
  51261. /**
  51262. * set a breaking condition for this timer. Default is to never break during count
  51263. * @param predicate the new break condition. Returns true to break, false otherwise
  51264. */
  51265. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51266. /**
  51267. * Reset ALL associated observables in this advanced timer
  51268. */
  51269. clearObservables(): void;
  51270. /**
  51271. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51272. *
  51273. * @param timeToEnd how much time to measure until timer ended
  51274. */
  51275. start(timeToEnd?: number): void;
  51276. /**
  51277. * Will force a stop on the next tick.
  51278. */
  51279. stop(): void;
  51280. /**
  51281. * Dispose this timer, clearing all resources
  51282. */
  51283. dispose(): void;
  51284. private _setState;
  51285. private _tick;
  51286. private _stop;
  51287. }
  51288. }
  51289. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51290. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51291. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51292. import { Nullable } from "babylonjs/types";
  51293. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51295. import { Vector3 } from "babylonjs/Maths/math.vector";
  51296. import { Material } from "babylonjs/Materials/material";
  51297. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51298. import { Scene } from "babylonjs/scene";
  51299. /**
  51300. * The options container for the teleportation module
  51301. */
  51302. export interface IWebXRTeleportationOptions {
  51303. /**
  51304. * if provided, this scene will be used to render meshes.
  51305. */
  51306. customUtilityLayerScene?: Scene;
  51307. /**
  51308. * Values to configure the default target mesh
  51309. */
  51310. defaultTargetMeshOptions?: {
  51311. /**
  51312. * Fill color of the teleportation area
  51313. */
  51314. teleportationFillColor?: string;
  51315. /**
  51316. * Border color for the teleportation area
  51317. */
  51318. teleportationBorderColor?: string;
  51319. /**
  51320. * Disable the mesh's animation sequence
  51321. */
  51322. disableAnimation?: boolean;
  51323. /**
  51324. * Disable lighting on the material or the ring and arrow
  51325. */
  51326. disableLighting?: boolean;
  51327. /**
  51328. * Override the default material of the torus and arrow
  51329. */
  51330. torusArrowMaterial?: Material;
  51331. };
  51332. /**
  51333. * A list of meshes to use as floor meshes.
  51334. * Meshes can be added and removed after initializing the feature using the
  51335. * addFloorMesh and removeFloorMesh functions
  51336. * If empty, rotation will still work
  51337. */
  51338. floorMeshes?: AbstractMesh[];
  51339. /**
  51340. * use this rendering group id for the meshes (optional)
  51341. */
  51342. renderingGroupId?: number;
  51343. /**
  51344. * Should teleportation move only to snap points
  51345. */
  51346. snapPointsOnly?: boolean;
  51347. /**
  51348. * An array of points to which the teleportation will snap to.
  51349. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51350. */
  51351. snapPositions?: Vector3[];
  51352. /**
  51353. * How close should the teleportation ray be in order to snap to position.
  51354. * Default to 0.8 units (meters)
  51355. */
  51356. snapToPositionRadius?: number;
  51357. /**
  51358. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51359. * If you want to support rotation, make sure your mesh has a direction indicator.
  51360. *
  51361. * When left untouched, the default mesh will be initialized.
  51362. */
  51363. teleportationTargetMesh?: AbstractMesh;
  51364. /**
  51365. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51366. */
  51367. timeToTeleport?: number;
  51368. /**
  51369. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51370. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51371. */
  51372. useMainComponentOnly?: boolean;
  51373. /**
  51374. * Should meshes created here be added to a utility layer or the main scene
  51375. */
  51376. useUtilityLayer?: boolean;
  51377. /**
  51378. * Babylon XR Input class for controller
  51379. */
  51380. xrInput: WebXRInput;
  51381. /**
  51382. * Meshes that the teleportation ray cannot go through
  51383. */
  51384. pickBlockerMeshes?: AbstractMesh[];
  51385. }
  51386. /**
  51387. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51388. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51389. * the input of the attached controllers.
  51390. */
  51391. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51392. private _options;
  51393. private _controllers;
  51394. private _currentTeleportationControllerId;
  51395. private _floorMeshes;
  51396. private _quadraticBezierCurve;
  51397. private _selectionFeature;
  51398. private _snapToPositions;
  51399. private _snappedToPoint;
  51400. private _teleportationRingMaterial?;
  51401. private _tmpRay;
  51402. private _tmpVector;
  51403. private _tmpQuaternion;
  51404. /**
  51405. * The module's name
  51406. */
  51407. static readonly Name: string;
  51408. /**
  51409. * The (Babylon) version of this module.
  51410. * This is an integer representing the implementation version.
  51411. * This number does not correspond to the webxr specs version
  51412. */
  51413. static readonly Version: number;
  51414. /**
  51415. * Is movement backwards enabled
  51416. */
  51417. backwardsMovementEnabled: boolean;
  51418. /**
  51419. * Distance to travel when moving backwards
  51420. */
  51421. backwardsTeleportationDistance: number;
  51422. /**
  51423. * The distance from the user to the inspection point in the direction of the controller
  51424. * A higher number will allow the user to move further
  51425. * defaults to 5 (meters, in xr units)
  51426. */
  51427. parabolicCheckRadius: number;
  51428. /**
  51429. * Should the module support parabolic ray on top of direct ray
  51430. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51431. * Very helpful when moving between floors / different heights
  51432. */
  51433. parabolicRayEnabled: boolean;
  51434. /**
  51435. * How much rotation should be applied when rotating right and left
  51436. */
  51437. rotationAngle: number;
  51438. /**
  51439. * Is rotation enabled when moving forward?
  51440. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51441. */
  51442. rotationEnabled: boolean;
  51443. /**
  51444. * constructs a new anchor system
  51445. * @param _xrSessionManager an instance of WebXRSessionManager
  51446. * @param _options configuration object for this feature
  51447. */
  51448. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51449. /**
  51450. * Get the snapPointsOnly flag
  51451. */
  51452. get snapPointsOnly(): boolean;
  51453. /**
  51454. * Sets the snapPointsOnly flag
  51455. * @param snapToPoints should teleportation be exclusively to snap points
  51456. */
  51457. set snapPointsOnly(snapToPoints: boolean);
  51458. /**
  51459. * Add a new mesh to the floor meshes array
  51460. * @param mesh the mesh to use as floor mesh
  51461. */
  51462. addFloorMesh(mesh: AbstractMesh): void;
  51463. /**
  51464. * Add a new snap-to point to fix teleportation to this position
  51465. * @param newSnapPoint The new Snap-To point
  51466. */
  51467. addSnapPoint(newSnapPoint: Vector3): void;
  51468. attach(): boolean;
  51469. detach(): boolean;
  51470. dispose(): void;
  51471. /**
  51472. * Remove a mesh from the floor meshes array
  51473. * @param mesh the mesh to remove
  51474. */
  51475. removeFloorMesh(mesh: AbstractMesh): void;
  51476. /**
  51477. * Remove a mesh from the floor meshes array using its name
  51478. * @param name the mesh name to remove
  51479. */
  51480. removeFloorMeshByName(name: string): void;
  51481. /**
  51482. * 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
  51483. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51484. * @returns was the point found and removed or not
  51485. */
  51486. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51487. /**
  51488. * This function sets a selection feature that will be disabled when
  51489. * the forward ray is shown and will be reattached when hidden.
  51490. * This is used to remove the selection rays when moving.
  51491. * @param selectionFeature the feature to disable when forward movement is enabled
  51492. */
  51493. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51494. protected _onXRFrame(_xrFrame: XRFrame): void;
  51495. private _attachController;
  51496. private _createDefaultTargetMesh;
  51497. private _detachController;
  51498. private _findClosestSnapPointWithRadius;
  51499. private _setTargetMeshPosition;
  51500. private _setTargetMeshVisibility;
  51501. private _showParabolicPath;
  51502. private _teleportForward;
  51503. }
  51504. }
  51505. declare module "babylonjs/XR/webXRDefaultExperience" {
  51506. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51507. import { Scene } from "babylonjs/scene";
  51508. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51509. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51510. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51511. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51513. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51514. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51515. /**
  51516. * Options for the default xr helper
  51517. */
  51518. export class WebXRDefaultExperienceOptions {
  51519. /**
  51520. * Enable or disable default UI to enter XR
  51521. */
  51522. disableDefaultUI?: boolean;
  51523. /**
  51524. * Should teleportation not initialize. defaults to false.
  51525. */
  51526. disableTeleportation?: boolean;
  51527. /**
  51528. * Floor meshes that will be used for teleport
  51529. */
  51530. floorMeshes?: Array<AbstractMesh>;
  51531. /**
  51532. * If set to true, the first frame will not be used to reset position
  51533. * The first frame is mainly used when copying transformation from the old camera
  51534. * Mainly used in AR
  51535. */
  51536. ignoreNativeCameraTransformation?: boolean;
  51537. /**
  51538. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51539. */
  51540. inputOptions?: IWebXRInputOptions;
  51541. /**
  51542. * optional configuration for the output canvas
  51543. */
  51544. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51545. /**
  51546. * optional UI options. This can be used among other to change session mode and reference space type
  51547. */
  51548. uiOptions?: WebXREnterExitUIOptions;
  51549. /**
  51550. * When loading teleportation and pointer select, use stable versions instead of latest.
  51551. */
  51552. useStablePlugins?: boolean;
  51553. /**
  51554. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51555. */
  51556. renderingGroupId?: number;
  51557. /**
  51558. * A list of optional features to init the session with
  51559. * If set to true, all features we support will be added
  51560. */
  51561. optionalFeatures?: boolean | string[];
  51562. }
  51563. /**
  51564. * Default experience which provides a similar setup to the previous webVRExperience
  51565. */
  51566. export class WebXRDefaultExperience {
  51567. /**
  51568. * Base experience
  51569. */
  51570. baseExperience: WebXRExperienceHelper;
  51571. /**
  51572. * Enables ui for entering/exiting xr
  51573. */
  51574. enterExitUI: WebXREnterExitUI;
  51575. /**
  51576. * Input experience extension
  51577. */
  51578. input: WebXRInput;
  51579. /**
  51580. * Enables laser pointer and selection
  51581. */
  51582. pointerSelection: WebXRControllerPointerSelection;
  51583. /**
  51584. * Default target xr should render to
  51585. */
  51586. renderTarget: WebXRRenderTarget;
  51587. /**
  51588. * Enables teleportation
  51589. */
  51590. teleportation: WebXRMotionControllerTeleportation;
  51591. private constructor();
  51592. /**
  51593. * Creates the default xr experience
  51594. * @param scene scene
  51595. * @param options options for basic configuration
  51596. * @returns resulting WebXRDefaultExperience
  51597. */
  51598. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51599. /**
  51600. * DIsposes of the experience helper
  51601. */
  51602. dispose(): void;
  51603. }
  51604. }
  51605. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51606. import { Observable } from "babylonjs/Misc/observable";
  51607. import { Nullable } from "babylonjs/types";
  51608. import { Camera } from "babylonjs/Cameras/camera";
  51609. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51610. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51611. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51612. import { Scene } from "babylonjs/scene";
  51613. import { Vector3 } from "babylonjs/Maths/math.vector";
  51614. import { Color3 } from "babylonjs/Maths/math.color";
  51615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51617. import { Mesh } from "babylonjs/Meshes/mesh";
  51618. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51619. import { EasingFunction } from "babylonjs/Animations/easing";
  51620. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51621. import "babylonjs/Meshes/Builders/groundBuilder";
  51622. import "babylonjs/Meshes/Builders/torusBuilder";
  51623. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51624. import "babylonjs/Gamepads/gamepadSceneComponent";
  51625. import "babylonjs/Animations/animatable";
  51626. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51627. /**
  51628. * Options to modify the vr teleportation behavior.
  51629. */
  51630. export interface VRTeleportationOptions {
  51631. /**
  51632. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51633. */
  51634. floorMeshName?: string;
  51635. /**
  51636. * A list of meshes to be used as the teleportation floor. (default: empty)
  51637. */
  51638. floorMeshes?: Mesh[];
  51639. /**
  51640. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51641. */
  51642. teleportationMode?: number;
  51643. /**
  51644. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51645. */
  51646. teleportationTime?: number;
  51647. /**
  51648. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51649. */
  51650. teleportationSpeed?: number;
  51651. /**
  51652. * The easing function used in the animation or null for Linear. (default CircleEase)
  51653. */
  51654. easingFunction?: EasingFunction;
  51655. }
  51656. /**
  51657. * Options to modify the vr experience helper's behavior.
  51658. */
  51659. export interface VRExperienceHelperOptions extends WebVROptions {
  51660. /**
  51661. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51662. */
  51663. createDeviceOrientationCamera?: boolean;
  51664. /**
  51665. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51666. */
  51667. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51668. /**
  51669. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51670. */
  51671. laserToggle?: boolean;
  51672. /**
  51673. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51674. */
  51675. floorMeshes?: Mesh[];
  51676. /**
  51677. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51678. */
  51679. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51680. /**
  51681. * Defines if WebXR should be used instead of WebVR (if available)
  51682. */
  51683. useXR?: boolean;
  51684. }
  51685. /**
  51686. * Event containing information after VR has been entered
  51687. */
  51688. export class OnAfterEnteringVRObservableEvent {
  51689. /**
  51690. * If entering vr was successful
  51691. */
  51692. success: boolean;
  51693. }
  51694. /**
  51695. * Helps to quickly add VR support to an existing scene.
  51696. * See https://doc.babylonjs.com/how_to/webvr_helper
  51697. */
  51698. export class VRExperienceHelper {
  51699. /** Options to modify the vr experience helper's behavior. */
  51700. webVROptions: VRExperienceHelperOptions;
  51701. private _scene;
  51702. private _position;
  51703. private _btnVR;
  51704. private _btnVRDisplayed;
  51705. private _webVRsupported;
  51706. private _webVRready;
  51707. private _webVRrequesting;
  51708. private _webVRpresenting;
  51709. private _hasEnteredVR;
  51710. private _fullscreenVRpresenting;
  51711. private _inputElement;
  51712. private _webVRCamera;
  51713. private _vrDeviceOrientationCamera;
  51714. private _deviceOrientationCamera;
  51715. private _existingCamera;
  51716. private _onKeyDown;
  51717. private _onVrDisplayPresentChange;
  51718. private _onVRDisplayChanged;
  51719. private _onVRRequestPresentStart;
  51720. private _onVRRequestPresentComplete;
  51721. /**
  51722. * 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)
  51723. */
  51724. enableGazeEvenWhenNoPointerLock: boolean;
  51725. /**
  51726. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51727. */
  51728. exitVROnDoubleTap: boolean;
  51729. /**
  51730. * Observable raised right before entering VR.
  51731. */
  51732. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51733. /**
  51734. * Observable raised when entering VR has completed.
  51735. */
  51736. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51737. /**
  51738. * Observable raised when exiting VR.
  51739. */
  51740. onExitingVRObservable: Observable<VRExperienceHelper>;
  51741. /**
  51742. * Observable raised when controller mesh is loaded.
  51743. */
  51744. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51745. /** Return this.onEnteringVRObservable
  51746. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51747. */
  51748. get onEnteringVR(): Observable<VRExperienceHelper>;
  51749. /** Return this.onExitingVRObservable
  51750. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51751. */
  51752. get onExitingVR(): Observable<VRExperienceHelper>;
  51753. /** Return this.onControllerMeshLoadedObservable
  51754. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51755. */
  51756. get onControllerMeshLoaded(): Observable<WebVRController>;
  51757. private _rayLength;
  51758. private _useCustomVRButton;
  51759. private _teleportationRequested;
  51760. private _teleportActive;
  51761. private _floorMeshName;
  51762. private _floorMeshesCollection;
  51763. private _teleportationMode;
  51764. private _teleportationTime;
  51765. private _teleportationSpeed;
  51766. private _teleportationEasing;
  51767. private _rotationAllowed;
  51768. private _teleportBackwardsVector;
  51769. private _teleportationTarget;
  51770. private _isDefaultTeleportationTarget;
  51771. private _postProcessMove;
  51772. private _teleportationFillColor;
  51773. private _teleportationBorderColor;
  51774. private _rotationAngle;
  51775. private _haloCenter;
  51776. private _cameraGazer;
  51777. private _padSensibilityUp;
  51778. private _padSensibilityDown;
  51779. private _leftController;
  51780. private _rightController;
  51781. private _gazeColor;
  51782. private _laserColor;
  51783. private _pickedLaserColor;
  51784. private _pickedGazeColor;
  51785. /**
  51786. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51787. */
  51788. onNewMeshSelected: Observable<AbstractMesh>;
  51789. /**
  51790. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51791. * This observable will provide the mesh and the controller used to select the mesh
  51792. */
  51793. onMeshSelectedWithController: Observable<{
  51794. mesh: AbstractMesh;
  51795. controller: WebVRController;
  51796. }>;
  51797. /**
  51798. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51799. */
  51800. onNewMeshPicked: Observable<PickingInfo>;
  51801. private _circleEase;
  51802. /**
  51803. * Observable raised before camera teleportation
  51804. */
  51805. onBeforeCameraTeleport: Observable<Vector3>;
  51806. /**
  51807. * Observable raised after camera teleportation
  51808. */
  51809. onAfterCameraTeleport: Observable<Vector3>;
  51810. /**
  51811. * Observable raised when current selected mesh gets unselected
  51812. */
  51813. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51814. private _raySelectionPredicate;
  51815. /**
  51816. * To be optionaly changed by user to define custom ray selection
  51817. */
  51818. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51819. /**
  51820. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51821. */
  51822. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51823. /**
  51824. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51825. */
  51826. teleportationEnabled: boolean;
  51827. private _defaultHeight;
  51828. private _teleportationInitialized;
  51829. private _interactionsEnabled;
  51830. private _interactionsRequested;
  51831. private _displayGaze;
  51832. private _displayLaserPointer;
  51833. /**
  51834. * The mesh used to display where the user is going to teleport.
  51835. */
  51836. get teleportationTarget(): Mesh;
  51837. /**
  51838. * Sets the mesh to be used to display where the user is going to teleport.
  51839. */
  51840. set teleportationTarget(value: Mesh);
  51841. /**
  51842. * 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
  51843. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51844. * See https://doc.babylonjs.com/resources/baking_transformations
  51845. */
  51846. get gazeTrackerMesh(): Mesh;
  51847. set gazeTrackerMesh(value: Mesh);
  51848. /**
  51849. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51850. */
  51851. updateGazeTrackerScale: boolean;
  51852. /**
  51853. * If the gaze trackers color should be updated when selecting meshes
  51854. */
  51855. updateGazeTrackerColor: boolean;
  51856. /**
  51857. * If the controller laser color should be updated when selecting meshes
  51858. */
  51859. updateControllerLaserColor: boolean;
  51860. /**
  51861. * The gaze tracking mesh corresponding to the left controller
  51862. */
  51863. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51864. /**
  51865. * The gaze tracking mesh corresponding to the right controller
  51866. */
  51867. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51868. /**
  51869. * If the ray of the gaze should be displayed.
  51870. */
  51871. get displayGaze(): boolean;
  51872. /**
  51873. * Sets if the ray of the gaze should be displayed.
  51874. */
  51875. set displayGaze(value: boolean);
  51876. /**
  51877. * If the ray of the LaserPointer should be displayed.
  51878. */
  51879. get displayLaserPointer(): boolean;
  51880. /**
  51881. * Sets if the ray of the LaserPointer should be displayed.
  51882. */
  51883. set displayLaserPointer(value: boolean);
  51884. /**
  51885. * The deviceOrientationCamera used as the camera when not in VR.
  51886. */
  51887. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51888. /**
  51889. * Based on the current WebVR support, returns the current VR camera used.
  51890. */
  51891. get currentVRCamera(): Nullable<Camera>;
  51892. /**
  51893. * The webVRCamera which is used when in VR.
  51894. */
  51895. get webVRCamera(): WebVRFreeCamera;
  51896. /**
  51897. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51898. */
  51899. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51900. /**
  51901. * The html button that is used to trigger entering into VR.
  51902. */
  51903. get vrButton(): Nullable<HTMLButtonElement>;
  51904. private get _teleportationRequestInitiated();
  51905. /**
  51906. * Defines whether or not Pointer lock should be requested when switching to
  51907. * full screen.
  51908. */
  51909. requestPointerLockOnFullScreen: boolean;
  51910. /**
  51911. * If asking to force XR, this will be populated with the default xr experience
  51912. */
  51913. xr: WebXRDefaultExperience;
  51914. /**
  51915. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51916. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51917. */
  51918. xrTestDone: boolean;
  51919. /**
  51920. * Instantiates a VRExperienceHelper.
  51921. * Helps to quickly add VR support to an existing scene.
  51922. * @param scene The scene the VRExperienceHelper belongs to.
  51923. * @param webVROptions Options to modify the vr experience helper's behavior.
  51924. */
  51925. constructor(scene: Scene,
  51926. /** Options to modify the vr experience helper's behavior. */
  51927. webVROptions?: VRExperienceHelperOptions);
  51928. private completeVRInit;
  51929. private _onDefaultMeshLoaded;
  51930. private _onResize;
  51931. private _onFullscreenChange;
  51932. /**
  51933. * Gets a value indicating if we are currently in VR mode.
  51934. */
  51935. get isInVRMode(): boolean;
  51936. private onVrDisplayPresentChange;
  51937. private onVRDisplayChanged;
  51938. private moveButtonToBottomRight;
  51939. private displayVRButton;
  51940. private updateButtonVisibility;
  51941. private _cachedAngularSensibility;
  51942. /**
  51943. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51944. * Otherwise, will use the fullscreen API.
  51945. */
  51946. enterVR(): void;
  51947. /**
  51948. * Attempt to exit VR, or fullscreen.
  51949. */
  51950. exitVR(): void;
  51951. /**
  51952. * The position of the vr experience helper.
  51953. */
  51954. get position(): Vector3;
  51955. /**
  51956. * Sets the position of the vr experience helper.
  51957. */
  51958. set position(value: Vector3);
  51959. /**
  51960. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51961. */
  51962. enableInteractions(): void;
  51963. private get _noControllerIsActive();
  51964. private beforeRender;
  51965. private _isTeleportationFloor;
  51966. /**
  51967. * Adds a floor mesh to be used for teleportation.
  51968. * @param floorMesh the mesh to be used for teleportation.
  51969. */
  51970. addFloorMesh(floorMesh: Mesh): void;
  51971. /**
  51972. * Removes a floor mesh from being used for teleportation.
  51973. * @param floorMesh the mesh to be removed.
  51974. */
  51975. removeFloorMesh(floorMesh: Mesh): void;
  51976. /**
  51977. * Enables interactions and teleportation using the VR controllers and gaze.
  51978. * @param vrTeleportationOptions options to modify teleportation behavior.
  51979. */
  51980. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51981. private _onNewGamepadConnected;
  51982. private _tryEnableInteractionOnController;
  51983. private _onNewGamepadDisconnected;
  51984. private _enableInteractionOnController;
  51985. private _checkTeleportWithRay;
  51986. private _checkRotate;
  51987. private _checkTeleportBackwards;
  51988. private _enableTeleportationOnController;
  51989. private _createTeleportationCircles;
  51990. private _displayTeleportationTarget;
  51991. private _hideTeleportationTarget;
  51992. private _rotateCamera;
  51993. private _moveTeleportationSelectorTo;
  51994. private _workingVector;
  51995. private _workingQuaternion;
  51996. private _workingMatrix;
  51997. /**
  51998. * Time Constant Teleportation Mode
  51999. */
  52000. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52001. /**
  52002. * Speed Constant Teleportation Mode
  52003. */
  52004. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52005. /**
  52006. * Teleports the users feet to the desired location
  52007. * @param location The location where the user's feet should be placed
  52008. */
  52009. teleportCamera(location: Vector3): void;
  52010. private _convertNormalToDirectionOfRay;
  52011. private _castRayAndSelectObject;
  52012. private _notifySelectedMeshUnselected;
  52013. /**
  52014. * Permanently set new colors for the laser pointer
  52015. * @param color the new laser color
  52016. * @param pickedColor the new laser color when picked mesh detected
  52017. */
  52018. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52019. /**
  52020. * Set lighting enabled / disabled on the laser pointer of both controllers
  52021. * @param enabled should the lighting be enabled on the laser pointer
  52022. */
  52023. setLaserLightingState(enabled?: boolean): void;
  52024. /**
  52025. * Permanently set new colors for the gaze pointer
  52026. * @param color the new gaze color
  52027. * @param pickedColor the new gaze color when picked mesh detected
  52028. */
  52029. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52030. /**
  52031. * Sets the color of the laser ray from the vr controllers.
  52032. * @param color new color for the ray.
  52033. */
  52034. changeLaserColor(color: Color3): void;
  52035. /**
  52036. * Sets the color of the ray from the vr headsets gaze.
  52037. * @param color new color for the ray.
  52038. */
  52039. changeGazeColor(color: Color3): void;
  52040. /**
  52041. * Exits VR and disposes of the vr experience helper
  52042. */
  52043. dispose(): void;
  52044. /**
  52045. * Gets the name of the VRExperienceHelper class
  52046. * @returns "VRExperienceHelper"
  52047. */
  52048. getClassName(): string;
  52049. }
  52050. }
  52051. declare module "babylonjs/Cameras/VR/index" {
  52052. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52053. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52054. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52055. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52056. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52057. export * from "babylonjs/Cameras/VR/webVRCamera";
  52058. }
  52059. declare module "babylonjs/Cameras/RigModes/index" {
  52060. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52061. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52062. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52063. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52064. }
  52065. declare module "babylonjs/Cameras/index" {
  52066. export * from "babylonjs/Cameras/Inputs/index";
  52067. export * from "babylonjs/Cameras/cameraInputsManager";
  52068. export * from "babylonjs/Cameras/camera";
  52069. export * from "babylonjs/Cameras/targetCamera";
  52070. export * from "babylonjs/Cameras/freeCamera";
  52071. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52072. export * from "babylonjs/Cameras/touchCamera";
  52073. export * from "babylonjs/Cameras/arcRotateCamera";
  52074. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52075. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52076. export * from "babylonjs/Cameras/flyCamera";
  52077. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52078. export * from "babylonjs/Cameras/followCamera";
  52079. export * from "babylonjs/Cameras/followCameraInputsManager";
  52080. export * from "babylonjs/Cameras/gamepadCamera";
  52081. export * from "babylonjs/Cameras/Stereoscopic/index";
  52082. export * from "babylonjs/Cameras/universalCamera";
  52083. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52084. export * from "babylonjs/Cameras/VR/index";
  52085. export * from "babylonjs/Cameras/RigModes/index";
  52086. }
  52087. declare module "babylonjs/Collisions/index" {
  52088. export * from "babylonjs/Collisions/collider";
  52089. export * from "babylonjs/Collisions/collisionCoordinator";
  52090. export * from "babylonjs/Collisions/pickingInfo";
  52091. export * from "babylonjs/Collisions/intersectionInfo";
  52092. export * from "babylonjs/Collisions/meshCollisionData";
  52093. }
  52094. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52095. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52096. import { Vector3 } from "babylonjs/Maths/math.vector";
  52097. import { Ray } from "babylonjs/Culling/ray";
  52098. import { Plane } from "babylonjs/Maths/math.plane";
  52099. /**
  52100. * Contains an array of blocks representing the octree
  52101. */
  52102. export interface IOctreeContainer<T> {
  52103. /**
  52104. * Blocks within the octree
  52105. */
  52106. blocks: Array<OctreeBlock<T>>;
  52107. }
  52108. /**
  52109. * Class used to store a cell in an octree
  52110. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52111. */
  52112. export class OctreeBlock<T> {
  52113. /**
  52114. * Gets the content of the current block
  52115. */
  52116. entries: T[];
  52117. /**
  52118. * Gets the list of block children
  52119. */
  52120. blocks: Array<OctreeBlock<T>>;
  52121. private _depth;
  52122. private _maxDepth;
  52123. private _capacity;
  52124. private _minPoint;
  52125. private _maxPoint;
  52126. private _boundingVectors;
  52127. private _creationFunc;
  52128. /**
  52129. * Creates a new block
  52130. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52131. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52132. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52133. * @param depth defines the current depth of this block in the octree
  52134. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52135. * @param creationFunc defines a callback to call when an element is added to the block
  52136. */
  52137. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52138. /**
  52139. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52140. */
  52141. get capacity(): number;
  52142. /**
  52143. * Gets the minimum vector (in world space) of the block's bounding box
  52144. */
  52145. get minPoint(): Vector3;
  52146. /**
  52147. * Gets the maximum vector (in world space) of the block's bounding box
  52148. */
  52149. get maxPoint(): Vector3;
  52150. /**
  52151. * Add a new element to this block
  52152. * @param entry defines the element to add
  52153. */
  52154. addEntry(entry: T): void;
  52155. /**
  52156. * Remove an element from this block
  52157. * @param entry defines the element to remove
  52158. */
  52159. removeEntry(entry: T): void;
  52160. /**
  52161. * Add an array of elements to this block
  52162. * @param entries defines the array of elements to add
  52163. */
  52164. addEntries(entries: T[]): void;
  52165. /**
  52166. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52167. * @param frustumPlanes defines the frustum planes to test
  52168. * @param selection defines the array to store current content if selection is positive
  52169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52170. */
  52171. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52172. /**
  52173. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52174. * @param sphereCenter defines the bounding sphere center
  52175. * @param sphereRadius defines the bounding sphere radius
  52176. * @param selection defines the array to store current content if selection is positive
  52177. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52178. */
  52179. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52180. /**
  52181. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52182. * @param ray defines the ray to test with
  52183. * @param selection defines the array to store current content if selection is positive
  52184. */
  52185. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52186. /**
  52187. * Subdivide the content into child blocks (this block will then be empty)
  52188. */
  52189. createInnerBlocks(): void;
  52190. /**
  52191. * @hidden
  52192. */
  52193. 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;
  52194. }
  52195. }
  52196. declare module "babylonjs/Culling/Octrees/octree" {
  52197. import { SmartArray } from "babylonjs/Misc/smartArray";
  52198. import { Vector3 } from "babylonjs/Maths/math.vector";
  52199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52201. import { Ray } from "babylonjs/Culling/ray";
  52202. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52203. import { Plane } from "babylonjs/Maths/math.plane";
  52204. /**
  52205. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52207. */
  52208. export class Octree<T> {
  52209. /** 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.) */
  52210. maxDepth: number;
  52211. /**
  52212. * Blocks within the octree containing objects
  52213. */
  52214. blocks: Array<OctreeBlock<T>>;
  52215. /**
  52216. * Content stored in the octree
  52217. */
  52218. dynamicContent: T[];
  52219. private _maxBlockCapacity;
  52220. private _selectionContent;
  52221. private _creationFunc;
  52222. /**
  52223. * Creates a octree
  52224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52225. * @param creationFunc function to be used to instatiate the octree
  52226. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52227. * @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.)
  52228. */
  52229. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52230. /** 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.) */
  52231. maxDepth?: number);
  52232. /**
  52233. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52234. * @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);
  52235. * @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);
  52236. * @param entries meshes to be added to the octree blocks
  52237. */
  52238. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52239. /**
  52240. * Adds a mesh to the octree
  52241. * @param entry Mesh to add to the octree
  52242. */
  52243. addMesh(entry: T): void;
  52244. /**
  52245. * Remove an element from the octree
  52246. * @param entry defines the element to remove
  52247. */
  52248. removeMesh(entry: T): void;
  52249. /**
  52250. * Selects an array of meshes within the frustum
  52251. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52252. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52253. * @returns array of meshes within the frustum
  52254. */
  52255. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52256. /**
  52257. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52258. * @param sphereCenter defines the bounding sphere center
  52259. * @param sphereRadius defines the bounding sphere radius
  52260. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52261. * @returns an array of objects that intersect the sphere
  52262. */
  52263. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52264. /**
  52265. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52266. * @param ray defines the ray to test with
  52267. * @returns array of intersected objects
  52268. */
  52269. intersectsRay(ray: Ray): SmartArray<T>;
  52270. /**
  52271. * Adds a mesh into the octree block if it intersects the block
  52272. */
  52273. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52274. /**
  52275. * Adds a submesh into the octree block if it intersects the block
  52276. */
  52277. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52278. }
  52279. }
  52280. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52281. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52282. import { Scene } from "babylonjs/scene";
  52283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52285. import { Ray } from "babylonjs/Culling/ray";
  52286. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52287. import { Collider } from "babylonjs/Collisions/collider";
  52288. module "babylonjs/scene" {
  52289. interface Scene {
  52290. /**
  52291. * @hidden
  52292. * Backing Filed
  52293. */
  52294. _selectionOctree: Octree<AbstractMesh>;
  52295. /**
  52296. * Gets the octree used to boost mesh selection (picking)
  52297. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52298. */
  52299. selectionOctree: Octree<AbstractMesh>;
  52300. /**
  52301. * Creates or updates the octree used to boost selection (picking)
  52302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52303. * @param maxCapacity defines the maximum capacity per leaf
  52304. * @param maxDepth defines the maximum depth of the octree
  52305. * @returns an octree of AbstractMesh
  52306. */
  52307. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52308. }
  52309. }
  52310. module "babylonjs/Meshes/abstractMesh" {
  52311. interface AbstractMesh {
  52312. /**
  52313. * @hidden
  52314. * Backing Field
  52315. */
  52316. _submeshesOctree: Octree<SubMesh>;
  52317. /**
  52318. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52319. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52320. * @param maxCapacity defines the maximum size of each block (64 by default)
  52321. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52322. * @returns the new octree
  52323. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52325. */
  52326. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52327. }
  52328. }
  52329. /**
  52330. * Defines the octree scene component responsible to manage any octrees
  52331. * in a given scene.
  52332. */
  52333. export class OctreeSceneComponent {
  52334. /**
  52335. * The component name help to identify the component in the list of scene components.
  52336. */
  52337. readonly name: string;
  52338. /**
  52339. * The scene the component belongs to.
  52340. */
  52341. scene: Scene;
  52342. /**
  52343. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52344. */
  52345. readonly checksIsEnabled: boolean;
  52346. /**
  52347. * Creates a new instance of the component for the given scene
  52348. * @param scene Defines the scene to register the component in
  52349. */
  52350. constructor(scene: Scene);
  52351. /**
  52352. * Registers the component in a given scene
  52353. */
  52354. register(): void;
  52355. /**
  52356. * Return the list of active meshes
  52357. * @returns the list of active meshes
  52358. */
  52359. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52360. /**
  52361. * Return the list of active sub meshes
  52362. * @param mesh The mesh to get the candidates sub meshes from
  52363. * @returns the list of active sub meshes
  52364. */
  52365. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52366. private _tempRay;
  52367. /**
  52368. * Return the list of sub meshes intersecting with a given local ray
  52369. * @param mesh defines the mesh to find the submesh for
  52370. * @param localRay defines the ray in local space
  52371. * @returns the list of intersecting sub meshes
  52372. */
  52373. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52374. /**
  52375. * Return the list of sub meshes colliding with a collider
  52376. * @param mesh defines the mesh to find the submesh for
  52377. * @param collider defines the collider to evaluate the collision against
  52378. * @returns the list of colliding sub meshes
  52379. */
  52380. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52381. /**
  52382. * Rebuilds the elements related to this component in case of
  52383. * context lost for instance.
  52384. */
  52385. rebuild(): void;
  52386. /**
  52387. * Disposes the component and the associated ressources.
  52388. */
  52389. dispose(): void;
  52390. }
  52391. }
  52392. declare module "babylonjs/Culling/Octrees/index" {
  52393. export * from "babylonjs/Culling/Octrees/octree";
  52394. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52395. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52396. }
  52397. declare module "babylonjs/Culling/index" {
  52398. export * from "babylonjs/Culling/boundingBox";
  52399. export * from "babylonjs/Culling/boundingInfo";
  52400. export * from "babylonjs/Culling/boundingSphere";
  52401. export * from "babylonjs/Culling/Octrees/index";
  52402. export * from "babylonjs/Culling/ray";
  52403. }
  52404. declare module "babylonjs/Gizmos/gizmo" {
  52405. import { Nullable } from "babylonjs/types";
  52406. import { IDisposable } from "babylonjs/scene";
  52407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52408. import { Mesh } from "babylonjs/Meshes/mesh";
  52409. import { Node } from "babylonjs/node";
  52410. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52411. /**
  52412. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52413. */
  52414. export class Gizmo implements IDisposable {
  52415. /** The utility layer the gizmo will be added to */
  52416. gizmoLayer: UtilityLayerRenderer;
  52417. /**
  52418. * The root mesh of the gizmo
  52419. */
  52420. _rootMesh: Mesh;
  52421. private _attachedMesh;
  52422. private _attachedNode;
  52423. /**
  52424. * Ratio for the scale of the gizmo (Default: 1)
  52425. */
  52426. protected _scaleRatio: number;
  52427. /**
  52428. * boolean updated by pointermove when a gizmo mesh is hovered
  52429. */
  52430. protected _isHovered: boolean;
  52431. /**
  52432. * Ratio for the scale of the gizmo (Default: 1)
  52433. */
  52434. set scaleRatio(value: number);
  52435. get scaleRatio(): number;
  52436. /**
  52437. * True when the mouse pointer is hovered a gizmo mesh
  52438. */
  52439. get isHovered(): boolean;
  52440. /**
  52441. * If a custom mesh has been set (Default: false)
  52442. */
  52443. protected _customMeshSet: boolean;
  52444. /**
  52445. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52446. * * When set, interactions will be enabled
  52447. */
  52448. get attachedMesh(): Nullable<AbstractMesh>;
  52449. set attachedMesh(value: Nullable<AbstractMesh>);
  52450. /**
  52451. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52452. * * When set, interactions will be enabled
  52453. */
  52454. get attachedNode(): Nullable<Node>;
  52455. set attachedNode(value: Nullable<Node>);
  52456. /**
  52457. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52458. * @param mesh The mesh to replace the default mesh of the gizmo
  52459. */
  52460. setCustomMesh(mesh: Mesh): void;
  52461. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52462. /**
  52463. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52464. */
  52465. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52466. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52467. /**
  52468. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52469. */
  52470. updateGizmoPositionToMatchAttachedMesh: boolean;
  52471. /**
  52472. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52473. */
  52474. updateScale: boolean;
  52475. protected _interactionsEnabled: boolean;
  52476. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52477. private _beforeRenderObserver;
  52478. private _tempQuaternion;
  52479. private _tempVector;
  52480. private _tempVector2;
  52481. private _tempMatrix1;
  52482. private _tempMatrix2;
  52483. private _rightHandtoLeftHandMatrix;
  52484. /**
  52485. * Creates a gizmo
  52486. * @param gizmoLayer The utility layer the gizmo will be added to
  52487. */
  52488. constructor(
  52489. /** The utility layer the gizmo will be added to */
  52490. gizmoLayer?: UtilityLayerRenderer);
  52491. /**
  52492. * Updates the gizmo to match the attached mesh's position/rotation
  52493. */
  52494. protected _update(): void;
  52495. /**
  52496. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52497. * @param value Node, TransformNode or mesh
  52498. */
  52499. protected _matrixChanged(): void;
  52500. /**
  52501. * Disposes of the gizmo
  52502. */
  52503. dispose(): void;
  52504. }
  52505. }
  52506. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52507. import { Observable } from "babylonjs/Misc/observable";
  52508. import { Nullable } from "babylonjs/types";
  52509. import { Vector3 } from "babylonjs/Maths/math.vector";
  52510. import { Color3 } from "babylonjs/Maths/math.color";
  52511. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52512. import { Node } from "babylonjs/node";
  52513. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52514. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52515. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52516. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52517. import { Scene } from "babylonjs/scene";
  52518. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52519. /**
  52520. * Single plane drag gizmo
  52521. */
  52522. export class PlaneDragGizmo extends Gizmo {
  52523. /**
  52524. * Drag behavior responsible for the gizmos dragging interactions
  52525. */
  52526. dragBehavior: PointerDragBehavior;
  52527. private _pointerObserver;
  52528. /**
  52529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52530. */
  52531. snapDistance: number;
  52532. /**
  52533. * Event that fires each time the gizmo snaps to a new location.
  52534. * * snapDistance is the the change in distance
  52535. */
  52536. onSnapObservable: Observable<{
  52537. snapDistance: number;
  52538. }>;
  52539. private _plane;
  52540. private _coloredMaterial;
  52541. private _hoverMaterial;
  52542. private _isEnabled;
  52543. private _parent;
  52544. /** @hidden */
  52545. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52546. /** @hidden */
  52547. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52548. /**
  52549. * Creates a PlaneDragGizmo
  52550. * @param gizmoLayer The utility layer the gizmo will be added to
  52551. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52552. * @param color The color of the gizmo
  52553. */
  52554. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52555. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52556. /**
  52557. * If the gizmo is enabled
  52558. */
  52559. set isEnabled(value: boolean);
  52560. get isEnabled(): boolean;
  52561. /**
  52562. * Disposes of the gizmo
  52563. */
  52564. dispose(): void;
  52565. }
  52566. }
  52567. declare module "babylonjs/Gizmos/positionGizmo" {
  52568. import { Observable } from "babylonjs/Misc/observable";
  52569. import { Nullable } from "babylonjs/types";
  52570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52571. import { Node } from "babylonjs/node";
  52572. import { Mesh } from "babylonjs/Meshes/mesh";
  52573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52574. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52575. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52576. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52577. /**
  52578. * Gizmo that enables dragging a mesh along 3 axis
  52579. */
  52580. export class PositionGizmo extends Gizmo {
  52581. /**
  52582. * Internal gizmo used for interactions on the x axis
  52583. */
  52584. xGizmo: AxisDragGizmo;
  52585. /**
  52586. * Internal gizmo used for interactions on the y axis
  52587. */
  52588. yGizmo: AxisDragGizmo;
  52589. /**
  52590. * Internal gizmo used for interactions on the z axis
  52591. */
  52592. zGizmo: AxisDragGizmo;
  52593. /**
  52594. * Internal gizmo used for interactions on the yz plane
  52595. */
  52596. xPlaneGizmo: PlaneDragGizmo;
  52597. /**
  52598. * Internal gizmo used for interactions on the xz plane
  52599. */
  52600. yPlaneGizmo: PlaneDragGizmo;
  52601. /**
  52602. * Internal gizmo used for interactions on the xy plane
  52603. */
  52604. zPlaneGizmo: PlaneDragGizmo;
  52605. /**
  52606. * private variables
  52607. */
  52608. private _meshAttached;
  52609. private _nodeAttached;
  52610. private _snapDistance;
  52611. /** Fires an event when any of it's sub gizmos are dragged */
  52612. onDragStartObservable: Observable<unknown>;
  52613. /** Fires an event when any of it's sub gizmos are released from dragging */
  52614. onDragEndObservable: Observable<unknown>;
  52615. /**
  52616. * If set to true, planar drag is enabled
  52617. */
  52618. private _planarGizmoEnabled;
  52619. get attachedMesh(): Nullable<AbstractMesh>;
  52620. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52621. get attachedNode(): Nullable<Node>;
  52622. set attachedNode(node: Nullable<Node>);
  52623. /**
  52624. * True when the mouse pointer is hovering a gizmo mesh
  52625. */
  52626. get isHovered(): boolean;
  52627. /**
  52628. * Creates a PositionGizmo
  52629. * @param gizmoLayer The utility layer the gizmo will be added to
  52630. @param thickness display gizmo axis thickness
  52631. */
  52632. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52633. /**
  52634. * If the planar drag gizmo is enabled
  52635. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52636. */
  52637. set planarGizmoEnabled(value: boolean);
  52638. get planarGizmoEnabled(): boolean;
  52639. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52640. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52641. /**
  52642. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52643. */
  52644. set snapDistance(value: number);
  52645. get snapDistance(): number;
  52646. /**
  52647. * Ratio for the scale of the gizmo (Default: 1)
  52648. */
  52649. set scaleRatio(value: number);
  52650. get scaleRatio(): number;
  52651. /**
  52652. * Disposes of the gizmo
  52653. */
  52654. dispose(): void;
  52655. /**
  52656. * CustomMeshes are not supported by this gizmo
  52657. * @param mesh The mesh to replace the default mesh of the gizmo
  52658. */
  52659. setCustomMesh(mesh: Mesh): void;
  52660. }
  52661. }
  52662. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52663. import { Observable } from "babylonjs/Misc/observable";
  52664. import { Nullable } from "babylonjs/types";
  52665. import { Vector3 } from "babylonjs/Maths/math.vector";
  52666. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52667. import { Node } from "babylonjs/node";
  52668. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52669. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52670. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52671. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52672. import { Scene } from "babylonjs/scene";
  52673. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52674. import { Color3 } from "babylonjs/Maths/math.color";
  52675. /**
  52676. * Single axis drag gizmo
  52677. */
  52678. export class AxisDragGizmo extends Gizmo {
  52679. /**
  52680. * Drag behavior responsible for the gizmos dragging interactions
  52681. */
  52682. dragBehavior: PointerDragBehavior;
  52683. private _pointerObserver;
  52684. /**
  52685. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52686. */
  52687. snapDistance: number;
  52688. /**
  52689. * Event that fires each time the gizmo snaps to a new location.
  52690. * * snapDistance is the the change in distance
  52691. */
  52692. onSnapObservable: Observable<{
  52693. snapDistance: number;
  52694. }>;
  52695. private _isEnabled;
  52696. private _parent;
  52697. private _arrow;
  52698. private _coloredMaterial;
  52699. private _hoverMaterial;
  52700. /** @hidden */
  52701. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52702. /** @hidden */
  52703. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52704. /**
  52705. * Creates an AxisDragGizmo
  52706. * @param gizmoLayer The utility layer the gizmo will be added to
  52707. * @param dragAxis The axis which the gizmo will be able to drag on
  52708. * @param color The color of the gizmo
  52709. * @param thickness display gizmo axis thickness
  52710. */
  52711. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52712. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52713. /**
  52714. * If the gizmo is enabled
  52715. */
  52716. set isEnabled(value: boolean);
  52717. get isEnabled(): boolean;
  52718. /**
  52719. * Disposes of the gizmo
  52720. */
  52721. dispose(): void;
  52722. }
  52723. }
  52724. declare module "babylonjs/Debug/axesViewer" {
  52725. import { Vector3 } from "babylonjs/Maths/math.vector";
  52726. import { Nullable } from "babylonjs/types";
  52727. import { Scene } from "babylonjs/scene";
  52728. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52729. /**
  52730. * The Axes viewer will show 3 axes in a specific point in space
  52731. */
  52732. export class AxesViewer {
  52733. private _xAxis;
  52734. private _yAxis;
  52735. private _zAxis;
  52736. private _scaleLinesFactor;
  52737. private _instanced;
  52738. /**
  52739. * Gets the hosting scene
  52740. */
  52741. scene: Nullable<Scene>;
  52742. /**
  52743. * Gets or sets a number used to scale line length
  52744. */
  52745. scaleLines: number;
  52746. /** Gets the node hierarchy used to render x-axis */
  52747. get xAxis(): TransformNode;
  52748. /** Gets the node hierarchy used to render y-axis */
  52749. get yAxis(): TransformNode;
  52750. /** Gets the node hierarchy used to render z-axis */
  52751. get zAxis(): TransformNode;
  52752. /**
  52753. * Creates a new AxesViewer
  52754. * @param scene defines the hosting scene
  52755. * @param scaleLines defines a number used to scale line length (1 by default)
  52756. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52757. * @param xAxis defines the node hierarchy used to render the x-axis
  52758. * @param yAxis defines the node hierarchy used to render the y-axis
  52759. * @param zAxis defines the node hierarchy used to render the z-axis
  52760. */
  52761. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52762. /**
  52763. * Force the viewer to update
  52764. * @param position defines the position of the viewer
  52765. * @param xaxis defines the x axis of the viewer
  52766. * @param yaxis defines the y axis of the viewer
  52767. * @param zaxis defines the z axis of the viewer
  52768. */
  52769. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52770. /**
  52771. * Creates an instance of this axes viewer.
  52772. * @returns a new axes viewer with instanced meshes
  52773. */
  52774. createInstance(): AxesViewer;
  52775. /** Releases resources */
  52776. dispose(): void;
  52777. private static _SetRenderingGroupId;
  52778. }
  52779. }
  52780. declare module "babylonjs/Debug/boneAxesViewer" {
  52781. import { Nullable } from "babylonjs/types";
  52782. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52783. import { Vector3 } from "babylonjs/Maths/math.vector";
  52784. import { Mesh } from "babylonjs/Meshes/mesh";
  52785. import { Bone } from "babylonjs/Bones/bone";
  52786. import { Scene } from "babylonjs/scene";
  52787. /**
  52788. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52789. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52790. */
  52791. export class BoneAxesViewer extends AxesViewer {
  52792. /**
  52793. * Gets or sets the target mesh where to display the axes viewer
  52794. */
  52795. mesh: Nullable<Mesh>;
  52796. /**
  52797. * Gets or sets the target bone where to display the axes viewer
  52798. */
  52799. bone: Nullable<Bone>;
  52800. /** Gets current position */
  52801. pos: Vector3;
  52802. /** Gets direction of X axis */
  52803. xaxis: Vector3;
  52804. /** Gets direction of Y axis */
  52805. yaxis: Vector3;
  52806. /** Gets direction of Z axis */
  52807. zaxis: Vector3;
  52808. /**
  52809. * Creates a new BoneAxesViewer
  52810. * @param scene defines the hosting scene
  52811. * @param bone defines the target bone
  52812. * @param mesh defines the target mesh
  52813. * @param scaleLines defines a scaling factor for line length (1 by default)
  52814. */
  52815. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52816. /**
  52817. * Force the viewer to update
  52818. */
  52819. update(): void;
  52820. /** Releases resources */
  52821. dispose(): void;
  52822. }
  52823. }
  52824. declare module "babylonjs/Debug/debugLayer" {
  52825. import { Scene } from "babylonjs/scene";
  52826. /**
  52827. * Interface used to define scene explorer extensibility option
  52828. */
  52829. export interface IExplorerExtensibilityOption {
  52830. /**
  52831. * Define the option label
  52832. */
  52833. label: string;
  52834. /**
  52835. * Defines the action to execute on click
  52836. */
  52837. action: (entity: any) => void;
  52838. }
  52839. /**
  52840. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52841. */
  52842. export interface IExplorerExtensibilityGroup {
  52843. /**
  52844. * Defines a predicate to test if a given type mut be extended
  52845. */
  52846. predicate: (entity: any) => boolean;
  52847. /**
  52848. * Gets the list of options added to a type
  52849. */
  52850. entries: IExplorerExtensibilityOption[];
  52851. }
  52852. /**
  52853. * Interface used to define the options to use to create the Inspector
  52854. */
  52855. export interface IInspectorOptions {
  52856. /**
  52857. * Display in overlay mode (default: false)
  52858. */
  52859. overlay?: boolean;
  52860. /**
  52861. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52862. */
  52863. globalRoot?: HTMLElement;
  52864. /**
  52865. * Display the Scene explorer
  52866. */
  52867. showExplorer?: boolean;
  52868. /**
  52869. * Display the property inspector
  52870. */
  52871. showInspector?: boolean;
  52872. /**
  52873. * Display in embed mode (both panes on the right)
  52874. */
  52875. embedMode?: boolean;
  52876. /**
  52877. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52878. */
  52879. handleResize?: boolean;
  52880. /**
  52881. * Allow the panes to popup (default: true)
  52882. */
  52883. enablePopup?: boolean;
  52884. /**
  52885. * Allow the panes to be closed by users (default: true)
  52886. */
  52887. enableClose?: boolean;
  52888. /**
  52889. * Optional list of extensibility entries
  52890. */
  52891. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52892. /**
  52893. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52894. */
  52895. inspectorURL?: string;
  52896. /**
  52897. * Optional initial tab (default to DebugLayerTab.Properties)
  52898. */
  52899. initialTab?: DebugLayerTab;
  52900. }
  52901. module "babylonjs/scene" {
  52902. interface Scene {
  52903. /**
  52904. * @hidden
  52905. * Backing field
  52906. */
  52907. _debugLayer: DebugLayer;
  52908. /**
  52909. * Gets the debug layer (aka Inspector) associated with the scene
  52910. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52911. */
  52912. debugLayer: DebugLayer;
  52913. }
  52914. }
  52915. /**
  52916. * Enum of inspector action tab
  52917. */
  52918. export enum DebugLayerTab {
  52919. /**
  52920. * Properties tag (default)
  52921. */
  52922. Properties = 0,
  52923. /**
  52924. * Debug tab
  52925. */
  52926. Debug = 1,
  52927. /**
  52928. * Statistics tab
  52929. */
  52930. Statistics = 2,
  52931. /**
  52932. * Tools tab
  52933. */
  52934. Tools = 3,
  52935. /**
  52936. * Settings tab
  52937. */
  52938. Settings = 4
  52939. }
  52940. /**
  52941. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52942. * what is happening in your scene
  52943. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52944. */
  52945. export class DebugLayer {
  52946. /**
  52947. * Define the url to get the inspector script from.
  52948. * By default it uses the babylonjs CDN.
  52949. * @ignoreNaming
  52950. */
  52951. static InspectorURL: string;
  52952. private _scene;
  52953. private BJSINSPECTOR;
  52954. private _onPropertyChangedObservable?;
  52955. /**
  52956. * Observable triggered when a property is changed through the inspector.
  52957. */
  52958. get onPropertyChangedObservable(): any;
  52959. /**
  52960. * Instantiates a new debug layer.
  52961. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52962. * what is happening in your scene
  52963. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52964. * @param scene Defines the scene to inspect
  52965. */
  52966. constructor(scene: Scene);
  52967. /** Creates the inspector window. */
  52968. private _createInspector;
  52969. /**
  52970. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52971. * @param entity defines the entity to select
  52972. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52973. */
  52974. select(entity: any, lineContainerTitles?: string | string[]): void;
  52975. /** Get the inspector from bundle or global */
  52976. private _getGlobalInspector;
  52977. /**
  52978. * Get if the inspector is visible or not.
  52979. * @returns true if visible otherwise, false
  52980. */
  52981. isVisible(): boolean;
  52982. /**
  52983. * Hide the inspector and close its window.
  52984. */
  52985. hide(): void;
  52986. /**
  52987. * Update the scene in the inspector
  52988. */
  52989. setAsActiveScene(): void;
  52990. /**
  52991. * Launch the debugLayer.
  52992. * @param config Define the configuration of the inspector
  52993. * @return a promise fulfilled when the debug layer is visible
  52994. */
  52995. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52996. }
  52997. }
  52998. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52999. import { Nullable } from "babylonjs/types";
  53000. import { Scene } from "babylonjs/scene";
  53001. import { Vector4 } from "babylonjs/Maths/math.vector";
  53002. import { Color4 } from "babylonjs/Maths/math.color";
  53003. import { Mesh } from "babylonjs/Meshes/mesh";
  53004. /**
  53005. * Class containing static functions to help procedurally build meshes
  53006. */
  53007. export class BoxBuilder {
  53008. /**
  53009. * Creates a box mesh
  53010. * * The parameter `size` sets the size (float) of each box side (default 1)
  53011. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53012. * * 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)
  53013. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53017. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53018. * @param name defines the name of the mesh
  53019. * @param options defines the options used to create the mesh
  53020. * @param scene defines the hosting scene
  53021. * @returns the box mesh
  53022. */
  53023. static CreateBox(name: string, options: {
  53024. size?: number;
  53025. width?: number;
  53026. height?: number;
  53027. depth?: number;
  53028. faceUV?: Vector4[];
  53029. faceColors?: Color4[];
  53030. sideOrientation?: number;
  53031. frontUVs?: Vector4;
  53032. backUVs?: Vector4;
  53033. wrap?: boolean;
  53034. topBaseAt?: number;
  53035. bottomBaseAt?: number;
  53036. updatable?: boolean;
  53037. }, scene?: Nullable<Scene>): Mesh;
  53038. }
  53039. }
  53040. declare module "babylonjs/Debug/physicsViewer" {
  53041. import { Nullable } from "babylonjs/types";
  53042. import { Scene } from "babylonjs/scene";
  53043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53044. import { Mesh } from "babylonjs/Meshes/mesh";
  53045. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53046. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53047. /**
  53048. * Used to show the physics impostor around the specific mesh
  53049. */
  53050. export class PhysicsViewer {
  53051. /** @hidden */
  53052. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53053. /** @hidden */
  53054. protected _meshes: Array<Nullable<AbstractMesh>>;
  53055. /** @hidden */
  53056. protected _scene: Nullable<Scene>;
  53057. /** @hidden */
  53058. protected _numMeshes: number;
  53059. /** @hidden */
  53060. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53061. private _renderFunction;
  53062. private _utilityLayer;
  53063. private _debugBoxMesh;
  53064. private _debugSphereMesh;
  53065. private _debugCylinderMesh;
  53066. private _debugMaterial;
  53067. private _debugMeshMeshes;
  53068. /**
  53069. * Creates a new PhysicsViewer
  53070. * @param scene defines the hosting scene
  53071. */
  53072. constructor(scene: Scene);
  53073. /** @hidden */
  53074. protected _updateDebugMeshes(): void;
  53075. /**
  53076. * Renders a specified physic impostor
  53077. * @param impostor defines the impostor to render
  53078. * @param targetMesh defines the mesh represented by the impostor
  53079. * @returns the new debug mesh used to render the impostor
  53080. */
  53081. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53082. /**
  53083. * Hides a specified physic impostor
  53084. * @param impostor defines the impostor to hide
  53085. */
  53086. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53087. private _getDebugMaterial;
  53088. private _getDebugBoxMesh;
  53089. private _getDebugSphereMesh;
  53090. private _getDebugCylinderMesh;
  53091. private _getDebugMeshMesh;
  53092. private _getDebugMesh;
  53093. /** Releases all resources */
  53094. dispose(): void;
  53095. }
  53096. }
  53097. declare module "babylonjs/Debug/rayHelper" {
  53098. import { Nullable } from "babylonjs/types";
  53099. import { Ray } from "babylonjs/Culling/ray";
  53100. import { Vector3 } from "babylonjs/Maths/math.vector";
  53101. import { Color3 } from "babylonjs/Maths/math.color";
  53102. import { Scene } from "babylonjs/scene";
  53103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53104. import "babylonjs/Meshes/Builders/linesBuilder";
  53105. /**
  53106. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53107. * in order to better appreciate the issue one might have.
  53108. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53109. */
  53110. export class RayHelper {
  53111. /**
  53112. * Defines the ray we are currently tryin to visualize.
  53113. */
  53114. ray: Nullable<Ray>;
  53115. private _renderPoints;
  53116. private _renderLine;
  53117. private _renderFunction;
  53118. private _scene;
  53119. private _onAfterRenderObserver;
  53120. private _onAfterStepObserver;
  53121. private _attachedToMesh;
  53122. private _meshSpaceDirection;
  53123. private _meshSpaceOrigin;
  53124. /**
  53125. * Helper function to create a colored helper in a scene in one line.
  53126. * @param ray Defines the ray we are currently tryin to visualize
  53127. * @param scene Defines the scene the ray is used in
  53128. * @param color Defines the color we want to see the ray in
  53129. * @returns The newly created ray helper.
  53130. */
  53131. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53132. /**
  53133. * Instantiate a new ray helper.
  53134. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53135. * in order to better appreciate the issue one might have.
  53136. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53137. * @param ray Defines the ray we are currently tryin to visualize
  53138. */
  53139. constructor(ray: Ray);
  53140. /**
  53141. * Shows the ray we are willing to debug.
  53142. * @param scene Defines the scene the ray needs to be rendered in
  53143. * @param color Defines the color the ray needs to be rendered in
  53144. */
  53145. show(scene: Scene, color?: Color3): void;
  53146. /**
  53147. * Hides the ray we are debugging.
  53148. */
  53149. hide(): void;
  53150. private _render;
  53151. /**
  53152. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53153. * @param mesh Defines the mesh we want the helper attached to
  53154. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53155. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53156. * @param length Defines the length of the ray
  53157. */
  53158. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53159. /**
  53160. * Detach the ray helper from the mesh it has previously been attached to.
  53161. */
  53162. detachFromMesh(): void;
  53163. private _updateToMesh;
  53164. /**
  53165. * Dispose the helper and release its associated resources.
  53166. */
  53167. dispose(): void;
  53168. }
  53169. }
  53170. declare module "babylonjs/Debug/ISkeletonViewer" {
  53171. import { Skeleton } from "babylonjs/Bones/skeleton";
  53172. import { Color3 } from "babylonjs/Maths/math.color";
  53173. /**
  53174. * Defines the options associated with the creation of a SkeletonViewer.
  53175. */
  53176. export interface ISkeletonViewerOptions {
  53177. /** Should the system pause animations before building the Viewer? */
  53178. pauseAnimations: boolean;
  53179. /** Should the system return the skeleton to rest before building? */
  53180. returnToRest: boolean;
  53181. /** public Display Mode of the Viewer */
  53182. displayMode: number;
  53183. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53184. displayOptions: ISkeletonViewerDisplayOptions;
  53185. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53186. computeBonesUsingShaders: boolean;
  53187. /** Flag ignore non weighted bones */
  53188. useAllBones: boolean;
  53189. }
  53190. /**
  53191. * Defines how to display the various bone meshes for the viewer.
  53192. */
  53193. export interface ISkeletonViewerDisplayOptions {
  53194. /** How far down to start tapering the bone spurs */
  53195. midStep?: number;
  53196. /** How big is the midStep? */
  53197. midStepFactor?: number;
  53198. /** Base for the Sphere Size */
  53199. sphereBaseSize?: number;
  53200. /** The ratio of the sphere to the longest bone in units */
  53201. sphereScaleUnit?: number;
  53202. /** Ratio for the Sphere Size */
  53203. sphereFactor?: number;
  53204. /** Whether to show local axes or not */
  53205. showLocalAxes?: boolean;
  53206. /** Length of each local axis */
  53207. localAxesSize?: number;
  53208. }
  53209. /**
  53210. * Defines the constructor options for the BoneWeight Shader.
  53211. */
  53212. export interface IBoneWeightShaderOptions {
  53213. /** Skeleton to Map */
  53214. skeleton: Skeleton;
  53215. /** Colors for Uninfluenced bones */
  53216. colorBase?: Color3;
  53217. /** Colors for 0.0-0.25 Weight bones */
  53218. colorZero?: Color3;
  53219. /** Color for 0.25-0.5 Weight Influence */
  53220. colorQuarter?: Color3;
  53221. /** Color for 0.5-0.75 Weight Influence */
  53222. colorHalf?: Color3;
  53223. /** Color for 0.75-1 Weight Influence */
  53224. colorFull?: Color3;
  53225. /** Color for Zero Weight Influence */
  53226. targetBoneIndex?: number;
  53227. }
  53228. /**
  53229. * Simple structure of the gradient steps for the Color Map.
  53230. */
  53231. export interface ISkeletonMapShaderColorMapKnot {
  53232. /** Color of the Knot */
  53233. color: Color3;
  53234. /** Location of the Knot */
  53235. location: number;
  53236. }
  53237. /**
  53238. * Defines the constructor options for the SkeletonMap Shader.
  53239. */
  53240. export interface ISkeletonMapShaderOptions {
  53241. /** Skeleton to Map */
  53242. skeleton: Skeleton;
  53243. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53244. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53245. }
  53246. }
  53247. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53248. import { Nullable } from "babylonjs/types";
  53249. import { Scene } from "babylonjs/scene";
  53250. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53251. import { Color4 } from "babylonjs/Maths/math.color";
  53252. import { Mesh } from "babylonjs/Meshes/mesh";
  53253. /**
  53254. * Class containing static functions to help procedurally build meshes
  53255. */
  53256. export class RibbonBuilder {
  53257. /**
  53258. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53259. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53260. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53261. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53262. * * 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
  53263. * * 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
  53264. * * 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
  53265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53268. * * 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
  53269. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53270. * * 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
  53271. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53273. * @param name defines the name of the mesh
  53274. * @param options defines the options used to create the mesh
  53275. * @param scene defines the hosting scene
  53276. * @returns the ribbon mesh
  53277. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53279. */
  53280. static CreateRibbon(name: string, options: {
  53281. pathArray: Vector3[][];
  53282. closeArray?: boolean;
  53283. closePath?: boolean;
  53284. offset?: number;
  53285. updatable?: boolean;
  53286. sideOrientation?: number;
  53287. frontUVs?: Vector4;
  53288. backUVs?: Vector4;
  53289. instance?: Mesh;
  53290. invertUV?: boolean;
  53291. uvs?: Vector2[];
  53292. colors?: Color4[];
  53293. }, scene?: Nullable<Scene>): Mesh;
  53294. }
  53295. }
  53296. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53297. import { Nullable } from "babylonjs/types";
  53298. import { Scene } from "babylonjs/scene";
  53299. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53300. import { Mesh } from "babylonjs/Meshes/mesh";
  53301. /**
  53302. * Class containing static functions to help procedurally build meshes
  53303. */
  53304. export class ShapeBuilder {
  53305. /**
  53306. * 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.
  53307. * * 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.
  53308. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53309. * * 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.
  53310. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53311. * * 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
  53312. * * 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
  53313. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53318. * @param name defines the name of the mesh
  53319. * @param options defines the options used to create the mesh
  53320. * @param scene defines the hosting scene
  53321. * @returns the extruded shape mesh
  53322. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53324. */
  53325. static ExtrudeShape(name: string, options: {
  53326. shape: Vector3[];
  53327. path: Vector3[];
  53328. scale?: number;
  53329. rotation?: number;
  53330. cap?: number;
  53331. updatable?: boolean;
  53332. sideOrientation?: number;
  53333. frontUVs?: Vector4;
  53334. backUVs?: Vector4;
  53335. instance?: Mesh;
  53336. invertUV?: boolean;
  53337. }, scene?: Nullable<Scene>): Mesh;
  53338. /**
  53339. * Creates an custom extruded shape mesh.
  53340. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53341. * * 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.
  53342. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53343. * * 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
  53344. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53345. * * 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
  53346. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53347. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53348. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53349. * * 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
  53350. * * 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
  53351. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53356. * @param name defines the name of the mesh
  53357. * @param options defines the options used to create the mesh
  53358. * @param scene defines the hosting scene
  53359. * @returns the custom extruded shape mesh
  53360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53363. */
  53364. static ExtrudeShapeCustom(name: string, options: {
  53365. shape: Vector3[];
  53366. path: Vector3[];
  53367. scaleFunction?: any;
  53368. rotationFunction?: any;
  53369. ribbonCloseArray?: boolean;
  53370. ribbonClosePath?: boolean;
  53371. cap?: number;
  53372. updatable?: boolean;
  53373. sideOrientation?: number;
  53374. frontUVs?: Vector4;
  53375. backUVs?: Vector4;
  53376. instance?: Mesh;
  53377. invertUV?: boolean;
  53378. }, scene?: Nullable<Scene>): Mesh;
  53379. private static _ExtrudeShapeGeneric;
  53380. }
  53381. }
  53382. declare module "babylonjs/Debug/skeletonViewer" {
  53383. import { Color3 } from "babylonjs/Maths/math.color";
  53384. import { Scene } from "babylonjs/scene";
  53385. import { Nullable } from "babylonjs/types";
  53386. import { Skeleton } from "babylonjs/Bones/skeleton";
  53387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53388. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53390. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53391. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53392. /**
  53393. * Class used to render a debug view of a given skeleton
  53394. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53395. */
  53396. export class SkeletonViewer {
  53397. /** defines the skeleton to render */
  53398. skeleton: Skeleton;
  53399. /** defines the mesh attached to the skeleton */
  53400. mesh: AbstractMesh;
  53401. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53402. autoUpdateBonesMatrices: boolean;
  53403. /** defines the rendering group id to use with the viewer */
  53404. renderingGroupId: number;
  53405. /** is the options for the viewer */
  53406. options: Partial<ISkeletonViewerOptions>;
  53407. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53408. static readonly DISPLAY_LINES: number;
  53409. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53410. static readonly DISPLAY_SPHERES: number;
  53411. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53412. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53413. /** public static method to create a BoneWeight Shader
  53414. * @param options The constructor options
  53415. * @param scene The scene that the shader is scoped to
  53416. * @returns The created ShaderMaterial
  53417. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53418. */
  53419. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53420. /** public static method to create a BoneWeight Shader
  53421. * @param options The constructor options
  53422. * @param scene The scene that the shader is scoped to
  53423. * @returns The created ShaderMaterial
  53424. */
  53425. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53426. /** private static method to create a BoneWeight Shader
  53427. * @param size The size of the buffer to create (usually the bone count)
  53428. * @param colorMap The gradient data to generate
  53429. * @param scene The scene that the shader is scoped to
  53430. * @returns an Array of floats from the color gradient values
  53431. */
  53432. private static _CreateBoneMapColorBuffer;
  53433. /** If SkeletonViewer scene scope. */
  53434. private _scene;
  53435. /** Gets or sets the color used to render the skeleton */
  53436. color: Color3;
  53437. /** Array of the points of the skeleton fo the line view. */
  53438. private _debugLines;
  53439. /** The SkeletonViewers Mesh. */
  53440. private _debugMesh;
  53441. /** The local axes Meshes. */
  53442. private _localAxes;
  53443. /** If SkeletonViewer is enabled. */
  53444. private _isEnabled;
  53445. /** If SkeletonViewer is ready. */
  53446. private _ready;
  53447. /** SkeletonViewer render observable. */
  53448. private _obs;
  53449. /** The Utility Layer to render the gizmos in. */
  53450. private _utilityLayer;
  53451. private _boneIndices;
  53452. /** Gets the Scene. */
  53453. get scene(): Scene;
  53454. /** Gets the utilityLayer. */
  53455. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53456. /** Checks Ready Status. */
  53457. get isReady(): Boolean;
  53458. /** Sets Ready Status. */
  53459. set ready(value: boolean);
  53460. /** Gets the debugMesh */
  53461. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53462. /** Sets the debugMesh */
  53463. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53464. /** Gets the displayMode */
  53465. get displayMode(): number;
  53466. /** Sets the displayMode */
  53467. set displayMode(value: number);
  53468. /**
  53469. * Creates a new SkeletonViewer
  53470. * @param skeleton defines the skeleton to render
  53471. * @param mesh defines the mesh attached to the skeleton
  53472. * @param scene defines the hosting scene
  53473. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53474. * @param renderingGroupId defines the rendering group id to use with the viewer
  53475. * @param options All of the extra constructor options for the SkeletonViewer
  53476. */
  53477. constructor(
  53478. /** defines the skeleton to render */
  53479. skeleton: Skeleton,
  53480. /** defines the mesh attached to the skeleton */
  53481. mesh: AbstractMesh,
  53482. /** The Scene scope*/
  53483. scene: Scene,
  53484. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53485. autoUpdateBonesMatrices?: boolean,
  53486. /** defines the rendering group id to use with the viewer */
  53487. renderingGroupId?: number,
  53488. /** is the options for the viewer */
  53489. options?: Partial<ISkeletonViewerOptions>);
  53490. /** The Dynamic bindings for the update functions */
  53491. private _bindObs;
  53492. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53493. update(): void;
  53494. /** Gets or sets a boolean indicating if the viewer is enabled */
  53495. set isEnabled(value: boolean);
  53496. get isEnabled(): boolean;
  53497. private _getBonePosition;
  53498. private _getLinesForBonesWithLength;
  53499. private _getLinesForBonesNoLength;
  53500. /** function to revert the mesh and scene back to the initial state. */
  53501. private _revert;
  53502. private getAbsoluteRestPose;
  53503. /** function to build and bind sphere joint points and spur bone representations. */
  53504. private _buildSpheresAndSpurs;
  53505. private _buildLocalAxes;
  53506. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53507. private _displayLinesUpdate;
  53508. /** Changes the displayMode of the skeleton viewer
  53509. * @param mode The displayMode numerical value
  53510. */
  53511. changeDisplayMode(mode: number): void;
  53512. /** Sets a display option of the skeleton viewer
  53513. *
  53514. * | Option | Type | Default | Description |
  53515. * | --------------- | ------- | ------- | ----------- |
  53516. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53517. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53518. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53519. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53520. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53521. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53522. *
  53523. * @param option String of the option name
  53524. * @param value The numerical option value
  53525. */
  53526. changeDisplayOptions(option: string, value: number): void;
  53527. /** Release associated resources */
  53528. dispose(): void;
  53529. }
  53530. }
  53531. declare module "babylonjs/Debug/index" {
  53532. export * from "babylonjs/Debug/axesViewer";
  53533. export * from "babylonjs/Debug/boneAxesViewer";
  53534. export * from "babylonjs/Debug/debugLayer";
  53535. export * from "babylonjs/Debug/physicsViewer";
  53536. export * from "babylonjs/Debug/rayHelper";
  53537. export * from "babylonjs/Debug/skeletonViewer";
  53538. export * from "babylonjs/Debug/ISkeletonViewer";
  53539. }
  53540. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53541. /**
  53542. * Enum for Device Types
  53543. */
  53544. export enum DeviceType {
  53545. /** Generic */
  53546. Generic = 0,
  53547. /** Keyboard */
  53548. Keyboard = 1,
  53549. /** Mouse */
  53550. Mouse = 2,
  53551. /** Touch Pointers */
  53552. Touch = 3,
  53553. /** PS4 Dual Shock */
  53554. DualShock = 4,
  53555. /** Xbox */
  53556. Xbox = 5,
  53557. /** Switch Controller */
  53558. Switch = 6
  53559. }
  53560. /**
  53561. * Enum for All Pointers (Touch/Mouse)
  53562. */
  53563. export enum PointerInput {
  53564. /** Horizontal Axis */
  53565. Horizontal = 0,
  53566. /** Vertical Axis */
  53567. Vertical = 1,
  53568. /** Left Click or Touch */
  53569. LeftClick = 2,
  53570. /** Middle Click */
  53571. MiddleClick = 3,
  53572. /** Right Click */
  53573. RightClick = 4,
  53574. /** Browser Back */
  53575. BrowserBack = 5,
  53576. /** Browser Forward */
  53577. BrowserForward = 6
  53578. }
  53579. /**
  53580. * Enum for Dual Shock Gamepad
  53581. */
  53582. export enum DualShockInput {
  53583. /** Cross */
  53584. Cross = 0,
  53585. /** Circle */
  53586. Circle = 1,
  53587. /** Square */
  53588. Square = 2,
  53589. /** Triangle */
  53590. Triangle = 3,
  53591. /** L1 */
  53592. L1 = 4,
  53593. /** R1 */
  53594. R1 = 5,
  53595. /** L2 */
  53596. L2 = 6,
  53597. /** R2 */
  53598. R2 = 7,
  53599. /** Share */
  53600. Share = 8,
  53601. /** Options */
  53602. Options = 9,
  53603. /** L3 */
  53604. L3 = 10,
  53605. /** R3 */
  53606. R3 = 11,
  53607. /** DPadUp */
  53608. DPadUp = 12,
  53609. /** DPadDown */
  53610. DPadDown = 13,
  53611. /** DPadLeft */
  53612. DPadLeft = 14,
  53613. /** DRight */
  53614. DPadRight = 15,
  53615. /** Home */
  53616. Home = 16,
  53617. /** TouchPad */
  53618. TouchPad = 17,
  53619. /** LStickXAxis */
  53620. LStickXAxis = 18,
  53621. /** LStickYAxis */
  53622. LStickYAxis = 19,
  53623. /** RStickXAxis */
  53624. RStickXAxis = 20,
  53625. /** RStickYAxis */
  53626. RStickYAxis = 21
  53627. }
  53628. /**
  53629. * Enum for Xbox Gamepad
  53630. */
  53631. export enum XboxInput {
  53632. /** A */
  53633. A = 0,
  53634. /** B */
  53635. B = 1,
  53636. /** X */
  53637. X = 2,
  53638. /** Y */
  53639. Y = 3,
  53640. /** LB */
  53641. LB = 4,
  53642. /** RB */
  53643. RB = 5,
  53644. /** LT */
  53645. LT = 6,
  53646. /** RT */
  53647. RT = 7,
  53648. /** Back */
  53649. Back = 8,
  53650. /** Start */
  53651. Start = 9,
  53652. /** LS */
  53653. LS = 10,
  53654. /** RS */
  53655. RS = 11,
  53656. /** DPadUp */
  53657. DPadUp = 12,
  53658. /** DPadDown */
  53659. DPadDown = 13,
  53660. /** DPadLeft */
  53661. DPadLeft = 14,
  53662. /** DRight */
  53663. DPadRight = 15,
  53664. /** Home */
  53665. Home = 16,
  53666. /** LStickXAxis */
  53667. LStickXAxis = 17,
  53668. /** LStickYAxis */
  53669. LStickYAxis = 18,
  53670. /** RStickXAxis */
  53671. RStickXAxis = 19,
  53672. /** RStickYAxis */
  53673. RStickYAxis = 20
  53674. }
  53675. /**
  53676. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53677. */
  53678. export enum SwitchInput {
  53679. /** B */
  53680. B = 0,
  53681. /** A */
  53682. A = 1,
  53683. /** Y */
  53684. Y = 2,
  53685. /** X */
  53686. X = 3,
  53687. /** L */
  53688. L = 4,
  53689. /** R */
  53690. R = 5,
  53691. /** ZL */
  53692. ZL = 6,
  53693. /** ZR */
  53694. ZR = 7,
  53695. /** Minus */
  53696. Minus = 8,
  53697. /** Plus */
  53698. Plus = 9,
  53699. /** LS */
  53700. LS = 10,
  53701. /** RS */
  53702. RS = 11,
  53703. /** DPadUp */
  53704. DPadUp = 12,
  53705. /** DPadDown */
  53706. DPadDown = 13,
  53707. /** DPadLeft */
  53708. DPadLeft = 14,
  53709. /** DRight */
  53710. DPadRight = 15,
  53711. /** Home */
  53712. Home = 16,
  53713. /** Capture */
  53714. Capture = 17,
  53715. /** LStickXAxis */
  53716. LStickXAxis = 18,
  53717. /** LStickYAxis */
  53718. LStickYAxis = 19,
  53719. /** RStickXAxis */
  53720. RStickXAxis = 20,
  53721. /** RStickYAxis */
  53722. RStickYAxis = 21
  53723. }
  53724. }
  53725. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53726. import { Engine } from "babylonjs/Engines/engine";
  53727. import { IDisposable } from "babylonjs/scene";
  53728. import { Nullable } from "babylonjs/types";
  53729. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53730. /**
  53731. * This class will take all inputs from Keyboard, Pointer, and
  53732. * any Gamepads and provide a polling system that all devices
  53733. * will use. This class assumes that there will only be one
  53734. * pointer device and one keyboard.
  53735. */
  53736. export class DeviceInputSystem implements IDisposable {
  53737. /**
  53738. * Callback to be triggered when a device is connected
  53739. */
  53740. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53741. /**
  53742. * Callback to be triggered when a device is disconnected
  53743. */
  53744. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53745. /**
  53746. * Callback to be triggered when event driven input is updated
  53747. */
  53748. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53749. private _inputs;
  53750. private _gamepads;
  53751. private _keyboardActive;
  53752. private _pointerActive;
  53753. private _elementToAttachTo;
  53754. private _keyboardDownEvent;
  53755. private _keyboardUpEvent;
  53756. private _pointerMoveEvent;
  53757. private _pointerDownEvent;
  53758. private _pointerUpEvent;
  53759. private _gamepadConnectedEvent;
  53760. private _gamepadDisconnectedEvent;
  53761. private static _MAX_KEYCODES;
  53762. private static _MAX_POINTER_INPUTS;
  53763. private constructor();
  53764. /**
  53765. * Creates a new DeviceInputSystem instance
  53766. * @param engine Engine to pull input element from
  53767. * @returns The new instance
  53768. */
  53769. static Create(engine: Engine): DeviceInputSystem;
  53770. /**
  53771. * Checks for current device input value, given an id and input index
  53772. * @param deviceName Id of connected device
  53773. * @param inputIndex Index of device input
  53774. * @returns Current value of input
  53775. */
  53776. /**
  53777. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53778. * @param deviceType Enum specifiying device type
  53779. * @param deviceSlot "Slot" or index that device is referenced in
  53780. * @param inputIndex Id of input to be checked
  53781. * @returns Current value of input
  53782. */
  53783. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53784. /**
  53785. * Dispose of all the eventlisteners
  53786. */
  53787. dispose(): void;
  53788. /**
  53789. * Add device and inputs to device array
  53790. * @param deviceType Enum specifiying device type
  53791. * @param deviceSlot "Slot" or index that device is referenced in
  53792. * @param numberOfInputs Number of input entries to create for given device
  53793. */
  53794. private _registerDevice;
  53795. /**
  53796. * Given a specific device name, remove that device from the device map
  53797. * @param deviceType Enum specifiying device type
  53798. * @param deviceSlot "Slot" or index that device is referenced in
  53799. */
  53800. private _unregisterDevice;
  53801. /**
  53802. * Handle all actions that come from keyboard interaction
  53803. */
  53804. private _handleKeyActions;
  53805. /**
  53806. * Handle all actions that come from pointer interaction
  53807. */
  53808. private _handlePointerActions;
  53809. /**
  53810. * Handle all actions that come from gamepad interaction
  53811. */
  53812. private _handleGamepadActions;
  53813. /**
  53814. * Update all non-event based devices with each frame
  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. */
  53819. private _updateDevice;
  53820. /**
  53821. * Gets DeviceType from the device name
  53822. * @param deviceName Name of Device from DeviceInputSystem
  53823. * @returns DeviceType enum value
  53824. */
  53825. private _getGamepadDeviceType;
  53826. }
  53827. }
  53828. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53829. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53830. /**
  53831. * Type to handle enforcement of inputs
  53832. */
  53833. 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;
  53834. }
  53835. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53836. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53837. import { Engine } from "babylonjs/Engines/engine";
  53838. import { IDisposable } from "babylonjs/scene";
  53839. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53840. import { Nullable } from "babylonjs/types";
  53841. import { Observable } from "babylonjs/Misc/observable";
  53842. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53843. /**
  53844. * Class that handles all input for a specific device
  53845. */
  53846. export class DeviceSource<T extends DeviceType> {
  53847. /** Type of device */
  53848. readonly deviceType: DeviceType;
  53849. /** "Slot" or index that device is referenced in */
  53850. readonly deviceSlot: number;
  53851. /**
  53852. * Observable to handle device input changes per device
  53853. */
  53854. readonly onInputChangedObservable: Observable<{
  53855. inputIndex: DeviceInput<T>;
  53856. previousState: Nullable<number>;
  53857. currentState: Nullable<number>;
  53858. }>;
  53859. private readonly _deviceInputSystem;
  53860. /**
  53861. * Default Constructor
  53862. * @param deviceInputSystem Reference to DeviceInputSystem
  53863. * @param deviceType Type of device
  53864. * @param deviceSlot "Slot" or index that device is referenced in
  53865. */
  53866. constructor(deviceInputSystem: DeviceInputSystem,
  53867. /** Type of device */
  53868. deviceType: DeviceType,
  53869. /** "Slot" or index that device is referenced in */
  53870. deviceSlot?: number);
  53871. /**
  53872. * Get input for specific input
  53873. * @param inputIndex index of specific input on device
  53874. * @returns Input value from DeviceInputSystem
  53875. */
  53876. getInput(inputIndex: DeviceInput<T>): number;
  53877. }
  53878. /**
  53879. * Class to keep track of devices
  53880. */
  53881. export class DeviceSourceManager implements IDisposable {
  53882. /**
  53883. * Observable to be triggered when before a device is connected
  53884. */
  53885. readonly onBeforeDeviceConnectedObservable: Observable<{
  53886. deviceType: DeviceType;
  53887. deviceSlot: number;
  53888. }>;
  53889. /**
  53890. * Observable to be triggered when before a device is disconnected
  53891. */
  53892. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53893. deviceType: DeviceType;
  53894. deviceSlot: number;
  53895. }>;
  53896. /**
  53897. * Observable to be triggered when after a device is connected
  53898. */
  53899. readonly onAfterDeviceConnectedObservable: Observable<{
  53900. deviceType: DeviceType;
  53901. deviceSlot: number;
  53902. }>;
  53903. /**
  53904. * Observable to be triggered when after a device is disconnected
  53905. */
  53906. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53907. deviceType: DeviceType;
  53908. deviceSlot: number;
  53909. }>;
  53910. private readonly _devices;
  53911. private readonly _firstDevice;
  53912. private readonly _deviceInputSystem;
  53913. /**
  53914. * Default Constructor
  53915. * @param engine engine to pull input element from
  53916. */
  53917. constructor(engine: Engine);
  53918. /**
  53919. * Gets a DeviceSource, given a type and slot
  53920. * @param deviceType Enum specifying device type
  53921. * @param deviceSlot "Slot" or index that device is referenced in
  53922. * @returns DeviceSource object
  53923. */
  53924. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53925. /**
  53926. * Gets an array of DeviceSource objects for a given device type
  53927. * @param deviceType Enum specifying device type
  53928. * @returns Array of DeviceSource objects
  53929. */
  53930. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53931. /**
  53932. * Dispose of DeviceInputSystem and other parts
  53933. */
  53934. dispose(): void;
  53935. /**
  53936. * Function to add device name to device list
  53937. * @param deviceType Enum specifying device type
  53938. * @param deviceSlot "Slot" or index that device is referenced in
  53939. */
  53940. private _addDevice;
  53941. /**
  53942. * Function to remove device name to device list
  53943. * @param deviceType Enum specifying device type
  53944. * @param deviceSlot "Slot" or index that device is referenced in
  53945. */
  53946. private _removeDevice;
  53947. /**
  53948. * Updates array storing first connected device of each type
  53949. * @param type Type of Device
  53950. */
  53951. private _updateFirstDevices;
  53952. }
  53953. }
  53954. declare module "babylonjs/DeviceInput/index" {
  53955. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53956. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53957. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53958. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53959. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53960. }
  53961. declare module "babylonjs/Engines/nullEngine" {
  53962. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53963. import { Engine } from "babylonjs/Engines/engine";
  53964. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53965. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53966. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53967. import { Effect } from "babylonjs/Materials/effect";
  53968. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53969. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53970. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53971. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53972. /**
  53973. * Options to create the null engine
  53974. */
  53975. export class NullEngineOptions {
  53976. /**
  53977. * Render width (Default: 512)
  53978. */
  53979. renderWidth: number;
  53980. /**
  53981. * Render height (Default: 256)
  53982. */
  53983. renderHeight: number;
  53984. /**
  53985. * Texture size (Default: 512)
  53986. */
  53987. textureSize: number;
  53988. /**
  53989. * If delta time between frames should be constant
  53990. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53991. */
  53992. deterministicLockstep: boolean;
  53993. /**
  53994. * Maximum about of steps between frames (Default: 4)
  53995. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53996. */
  53997. lockstepMaxSteps: number;
  53998. /**
  53999. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54000. */
  54001. useHighPrecisionMatrix?: boolean;
  54002. }
  54003. /**
  54004. * The null engine class provides support for headless version of babylon.js.
  54005. * This can be used in server side scenario or for testing purposes
  54006. */
  54007. export class NullEngine extends Engine {
  54008. private _options;
  54009. /**
  54010. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54011. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54012. * @returns true if engine is in deterministic lock step mode
  54013. */
  54014. isDeterministicLockStep(): boolean;
  54015. /**
  54016. * Gets the max steps when engine is running in deterministic lock step
  54017. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54018. * @returns the max steps
  54019. */
  54020. getLockstepMaxSteps(): number;
  54021. /**
  54022. * Gets the current hardware scaling level.
  54023. * By default the hardware scaling level is computed from the window device ratio.
  54024. * 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.
  54025. * @returns a number indicating the current hardware scaling level
  54026. */
  54027. getHardwareScalingLevel(): number;
  54028. constructor(options?: NullEngineOptions);
  54029. /**
  54030. * Creates a vertex buffer
  54031. * @param vertices the data for the vertex buffer
  54032. * @returns the new WebGL static buffer
  54033. */
  54034. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54035. /**
  54036. * Creates a new index buffer
  54037. * @param indices defines the content of the index buffer
  54038. * @param updatable defines if the index buffer must be updatable
  54039. * @returns a new webGL buffer
  54040. */
  54041. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54042. /**
  54043. * Clear the current render buffer or the current render target (if any is set up)
  54044. * @param color defines the color to use
  54045. * @param backBuffer defines if the back buffer must be cleared
  54046. * @param depth defines if the depth buffer must be cleared
  54047. * @param stencil defines if the stencil buffer must be cleared
  54048. */
  54049. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54050. /**
  54051. * Gets the current render width
  54052. * @param useScreen defines if screen size must be used (or the current render target if any)
  54053. * @returns a number defining the current render width
  54054. */
  54055. getRenderWidth(useScreen?: boolean): number;
  54056. /**
  54057. * Gets the current render height
  54058. * @param useScreen defines if screen size must be used (or the current render target if any)
  54059. * @returns a number defining the current render height
  54060. */
  54061. getRenderHeight(useScreen?: boolean): number;
  54062. /**
  54063. * Set the WebGL's viewport
  54064. * @param viewport defines the viewport element to be used
  54065. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54066. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54067. */
  54068. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54069. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54070. /**
  54071. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54072. * @param pipelineContext defines the pipeline context to use
  54073. * @param uniformsNames defines the list of uniform names
  54074. * @returns an array of webGL uniform locations
  54075. */
  54076. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54077. /**
  54078. * Gets the lsit of active attributes for a given webGL program
  54079. * @param pipelineContext defines the pipeline context to use
  54080. * @param attributesNames defines the list of attribute names to get
  54081. * @returns an array of indices indicating the offset of each attribute
  54082. */
  54083. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54084. /**
  54085. * Binds an effect to the webGL context
  54086. * @param effect defines the effect to bind
  54087. */
  54088. bindSamplers(effect: Effect): void;
  54089. /**
  54090. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54091. * @param effect defines the effect to activate
  54092. */
  54093. enableEffect(effect: Effect): void;
  54094. /**
  54095. * Set various states to the webGL context
  54096. * @param culling defines backface culling state
  54097. * @param zOffset defines the value to apply to zOffset (0 by default)
  54098. * @param force defines if states must be applied even if cache is up to date
  54099. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54100. */
  54101. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54102. /**
  54103. * Set the value of an uniform to an array of int32
  54104. * @param uniform defines the webGL uniform location where to store the value
  54105. * @param array defines the array of int32 to store
  54106. * @returns true if value was set
  54107. */
  54108. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54109. /**
  54110. * Set the value of an uniform to an array of int32 (stored as vec2)
  54111. * @param uniform defines the webGL uniform location where to store the value
  54112. * @param array defines the array of int32 to store
  54113. * @returns true if value was set
  54114. */
  54115. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54116. /**
  54117. * Set the value of an uniform to an array of int32 (stored as vec3)
  54118. * @param uniform defines the webGL uniform location where to store the value
  54119. * @param array defines the array of int32 to store
  54120. * @returns true if value was set
  54121. */
  54122. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54123. /**
  54124. * Set the value of an uniform to an array of int32 (stored as vec4)
  54125. * @param uniform defines the webGL uniform location where to store the value
  54126. * @param array defines the array of int32 to store
  54127. * @returns true if value was set
  54128. */
  54129. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54130. /**
  54131. * Set the value of an uniform to an array of float32
  54132. * @param uniform defines the webGL uniform location where to store the value
  54133. * @param array defines the array of float32 to store
  54134. * @returns true if value was set
  54135. */
  54136. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54137. /**
  54138. * Set the value of an uniform to an array of float32 (stored as vec2)
  54139. * @param uniform defines the webGL uniform location where to store the value
  54140. * @param array defines the array of float32 to store
  54141. * @returns true if value was set
  54142. */
  54143. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54144. /**
  54145. * Set the value of an uniform to an array of float32 (stored as vec3)
  54146. * @param uniform defines the webGL uniform location where to store the value
  54147. * @param array defines the array of float32 to store
  54148. * @returns true if value was set
  54149. */
  54150. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54151. /**
  54152. * Set the value of an uniform to an array of float32 (stored as vec4)
  54153. * @param uniform defines the webGL uniform location where to store the value
  54154. * @param array defines the array of float32 to store
  54155. * @returns true if value was set
  54156. */
  54157. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54158. /**
  54159. * Set the value of an uniform to an array of number
  54160. * @param uniform defines the webGL uniform location where to store the value
  54161. * @param array defines the array of number to store
  54162. * @returns true if value was set
  54163. */
  54164. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54165. /**
  54166. * Set the value of an uniform to an array of number (stored as vec2)
  54167. * @param uniform defines the webGL uniform location where to store the value
  54168. * @param array defines the array of number to store
  54169. * @returns true if value was set
  54170. */
  54171. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54172. /**
  54173. * Set the value of an uniform to an array of number (stored as vec3)
  54174. * @param uniform defines the webGL uniform location where to store the value
  54175. * @param array defines the array of number to store
  54176. * @returns true if value was set
  54177. */
  54178. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54179. /**
  54180. * Set the value of an uniform to an array of number (stored as vec4)
  54181. * @param uniform defines the webGL uniform location where to store the value
  54182. * @param array defines the array of number to store
  54183. * @returns true if value was set
  54184. */
  54185. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54186. /**
  54187. * Set the value of an uniform to an array of float32 (stored as matrices)
  54188. * @param uniform defines the webGL uniform location where to store the value
  54189. * @param matrices defines the array of float32 to store
  54190. * @returns true if value was set
  54191. */
  54192. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54193. /**
  54194. * Set the value of an uniform to a matrix (3x3)
  54195. * @param uniform defines the webGL uniform location where to store the value
  54196. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54197. * @returns true if value was set
  54198. */
  54199. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54200. /**
  54201. * Set the value of an uniform to a matrix (2x2)
  54202. * @param uniform defines the webGL uniform location where to store the value
  54203. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54204. * @returns true if value was set
  54205. */
  54206. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54207. /**
  54208. * Set the value of an uniform to a number (float)
  54209. * @param uniform defines the webGL uniform location where to store the value
  54210. * @param value defines the float number to store
  54211. * @returns true if value was set
  54212. */
  54213. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54214. /**
  54215. * Set the value of an uniform to a vec2
  54216. * @param uniform defines the webGL uniform location where to store the value
  54217. * @param x defines the 1st component of the value
  54218. * @param y defines the 2nd component of the value
  54219. * @returns true if value was set
  54220. */
  54221. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54222. /**
  54223. * Set the value of an uniform to a vec3
  54224. * @param uniform defines the webGL uniform location where to store the value
  54225. * @param x defines the 1st component of the value
  54226. * @param y defines the 2nd component of the value
  54227. * @param z defines the 3rd component of the value
  54228. * @returns true if value was set
  54229. */
  54230. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54231. /**
  54232. * Set the value of an uniform to a boolean
  54233. * @param uniform defines the webGL uniform location where to store the value
  54234. * @param bool defines the boolean to store
  54235. * @returns true if value was set
  54236. */
  54237. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54238. /**
  54239. * Set the value of an uniform to a vec4
  54240. * @param uniform defines the webGL uniform location where to store the value
  54241. * @param x defines the 1st component of the value
  54242. * @param y defines the 2nd component of the value
  54243. * @param z defines the 3rd component of the value
  54244. * @param w defines the 4th component of the value
  54245. * @returns true if value was set
  54246. */
  54247. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54248. /**
  54249. * Sets the current alpha mode
  54250. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54251. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54252. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54253. */
  54254. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54255. /**
  54256. * Bind webGl buffers directly to the webGL context
  54257. * @param vertexBuffers defines the vertex buffer to bind
  54258. * @param indexBuffer defines the index buffer to bind
  54259. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54260. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54261. * @param effect defines the effect associated with the vertex buffer
  54262. */
  54263. bindBuffers(vertexBuffers: {
  54264. [key: string]: VertexBuffer;
  54265. }, indexBuffer: DataBuffer, effect: Effect): void;
  54266. /**
  54267. * Force the entire cache to be cleared
  54268. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54269. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54270. */
  54271. wipeCaches(bruteForce?: boolean): void;
  54272. /**
  54273. * Send a draw order
  54274. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54275. * @param indexStart defines the starting index
  54276. * @param indexCount defines the number of index to draw
  54277. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54278. */
  54279. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54280. /**
  54281. * Draw a list of indexed primitives
  54282. * @param fillMode defines the primitive to use
  54283. * @param indexStart defines the starting index
  54284. * @param indexCount defines the number of index to draw
  54285. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54286. */
  54287. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54288. /**
  54289. * Draw a list of unindexed primitives
  54290. * @param fillMode defines the primitive to use
  54291. * @param verticesStart defines the index of first vertex to draw
  54292. * @param verticesCount defines the count of vertices to draw
  54293. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54294. */
  54295. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54296. /** @hidden */
  54297. _createTexture(): WebGLTexture;
  54298. /** @hidden */
  54299. _releaseTexture(texture: InternalTexture): void;
  54300. /**
  54301. * Usually called from Texture.ts.
  54302. * Passed information to create a WebGLTexture
  54303. * @param urlArg defines a value which contains one of the following:
  54304. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54305. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54306. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54307. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54308. * @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)
  54309. * @param scene needed for loading to the correct scene
  54310. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54311. * @param onLoad optional callback to be called upon successful completion
  54312. * @param onError optional callback to be called upon failure
  54313. * @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
  54314. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54315. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54316. * @param forcedExtension defines the extension to use to pick the right loader
  54317. * @param mimeType defines an optional mime type
  54318. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54319. */
  54320. 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;
  54321. /**
  54322. * Creates a new render target texture
  54323. * @param size defines the size of the texture
  54324. * @param options defines the options used to create the texture
  54325. * @returns a new render target texture stored in an InternalTexture
  54326. */
  54327. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54328. /**
  54329. * Update the sampling mode of a given texture
  54330. * @param samplingMode defines the required sampling mode
  54331. * @param texture defines the texture to update
  54332. */
  54333. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54334. /**
  54335. * Binds the frame buffer to the specified texture.
  54336. * @param texture The texture to render to or null for the default canvas
  54337. * @param faceIndex The face of the texture to render to in case of cube texture
  54338. * @param requiredWidth The width of the target to render to
  54339. * @param requiredHeight The height of the target to render to
  54340. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54341. * @param lodLevel defines le lod level to bind to the frame buffer
  54342. */
  54343. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54344. /**
  54345. * Unbind the current render target texture from the webGL context
  54346. * @param texture defines the render target texture to unbind
  54347. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54348. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54349. */
  54350. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54351. /**
  54352. * Creates a dynamic vertex buffer
  54353. * @param vertices the data for the dynamic vertex buffer
  54354. * @returns the new WebGL dynamic buffer
  54355. */
  54356. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54357. /**
  54358. * Update the content of a dynamic texture
  54359. * @param texture defines the texture to update
  54360. * @param canvas defines the canvas containing the source
  54361. * @param invertY defines if data must be stored with Y axis inverted
  54362. * @param premulAlpha defines if alpha is stored as premultiplied
  54363. * @param format defines the format of the data
  54364. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54365. */
  54366. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54367. /**
  54368. * Gets a boolean indicating if all created effects are ready
  54369. * @returns true if all effects are ready
  54370. */
  54371. areAllEffectsReady(): boolean;
  54372. /**
  54373. * @hidden
  54374. * Get the current error code of the webGL context
  54375. * @returns the error code
  54376. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54377. */
  54378. getError(): number;
  54379. /** @hidden */
  54380. _getUnpackAlignement(): number;
  54381. /** @hidden */
  54382. _unpackFlipY(value: boolean): void;
  54383. /**
  54384. * Update a dynamic index buffer
  54385. * @param indexBuffer defines the target index buffer
  54386. * @param indices defines the data to update
  54387. * @param offset defines the offset in the target index buffer where update should start
  54388. */
  54389. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54390. /**
  54391. * Updates a dynamic vertex buffer.
  54392. * @param vertexBuffer the vertex buffer to update
  54393. * @param vertices the data used to update the vertex buffer
  54394. * @param byteOffset the byte offset of the data (optional)
  54395. * @param byteLength the byte length of the data (optional)
  54396. */
  54397. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54398. /** @hidden */
  54399. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54400. /** @hidden */
  54401. _bindTexture(channel: number, texture: InternalTexture): void;
  54402. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54403. /**
  54404. * 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
  54405. */
  54406. releaseEffects(): void;
  54407. displayLoadingUI(): void;
  54408. hideLoadingUI(): void;
  54409. /** @hidden */
  54410. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54411. /** @hidden */
  54412. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54413. /** @hidden */
  54414. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54415. /** @hidden */
  54416. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54417. }
  54418. }
  54419. declare module "babylonjs/Instrumentation/timeToken" {
  54420. import { Nullable } from "babylonjs/types";
  54421. /**
  54422. * @hidden
  54423. **/
  54424. export class _TimeToken {
  54425. _startTimeQuery: Nullable<WebGLQuery>;
  54426. _endTimeQuery: Nullable<WebGLQuery>;
  54427. _timeElapsedQuery: Nullable<WebGLQuery>;
  54428. _timeElapsedQueryEnded: boolean;
  54429. }
  54430. }
  54431. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54432. import { Nullable, int } from "babylonjs/types";
  54433. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54434. /** @hidden */
  54435. export class _OcclusionDataStorage {
  54436. /** @hidden */
  54437. occlusionInternalRetryCounter: number;
  54438. /** @hidden */
  54439. isOcclusionQueryInProgress: boolean;
  54440. /** @hidden */
  54441. isOccluded: boolean;
  54442. /** @hidden */
  54443. occlusionRetryCount: number;
  54444. /** @hidden */
  54445. occlusionType: number;
  54446. /** @hidden */
  54447. occlusionQueryAlgorithmType: number;
  54448. }
  54449. module "babylonjs/Engines/engine" {
  54450. interface Engine {
  54451. /**
  54452. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54453. * @return the new query
  54454. */
  54455. createQuery(): WebGLQuery;
  54456. /**
  54457. * Delete and release a webGL query
  54458. * @param query defines the query to delete
  54459. * @return the current engine
  54460. */
  54461. deleteQuery(query: WebGLQuery): Engine;
  54462. /**
  54463. * Check if a given query has resolved and got its value
  54464. * @param query defines the query to check
  54465. * @returns true if the query got its value
  54466. */
  54467. isQueryResultAvailable(query: WebGLQuery): boolean;
  54468. /**
  54469. * Gets the value of a given query
  54470. * @param query defines the query to check
  54471. * @returns the value of the query
  54472. */
  54473. getQueryResult(query: WebGLQuery): number;
  54474. /**
  54475. * Initiates an occlusion query
  54476. * @param algorithmType defines the algorithm to use
  54477. * @param query defines the query to use
  54478. * @returns the current engine
  54479. * @see https://doc.babylonjs.com/features/occlusionquery
  54480. */
  54481. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54482. /**
  54483. * Ends an occlusion query
  54484. * @see https://doc.babylonjs.com/features/occlusionquery
  54485. * @param algorithmType defines the algorithm to use
  54486. * @returns the current engine
  54487. */
  54488. endOcclusionQuery(algorithmType: number): Engine;
  54489. /**
  54490. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54491. * Please note that only one query can be issued at a time
  54492. * @returns a time token used to track the time span
  54493. */
  54494. startTimeQuery(): Nullable<_TimeToken>;
  54495. /**
  54496. * Ends a time query
  54497. * @param token defines the token used to measure the time span
  54498. * @returns the time spent (in ns)
  54499. */
  54500. endTimeQuery(token: _TimeToken): int;
  54501. /** @hidden */
  54502. _currentNonTimestampToken: Nullable<_TimeToken>;
  54503. /** @hidden */
  54504. _createTimeQuery(): WebGLQuery;
  54505. /** @hidden */
  54506. _deleteTimeQuery(query: WebGLQuery): void;
  54507. /** @hidden */
  54508. _getGlAlgorithmType(algorithmType: number): number;
  54509. /** @hidden */
  54510. _getTimeQueryResult(query: WebGLQuery): any;
  54511. /** @hidden */
  54512. _getTimeQueryAvailability(query: WebGLQuery): any;
  54513. }
  54514. }
  54515. module "babylonjs/Meshes/abstractMesh" {
  54516. interface AbstractMesh {
  54517. /**
  54518. * Backing filed
  54519. * @hidden
  54520. */
  54521. __occlusionDataStorage: _OcclusionDataStorage;
  54522. /**
  54523. * Access property
  54524. * @hidden
  54525. */
  54526. _occlusionDataStorage: _OcclusionDataStorage;
  54527. /**
  54528. * 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.
  54529. * The default value is -1 which means don't break the query and wait till the result
  54530. * @see https://doc.babylonjs.com/features/occlusionquery
  54531. */
  54532. occlusionRetryCount: number;
  54533. /**
  54534. * 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:
  54535. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54536. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54537. * * 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.
  54538. * @see https://doc.babylonjs.com/features/occlusionquery
  54539. */
  54540. occlusionType: number;
  54541. /**
  54542. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54543. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54544. * * 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.
  54545. * @see https://doc.babylonjs.com/features/occlusionquery
  54546. */
  54547. occlusionQueryAlgorithmType: number;
  54548. /**
  54549. * 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
  54550. * @see https://doc.babylonjs.com/features/occlusionquery
  54551. */
  54552. isOccluded: boolean;
  54553. /**
  54554. * Flag to check the progress status of the query
  54555. * @see https://doc.babylonjs.com/features/occlusionquery
  54556. */
  54557. isOcclusionQueryInProgress: boolean;
  54558. }
  54559. }
  54560. }
  54561. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54562. import { Nullable } from "babylonjs/types";
  54563. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54564. /** @hidden */
  54565. export var _forceTransformFeedbackToBundle: boolean;
  54566. module "babylonjs/Engines/engine" {
  54567. interface Engine {
  54568. /**
  54569. * Creates a webGL transform feedback object
  54570. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54571. * @returns the webGL transform feedback object
  54572. */
  54573. createTransformFeedback(): WebGLTransformFeedback;
  54574. /**
  54575. * Delete a webGL transform feedback object
  54576. * @param value defines the webGL transform feedback object to delete
  54577. */
  54578. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54579. /**
  54580. * Bind a webGL transform feedback object to the webgl context
  54581. * @param value defines the webGL transform feedback object to bind
  54582. */
  54583. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54584. /**
  54585. * Begins a transform feedback operation
  54586. * @param usePoints defines if points or triangles must be used
  54587. */
  54588. beginTransformFeedback(usePoints: boolean): void;
  54589. /**
  54590. * Ends a transform feedback operation
  54591. */
  54592. endTransformFeedback(): void;
  54593. /**
  54594. * Specify the varyings to use with transform feedback
  54595. * @param program defines the associated webGL program
  54596. * @param value defines the list of strings representing the varying names
  54597. */
  54598. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54599. /**
  54600. * Bind a webGL buffer for a transform feedback operation
  54601. * @param value defines the webGL buffer to bind
  54602. */
  54603. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54604. }
  54605. }
  54606. }
  54607. declare module "babylonjs/Engines/Extensions/engine.views" {
  54608. import { Camera } from "babylonjs/Cameras/camera";
  54609. import { Nullable } from "babylonjs/types";
  54610. /**
  54611. * Class used to define an additional view for the engine
  54612. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54613. */
  54614. export class EngineView {
  54615. /** Defines the canvas where to render the view */
  54616. target: HTMLCanvasElement;
  54617. /** Defines an optional camera used to render the view (will use active camera else) */
  54618. camera?: Camera;
  54619. }
  54620. module "babylonjs/Engines/engine" {
  54621. interface Engine {
  54622. /**
  54623. * Gets or sets the HTML element to use for attaching events
  54624. */
  54625. inputElement: Nullable<HTMLElement>;
  54626. /**
  54627. * Gets the current engine view
  54628. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54629. */
  54630. activeView: Nullable<EngineView>;
  54631. /** Gets or sets the list of views */
  54632. views: EngineView[];
  54633. /**
  54634. * Register a new child canvas
  54635. * @param canvas defines the canvas to register
  54636. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54637. * @returns the associated view
  54638. */
  54639. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54640. /**
  54641. * Remove a registered child canvas
  54642. * @param canvas defines the canvas to remove
  54643. * @returns the current engine
  54644. */
  54645. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54646. }
  54647. }
  54648. }
  54649. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54650. import { Nullable } from "babylonjs/types";
  54651. module "babylonjs/Engines/engine" {
  54652. interface Engine {
  54653. /** @hidden */
  54654. _excludedCompressedTextures: string[];
  54655. /** @hidden */
  54656. _textureFormatInUse: string;
  54657. /**
  54658. * Gets the list of texture formats supported
  54659. */
  54660. readonly texturesSupported: Array<string>;
  54661. /**
  54662. * Gets the texture format in use
  54663. */
  54664. readonly textureFormatInUse: Nullable<string>;
  54665. /**
  54666. * Set the compressed texture extensions or file names to skip.
  54667. *
  54668. * @param skippedFiles defines the list of those texture files you want to skip
  54669. * Example: [".dds", ".env", "myfile.png"]
  54670. */
  54671. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54672. /**
  54673. * Set the compressed texture format to use, based on the formats you have, and the formats
  54674. * supported by the hardware / browser.
  54675. *
  54676. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54677. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54678. * to API arguments needed to compressed textures. This puts the burden on the container
  54679. * generator to house the arcane code for determining these for current & future formats.
  54680. *
  54681. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54682. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54683. *
  54684. * Note: The result of this call is not taken into account when a texture is base64.
  54685. *
  54686. * @param formatsAvailable defines the list of those format families you have created
  54687. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54688. *
  54689. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54690. * @returns The extension selected.
  54691. */
  54692. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54693. }
  54694. }
  54695. }
  54696. declare module "babylonjs/Engines/Extensions/index" {
  54697. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54698. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54699. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54700. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54701. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54702. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54703. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54704. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54705. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54706. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54707. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54708. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54709. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54710. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54711. export * from "babylonjs/Engines/Extensions/engine.views";
  54712. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54713. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54714. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54715. }
  54716. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54717. import { Nullable } from "babylonjs/types";
  54718. /**
  54719. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54720. */
  54721. export interface CubeMapInfo {
  54722. /**
  54723. * The pixel array for the front face.
  54724. * This is stored in format, left to right, up to down format.
  54725. */
  54726. front: Nullable<ArrayBufferView>;
  54727. /**
  54728. * The pixel array for the back face.
  54729. * This is stored in format, left to right, up to down format.
  54730. */
  54731. back: Nullable<ArrayBufferView>;
  54732. /**
  54733. * The pixel array for the left face.
  54734. * This is stored in format, left to right, up to down format.
  54735. */
  54736. left: Nullable<ArrayBufferView>;
  54737. /**
  54738. * The pixel array for the right face.
  54739. * This is stored in format, left to right, up to down format.
  54740. */
  54741. right: Nullable<ArrayBufferView>;
  54742. /**
  54743. * The pixel array for the up face.
  54744. * This is stored in format, left to right, up to down format.
  54745. */
  54746. up: Nullable<ArrayBufferView>;
  54747. /**
  54748. * The pixel array for the down face.
  54749. * This is stored in format, left to right, up to down format.
  54750. */
  54751. down: Nullable<ArrayBufferView>;
  54752. /**
  54753. * The size of the cubemap stored.
  54754. *
  54755. * Each faces will be size * size pixels.
  54756. */
  54757. size: number;
  54758. /**
  54759. * The format of the texture.
  54760. *
  54761. * RGBA, RGB.
  54762. */
  54763. format: number;
  54764. /**
  54765. * The type of the texture data.
  54766. *
  54767. * UNSIGNED_INT, FLOAT.
  54768. */
  54769. type: number;
  54770. /**
  54771. * Specifies whether the texture is in gamma space.
  54772. */
  54773. gammaSpace: boolean;
  54774. }
  54775. /**
  54776. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54777. */
  54778. export class PanoramaToCubeMapTools {
  54779. private static FACE_LEFT;
  54780. private static FACE_RIGHT;
  54781. private static FACE_FRONT;
  54782. private static FACE_BACK;
  54783. private static FACE_DOWN;
  54784. private static FACE_UP;
  54785. /**
  54786. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54787. *
  54788. * @param float32Array The source data.
  54789. * @param inputWidth The width of the input panorama.
  54790. * @param inputHeight The height of the input panorama.
  54791. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54792. * @return The cubemap data
  54793. */
  54794. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54795. private static CreateCubemapTexture;
  54796. private static CalcProjectionSpherical;
  54797. }
  54798. }
  54799. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54800. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54802. import { Nullable } from "babylonjs/types";
  54803. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54804. /**
  54805. * Helper class dealing with the extraction of spherical polynomial dataArray
  54806. * from a cube map.
  54807. */
  54808. export class CubeMapToSphericalPolynomialTools {
  54809. private static FileFaces;
  54810. /**
  54811. * Converts a texture to the according Spherical Polynomial data.
  54812. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54813. *
  54814. * @param texture The texture to extract the information from.
  54815. * @return The Spherical Polynomial data.
  54816. */
  54817. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54818. /**
  54819. * Converts a cubemap to the according Spherical Polynomial data.
  54820. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54821. *
  54822. * @param cubeInfo The Cube map to extract the information from.
  54823. * @return The Spherical Polynomial data.
  54824. */
  54825. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54826. }
  54827. }
  54828. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54829. import { Nullable } from "babylonjs/types";
  54830. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54831. module "babylonjs/Materials/Textures/baseTexture" {
  54832. interface BaseTexture {
  54833. /**
  54834. * Get the polynomial representation of the texture data.
  54835. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54836. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54837. */
  54838. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54839. }
  54840. }
  54841. }
  54842. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54843. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54844. /** @hidden */
  54845. export var rgbdEncodePixelShader: {
  54846. name: string;
  54847. shader: string;
  54848. };
  54849. }
  54850. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54851. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54852. /** @hidden */
  54853. export var rgbdDecodePixelShader: {
  54854. name: string;
  54855. shader: string;
  54856. };
  54857. }
  54858. declare module "babylonjs/Misc/environmentTextureTools" {
  54859. import { Nullable } from "babylonjs/types";
  54860. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54863. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54864. import "babylonjs/Engines/Extensions/engine.readTexture";
  54865. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54866. import "babylonjs/Shaders/rgbdEncode.fragment";
  54867. import "babylonjs/Shaders/rgbdDecode.fragment";
  54868. /**
  54869. * Raw texture data and descriptor sufficient for WebGL texture upload
  54870. */
  54871. export interface EnvironmentTextureInfo {
  54872. /**
  54873. * Version of the environment map
  54874. */
  54875. version: number;
  54876. /**
  54877. * Width of image
  54878. */
  54879. width: number;
  54880. /**
  54881. * Irradiance information stored in the file.
  54882. */
  54883. irradiance: any;
  54884. /**
  54885. * Specular information stored in the file.
  54886. */
  54887. specular: any;
  54888. }
  54889. /**
  54890. * Defines One Image in the file. It requires only the position in the file
  54891. * as well as the length.
  54892. */
  54893. interface BufferImageData {
  54894. /**
  54895. * Length of the image data.
  54896. */
  54897. length: number;
  54898. /**
  54899. * Position of the data from the null terminator delimiting the end of the JSON.
  54900. */
  54901. position: number;
  54902. }
  54903. /**
  54904. * Defines the specular data enclosed in the file.
  54905. * This corresponds to the version 1 of the data.
  54906. */
  54907. export interface EnvironmentTextureSpecularInfoV1 {
  54908. /**
  54909. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54910. */
  54911. specularDataPosition?: number;
  54912. /**
  54913. * This contains all the images data needed to reconstruct the cubemap.
  54914. */
  54915. mipmaps: Array<BufferImageData>;
  54916. /**
  54917. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54918. */
  54919. lodGenerationScale: number;
  54920. }
  54921. /**
  54922. * Sets of helpers addressing the serialization and deserialization of environment texture
  54923. * stored in a BabylonJS env file.
  54924. * Those files are usually stored as .env files.
  54925. */
  54926. export class EnvironmentTextureTools {
  54927. /**
  54928. * Magic number identifying the env file.
  54929. */
  54930. private static _MagicBytes;
  54931. /**
  54932. * Gets the environment info from an env file.
  54933. * @param data The array buffer containing the .env bytes.
  54934. * @returns the environment file info (the json header) if successfully parsed.
  54935. */
  54936. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54937. /**
  54938. * Creates an environment texture from a loaded cube texture.
  54939. * @param texture defines the cube texture to convert in env file
  54940. * @return a promise containing the environment data if succesfull.
  54941. */
  54942. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54943. /**
  54944. * Creates a JSON representation of the spherical data.
  54945. * @param texture defines the texture containing the polynomials
  54946. * @return the JSON representation of the spherical info
  54947. */
  54948. private static _CreateEnvTextureIrradiance;
  54949. /**
  54950. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54951. * @param data the image data
  54952. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54953. * @return the views described by info providing access to the underlying buffer
  54954. */
  54955. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54956. /**
  54957. * Uploads the texture info contained in the env file to the GPU.
  54958. * @param texture defines the internal texture to upload to
  54959. * @param data defines the data to load
  54960. * @param info defines the texture info retrieved through the GetEnvInfo method
  54961. * @returns a promise
  54962. */
  54963. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54964. private static _OnImageReadyAsync;
  54965. /**
  54966. * Uploads the levels of image data to the GPU.
  54967. * @param texture defines the internal texture to upload to
  54968. * @param imageData defines the array buffer views of image data [mipmap][face]
  54969. * @returns a promise
  54970. */
  54971. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54972. /**
  54973. * Uploads spherical polynomials information to the texture.
  54974. * @param texture defines the texture we are trying to upload the information to
  54975. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54976. */
  54977. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54978. /** @hidden */
  54979. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54980. }
  54981. }
  54982. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54983. /**
  54984. * Class used to inline functions in shader code
  54985. */
  54986. export class ShaderCodeInliner {
  54987. private static readonly _RegexpFindFunctionNameAndType;
  54988. private _sourceCode;
  54989. private _functionDescr;
  54990. private _numMaxIterations;
  54991. /** Gets or sets the token used to mark the functions to inline */
  54992. inlineToken: string;
  54993. /** Gets or sets the debug mode */
  54994. debug: boolean;
  54995. /** Gets the code after the inlining process */
  54996. get code(): string;
  54997. /**
  54998. * Initializes the inliner
  54999. * @param sourceCode shader code source to inline
  55000. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55001. */
  55002. constructor(sourceCode: string, numMaxIterations?: number);
  55003. /**
  55004. * Start the processing of the shader code
  55005. */
  55006. processCode(): void;
  55007. private _collectFunctions;
  55008. private _processInlining;
  55009. private _extractBetweenMarkers;
  55010. private _skipWhitespaces;
  55011. private _removeComments;
  55012. private _replaceFunctionCallsByCode;
  55013. private _findBackward;
  55014. private _escapeRegExp;
  55015. private _replaceNames;
  55016. }
  55017. }
  55018. declare module "babylonjs/Engines/nativeEngine" {
  55019. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55020. import { Engine } from "babylonjs/Engines/engine";
  55021. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55022. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55023. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55024. import { Effect } from "babylonjs/Materials/effect";
  55025. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55026. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55027. import { IColor4Like } from "babylonjs/Maths/math.like";
  55028. import { Scene } from "babylonjs/scene";
  55029. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55030. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55031. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55032. /**
  55033. * Container for accessors for natively-stored mesh data buffers.
  55034. */
  55035. class NativeDataBuffer extends DataBuffer {
  55036. /**
  55037. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55038. */
  55039. nativeIndexBuffer?: any;
  55040. /**
  55041. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55042. */
  55043. nativeVertexBuffer?: any;
  55044. }
  55045. /** @hidden */
  55046. class NativeTexture extends InternalTexture {
  55047. getInternalTexture(): InternalTexture;
  55048. getViewCount(): number;
  55049. }
  55050. /** @hidden */
  55051. export class NativeEngine extends Engine {
  55052. private readonly _native;
  55053. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55054. private readonly INVALID_HANDLE;
  55055. private _boundBuffersVertexArray;
  55056. private _currentDepthTest;
  55057. getHardwareScalingLevel(): number;
  55058. constructor();
  55059. dispose(): void;
  55060. /**
  55061. * Can be used to override the current requestAnimationFrame requester.
  55062. * @hidden
  55063. */
  55064. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55065. /**
  55066. * Override default engine behavior.
  55067. * @param color
  55068. * @param backBuffer
  55069. * @param depth
  55070. * @param stencil
  55071. */
  55072. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55073. /**
  55074. * Gets host document
  55075. * @returns the host document object
  55076. */
  55077. getHostDocument(): Nullable<Document>;
  55078. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55079. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55080. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55081. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55082. [key: string]: VertexBuffer;
  55083. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55084. bindBuffers(vertexBuffers: {
  55085. [key: string]: VertexBuffer;
  55086. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55087. recordVertexArrayObject(vertexBuffers: {
  55088. [key: string]: VertexBuffer;
  55089. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55090. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55091. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55092. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55093. /**
  55094. * Draw a list of indexed primitives
  55095. * @param fillMode defines the primitive to use
  55096. * @param indexStart defines the starting index
  55097. * @param indexCount defines the number of index to draw
  55098. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55099. */
  55100. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55101. /**
  55102. * Draw a list of unindexed primitives
  55103. * @param fillMode defines the primitive to use
  55104. * @param verticesStart defines the index of first vertex to draw
  55105. * @param verticesCount defines the count of vertices to draw
  55106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55107. */
  55108. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55109. createPipelineContext(): IPipelineContext;
  55110. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55111. /** @hidden */
  55112. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55113. /** @hidden */
  55114. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55115. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55116. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55117. protected _setProgram(program: WebGLProgram): void;
  55118. _releaseEffect(effect: Effect): void;
  55119. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55120. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55121. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55122. bindSamplers(effect: Effect): void;
  55123. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55124. getRenderWidth(useScreen?: boolean): number;
  55125. getRenderHeight(useScreen?: boolean): number;
  55126. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55127. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55128. /**
  55129. * Set the z offset to apply to current rendering
  55130. * @param value defines the offset to apply
  55131. */
  55132. setZOffset(value: number): void;
  55133. /**
  55134. * Gets the current value of the zOffset
  55135. * @returns the current zOffset state
  55136. */
  55137. getZOffset(): number;
  55138. /**
  55139. * Enable or disable depth buffering
  55140. * @param enable defines the state to set
  55141. */
  55142. setDepthBuffer(enable: boolean): void;
  55143. /**
  55144. * Gets a boolean indicating if depth writing is enabled
  55145. * @returns the current depth writing state
  55146. */
  55147. getDepthWrite(): boolean;
  55148. setDepthFunctionToGreater(): void;
  55149. setDepthFunctionToGreaterOrEqual(): void;
  55150. setDepthFunctionToLess(): void;
  55151. setDepthFunctionToLessOrEqual(): void;
  55152. /**
  55153. * Enable or disable depth writing
  55154. * @param enable defines the state to set
  55155. */
  55156. setDepthWrite(enable: boolean): void;
  55157. /**
  55158. * Enable or disable color writing
  55159. * @param enable defines the state to set
  55160. */
  55161. setColorWrite(enable: boolean): void;
  55162. /**
  55163. * Gets a boolean indicating if color writing is enabled
  55164. * @returns the current color writing state
  55165. */
  55166. getColorWrite(): boolean;
  55167. /**
  55168. * Sets alpha constants used by some alpha blending modes
  55169. * @param r defines the red component
  55170. * @param g defines the green component
  55171. * @param b defines the blue component
  55172. * @param a defines the alpha component
  55173. */
  55174. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55175. /**
  55176. * Sets the current alpha mode
  55177. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55178. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55179. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55180. */
  55181. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55182. /**
  55183. * Gets the current alpha mode
  55184. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55185. * @returns the current alpha mode
  55186. */
  55187. getAlphaMode(): number;
  55188. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55189. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55190. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55191. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55192. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55193. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55194. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55195. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55196. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55197. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55198. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55199. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55200. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55201. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55202. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55203. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55204. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55205. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55206. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55207. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55208. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55209. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55210. wipeCaches(bruteForce?: boolean): void;
  55211. _createTexture(): WebGLTexture;
  55212. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55213. /**
  55214. * Usually called from Texture.ts.
  55215. * Passed information to create a WebGLTexture
  55216. * @param url defines a value which contains one of the following:
  55217. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55218. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55219. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55220. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55221. * @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)
  55222. * @param scene needed for loading to the correct scene
  55223. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55224. * @param onLoad optional callback to be called upon successful completion
  55225. * @param onError optional callback to be called upon failure
  55226. * @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
  55227. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55228. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55229. * @param forcedExtension defines the extension to use to pick the right loader
  55230. * @param mimeType defines an optional mime type
  55231. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55232. */
  55233. 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;
  55234. /**
  55235. * Creates a cube texture
  55236. * @param rootUrl defines the url where the files to load is located
  55237. * @param scene defines the current scene
  55238. * @param files defines the list of files to load (1 per face)
  55239. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55240. * @param onLoad defines an optional callback raised when the texture is loaded
  55241. * @param onError defines an optional callback raised if there is an issue to load the texture
  55242. * @param format defines the format of the data
  55243. * @param forcedExtension defines the extension to use to pick the right loader
  55244. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55245. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55246. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55247. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55248. * @returns the cube texture as an InternalTexture
  55249. */
  55250. 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;
  55251. private _getSamplingFilter;
  55252. private static _GetNativeTextureFormat;
  55253. createRenderTargetTexture(size: number | {
  55254. width: number;
  55255. height: number;
  55256. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55257. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55258. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55259. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55260. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55261. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55262. /**
  55263. * Updates a dynamic vertex buffer.
  55264. * @param vertexBuffer the vertex buffer to update
  55265. * @param data the data used to update the vertex buffer
  55266. * @param byteOffset the byte offset of the data (optional)
  55267. * @param byteLength the byte length of the data (optional)
  55268. */
  55269. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55270. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55271. private _updateAnisotropicLevel;
  55272. private _getAddressMode;
  55273. /** @hidden */
  55274. _bindTexture(channel: number, texture: InternalTexture): void;
  55275. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55276. releaseEffects(): void;
  55277. /** @hidden */
  55278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55279. /** @hidden */
  55280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55281. /** @hidden */
  55282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55283. /** @hidden */
  55284. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55285. }
  55286. }
  55287. declare module "babylonjs/Engines/index" {
  55288. export * from "babylonjs/Engines/constants";
  55289. export * from "babylonjs/Engines/engineCapabilities";
  55290. export * from "babylonjs/Engines/instancingAttributeInfo";
  55291. export * from "babylonjs/Engines/thinEngine";
  55292. export * from "babylonjs/Engines/engine";
  55293. export * from "babylonjs/Engines/engineStore";
  55294. export * from "babylonjs/Engines/nullEngine";
  55295. export * from "babylonjs/Engines/Extensions/index";
  55296. export * from "babylonjs/Engines/IPipelineContext";
  55297. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55298. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55299. export * from "babylonjs/Engines/nativeEngine";
  55300. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55301. export * from "babylonjs/Engines/performanceConfigurator";
  55302. }
  55303. declare module "babylonjs/Events/clipboardEvents" {
  55304. /**
  55305. * Gather the list of clipboard event types as constants.
  55306. */
  55307. export class ClipboardEventTypes {
  55308. /**
  55309. * The clipboard event is fired when a copy command is active (pressed).
  55310. */
  55311. static readonly COPY: number;
  55312. /**
  55313. * The clipboard event is fired when a cut command is active (pressed).
  55314. */
  55315. static readonly CUT: number;
  55316. /**
  55317. * The clipboard event is fired when a paste command is active (pressed).
  55318. */
  55319. static readonly PASTE: number;
  55320. }
  55321. /**
  55322. * This class is used to store clipboard related info for the onClipboardObservable event.
  55323. */
  55324. export class ClipboardInfo {
  55325. /**
  55326. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55327. */
  55328. type: number;
  55329. /**
  55330. * Defines the related dom event
  55331. */
  55332. event: ClipboardEvent;
  55333. /**
  55334. *Creates an instance of ClipboardInfo.
  55335. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55336. * @param event Defines the related dom event
  55337. */
  55338. constructor(
  55339. /**
  55340. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55341. */
  55342. type: number,
  55343. /**
  55344. * Defines the related dom event
  55345. */
  55346. event: ClipboardEvent);
  55347. /**
  55348. * Get the clipboard event's type from the keycode.
  55349. * @param keyCode Defines the keyCode for the current keyboard event.
  55350. * @return {number}
  55351. */
  55352. static GetTypeFromCharacter(keyCode: number): number;
  55353. }
  55354. }
  55355. declare module "babylonjs/Events/index" {
  55356. export * from "babylonjs/Events/keyboardEvents";
  55357. export * from "babylonjs/Events/pointerEvents";
  55358. export * from "babylonjs/Events/clipboardEvents";
  55359. }
  55360. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55361. import { Scene } from "babylonjs/scene";
  55362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55363. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55364. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55365. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55366. /**
  55367. * Google Daydream controller
  55368. */
  55369. export class DaydreamController extends WebVRController {
  55370. /**
  55371. * Base Url for the controller model.
  55372. */
  55373. static MODEL_BASE_URL: string;
  55374. /**
  55375. * File name for the controller model.
  55376. */
  55377. static MODEL_FILENAME: string;
  55378. /**
  55379. * Gamepad Id prefix used to identify Daydream Controller.
  55380. */
  55381. static readonly GAMEPAD_ID_PREFIX: string;
  55382. /**
  55383. * Creates a new DaydreamController from a gamepad
  55384. * @param vrGamepad the gamepad that the controller should be created from
  55385. */
  55386. constructor(vrGamepad: any);
  55387. /**
  55388. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55389. * @param scene scene in which to add meshes
  55390. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55391. */
  55392. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55393. /**
  55394. * Called once for each button that changed state since the last frame
  55395. * @param buttonIdx Which button index changed
  55396. * @param state New state of the button
  55397. * @param changes Which properties on the state changed since last frame
  55398. */
  55399. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55400. }
  55401. }
  55402. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55403. import { Scene } from "babylonjs/scene";
  55404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55405. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55406. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55407. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55408. /**
  55409. * Gear VR Controller
  55410. */
  55411. export class GearVRController extends WebVRController {
  55412. /**
  55413. * Base Url for the controller model.
  55414. */
  55415. static MODEL_BASE_URL: string;
  55416. /**
  55417. * File name for the controller model.
  55418. */
  55419. static MODEL_FILENAME: string;
  55420. /**
  55421. * Gamepad Id prefix used to identify this controller.
  55422. */
  55423. static readonly GAMEPAD_ID_PREFIX: string;
  55424. private readonly _buttonIndexToObservableNameMap;
  55425. /**
  55426. * Creates a new GearVRController from a gamepad
  55427. * @param vrGamepad the gamepad that the controller should be created from
  55428. */
  55429. constructor(vrGamepad: any);
  55430. /**
  55431. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55432. * @param scene scene in which to add meshes
  55433. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55434. */
  55435. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55436. /**
  55437. * Called once for each button that changed state since the last frame
  55438. * @param buttonIdx Which button index changed
  55439. * @param state New state of the button
  55440. * @param changes Which properties on the state changed since last frame
  55441. */
  55442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55443. }
  55444. }
  55445. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55446. import { Scene } from "babylonjs/scene";
  55447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55448. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55449. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55450. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55451. /**
  55452. * Generic Controller
  55453. */
  55454. export class GenericController extends WebVRController {
  55455. /**
  55456. * Base Url for the controller model.
  55457. */
  55458. static readonly MODEL_BASE_URL: string;
  55459. /**
  55460. * File name for the controller model.
  55461. */
  55462. static readonly MODEL_FILENAME: string;
  55463. /**
  55464. * Creates a new GenericController from a gamepad
  55465. * @param vrGamepad the gamepad that the controller should be created from
  55466. */
  55467. constructor(vrGamepad: any);
  55468. /**
  55469. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55470. * @param scene scene in which to add meshes
  55471. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55472. */
  55473. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55474. /**
  55475. * Called once for each button that changed state since the last frame
  55476. * @param buttonIdx Which button index changed
  55477. * @param state New state of the button
  55478. * @param changes Which properties on the state changed since last frame
  55479. */
  55480. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55481. }
  55482. }
  55483. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55484. import { Observable } from "babylonjs/Misc/observable";
  55485. import { Scene } from "babylonjs/scene";
  55486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55487. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55488. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55489. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55490. /**
  55491. * Oculus Touch Controller
  55492. */
  55493. export class OculusTouchController extends WebVRController {
  55494. /**
  55495. * Base Url for the controller model.
  55496. */
  55497. static MODEL_BASE_URL: string;
  55498. /**
  55499. * File name for the left controller model.
  55500. */
  55501. static MODEL_LEFT_FILENAME: string;
  55502. /**
  55503. * File name for the right controller model.
  55504. */
  55505. static MODEL_RIGHT_FILENAME: string;
  55506. /**
  55507. * Base Url for the Quest controller model.
  55508. */
  55509. static QUEST_MODEL_BASE_URL: string;
  55510. /**
  55511. * @hidden
  55512. * If the controllers are running on a device that needs the updated Quest controller models
  55513. */
  55514. static _IsQuest: boolean;
  55515. /**
  55516. * Fired when the secondary trigger on this controller is modified
  55517. */
  55518. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55519. /**
  55520. * Fired when the thumb rest on this controller is modified
  55521. */
  55522. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55523. /**
  55524. * Creates a new OculusTouchController from a gamepad
  55525. * @param vrGamepad the gamepad that the controller should be created from
  55526. */
  55527. constructor(vrGamepad: any);
  55528. /**
  55529. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55530. * @param scene scene in which to add meshes
  55531. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55532. */
  55533. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55534. /**
  55535. * Fired when the A button on this controller is modified
  55536. */
  55537. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55538. /**
  55539. * Fired when the B button on this controller is modified
  55540. */
  55541. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55542. /**
  55543. * Fired when the X button on this controller is modified
  55544. */
  55545. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55546. /**
  55547. * Fired when the Y button on this controller is modified
  55548. */
  55549. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55550. /**
  55551. * Called once for each button that changed state since the last frame
  55552. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55553. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55554. * 2) secondary trigger (same)
  55555. * 3) A (right) X (left), touch, pressed = value
  55556. * 4) B / Y
  55557. * 5) thumb rest
  55558. * @param buttonIdx Which button index changed
  55559. * @param state New state of the button
  55560. * @param changes Which properties on the state changed since last frame
  55561. */
  55562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55563. }
  55564. }
  55565. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55566. import { Scene } from "babylonjs/scene";
  55567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55568. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55569. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55570. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55571. import { Observable } from "babylonjs/Misc/observable";
  55572. /**
  55573. * Vive Controller
  55574. */
  55575. export class ViveController extends WebVRController {
  55576. /**
  55577. * Base Url for the controller model.
  55578. */
  55579. static MODEL_BASE_URL: string;
  55580. /**
  55581. * File name for the controller model.
  55582. */
  55583. static MODEL_FILENAME: string;
  55584. /**
  55585. * Creates a new ViveController from a gamepad
  55586. * @param vrGamepad the gamepad that the controller should be created from
  55587. */
  55588. constructor(vrGamepad: any);
  55589. /**
  55590. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55591. * @param scene scene in which to add meshes
  55592. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55593. */
  55594. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55595. /**
  55596. * Fired when the left button on this controller is modified
  55597. */
  55598. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55599. /**
  55600. * Fired when the right button on this controller is modified
  55601. */
  55602. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55603. /**
  55604. * Fired when the menu button on this controller is modified
  55605. */
  55606. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55607. /**
  55608. * Called once for each button that changed state since the last frame
  55609. * Vive mapping:
  55610. * 0: touchpad
  55611. * 1: trigger
  55612. * 2: left AND right buttons
  55613. * 3: menu button
  55614. * @param buttonIdx Which button index changed
  55615. * @param state New state of the button
  55616. * @param changes Which properties on the state changed since last frame
  55617. */
  55618. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55619. }
  55620. }
  55621. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55622. import { Observable } from "babylonjs/Misc/observable";
  55623. import { Scene } from "babylonjs/scene";
  55624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55625. import { Ray } from "babylonjs/Culling/ray";
  55626. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55627. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55628. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55629. /**
  55630. * Defines the WindowsMotionController object that the state of the windows motion controller
  55631. */
  55632. export class WindowsMotionController extends WebVRController {
  55633. /**
  55634. * The base url used to load the left and right controller models
  55635. */
  55636. static MODEL_BASE_URL: string;
  55637. /**
  55638. * The name of the left controller model file
  55639. */
  55640. static MODEL_LEFT_FILENAME: string;
  55641. /**
  55642. * The name of the right controller model file
  55643. */
  55644. static MODEL_RIGHT_FILENAME: string;
  55645. /**
  55646. * The controller name prefix for this controller type
  55647. */
  55648. static readonly GAMEPAD_ID_PREFIX: string;
  55649. /**
  55650. * The controller id pattern for this controller type
  55651. */
  55652. private static readonly GAMEPAD_ID_PATTERN;
  55653. private _loadedMeshInfo;
  55654. protected readonly _mapping: {
  55655. buttons: string[];
  55656. buttonMeshNames: {
  55657. trigger: string;
  55658. menu: string;
  55659. grip: string;
  55660. thumbstick: string;
  55661. trackpad: string;
  55662. };
  55663. buttonObservableNames: {
  55664. trigger: string;
  55665. menu: string;
  55666. grip: string;
  55667. thumbstick: string;
  55668. trackpad: string;
  55669. };
  55670. axisMeshNames: string[];
  55671. pointingPoseMeshName: string;
  55672. };
  55673. /**
  55674. * Fired when the trackpad on this controller is clicked
  55675. */
  55676. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55677. /**
  55678. * Fired when the trackpad on this controller is modified
  55679. */
  55680. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55681. /**
  55682. * The current x and y values of this controller's trackpad
  55683. */
  55684. trackpad: StickValues;
  55685. /**
  55686. * Creates a new WindowsMotionController from a gamepad
  55687. * @param vrGamepad the gamepad that the controller should be created from
  55688. */
  55689. constructor(vrGamepad: any);
  55690. /**
  55691. * Fired when the trigger on this controller is modified
  55692. */
  55693. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55694. /**
  55695. * Fired when the menu button on this controller is modified
  55696. */
  55697. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55698. /**
  55699. * Fired when the grip button on this controller is modified
  55700. */
  55701. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55702. /**
  55703. * Fired when the thumbstick button on this controller is modified
  55704. */
  55705. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55706. /**
  55707. * Fired when the touchpad button on this controller is modified
  55708. */
  55709. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55710. /**
  55711. * Fired when the touchpad values on this controller are modified
  55712. */
  55713. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55714. protected _updateTrackpad(): void;
  55715. /**
  55716. * Called once per frame by the engine.
  55717. */
  55718. update(): void;
  55719. /**
  55720. * Called once for each button that changed state since the last frame
  55721. * @param buttonIdx Which button index changed
  55722. * @param state New state of the button
  55723. * @param changes Which properties on the state changed since last frame
  55724. */
  55725. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55726. /**
  55727. * Moves the buttons on the controller mesh based on their current state
  55728. * @param buttonName the name of the button to move
  55729. * @param buttonValue the value of the button which determines the buttons new position
  55730. */
  55731. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55732. /**
  55733. * Moves the axis on the controller mesh based on its current state
  55734. * @param axis the index of the axis
  55735. * @param axisValue the value of the axis which determines the meshes new position
  55736. * @hidden
  55737. */
  55738. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55739. /**
  55740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55741. * @param scene scene in which to add meshes
  55742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55743. */
  55744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55745. /**
  55746. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55747. * can be transformed by button presses and axes values, based on this._mapping.
  55748. *
  55749. * @param scene scene in which the meshes exist
  55750. * @param meshes list of meshes that make up the controller model to process
  55751. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55752. */
  55753. private processModel;
  55754. private createMeshInfo;
  55755. /**
  55756. * Gets the ray of the controller in the direction the controller is pointing
  55757. * @param length the length the resulting ray should be
  55758. * @returns a ray in the direction the controller is pointing
  55759. */
  55760. getForwardRay(length?: number): Ray;
  55761. /**
  55762. * Disposes of the controller
  55763. */
  55764. dispose(): void;
  55765. }
  55766. /**
  55767. * This class represents a new windows motion controller in XR.
  55768. */
  55769. export class XRWindowsMotionController extends WindowsMotionController {
  55770. /**
  55771. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55772. */
  55773. protected readonly _mapping: {
  55774. buttons: string[];
  55775. buttonMeshNames: {
  55776. trigger: string;
  55777. menu: string;
  55778. grip: string;
  55779. thumbstick: string;
  55780. trackpad: string;
  55781. };
  55782. buttonObservableNames: {
  55783. trigger: string;
  55784. menu: string;
  55785. grip: string;
  55786. thumbstick: string;
  55787. trackpad: string;
  55788. };
  55789. axisMeshNames: string[];
  55790. pointingPoseMeshName: string;
  55791. };
  55792. /**
  55793. * Construct a new XR-Based windows motion controller
  55794. *
  55795. * @param gamepadInfo the gamepad object from the browser
  55796. */
  55797. constructor(gamepadInfo: any);
  55798. /**
  55799. * holds the thumbstick values (X,Y)
  55800. */
  55801. thumbstickValues: StickValues;
  55802. /**
  55803. * Fired when the thumbstick on this controller is clicked
  55804. */
  55805. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55806. /**
  55807. * Fired when the thumbstick on this controller is modified
  55808. */
  55809. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55810. /**
  55811. * Fired when the touchpad button on this controller is modified
  55812. */
  55813. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55814. /**
  55815. * Fired when the touchpad values on this controller are modified
  55816. */
  55817. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55818. /**
  55819. * Fired when the thumbstick button on this controller is modified
  55820. * here to prevent breaking changes
  55821. */
  55822. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55823. /**
  55824. * updating the thumbstick(!) and not the trackpad.
  55825. * This is named this way due to the difference between WebVR and XR and to avoid
  55826. * changing the parent class.
  55827. */
  55828. protected _updateTrackpad(): void;
  55829. /**
  55830. * Disposes the class with joy
  55831. */
  55832. dispose(): void;
  55833. }
  55834. }
  55835. declare module "babylonjs/Gamepads/Controllers/index" {
  55836. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55837. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55838. export * from "babylonjs/Gamepads/Controllers/genericController";
  55839. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55840. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55841. export * from "babylonjs/Gamepads/Controllers/viveController";
  55842. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55843. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55844. }
  55845. declare module "babylonjs/Gamepads/index" {
  55846. export * from "babylonjs/Gamepads/Controllers/index";
  55847. export * from "babylonjs/Gamepads/gamepad";
  55848. export * from "babylonjs/Gamepads/gamepadManager";
  55849. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55850. export * from "babylonjs/Gamepads/xboxGamepad";
  55851. export * from "babylonjs/Gamepads/dualShockGamepad";
  55852. }
  55853. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55854. import { Scene } from "babylonjs/scene";
  55855. import { Vector4 } from "babylonjs/Maths/math.vector";
  55856. import { Color4 } from "babylonjs/Maths/math.color";
  55857. import { Mesh } from "babylonjs/Meshes/mesh";
  55858. import { Nullable } from "babylonjs/types";
  55859. /**
  55860. * Class containing static functions to help procedurally build meshes
  55861. */
  55862. export class PolyhedronBuilder {
  55863. /**
  55864. * Creates a polyhedron mesh
  55865. * * 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
  55866. * * The parameter `size` (positive float, default 1) sets the polygon size
  55867. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55868. * * 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`
  55869. * * 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
  55870. * * 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)`)
  55871. * * 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
  55872. * * 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
  55873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55876. * @param name defines the name of the mesh
  55877. * @param options defines the options used to create the mesh
  55878. * @param scene defines the hosting scene
  55879. * @returns the polyhedron mesh
  55880. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55881. */
  55882. static CreatePolyhedron(name: string, options: {
  55883. type?: number;
  55884. size?: number;
  55885. sizeX?: number;
  55886. sizeY?: number;
  55887. sizeZ?: number;
  55888. custom?: any;
  55889. faceUV?: Vector4[];
  55890. faceColors?: Color4[];
  55891. flat?: boolean;
  55892. updatable?: boolean;
  55893. sideOrientation?: number;
  55894. frontUVs?: Vector4;
  55895. backUVs?: Vector4;
  55896. }, scene?: Nullable<Scene>): Mesh;
  55897. }
  55898. }
  55899. declare module "babylonjs/Gizmos/scaleGizmo" {
  55900. import { Observable } from "babylonjs/Misc/observable";
  55901. import { Nullable } from "babylonjs/types";
  55902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55903. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55904. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55905. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55906. import { Node } from "babylonjs/node";
  55907. /**
  55908. * Gizmo that enables scaling a mesh along 3 axis
  55909. */
  55910. export class ScaleGizmo extends Gizmo {
  55911. /**
  55912. * Internal gizmo used for interactions on the x axis
  55913. */
  55914. xGizmo: AxisScaleGizmo;
  55915. /**
  55916. * Internal gizmo used for interactions on the y axis
  55917. */
  55918. yGizmo: AxisScaleGizmo;
  55919. /**
  55920. * Internal gizmo used for interactions on the z axis
  55921. */
  55922. zGizmo: AxisScaleGizmo;
  55923. /**
  55924. * Internal gizmo used to scale all axis equally
  55925. */
  55926. uniformScaleGizmo: AxisScaleGizmo;
  55927. private _meshAttached;
  55928. private _nodeAttached;
  55929. private _snapDistance;
  55930. private _uniformScalingMesh;
  55931. private _octahedron;
  55932. private _sensitivity;
  55933. /** Fires an event when any of it's sub gizmos are dragged */
  55934. onDragStartObservable: Observable<unknown>;
  55935. /** Fires an event when any of it's sub gizmos are released from dragging */
  55936. onDragEndObservable: Observable<unknown>;
  55937. get attachedMesh(): Nullable<AbstractMesh>;
  55938. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55939. get attachedNode(): Nullable<Node>;
  55940. set attachedNode(node: Nullable<Node>);
  55941. /**
  55942. * True when the mouse pointer is hovering a gizmo mesh
  55943. */
  55944. get isHovered(): boolean;
  55945. /**
  55946. * Creates a ScaleGizmo
  55947. * @param gizmoLayer The utility layer the gizmo will be added to
  55948. * @param thickness display gizmo axis thickness
  55949. */
  55950. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55951. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55952. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55953. /**
  55954. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55955. */
  55956. set snapDistance(value: number);
  55957. get snapDistance(): number;
  55958. /**
  55959. * Ratio for the scale of the gizmo (Default: 1)
  55960. */
  55961. set scaleRatio(value: number);
  55962. get scaleRatio(): number;
  55963. /**
  55964. * Sensitivity factor for dragging (Default: 1)
  55965. */
  55966. set sensitivity(value: number);
  55967. get sensitivity(): number;
  55968. /**
  55969. * Disposes of the gizmo
  55970. */
  55971. dispose(): void;
  55972. }
  55973. }
  55974. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55975. import { Observable } from "babylonjs/Misc/observable";
  55976. import { Nullable } from "babylonjs/types";
  55977. import { Vector3 } from "babylonjs/Maths/math.vector";
  55978. import { Node } from "babylonjs/node";
  55979. import { Mesh } from "babylonjs/Meshes/mesh";
  55980. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55981. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55982. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55983. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55984. import { Color3 } from "babylonjs/Maths/math.color";
  55985. /**
  55986. * Single axis scale gizmo
  55987. */
  55988. export class AxisScaleGizmo extends Gizmo {
  55989. /**
  55990. * Drag behavior responsible for the gizmos dragging interactions
  55991. */
  55992. dragBehavior: PointerDragBehavior;
  55993. private _pointerObserver;
  55994. /**
  55995. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55996. */
  55997. snapDistance: number;
  55998. /**
  55999. * Event that fires each time the gizmo snaps to a new location.
  56000. * * snapDistance is the the change in distance
  56001. */
  56002. onSnapObservable: Observable<{
  56003. snapDistance: number;
  56004. }>;
  56005. /**
  56006. * If the scaling operation should be done on all axis (default: false)
  56007. */
  56008. uniformScaling: boolean;
  56009. /**
  56010. * Custom sensitivity value for the drag strength
  56011. */
  56012. sensitivity: number;
  56013. private _isEnabled;
  56014. private _parent;
  56015. private _arrow;
  56016. private _coloredMaterial;
  56017. private _hoverMaterial;
  56018. /**
  56019. * Creates an AxisScaleGizmo
  56020. * @param gizmoLayer The utility layer the gizmo will be added to
  56021. * @param dragAxis The axis which the gizmo will be able to scale on
  56022. * @param color The color of the gizmo
  56023. * @param thickness display gizmo axis thickness
  56024. */
  56025. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56026. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56027. /**
  56028. * If the gizmo is enabled
  56029. */
  56030. set isEnabled(value: boolean);
  56031. get isEnabled(): boolean;
  56032. /**
  56033. * Disposes of the gizmo
  56034. */
  56035. dispose(): void;
  56036. /**
  56037. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56038. * @param mesh The mesh to replace the default mesh of the gizmo
  56039. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56040. */
  56041. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56042. }
  56043. }
  56044. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56045. import { Observable } from "babylonjs/Misc/observable";
  56046. import { Nullable } from "babylonjs/types";
  56047. import { Vector3 } from "babylonjs/Maths/math.vector";
  56048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56049. import { Mesh } from "babylonjs/Meshes/mesh";
  56050. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56051. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56052. import { Color3 } from "babylonjs/Maths/math.color";
  56053. import "babylonjs/Meshes/Builders/boxBuilder";
  56054. /**
  56055. * Bounding box gizmo
  56056. */
  56057. export class BoundingBoxGizmo extends Gizmo {
  56058. private _lineBoundingBox;
  56059. private _rotateSpheresParent;
  56060. private _scaleBoxesParent;
  56061. private _boundingDimensions;
  56062. private _renderObserver;
  56063. private _pointerObserver;
  56064. private _scaleDragSpeed;
  56065. private _tmpQuaternion;
  56066. private _tmpVector;
  56067. private _tmpRotationMatrix;
  56068. /**
  56069. * 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)
  56070. */
  56071. ignoreChildren: boolean;
  56072. /**
  56073. * 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)
  56074. */
  56075. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56076. /**
  56077. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56078. */
  56079. rotationSphereSize: number;
  56080. /**
  56081. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56082. */
  56083. scaleBoxSize: number;
  56084. /**
  56085. * 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)
  56086. */
  56087. fixedDragMeshScreenSize: boolean;
  56088. /**
  56089. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56090. */
  56091. fixedDragMeshScreenSizeDistanceFactor: number;
  56092. /**
  56093. * Fired when a rotation sphere or scale box is dragged
  56094. */
  56095. onDragStartObservable: Observable<{}>;
  56096. /**
  56097. * Fired when a scale box is dragged
  56098. */
  56099. onScaleBoxDragObservable: Observable<{}>;
  56100. /**
  56101. * Fired when a scale box drag is ended
  56102. */
  56103. onScaleBoxDragEndObservable: Observable<{}>;
  56104. /**
  56105. * Fired when a rotation sphere is dragged
  56106. */
  56107. onRotationSphereDragObservable: Observable<{}>;
  56108. /**
  56109. * Fired when a rotation sphere drag is ended
  56110. */
  56111. onRotationSphereDragEndObservable: Observable<{}>;
  56112. /**
  56113. * 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)
  56114. */
  56115. scalePivot: Nullable<Vector3>;
  56116. /**
  56117. * Mesh used as a pivot to rotate the attached node
  56118. */
  56119. private _anchorMesh;
  56120. private _existingMeshScale;
  56121. private _dragMesh;
  56122. private pointerDragBehavior;
  56123. private coloredMaterial;
  56124. private hoverColoredMaterial;
  56125. /**
  56126. * Sets the color of the bounding box gizmo
  56127. * @param color the color to set
  56128. */
  56129. setColor(color: Color3): void;
  56130. /**
  56131. * Creates an BoundingBoxGizmo
  56132. * @param gizmoLayer The utility layer the gizmo will be added to
  56133. * @param color The color of the gizmo
  56134. */
  56135. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56136. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56137. private _selectNode;
  56138. /**
  56139. * Updates the bounding box information for the Gizmo
  56140. */
  56141. updateBoundingBox(): void;
  56142. private _updateRotationSpheres;
  56143. private _updateScaleBoxes;
  56144. /**
  56145. * Enables rotation on the specified axis and disables rotation on the others
  56146. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56147. */
  56148. setEnabledRotationAxis(axis: string): void;
  56149. /**
  56150. * Enables/disables scaling
  56151. * @param enable if scaling should be enabled
  56152. * @param homogeneousScaling defines if scaling should only be homogeneous
  56153. */
  56154. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56155. private _updateDummy;
  56156. /**
  56157. * Enables a pointer drag behavior on the bounding box of the gizmo
  56158. */
  56159. enableDragBehavior(): void;
  56160. /**
  56161. * Disposes of the gizmo
  56162. */
  56163. dispose(): void;
  56164. /**
  56165. * 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)
  56166. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56167. * @returns the bounding box mesh with the passed in mesh as a child
  56168. */
  56169. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56170. /**
  56171. * CustomMeshes are not supported by this gizmo
  56172. * @param mesh The mesh to replace the default mesh of the gizmo
  56173. */
  56174. setCustomMesh(mesh: Mesh): void;
  56175. }
  56176. }
  56177. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56178. import { Observable } from "babylonjs/Misc/observable";
  56179. import { Nullable } from "babylonjs/types";
  56180. import { Vector3 } from "babylonjs/Maths/math.vector";
  56181. import { Color3 } from "babylonjs/Maths/math.color";
  56182. import { Node } from "babylonjs/node";
  56183. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56184. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56185. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56186. import "babylonjs/Meshes/Builders/linesBuilder";
  56187. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56188. /**
  56189. * Single plane rotation gizmo
  56190. */
  56191. export class PlaneRotationGizmo extends Gizmo {
  56192. /**
  56193. * Drag behavior responsible for the gizmos dragging interactions
  56194. */
  56195. dragBehavior: PointerDragBehavior;
  56196. private _pointerObserver;
  56197. /**
  56198. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56199. */
  56200. snapDistance: number;
  56201. /**
  56202. * Event that fires each time the gizmo snaps to a new location.
  56203. * * snapDistance is the the change in distance
  56204. */
  56205. onSnapObservable: Observable<{
  56206. snapDistance: number;
  56207. }>;
  56208. private _isEnabled;
  56209. private _parent;
  56210. /**
  56211. * Creates a PlaneRotationGizmo
  56212. * @param gizmoLayer The utility layer the gizmo will be added to
  56213. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56214. * @param color The color of the gizmo
  56215. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56216. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56217. * @param thickness display gizmo axis thickness
  56218. */
  56219. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56220. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56221. /**
  56222. * If the gizmo is enabled
  56223. */
  56224. set isEnabled(value: boolean);
  56225. get isEnabled(): boolean;
  56226. /**
  56227. * Disposes of the gizmo
  56228. */
  56229. dispose(): void;
  56230. }
  56231. }
  56232. declare module "babylonjs/Gizmos/rotationGizmo" {
  56233. import { Observable } from "babylonjs/Misc/observable";
  56234. import { Nullable } from "babylonjs/types";
  56235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56236. import { Mesh } from "babylonjs/Meshes/mesh";
  56237. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56238. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56239. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56240. import { Node } from "babylonjs/node";
  56241. /**
  56242. * Gizmo that enables rotating a mesh along 3 axis
  56243. */
  56244. export class RotationGizmo extends Gizmo {
  56245. /**
  56246. * Internal gizmo used for interactions on the x axis
  56247. */
  56248. xGizmo: PlaneRotationGizmo;
  56249. /**
  56250. * Internal gizmo used for interactions on the y axis
  56251. */
  56252. yGizmo: PlaneRotationGizmo;
  56253. /**
  56254. * Internal gizmo used for interactions on the z axis
  56255. */
  56256. zGizmo: PlaneRotationGizmo;
  56257. /** Fires an event when any of it's sub gizmos are dragged */
  56258. onDragStartObservable: Observable<unknown>;
  56259. /** Fires an event when any of it's sub gizmos are released from dragging */
  56260. onDragEndObservable: Observable<unknown>;
  56261. private _meshAttached;
  56262. private _nodeAttached;
  56263. get attachedMesh(): Nullable<AbstractMesh>;
  56264. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56265. get attachedNode(): Nullable<Node>;
  56266. set attachedNode(node: Nullable<Node>);
  56267. /**
  56268. * True when the mouse pointer is hovering a gizmo mesh
  56269. */
  56270. get isHovered(): boolean;
  56271. /**
  56272. * Creates a RotationGizmo
  56273. * @param gizmoLayer The utility layer the gizmo will be added to
  56274. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56275. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56276. * @param thickness display gizmo axis thickness
  56277. */
  56278. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56279. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56280. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56281. /**
  56282. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56283. */
  56284. set snapDistance(value: number);
  56285. get snapDistance(): number;
  56286. /**
  56287. * Ratio for the scale of the gizmo (Default: 1)
  56288. */
  56289. set scaleRatio(value: number);
  56290. get scaleRatio(): number;
  56291. /**
  56292. * Disposes of the gizmo
  56293. */
  56294. dispose(): void;
  56295. /**
  56296. * CustomMeshes are not supported by this gizmo
  56297. * @param mesh The mesh to replace the default mesh of the gizmo
  56298. */
  56299. setCustomMesh(mesh: Mesh): void;
  56300. }
  56301. }
  56302. declare module "babylonjs/Gizmos/gizmoManager" {
  56303. import { Observable } from "babylonjs/Misc/observable";
  56304. import { Nullable } from "babylonjs/types";
  56305. import { Scene, IDisposable } from "babylonjs/scene";
  56306. import { Node } from "babylonjs/node";
  56307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56308. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56309. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56310. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56311. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56312. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56313. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56314. /**
  56315. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56316. */
  56317. export class GizmoManager implements IDisposable {
  56318. private scene;
  56319. /**
  56320. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56321. */
  56322. gizmos: {
  56323. positionGizmo: Nullable<PositionGizmo>;
  56324. rotationGizmo: Nullable<RotationGizmo>;
  56325. scaleGizmo: Nullable<ScaleGizmo>;
  56326. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56327. };
  56328. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56329. clearGizmoOnEmptyPointerEvent: boolean;
  56330. /** Fires an event when the manager is attached to a mesh */
  56331. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56332. /** Fires an event when the manager is attached to a node */
  56333. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56334. private _gizmosEnabled;
  56335. private _pointerObserver;
  56336. private _attachedMesh;
  56337. private _attachedNode;
  56338. private _boundingBoxColor;
  56339. private _defaultUtilityLayer;
  56340. private _defaultKeepDepthUtilityLayer;
  56341. private _thickness;
  56342. /**
  56343. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56344. */
  56345. boundingBoxDragBehavior: SixDofDragBehavior;
  56346. /**
  56347. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56348. */
  56349. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56350. /**
  56351. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56352. */
  56353. attachableNodes: Nullable<Array<Node>>;
  56354. /**
  56355. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56356. */
  56357. usePointerToAttachGizmos: boolean;
  56358. /**
  56359. * Utility layer that the bounding box gizmo belongs to
  56360. */
  56361. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56362. /**
  56363. * Utility layer that all gizmos besides bounding box belong to
  56364. */
  56365. get utilityLayer(): UtilityLayerRenderer;
  56366. /**
  56367. * True when the mouse pointer is hovering a gizmo mesh
  56368. */
  56369. get isHovered(): boolean;
  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/subSurfaceScatteringFunctions" {
  58716. /** @hidden */
  58717. export var subSurfaceScatteringFunctions: {
  58718. name: string;
  58719. shader: string;
  58720. };
  58721. }
  58722. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58723. /** @hidden */
  58724. export var importanceSampling: {
  58725. name: string;
  58726. shader: string;
  58727. };
  58728. }
  58729. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58730. /** @hidden */
  58731. export var pbrHelperFunctions: {
  58732. name: string;
  58733. shader: string;
  58734. };
  58735. }
  58736. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58737. /** @hidden */
  58738. export var harmonicsFunctions: {
  58739. name: string;
  58740. shader: string;
  58741. };
  58742. }
  58743. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58744. /** @hidden */
  58745. export var pbrDirectLightingSetupFunctions: {
  58746. name: string;
  58747. shader: string;
  58748. };
  58749. }
  58750. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58751. /** @hidden */
  58752. export var pbrDirectLightingFalloffFunctions: {
  58753. name: string;
  58754. shader: string;
  58755. };
  58756. }
  58757. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58758. /** @hidden */
  58759. export var pbrBRDFFunctions: {
  58760. name: string;
  58761. shader: string;
  58762. };
  58763. }
  58764. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58765. /** @hidden */
  58766. export var hdrFilteringFunctions: {
  58767. name: string;
  58768. shader: string;
  58769. };
  58770. }
  58771. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58772. /** @hidden */
  58773. export var pbrDirectLightingFunctions: {
  58774. name: string;
  58775. shader: string;
  58776. };
  58777. }
  58778. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58779. /** @hidden */
  58780. export var pbrIBLFunctions: {
  58781. name: string;
  58782. shader: string;
  58783. };
  58784. }
  58785. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58786. /** @hidden */
  58787. export var pbrBlockAlbedoOpacity: {
  58788. name: string;
  58789. shader: string;
  58790. };
  58791. }
  58792. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58793. /** @hidden */
  58794. export var pbrBlockReflectivity: {
  58795. name: string;
  58796. shader: string;
  58797. };
  58798. }
  58799. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58800. /** @hidden */
  58801. export var pbrBlockAmbientOcclusion: {
  58802. name: string;
  58803. shader: string;
  58804. };
  58805. }
  58806. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58807. /** @hidden */
  58808. export var pbrBlockAlphaFresnel: {
  58809. name: string;
  58810. shader: string;
  58811. };
  58812. }
  58813. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58814. /** @hidden */
  58815. export var pbrBlockAnisotropic: {
  58816. name: string;
  58817. shader: string;
  58818. };
  58819. }
  58820. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58821. /** @hidden */
  58822. export var pbrBlockReflection: {
  58823. name: string;
  58824. shader: string;
  58825. };
  58826. }
  58827. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58828. /** @hidden */
  58829. export var pbrBlockSheen: {
  58830. name: string;
  58831. shader: string;
  58832. };
  58833. }
  58834. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58835. /** @hidden */
  58836. export var pbrBlockClearcoat: {
  58837. name: string;
  58838. shader: string;
  58839. };
  58840. }
  58841. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58842. /** @hidden */
  58843. export var pbrBlockSubSurface: {
  58844. name: string;
  58845. shader: string;
  58846. };
  58847. }
  58848. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58849. /** @hidden */
  58850. export var pbrBlockNormalGeometric: {
  58851. name: string;
  58852. shader: string;
  58853. };
  58854. }
  58855. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58856. /** @hidden */
  58857. export var pbrBlockNormalFinal: {
  58858. name: string;
  58859. shader: string;
  58860. };
  58861. }
  58862. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58863. /** @hidden */
  58864. export var pbrBlockLightmapInit: {
  58865. name: string;
  58866. shader: string;
  58867. };
  58868. }
  58869. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58870. /** @hidden */
  58871. export var pbrBlockGeometryInfo: {
  58872. name: string;
  58873. shader: string;
  58874. };
  58875. }
  58876. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58877. /** @hidden */
  58878. export var pbrBlockReflectance0: {
  58879. name: string;
  58880. shader: string;
  58881. };
  58882. }
  58883. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58884. /** @hidden */
  58885. export var pbrBlockReflectance: {
  58886. name: string;
  58887. shader: string;
  58888. };
  58889. }
  58890. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58891. /** @hidden */
  58892. export var pbrBlockDirectLighting: {
  58893. name: string;
  58894. shader: string;
  58895. };
  58896. }
  58897. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58898. /** @hidden */
  58899. export var pbrBlockFinalLitComponents: {
  58900. name: string;
  58901. shader: string;
  58902. };
  58903. }
  58904. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58905. /** @hidden */
  58906. export var pbrBlockFinalUnlitComponents: {
  58907. name: string;
  58908. shader: string;
  58909. };
  58910. }
  58911. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58912. /** @hidden */
  58913. export var pbrBlockFinalColorComposition: {
  58914. name: string;
  58915. shader: string;
  58916. };
  58917. }
  58918. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58919. /** @hidden */
  58920. export var pbrBlockImageProcessing: {
  58921. name: string;
  58922. shader: string;
  58923. };
  58924. }
  58925. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58926. /** @hidden */
  58927. export var pbrDebug: {
  58928. name: string;
  58929. shader: string;
  58930. };
  58931. }
  58932. declare module "babylonjs/Shaders/pbr.fragment" {
  58933. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58934. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58935. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58936. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58937. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58938. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58939. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58940. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58941. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58942. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58943. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58944. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58945. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58946. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58947. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58948. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58949. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58950. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58951. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58952. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58953. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58954. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58955. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58956. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58957. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58958. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58959. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58960. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58961. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58962. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58963. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58964. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58965. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58966. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58967. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58968. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58969. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58970. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58971. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58972. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58973. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58974. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58975. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58976. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58977. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58978. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58979. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58980. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58981. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58982. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58983. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58984. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58985. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58986. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58987. /** @hidden */
  58988. export var pbrPixelShader: {
  58989. name: string;
  58990. shader: string;
  58991. };
  58992. }
  58993. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58994. /** @hidden */
  58995. export var pbrVertexDeclaration: {
  58996. name: string;
  58997. shader: string;
  58998. };
  58999. }
  59000. declare module "babylonjs/Shaders/pbr.vertex" {
  59001. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  59002. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59003. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59004. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59005. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59006. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59007. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59008. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59009. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59010. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59011. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59012. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59013. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59014. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59016. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59017. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59018. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59019. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59020. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59021. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59022. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59023. /** @hidden */
  59024. export var pbrVertexShader: {
  59025. name: string;
  59026. shader: string;
  59027. };
  59028. }
  59029. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59030. import { Nullable } from "babylonjs/types";
  59031. import { Scene } from "babylonjs/scene";
  59032. import { Matrix } from "babylonjs/Maths/math.vector";
  59033. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59035. import { Mesh } from "babylonjs/Meshes/mesh";
  59036. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59037. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59038. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59039. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59040. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59041. import { Color3 } from "babylonjs/Maths/math.color";
  59042. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59043. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59044. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59045. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59046. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59047. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59048. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59049. import "babylonjs/Shaders/pbr.fragment";
  59050. import "babylonjs/Shaders/pbr.vertex";
  59051. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59052. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59053. /**
  59054. * Manages the defines for the PBR Material.
  59055. * @hidden
  59056. */
  59057. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59058. PBR: boolean;
  59059. NUM_SAMPLES: string;
  59060. REALTIME_FILTERING: boolean;
  59061. MAINUV1: boolean;
  59062. MAINUV2: boolean;
  59063. UV1: boolean;
  59064. UV2: boolean;
  59065. ALBEDO: boolean;
  59066. GAMMAALBEDO: boolean;
  59067. ALBEDODIRECTUV: number;
  59068. VERTEXCOLOR: boolean;
  59069. DETAIL: boolean;
  59070. DETAILDIRECTUV: number;
  59071. DETAIL_NORMALBLENDMETHOD: number;
  59072. AMBIENT: boolean;
  59073. AMBIENTDIRECTUV: number;
  59074. AMBIENTINGRAYSCALE: boolean;
  59075. OPACITY: boolean;
  59076. VERTEXALPHA: boolean;
  59077. OPACITYDIRECTUV: number;
  59078. OPACITYRGB: boolean;
  59079. ALPHATEST: boolean;
  59080. DEPTHPREPASS: boolean;
  59081. ALPHABLEND: boolean;
  59082. ALPHAFROMALBEDO: boolean;
  59083. ALPHATESTVALUE: string;
  59084. SPECULAROVERALPHA: boolean;
  59085. RADIANCEOVERALPHA: boolean;
  59086. ALPHAFRESNEL: boolean;
  59087. LINEARALPHAFRESNEL: boolean;
  59088. PREMULTIPLYALPHA: boolean;
  59089. EMISSIVE: boolean;
  59090. EMISSIVEDIRECTUV: number;
  59091. REFLECTIVITY: boolean;
  59092. REFLECTIVITYDIRECTUV: number;
  59093. SPECULARTERM: boolean;
  59094. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59095. MICROSURFACEAUTOMATIC: boolean;
  59096. LODBASEDMICROSFURACE: boolean;
  59097. MICROSURFACEMAP: boolean;
  59098. MICROSURFACEMAPDIRECTUV: number;
  59099. METALLICWORKFLOW: boolean;
  59100. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59101. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59102. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59103. AOSTOREINMETALMAPRED: boolean;
  59104. METALLIC_REFLECTANCE: boolean;
  59105. METALLIC_REFLECTANCEDIRECTUV: number;
  59106. ENVIRONMENTBRDF: boolean;
  59107. ENVIRONMENTBRDF_RGBD: boolean;
  59108. NORMAL: boolean;
  59109. TANGENT: boolean;
  59110. BUMP: boolean;
  59111. BUMPDIRECTUV: number;
  59112. OBJECTSPACE_NORMALMAP: boolean;
  59113. PARALLAX: boolean;
  59114. PARALLAXOCCLUSION: boolean;
  59115. NORMALXYSCALE: boolean;
  59116. LIGHTMAP: boolean;
  59117. LIGHTMAPDIRECTUV: number;
  59118. USELIGHTMAPASSHADOWMAP: boolean;
  59119. GAMMALIGHTMAP: boolean;
  59120. RGBDLIGHTMAP: boolean;
  59121. REFLECTION: boolean;
  59122. REFLECTIONMAP_3D: boolean;
  59123. REFLECTIONMAP_SPHERICAL: boolean;
  59124. REFLECTIONMAP_PLANAR: boolean;
  59125. REFLECTIONMAP_CUBIC: boolean;
  59126. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59127. REFLECTIONMAP_PROJECTION: boolean;
  59128. REFLECTIONMAP_SKYBOX: boolean;
  59129. REFLECTIONMAP_EXPLICIT: boolean;
  59130. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59131. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59132. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59133. INVERTCUBICMAP: boolean;
  59134. USESPHERICALFROMREFLECTIONMAP: boolean;
  59135. USEIRRADIANCEMAP: boolean;
  59136. SPHERICAL_HARMONICS: boolean;
  59137. USESPHERICALINVERTEX: boolean;
  59138. REFLECTIONMAP_OPPOSITEZ: boolean;
  59139. LODINREFLECTIONALPHA: boolean;
  59140. GAMMAREFLECTION: boolean;
  59141. RGBDREFLECTION: boolean;
  59142. LINEARSPECULARREFLECTION: boolean;
  59143. RADIANCEOCCLUSION: boolean;
  59144. HORIZONOCCLUSION: boolean;
  59145. INSTANCES: boolean;
  59146. THIN_INSTANCES: boolean;
  59147. PREPASS: boolean;
  59148. PREPASS_IRRADIANCE: boolean;
  59149. PREPASS_IRRADIANCE_INDEX: number;
  59150. PREPASS_ALBEDO: boolean;
  59151. PREPASS_ALBEDO_INDEX: number;
  59152. PREPASS_DEPTHNORMAL: boolean;
  59153. PREPASS_DEPTHNORMAL_INDEX: number;
  59154. SCENE_MRT_COUNT: number;
  59155. NUM_BONE_INFLUENCERS: number;
  59156. BonesPerMesh: number;
  59157. BONETEXTURE: boolean;
  59158. NONUNIFORMSCALING: boolean;
  59159. MORPHTARGETS: boolean;
  59160. MORPHTARGETS_NORMAL: boolean;
  59161. MORPHTARGETS_TANGENT: boolean;
  59162. MORPHTARGETS_UV: boolean;
  59163. NUM_MORPH_INFLUENCERS: number;
  59164. IMAGEPROCESSING: boolean;
  59165. VIGNETTE: boolean;
  59166. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59167. VIGNETTEBLENDMODEOPAQUE: boolean;
  59168. TONEMAPPING: boolean;
  59169. TONEMAPPING_ACES: boolean;
  59170. CONTRAST: boolean;
  59171. COLORCURVES: boolean;
  59172. COLORGRADING: boolean;
  59173. COLORGRADING3D: boolean;
  59174. SAMPLER3DGREENDEPTH: boolean;
  59175. SAMPLER3DBGRMAP: boolean;
  59176. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59177. EXPOSURE: boolean;
  59178. MULTIVIEW: boolean;
  59179. USEPHYSICALLIGHTFALLOFF: boolean;
  59180. USEGLTFLIGHTFALLOFF: boolean;
  59181. TWOSIDEDLIGHTING: boolean;
  59182. SHADOWFLOAT: boolean;
  59183. CLIPPLANE: boolean;
  59184. CLIPPLANE2: boolean;
  59185. CLIPPLANE3: boolean;
  59186. CLIPPLANE4: boolean;
  59187. CLIPPLANE5: boolean;
  59188. CLIPPLANE6: boolean;
  59189. POINTSIZE: boolean;
  59190. FOG: boolean;
  59191. LOGARITHMICDEPTH: boolean;
  59192. FORCENORMALFORWARD: boolean;
  59193. SPECULARAA: boolean;
  59194. CLEARCOAT: boolean;
  59195. CLEARCOAT_DEFAULTIOR: boolean;
  59196. CLEARCOAT_TEXTURE: boolean;
  59197. CLEARCOAT_TEXTUREDIRECTUV: number;
  59198. CLEARCOAT_BUMP: boolean;
  59199. CLEARCOAT_BUMPDIRECTUV: number;
  59200. CLEARCOAT_TINT: boolean;
  59201. CLEARCOAT_TINT_TEXTURE: boolean;
  59202. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59203. ANISOTROPIC: boolean;
  59204. ANISOTROPIC_TEXTURE: boolean;
  59205. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59206. BRDF_V_HEIGHT_CORRELATED: boolean;
  59207. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59208. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59209. SHEEN: boolean;
  59210. SHEEN_TEXTURE: boolean;
  59211. SHEEN_TEXTUREDIRECTUV: number;
  59212. SHEEN_LINKWITHALBEDO: boolean;
  59213. SHEEN_ROUGHNESS: boolean;
  59214. SHEEN_ALBEDOSCALING: boolean;
  59215. SUBSURFACE: boolean;
  59216. SS_REFRACTION: boolean;
  59217. SS_TRANSLUCENCY: boolean;
  59218. SS_SCATTERING: boolean;
  59219. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59220. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59221. SS_REFRACTIONMAP_3D: boolean;
  59222. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59223. SS_LODINREFRACTIONALPHA: boolean;
  59224. SS_GAMMAREFRACTION: boolean;
  59225. SS_RGBDREFRACTION: boolean;
  59226. SS_LINEARSPECULARREFRACTION: boolean;
  59227. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59228. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59229. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59230. UNLIT: boolean;
  59231. DEBUGMODE: number;
  59232. /**
  59233. * Initializes the PBR Material defines.
  59234. */
  59235. constructor();
  59236. /**
  59237. * Resets the PBR Material defines.
  59238. */
  59239. reset(): void;
  59240. }
  59241. /**
  59242. * The Physically based material base class of BJS.
  59243. *
  59244. * This offers the main features of a standard PBR material.
  59245. * For more information, please refer to the documentation :
  59246. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59247. */
  59248. export abstract class PBRBaseMaterial extends PushMaterial {
  59249. /**
  59250. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59251. */
  59252. static readonly PBRMATERIAL_OPAQUE: number;
  59253. /**
  59254. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59255. */
  59256. static readonly PBRMATERIAL_ALPHATEST: number;
  59257. /**
  59258. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59259. */
  59260. static readonly PBRMATERIAL_ALPHABLEND: number;
  59261. /**
  59262. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59263. * They are also discarded below the alpha cutoff threshold to improve performances.
  59264. */
  59265. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59266. /**
  59267. * Defines the default value of how much AO map is occluding the analytical lights
  59268. * (point spot...).
  59269. */
  59270. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59271. /**
  59272. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59273. */
  59274. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59275. /**
  59276. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59277. * to enhance interoperability with other engines.
  59278. */
  59279. static readonly LIGHTFALLOFF_GLTF: number;
  59280. /**
  59281. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59282. * to enhance interoperability with other materials.
  59283. */
  59284. static readonly LIGHTFALLOFF_STANDARD: number;
  59285. /**
  59286. * Intensity of the direct lights e.g. the four lights available in your scene.
  59287. * This impacts both the direct diffuse and specular highlights.
  59288. */
  59289. protected _directIntensity: number;
  59290. /**
  59291. * Intensity of the emissive part of the material.
  59292. * This helps controlling the emissive effect without modifying the emissive color.
  59293. */
  59294. protected _emissiveIntensity: number;
  59295. /**
  59296. * Intensity of the environment e.g. how much the environment will light the object
  59297. * either through harmonics for rough material or through the refelction for shiny ones.
  59298. */
  59299. protected _environmentIntensity: number;
  59300. /**
  59301. * This is a special control allowing the reduction of the specular highlights coming from the
  59302. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59303. */
  59304. protected _specularIntensity: number;
  59305. /**
  59306. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59307. */
  59308. private _lightingInfos;
  59309. /**
  59310. * Debug Control allowing disabling the bump map on this material.
  59311. */
  59312. protected _disableBumpMap: boolean;
  59313. /**
  59314. * AKA Diffuse Texture in standard nomenclature.
  59315. */
  59316. protected _albedoTexture: Nullable<BaseTexture>;
  59317. /**
  59318. * AKA Occlusion Texture in other nomenclature.
  59319. */
  59320. protected _ambientTexture: Nullable<BaseTexture>;
  59321. /**
  59322. * AKA Occlusion Texture Intensity in other nomenclature.
  59323. */
  59324. protected _ambientTextureStrength: number;
  59325. /**
  59326. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59327. * 1 means it completely occludes it
  59328. * 0 mean it has no impact
  59329. */
  59330. protected _ambientTextureImpactOnAnalyticalLights: number;
  59331. /**
  59332. * Stores the alpha values in a texture.
  59333. */
  59334. protected _opacityTexture: Nullable<BaseTexture>;
  59335. /**
  59336. * Stores the reflection values in a texture.
  59337. */
  59338. protected _reflectionTexture: Nullable<BaseTexture>;
  59339. /**
  59340. * Stores the emissive values in a texture.
  59341. */
  59342. protected _emissiveTexture: Nullable<BaseTexture>;
  59343. /**
  59344. * AKA Specular texture in other nomenclature.
  59345. */
  59346. protected _reflectivityTexture: Nullable<BaseTexture>;
  59347. /**
  59348. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59349. */
  59350. protected _metallicTexture: Nullable<BaseTexture>;
  59351. /**
  59352. * Specifies the metallic scalar of the metallic/roughness workflow.
  59353. * Can also be used to scale the metalness values of the metallic texture.
  59354. */
  59355. protected _metallic: Nullable<number>;
  59356. /**
  59357. * Specifies the roughness scalar of the metallic/roughness workflow.
  59358. * Can also be used to scale the roughness values of the metallic texture.
  59359. */
  59360. protected _roughness: Nullable<number>;
  59361. /**
  59362. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59363. * By default the indexOfrefraction is used to compute F0;
  59364. *
  59365. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59366. *
  59367. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59368. * F90 = metallicReflectanceColor;
  59369. */
  59370. protected _metallicF0Factor: number;
  59371. /**
  59372. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59373. * By default the F90 is always 1;
  59374. *
  59375. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59376. *
  59377. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59378. * F90 = metallicReflectanceColor;
  59379. */
  59380. protected _metallicReflectanceColor: Color3;
  59381. /**
  59382. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59383. * This is multiply against the scalar values defined in the material.
  59384. */
  59385. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59386. /**
  59387. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59388. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59389. */
  59390. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59391. /**
  59392. * Stores surface normal data used to displace a mesh in a texture.
  59393. */
  59394. protected _bumpTexture: Nullable<BaseTexture>;
  59395. /**
  59396. * Stores the pre-calculated light information of a mesh in a texture.
  59397. */
  59398. protected _lightmapTexture: Nullable<BaseTexture>;
  59399. /**
  59400. * The color of a material in ambient lighting.
  59401. */
  59402. protected _ambientColor: Color3;
  59403. /**
  59404. * AKA Diffuse Color in other nomenclature.
  59405. */
  59406. protected _albedoColor: Color3;
  59407. /**
  59408. * AKA Specular Color in other nomenclature.
  59409. */
  59410. protected _reflectivityColor: Color3;
  59411. /**
  59412. * The color applied when light is reflected from a material.
  59413. */
  59414. protected _reflectionColor: Color3;
  59415. /**
  59416. * The color applied when light is emitted from a material.
  59417. */
  59418. protected _emissiveColor: Color3;
  59419. /**
  59420. * AKA Glossiness in other nomenclature.
  59421. */
  59422. protected _microSurface: number;
  59423. /**
  59424. * Specifies that the material will use the light map as a show map.
  59425. */
  59426. protected _useLightmapAsShadowmap: boolean;
  59427. /**
  59428. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59429. * makes the reflect vector face the model (under horizon).
  59430. */
  59431. protected _useHorizonOcclusion: boolean;
  59432. /**
  59433. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59434. * too much the area relying on ambient texture to define their ambient occlusion.
  59435. */
  59436. protected _useRadianceOcclusion: boolean;
  59437. /**
  59438. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59439. */
  59440. protected _useAlphaFromAlbedoTexture: boolean;
  59441. /**
  59442. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59443. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59444. */
  59445. protected _useSpecularOverAlpha: boolean;
  59446. /**
  59447. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59448. */
  59449. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59450. /**
  59451. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59452. */
  59453. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59454. /**
  59455. * Specifies if the metallic texture contains the roughness information in its green channel.
  59456. */
  59457. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59458. /**
  59459. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59460. */
  59461. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59462. /**
  59463. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59464. */
  59465. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59466. /**
  59467. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59468. */
  59469. protected _useAmbientInGrayScale: boolean;
  59470. /**
  59471. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59472. * The material will try to infer what glossiness each pixel should be.
  59473. */
  59474. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59475. /**
  59476. * Defines the falloff type used in this material.
  59477. * It by default is Physical.
  59478. */
  59479. protected _lightFalloff: number;
  59480. /**
  59481. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59482. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59483. */
  59484. protected _useRadianceOverAlpha: boolean;
  59485. /**
  59486. * Allows using an object space normal map (instead of tangent space).
  59487. */
  59488. protected _useObjectSpaceNormalMap: boolean;
  59489. /**
  59490. * Allows using the bump map in parallax mode.
  59491. */
  59492. protected _useParallax: boolean;
  59493. /**
  59494. * Allows using the bump map in parallax occlusion mode.
  59495. */
  59496. protected _useParallaxOcclusion: boolean;
  59497. /**
  59498. * Controls the scale bias of the parallax mode.
  59499. */
  59500. protected _parallaxScaleBias: number;
  59501. /**
  59502. * If sets to true, disables all the lights affecting the material.
  59503. */
  59504. protected _disableLighting: boolean;
  59505. /**
  59506. * Number of Simultaneous lights allowed on the material.
  59507. */
  59508. protected _maxSimultaneousLights: number;
  59509. /**
  59510. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59511. */
  59512. protected _invertNormalMapX: boolean;
  59513. /**
  59514. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59515. */
  59516. protected _invertNormalMapY: boolean;
  59517. /**
  59518. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59519. */
  59520. protected _twoSidedLighting: boolean;
  59521. /**
  59522. * Defines the alpha limits in alpha test mode.
  59523. */
  59524. protected _alphaCutOff: number;
  59525. /**
  59526. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59527. */
  59528. protected _forceAlphaTest: boolean;
  59529. /**
  59530. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59531. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59532. */
  59533. protected _useAlphaFresnel: boolean;
  59534. /**
  59535. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59536. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59537. */
  59538. protected _useLinearAlphaFresnel: boolean;
  59539. /**
  59540. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59541. * from cos thetav and roughness:
  59542. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59543. */
  59544. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59545. /**
  59546. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59547. */
  59548. protected _forceIrradianceInFragment: boolean;
  59549. private _realTimeFiltering;
  59550. /**
  59551. * Enables realtime filtering on the texture.
  59552. */
  59553. get realTimeFiltering(): boolean;
  59554. set realTimeFiltering(b: boolean);
  59555. private _realTimeFilteringQuality;
  59556. /**
  59557. * Quality switch for realtime filtering
  59558. */
  59559. get realTimeFilteringQuality(): number;
  59560. set realTimeFilteringQuality(n: number);
  59561. /**
  59562. * Can this material render to several textures at once
  59563. */
  59564. get canRenderToMRT(): boolean;
  59565. /**
  59566. * Force normal to face away from face.
  59567. */
  59568. protected _forceNormalForward: boolean;
  59569. /**
  59570. * Enables specular anti aliasing in the PBR shader.
  59571. * It will both interacts on the Geometry for analytical and IBL lighting.
  59572. * It also prefilter the roughness map based on the bump values.
  59573. */
  59574. protected _enableSpecularAntiAliasing: boolean;
  59575. /**
  59576. * Default configuration related to image processing available in the PBR Material.
  59577. */
  59578. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59579. /**
  59580. * Keep track of the image processing observer to allow dispose and replace.
  59581. */
  59582. private _imageProcessingObserver;
  59583. /**
  59584. * Attaches a new image processing configuration to the PBR Material.
  59585. * @param configuration
  59586. */
  59587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59588. /**
  59589. * Stores the available render targets.
  59590. */
  59591. private _renderTargets;
  59592. /**
  59593. * Sets the global ambient color for the material used in lighting calculations.
  59594. */
  59595. private _globalAmbientColor;
  59596. /**
  59597. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59598. */
  59599. private _useLogarithmicDepth;
  59600. /**
  59601. * If set to true, no lighting calculations will be applied.
  59602. */
  59603. private _unlit;
  59604. private _debugMode;
  59605. /**
  59606. * @hidden
  59607. * This is reserved for the inspector.
  59608. * Defines the material debug mode.
  59609. * It helps seeing only some components of the material while troubleshooting.
  59610. */
  59611. debugMode: number;
  59612. /**
  59613. * @hidden
  59614. * This is reserved for the inspector.
  59615. * Specify from where on screen the debug mode should start.
  59616. * The value goes from -1 (full screen) to 1 (not visible)
  59617. * It helps with side by side comparison against the final render
  59618. * This defaults to -1
  59619. */
  59620. private debugLimit;
  59621. /**
  59622. * @hidden
  59623. * This is reserved for the inspector.
  59624. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59625. * You can use the factor to better multiply the final value.
  59626. */
  59627. private debugFactor;
  59628. /**
  59629. * Defines the clear coat layer parameters for the material.
  59630. */
  59631. readonly clearCoat: PBRClearCoatConfiguration;
  59632. /**
  59633. * Defines the anisotropic parameters for the material.
  59634. */
  59635. readonly anisotropy: PBRAnisotropicConfiguration;
  59636. /**
  59637. * Defines the BRDF parameters for the material.
  59638. */
  59639. readonly brdf: PBRBRDFConfiguration;
  59640. /**
  59641. * Defines the Sheen parameters for the material.
  59642. */
  59643. readonly sheen: PBRSheenConfiguration;
  59644. /**
  59645. * Defines the SubSurface parameters for the material.
  59646. */
  59647. readonly subSurface: PBRSubSurfaceConfiguration;
  59648. /**
  59649. * Defines the detail map parameters for the material.
  59650. */
  59651. readonly detailMap: DetailMapConfiguration;
  59652. protected _rebuildInParallel: boolean;
  59653. /**
  59654. * Instantiates a new PBRMaterial instance.
  59655. *
  59656. * @param name The material name
  59657. * @param scene The scene the material will be use in.
  59658. */
  59659. constructor(name: string, scene: Scene);
  59660. /**
  59661. * Gets a boolean indicating that current material needs to register RTT
  59662. */
  59663. get hasRenderTargetTextures(): boolean;
  59664. /**
  59665. * Gets the name of the material class.
  59666. */
  59667. getClassName(): string;
  59668. /**
  59669. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59670. */
  59671. get useLogarithmicDepth(): boolean;
  59672. /**
  59673. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59674. */
  59675. set useLogarithmicDepth(value: boolean);
  59676. /**
  59677. * Returns true if alpha blending should be disabled.
  59678. */
  59679. protected get _disableAlphaBlending(): boolean;
  59680. /**
  59681. * Specifies whether or not this material should be rendered in alpha blend mode.
  59682. */
  59683. needAlphaBlending(): boolean;
  59684. /**
  59685. * Specifies whether or not this material should be rendered in alpha test mode.
  59686. */
  59687. needAlphaTesting(): boolean;
  59688. /**
  59689. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59690. */
  59691. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59692. /**
  59693. * Gets the texture used for the alpha test.
  59694. */
  59695. getAlphaTestTexture(): Nullable<BaseTexture>;
  59696. /**
  59697. * Specifies that the submesh is ready to be used.
  59698. * @param mesh - BJS mesh.
  59699. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59700. * @param useInstances - Specifies that instances should be used.
  59701. * @returns - boolean indicating that the submesh is ready or not.
  59702. */
  59703. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59704. /**
  59705. * Specifies if the material uses metallic roughness workflow.
  59706. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59707. */
  59708. isMetallicWorkflow(): boolean;
  59709. private _prepareEffect;
  59710. private _prepareDefines;
  59711. /**
  59712. * Force shader compilation
  59713. */
  59714. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59715. /**
  59716. * Initializes the uniform buffer layout for the shader.
  59717. */
  59718. buildUniformLayout(): void;
  59719. /**
  59720. * Unbinds the material from the mesh
  59721. */
  59722. unbind(): void;
  59723. /**
  59724. * Binds the submesh data.
  59725. * @param world - The world matrix.
  59726. * @param mesh - The BJS mesh.
  59727. * @param subMesh - A submesh of the BJS mesh.
  59728. */
  59729. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59730. /**
  59731. * Returns the animatable textures.
  59732. * @returns - Array of animatable textures.
  59733. */
  59734. getAnimatables(): IAnimatable[];
  59735. /**
  59736. * Returns the texture used for reflections.
  59737. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59738. */
  59739. private _getReflectionTexture;
  59740. /**
  59741. * Returns an array of the actively used textures.
  59742. * @returns - Array of BaseTextures
  59743. */
  59744. getActiveTextures(): BaseTexture[];
  59745. /**
  59746. * Checks to see if a texture is used in the material.
  59747. * @param texture - Base texture to use.
  59748. * @returns - Boolean specifying if a texture is used in the material.
  59749. */
  59750. hasTexture(texture: BaseTexture): boolean;
  59751. /**
  59752. * Sets the required values to the prepass renderer.
  59753. * @param prePassRenderer defines the prepass renderer to setup
  59754. */
  59755. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59756. /**
  59757. * Disposes the resources of the material.
  59758. * @param forceDisposeEffect - Forces the disposal of effects.
  59759. * @param forceDisposeTextures - Forces the disposal of all textures.
  59760. */
  59761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59762. }
  59763. }
  59764. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59765. import { Nullable } from "babylonjs/types";
  59766. import { Scene } from "babylonjs/scene";
  59767. import { Color3 } from "babylonjs/Maths/math.color";
  59768. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59769. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59771. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59772. /**
  59773. * The Physically based material of BJS.
  59774. *
  59775. * This offers the main features of a standard PBR material.
  59776. * For more information, please refer to the documentation :
  59777. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59778. */
  59779. export class PBRMaterial extends PBRBaseMaterial {
  59780. /**
  59781. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59782. */
  59783. static readonly PBRMATERIAL_OPAQUE: number;
  59784. /**
  59785. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59786. */
  59787. static readonly PBRMATERIAL_ALPHATEST: number;
  59788. /**
  59789. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59790. */
  59791. static readonly PBRMATERIAL_ALPHABLEND: number;
  59792. /**
  59793. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59794. * They are also discarded below the alpha cutoff threshold to improve performances.
  59795. */
  59796. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59797. /**
  59798. * Defines the default value of how much AO map is occluding the analytical lights
  59799. * (point spot...).
  59800. */
  59801. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59802. /**
  59803. * Intensity of the direct lights e.g. the four lights available in your scene.
  59804. * This impacts both the direct diffuse and specular highlights.
  59805. */
  59806. directIntensity: number;
  59807. /**
  59808. * Intensity of the emissive part of the material.
  59809. * This helps controlling the emissive effect without modifying the emissive color.
  59810. */
  59811. emissiveIntensity: number;
  59812. /**
  59813. * Intensity of the environment e.g. how much the environment will light the object
  59814. * either through harmonics for rough material or through the refelction for shiny ones.
  59815. */
  59816. environmentIntensity: number;
  59817. /**
  59818. * This is a special control allowing the reduction of the specular highlights coming from the
  59819. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59820. */
  59821. specularIntensity: number;
  59822. /**
  59823. * Debug Control allowing disabling the bump map on this material.
  59824. */
  59825. disableBumpMap: boolean;
  59826. /**
  59827. * AKA Diffuse Texture in standard nomenclature.
  59828. */
  59829. albedoTexture: BaseTexture;
  59830. /**
  59831. * AKA Occlusion Texture in other nomenclature.
  59832. */
  59833. ambientTexture: BaseTexture;
  59834. /**
  59835. * AKA Occlusion Texture Intensity in other nomenclature.
  59836. */
  59837. ambientTextureStrength: number;
  59838. /**
  59839. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59840. * 1 means it completely occludes it
  59841. * 0 mean it has no impact
  59842. */
  59843. ambientTextureImpactOnAnalyticalLights: number;
  59844. /**
  59845. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59846. */
  59847. opacityTexture: BaseTexture;
  59848. /**
  59849. * Stores the reflection values in a texture.
  59850. */
  59851. reflectionTexture: Nullable<BaseTexture>;
  59852. /**
  59853. * Stores the emissive values in a texture.
  59854. */
  59855. emissiveTexture: BaseTexture;
  59856. /**
  59857. * AKA Specular texture in other nomenclature.
  59858. */
  59859. reflectivityTexture: BaseTexture;
  59860. /**
  59861. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59862. */
  59863. metallicTexture: BaseTexture;
  59864. /**
  59865. * Specifies the metallic scalar of the metallic/roughness workflow.
  59866. * Can also be used to scale the metalness values of the metallic texture.
  59867. */
  59868. metallic: Nullable<number>;
  59869. /**
  59870. * Specifies the roughness scalar of the metallic/roughness workflow.
  59871. * Can also be used to scale the roughness values of the metallic texture.
  59872. */
  59873. roughness: Nullable<number>;
  59874. /**
  59875. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59876. * By default the indexOfrefraction is used to compute F0;
  59877. *
  59878. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59879. *
  59880. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59881. * F90 = metallicReflectanceColor;
  59882. */
  59883. metallicF0Factor: number;
  59884. /**
  59885. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59886. * By default the F90 is always 1;
  59887. *
  59888. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59889. *
  59890. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59891. * F90 = metallicReflectanceColor;
  59892. */
  59893. metallicReflectanceColor: Color3;
  59894. /**
  59895. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59896. * This is multiply against the scalar values defined in the material.
  59897. */
  59898. metallicReflectanceTexture: Nullable<BaseTexture>;
  59899. /**
  59900. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59901. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59902. */
  59903. microSurfaceTexture: BaseTexture;
  59904. /**
  59905. * Stores surface normal data used to displace a mesh in a texture.
  59906. */
  59907. bumpTexture: BaseTexture;
  59908. /**
  59909. * Stores the pre-calculated light information of a mesh in a texture.
  59910. */
  59911. lightmapTexture: BaseTexture;
  59912. /**
  59913. * Stores the refracted light information in a texture.
  59914. */
  59915. get refractionTexture(): Nullable<BaseTexture>;
  59916. set refractionTexture(value: Nullable<BaseTexture>);
  59917. /**
  59918. * The color of a material in ambient lighting.
  59919. */
  59920. ambientColor: Color3;
  59921. /**
  59922. * AKA Diffuse Color in other nomenclature.
  59923. */
  59924. albedoColor: Color3;
  59925. /**
  59926. * AKA Specular Color in other nomenclature.
  59927. */
  59928. reflectivityColor: Color3;
  59929. /**
  59930. * The color reflected from the material.
  59931. */
  59932. reflectionColor: Color3;
  59933. /**
  59934. * The color emitted from the material.
  59935. */
  59936. emissiveColor: Color3;
  59937. /**
  59938. * AKA Glossiness in other nomenclature.
  59939. */
  59940. microSurface: number;
  59941. /**
  59942. * Index of refraction of the material base layer.
  59943. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59944. *
  59945. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59946. *
  59947. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59948. */
  59949. get indexOfRefraction(): number;
  59950. set indexOfRefraction(value: number);
  59951. /**
  59952. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59953. */
  59954. get invertRefractionY(): boolean;
  59955. set invertRefractionY(value: boolean);
  59956. /**
  59957. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59958. * Materials half opaque for instance using refraction could benefit from this control.
  59959. */
  59960. get linkRefractionWithTransparency(): boolean;
  59961. set linkRefractionWithTransparency(value: boolean);
  59962. /**
  59963. * If true, the light map contains occlusion information instead of lighting info.
  59964. */
  59965. useLightmapAsShadowmap: boolean;
  59966. /**
  59967. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59968. */
  59969. useAlphaFromAlbedoTexture: boolean;
  59970. /**
  59971. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59972. */
  59973. forceAlphaTest: boolean;
  59974. /**
  59975. * Defines the alpha limits in alpha test mode.
  59976. */
  59977. alphaCutOff: number;
  59978. /**
  59979. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59980. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59981. */
  59982. useSpecularOverAlpha: boolean;
  59983. /**
  59984. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59985. */
  59986. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59987. /**
  59988. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59989. */
  59990. useRoughnessFromMetallicTextureAlpha: boolean;
  59991. /**
  59992. * Specifies if the metallic texture contains the roughness information in its green channel.
  59993. */
  59994. useRoughnessFromMetallicTextureGreen: boolean;
  59995. /**
  59996. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59997. */
  59998. useMetallnessFromMetallicTextureBlue: boolean;
  59999. /**
  60000. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60001. */
  60002. useAmbientOcclusionFromMetallicTextureRed: boolean;
  60003. /**
  60004. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60005. */
  60006. useAmbientInGrayScale: boolean;
  60007. /**
  60008. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60009. * The material will try to infer what glossiness each pixel should be.
  60010. */
  60011. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60012. /**
  60013. * BJS is using an harcoded light falloff based on a manually sets up range.
  60014. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60015. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60016. */
  60017. get usePhysicalLightFalloff(): boolean;
  60018. /**
  60019. * BJS is using an harcoded light falloff based on a manually sets up range.
  60020. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60021. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60022. */
  60023. set usePhysicalLightFalloff(value: boolean);
  60024. /**
  60025. * In order to support the falloff compatibility with gltf, a special mode has been added
  60026. * to reproduce the gltf light falloff.
  60027. */
  60028. get useGLTFLightFalloff(): boolean;
  60029. /**
  60030. * In order to support the falloff compatibility with gltf, a special mode has been added
  60031. * to reproduce the gltf light falloff.
  60032. */
  60033. set useGLTFLightFalloff(value: boolean);
  60034. /**
  60035. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60036. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60037. */
  60038. useRadianceOverAlpha: boolean;
  60039. /**
  60040. * Allows using an object space normal map (instead of tangent space).
  60041. */
  60042. useObjectSpaceNormalMap: boolean;
  60043. /**
  60044. * Allows using the bump map in parallax mode.
  60045. */
  60046. useParallax: boolean;
  60047. /**
  60048. * Allows using the bump map in parallax occlusion mode.
  60049. */
  60050. useParallaxOcclusion: boolean;
  60051. /**
  60052. * Controls the scale bias of the parallax mode.
  60053. */
  60054. parallaxScaleBias: number;
  60055. /**
  60056. * If sets to true, disables all the lights affecting the material.
  60057. */
  60058. disableLighting: boolean;
  60059. /**
  60060. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60061. */
  60062. forceIrradianceInFragment: boolean;
  60063. /**
  60064. * Number of Simultaneous lights allowed on the material.
  60065. */
  60066. maxSimultaneousLights: number;
  60067. /**
  60068. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60069. */
  60070. invertNormalMapX: boolean;
  60071. /**
  60072. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60073. */
  60074. invertNormalMapY: boolean;
  60075. /**
  60076. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60077. */
  60078. twoSidedLighting: boolean;
  60079. /**
  60080. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60081. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60082. */
  60083. useAlphaFresnel: boolean;
  60084. /**
  60085. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60086. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60087. */
  60088. useLinearAlphaFresnel: boolean;
  60089. /**
  60090. * Let user defines the brdf lookup texture used for IBL.
  60091. * A default 8bit version is embedded but you could point at :
  60092. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60093. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60094. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60095. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60096. */
  60097. environmentBRDFTexture: Nullable<BaseTexture>;
  60098. /**
  60099. * Force normal to face away from face.
  60100. */
  60101. forceNormalForward: boolean;
  60102. /**
  60103. * Enables specular anti aliasing in the PBR shader.
  60104. * It will both interacts on the Geometry for analytical and IBL lighting.
  60105. * It also prefilter the roughness map based on the bump values.
  60106. */
  60107. enableSpecularAntiAliasing: boolean;
  60108. /**
  60109. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60110. * makes the reflect vector face the model (under horizon).
  60111. */
  60112. useHorizonOcclusion: boolean;
  60113. /**
  60114. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60115. * too much the area relying on ambient texture to define their ambient occlusion.
  60116. */
  60117. useRadianceOcclusion: boolean;
  60118. /**
  60119. * If set to true, no lighting calculations will be applied.
  60120. */
  60121. unlit: boolean;
  60122. /**
  60123. * Gets the image processing configuration used either in this material.
  60124. */
  60125. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60126. /**
  60127. * Sets the Default image processing configuration used either in the this material.
  60128. *
  60129. * If sets to null, the scene one is in use.
  60130. */
  60131. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60132. /**
  60133. * Gets wether the color curves effect is enabled.
  60134. */
  60135. get cameraColorCurvesEnabled(): boolean;
  60136. /**
  60137. * Sets wether the color curves effect is enabled.
  60138. */
  60139. set cameraColorCurvesEnabled(value: boolean);
  60140. /**
  60141. * Gets wether the color grading effect is enabled.
  60142. */
  60143. get cameraColorGradingEnabled(): boolean;
  60144. /**
  60145. * Gets wether the color grading effect is enabled.
  60146. */
  60147. set cameraColorGradingEnabled(value: boolean);
  60148. /**
  60149. * Gets wether tonemapping is enabled or not.
  60150. */
  60151. get cameraToneMappingEnabled(): boolean;
  60152. /**
  60153. * Sets wether tonemapping is enabled or not
  60154. */
  60155. set cameraToneMappingEnabled(value: boolean);
  60156. /**
  60157. * The camera exposure used on this material.
  60158. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60159. * This corresponds to a photographic exposure.
  60160. */
  60161. get cameraExposure(): number;
  60162. /**
  60163. * The camera exposure used on this material.
  60164. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60165. * This corresponds to a photographic exposure.
  60166. */
  60167. set cameraExposure(value: number);
  60168. /**
  60169. * Gets The camera contrast used on this material.
  60170. */
  60171. get cameraContrast(): number;
  60172. /**
  60173. * Sets The camera contrast used on this material.
  60174. */
  60175. set cameraContrast(value: number);
  60176. /**
  60177. * Gets the Color Grading 2D Lookup Texture.
  60178. */
  60179. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60180. /**
  60181. * Sets the Color Grading 2D Lookup Texture.
  60182. */
  60183. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60184. /**
  60185. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60186. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60187. * 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;
  60188. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60189. */
  60190. get cameraColorCurves(): Nullable<ColorCurves>;
  60191. /**
  60192. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60193. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60194. * 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;
  60195. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60196. */
  60197. set cameraColorCurves(value: Nullable<ColorCurves>);
  60198. /**
  60199. * Instantiates a new PBRMaterial instance.
  60200. *
  60201. * @param name The material name
  60202. * @param scene The scene the material will be use in.
  60203. */
  60204. constructor(name: string, scene: Scene);
  60205. /**
  60206. * Returns the name of this material class.
  60207. */
  60208. getClassName(): string;
  60209. /**
  60210. * Makes a duplicate of the current material.
  60211. * @param name - name to use for the new material.
  60212. */
  60213. clone(name: string): PBRMaterial;
  60214. /**
  60215. * Serializes this PBR Material.
  60216. * @returns - An object with the serialized material.
  60217. */
  60218. serialize(): any;
  60219. /**
  60220. * Parses a PBR Material from a serialized object.
  60221. * @param source - Serialized object.
  60222. * @param scene - BJS scene instance.
  60223. * @param rootUrl - url for the scene object
  60224. * @returns - PBRMaterial
  60225. */
  60226. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60227. }
  60228. }
  60229. declare module "babylonjs/Misc/dds" {
  60230. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60231. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60232. import { Nullable } from "babylonjs/types";
  60233. import { Scene } from "babylonjs/scene";
  60234. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60235. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60236. /**
  60237. * Direct draw surface info
  60238. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60239. */
  60240. export interface DDSInfo {
  60241. /**
  60242. * Width of the texture
  60243. */
  60244. width: number;
  60245. /**
  60246. * Width of the texture
  60247. */
  60248. height: number;
  60249. /**
  60250. * Number of Mipmaps for the texture
  60251. * @see https://en.wikipedia.org/wiki/Mipmap
  60252. */
  60253. mipmapCount: number;
  60254. /**
  60255. * If the textures format is a known fourCC format
  60256. * @see https://www.fourcc.org/
  60257. */
  60258. isFourCC: boolean;
  60259. /**
  60260. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60261. */
  60262. isRGB: boolean;
  60263. /**
  60264. * If the texture is a lumincance format
  60265. */
  60266. isLuminance: boolean;
  60267. /**
  60268. * If this is a cube texture
  60269. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60270. */
  60271. isCube: boolean;
  60272. /**
  60273. * If the texture is a compressed format eg. FOURCC_DXT1
  60274. */
  60275. isCompressed: boolean;
  60276. /**
  60277. * The dxgiFormat of the texture
  60278. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60279. */
  60280. dxgiFormat: number;
  60281. /**
  60282. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60283. */
  60284. textureType: number;
  60285. /**
  60286. * Sphericle polynomial created for the dds texture
  60287. */
  60288. sphericalPolynomial?: SphericalPolynomial;
  60289. }
  60290. /**
  60291. * Class used to provide DDS decompression tools
  60292. */
  60293. export class DDSTools {
  60294. /**
  60295. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60296. */
  60297. static StoreLODInAlphaChannel: boolean;
  60298. /**
  60299. * Gets DDS information from an array buffer
  60300. * @param data defines the array buffer view to read data from
  60301. * @returns the DDS information
  60302. */
  60303. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60304. private static _FloatView;
  60305. private static _Int32View;
  60306. private static _ToHalfFloat;
  60307. private static _FromHalfFloat;
  60308. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60309. private static _GetHalfFloatRGBAArrayBuffer;
  60310. private static _GetFloatRGBAArrayBuffer;
  60311. private static _GetFloatAsUIntRGBAArrayBuffer;
  60312. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60313. private static _GetRGBAArrayBuffer;
  60314. private static _ExtractLongWordOrder;
  60315. private static _GetRGBArrayBuffer;
  60316. private static _GetLuminanceArrayBuffer;
  60317. /**
  60318. * Uploads DDS Levels to a Babylon Texture
  60319. * @hidden
  60320. */
  60321. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60322. }
  60323. module "babylonjs/Engines/thinEngine" {
  60324. interface ThinEngine {
  60325. /**
  60326. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60327. * @param rootUrl defines the url where the file to load is located
  60328. * @param scene defines the current scene
  60329. * @param lodScale defines scale to apply to the mip map selection
  60330. * @param lodOffset defines offset to apply to the mip map selection
  60331. * @param onLoad defines an optional callback raised when the texture is loaded
  60332. * @param onError defines an optional callback raised if there is an issue to load the texture
  60333. * @param format defines the format of the data
  60334. * @param forcedExtension defines the extension to use to pick the right loader
  60335. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60336. * @returns the cube texture as an InternalTexture
  60337. */
  60338. 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;
  60339. }
  60340. }
  60341. }
  60342. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60343. import { Nullable } from "babylonjs/types";
  60344. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60345. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60346. /**
  60347. * Implementation of the DDS Texture Loader.
  60348. * @hidden
  60349. */
  60350. export class _DDSTextureLoader implements IInternalTextureLoader {
  60351. /**
  60352. * Defines wether the loader supports cascade loading the different faces.
  60353. */
  60354. readonly supportCascades: boolean;
  60355. /**
  60356. * This returns if the loader support the current file information.
  60357. * @param extension defines the file extension of the file being loaded
  60358. * @returns true if the loader can load the specified file
  60359. */
  60360. canLoad(extension: string): boolean;
  60361. /**
  60362. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60363. * @param data contains the texture data
  60364. * @param texture defines the BabylonJS internal texture
  60365. * @param createPolynomials will be true if polynomials have been requested
  60366. * @param onLoad defines the callback to trigger once the texture is ready
  60367. * @param onError defines the callback to trigger in case of error
  60368. */
  60369. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60370. /**
  60371. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60372. * @param data contains the texture data
  60373. * @param texture defines the BabylonJS internal texture
  60374. * @param callback defines the method to call once ready to upload
  60375. */
  60376. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60377. }
  60378. }
  60379. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60380. import { Nullable } from "babylonjs/types";
  60381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60382. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60383. /**
  60384. * Implementation of the ENV Texture Loader.
  60385. * @hidden
  60386. */
  60387. export class _ENVTextureLoader implements IInternalTextureLoader {
  60388. /**
  60389. * Defines wether the loader supports cascade loading the different faces.
  60390. */
  60391. readonly supportCascades: boolean;
  60392. /**
  60393. * This returns if the loader support the current file information.
  60394. * @param extension defines the file extension of the file being loaded
  60395. * @returns true if the loader can load the specified file
  60396. */
  60397. canLoad(extension: string): boolean;
  60398. /**
  60399. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60400. * @param data contains the texture data
  60401. * @param texture defines the BabylonJS internal texture
  60402. * @param createPolynomials will be true if polynomials have been requested
  60403. * @param onLoad defines the callback to trigger once the texture is ready
  60404. * @param onError defines the callback to trigger in case of error
  60405. */
  60406. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60407. /**
  60408. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60409. * @param data contains the texture data
  60410. * @param texture defines the BabylonJS internal texture
  60411. * @param callback defines the method to call once ready to upload
  60412. */
  60413. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60414. }
  60415. }
  60416. declare module "babylonjs/Misc/khronosTextureContainer" {
  60417. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60418. /**
  60419. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60420. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60421. */
  60422. export class KhronosTextureContainer {
  60423. /** contents of the KTX container file */
  60424. data: ArrayBufferView;
  60425. private static HEADER_LEN;
  60426. private static COMPRESSED_2D;
  60427. private static COMPRESSED_3D;
  60428. private static TEX_2D;
  60429. private static TEX_3D;
  60430. /**
  60431. * Gets the openGL type
  60432. */
  60433. glType: number;
  60434. /**
  60435. * Gets the openGL type size
  60436. */
  60437. glTypeSize: number;
  60438. /**
  60439. * Gets the openGL format
  60440. */
  60441. glFormat: number;
  60442. /**
  60443. * Gets the openGL internal format
  60444. */
  60445. glInternalFormat: number;
  60446. /**
  60447. * Gets the base internal format
  60448. */
  60449. glBaseInternalFormat: number;
  60450. /**
  60451. * Gets image width in pixel
  60452. */
  60453. pixelWidth: number;
  60454. /**
  60455. * Gets image height in pixel
  60456. */
  60457. pixelHeight: number;
  60458. /**
  60459. * Gets image depth in pixels
  60460. */
  60461. pixelDepth: number;
  60462. /**
  60463. * Gets the number of array elements
  60464. */
  60465. numberOfArrayElements: number;
  60466. /**
  60467. * Gets the number of faces
  60468. */
  60469. numberOfFaces: number;
  60470. /**
  60471. * Gets the number of mipmap levels
  60472. */
  60473. numberOfMipmapLevels: number;
  60474. /**
  60475. * Gets the bytes of key value data
  60476. */
  60477. bytesOfKeyValueData: number;
  60478. /**
  60479. * Gets the load type
  60480. */
  60481. loadType: number;
  60482. /**
  60483. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60484. */
  60485. isInvalid: boolean;
  60486. /**
  60487. * Creates a new KhronosTextureContainer
  60488. * @param data contents of the KTX container file
  60489. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60490. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60491. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60492. */
  60493. constructor(
  60494. /** contents of the KTX container file */
  60495. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60496. /**
  60497. * Uploads KTX content to a Babylon Texture.
  60498. * It is assumed that the texture has already been created & is currently bound
  60499. * @hidden
  60500. */
  60501. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60502. private _upload2DCompressedLevels;
  60503. /**
  60504. * Checks if the given data starts with a KTX file identifier.
  60505. * @param data the data to check
  60506. * @returns true if the data is a KTX file or false otherwise
  60507. */
  60508. static IsValid(data: ArrayBufferView): boolean;
  60509. }
  60510. }
  60511. declare module "babylonjs/Misc/workerPool" {
  60512. import { IDisposable } from "babylonjs/scene";
  60513. /**
  60514. * Helper class to push actions to a pool of workers.
  60515. */
  60516. export class WorkerPool implements IDisposable {
  60517. private _workerInfos;
  60518. private _pendingActions;
  60519. /**
  60520. * Constructor
  60521. * @param workers Array of workers to use for actions
  60522. */
  60523. constructor(workers: Array<Worker>);
  60524. /**
  60525. * Terminates all workers and clears any pending actions.
  60526. */
  60527. dispose(): void;
  60528. /**
  60529. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60530. * pended until a worker has completed its action.
  60531. * @param action The action to perform. Call onComplete when the action is complete.
  60532. */
  60533. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60534. private _execute;
  60535. }
  60536. }
  60537. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60539. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60540. /**
  60541. * Class for loading KTX2 files
  60542. * @hidden
  60543. */
  60544. export class KhronosTextureContainer2 {
  60545. private static _WorkerPoolPromise?;
  60546. private static _Initialized;
  60547. private static _Ktx2Decoder;
  60548. /**
  60549. * URL to use when loading the KTX2 decoder module
  60550. */
  60551. static JSModuleURL: string;
  60552. /**
  60553. * Default number of workers used to handle data decoding
  60554. */
  60555. static DefaultNumWorkers: number;
  60556. private static GetDefaultNumWorkers;
  60557. private _engine;
  60558. private static _CreateWorkerPool;
  60559. /**
  60560. * Constructor
  60561. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60562. */
  60563. constructor(engine: ThinEngine, numWorkers?: number);
  60564. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60565. /**
  60566. * Stop all async operations and release resources.
  60567. */
  60568. dispose(): void;
  60569. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60570. /**
  60571. * Checks if the given data starts with a KTX2 file identifier.
  60572. * @param data the data to check
  60573. * @returns true if the data is a KTX2 file or false otherwise
  60574. */
  60575. static IsValid(data: ArrayBufferView): boolean;
  60576. }
  60577. export function workerFunc(): void;
  60578. }
  60579. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60580. import { Nullable } from "babylonjs/types";
  60581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60582. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60583. /**
  60584. * Implementation of the KTX Texture Loader.
  60585. * @hidden
  60586. */
  60587. export class _KTXTextureLoader implements IInternalTextureLoader {
  60588. /**
  60589. * Defines wether the loader supports cascade loading the different faces.
  60590. */
  60591. readonly supportCascades: boolean;
  60592. /**
  60593. * This returns if the loader support the current file information.
  60594. * @param extension defines the file extension of the file being loaded
  60595. * @param mimeType defines the optional mime type of the file being loaded
  60596. * @returns true if the loader can load the specified file
  60597. */
  60598. canLoad(extension: string, mimeType?: string): boolean;
  60599. /**
  60600. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60601. * @param data contains the texture data
  60602. * @param texture defines the BabylonJS internal texture
  60603. * @param createPolynomials will be true if polynomials have been requested
  60604. * @param onLoad defines the callback to trigger once the texture is ready
  60605. * @param onError defines the callback to trigger in case of error
  60606. */
  60607. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60608. /**
  60609. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60610. * @param data contains the texture data
  60611. * @param texture defines the BabylonJS internal texture
  60612. * @param callback defines the method to call once ready to upload
  60613. */
  60614. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60615. }
  60616. }
  60617. declare module "babylonjs/Helpers/sceneHelpers" {
  60618. import { Nullable } from "babylonjs/types";
  60619. import { Mesh } from "babylonjs/Meshes/mesh";
  60620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60621. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60622. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60623. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60624. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60625. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60626. import "babylonjs/Meshes/Builders/boxBuilder";
  60627. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60628. /** @hidden */
  60629. export var _forceSceneHelpersToBundle: boolean;
  60630. module "babylonjs/scene" {
  60631. interface Scene {
  60632. /**
  60633. * Creates a default light for the scene.
  60634. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60635. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60636. */
  60637. createDefaultLight(replace?: boolean): void;
  60638. /**
  60639. * Creates a default camera for the scene.
  60640. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60641. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60642. * @param replace has default false, when true replaces the active camera in the scene
  60643. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60644. */
  60645. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60646. /**
  60647. * Creates a default camera and a default light.
  60648. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60649. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60650. * @param replace has the default false, when true replaces the active camera/light in the scene
  60651. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60652. */
  60653. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60654. /**
  60655. * Creates a new sky box
  60656. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60657. * @param environmentTexture defines the texture to use as environment texture
  60658. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60659. * @param scale defines the overall scale of the skybox
  60660. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60661. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60662. * @returns a new mesh holding the sky box
  60663. */
  60664. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60665. /**
  60666. * Creates a new environment
  60667. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60668. * @param options defines the options you can use to configure the environment
  60669. * @returns the new EnvironmentHelper
  60670. */
  60671. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60672. /**
  60673. * Creates a new VREXperienceHelper
  60674. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60675. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60676. * @returns a new VREXperienceHelper
  60677. */
  60678. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60679. /**
  60680. * Creates a new WebXRDefaultExperience
  60681. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60682. * @param options experience options
  60683. * @returns a promise for a new WebXRDefaultExperience
  60684. */
  60685. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60686. }
  60687. }
  60688. }
  60689. declare module "babylonjs/Helpers/videoDome" {
  60690. import { Scene } from "babylonjs/scene";
  60691. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60692. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60693. /**
  60694. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60695. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60696. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60697. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60698. */
  60699. export class VideoDome extends TextureDome<VideoTexture> {
  60700. /**
  60701. * Define the video source as a Monoscopic panoramic 360 video.
  60702. */
  60703. static readonly MODE_MONOSCOPIC: number;
  60704. /**
  60705. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60706. */
  60707. static readonly MODE_TOPBOTTOM: number;
  60708. /**
  60709. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60710. */
  60711. static readonly MODE_SIDEBYSIDE: number;
  60712. /**
  60713. * Get the video texture associated with this video dome
  60714. */
  60715. get videoTexture(): VideoTexture;
  60716. /**
  60717. * Get the video mode of this dome
  60718. */
  60719. get videoMode(): number;
  60720. /**
  60721. * Set the video mode of this dome.
  60722. * @see textureMode
  60723. */
  60724. set videoMode(value: number);
  60725. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60726. }
  60727. }
  60728. declare module "babylonjs/Helpers/index" {
  60729. export * from "babylonjs/Helpers/environmentHelper";
  60730. export * from "babylonjs/Helpers/photoDome";
  60731. export * from "babylonjs/Helpers/sceneHelpers";
  60732. export * from "babylonjs/Helpers/videoDome";
  60733. }
  60734. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60735. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60736. import { IDisposable } from "babylonjs/scene";
  60737. import { Engine } from "babylonjs/Engines/engine";
  60738. /**
  60739. * This class can be used to get instrumentation data from a Babylon engine
  60740. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60741. */
  60742. export class EngineInstrumentation implements IDisposable {
  60743. /**
  60744. * Define the instrumented engine.
  60745. */
  60746. engine: Engine;
  60747. private _captureGPUFrameTime;
  60748. private _gpuFrameTimeToken;
  60749. private _gpuFrameTime;
  60750. private _captureShaderCompilationTime;
  60751. private _shaderCompilationTime;
  60752. private _onBeginFrameObserver;
  60753. private _onEndFrameObserver;
  60754. private _onBeforeShaderCompilationObserver;
  60755. private _onAfterShaderCompilationObserver;
  60756. /**
  60757. * Gets the perf counter used for GPU frame time
  60758. */
  60759. get gpuFrameTimeCounter(): PerfCounter;
  60760. /**
  60761. * Gets the GPU frame time capture status
  60762. */
  60763. get captureGPUFrameTime(): boolean;
  60764. /**
  60765. * Enable or disable the GPU frame time capture
  60766. */
  60767. set captureGPUFrameTime(value: boolean);
  60768. /**
  60769. * Gets the perf counter used for shader compilation time
  60770. */
  60771. get shaderCompilationTimeCounter(): PerfCounter;
  60772. /**
  60773. * Gets the shader compilation time capture status
  60774. */
  60775. get captureShaderCompilationTime(): boolean;
  60776. /**
  60777. * Enable or disable the shader compilation time capture
  60778. */
  60779. set captureShaderCompilationTime(value: boolean);
  60780. /**
  60781. * Instantiates a new engine instrumentation.
  60782. * This class can be used to get instrumentation data from a Babylon engine
  60783. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60784. * @param engine Defines the engine to instrument
  60785. */
  60786. constructor(
  60787. /**
  60788. * Define the instrumented engine.
  60789. */
  60790. engine: Engine);
  60791. /**
  60792. * Dispose and release associated resources.
  60793. */
  60794. dispose(): void;
  60795. }
  60796. }
  60797. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60798. import { Scene, IDisposable } from "babylonjs/scene";
  60799. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60800. /**
  60801. * This class can be used to get instrumentation data from a Babylon engine
  60802. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60803. */
  60804. export class SceneInstrumentation implements IDisposable {
  60805. /**
  60806. * Defines the scene to instrument
  60807. */
  60808. scene: Scene;
  60809. private _captureActiveMeshesEvaluationTime;
  60810. private _activeMeshesEvaluationTime;
  60811. private _captureRenderTargetsRenderTime;
  60812. private _renderTargetsRenderTime;
  60813. private _captureFrameTime;
  60814. private _frameTime;
  60815. private _captureRenderTime;
  60816. private _renderTime;
  60817. private _captureInterFrameTime;
  60818. private _interFrameTime;
  60819. private _captureParticlesRenderTime;
  60820. private _particlesRenderTime;
  60821. private _captureSpritesRenderTime;
  60822. private _spritesRenderTime;
  60823. private _capturePhysicsTime;
  60824. private _physicsTime;
  60825. private _captureAnimationsTime;
  60826. private _animationsTime;
  60827. private _captureCameraRenderTime;
  60828. private _cameraRenderTime;
  60829. private _onBeforeActiveMeshesEvaluationObserver;
  60830. private _onAfterActiveMeshesEvaluationObserver;
  60831. private _onBeforeRenderTargetsRenderObserver;
  60832. private _onAfterRenderTargetsRenderObserver;
  60833. private _onAfterRenderObserver;
  60834. private _onBeforeDrawPhaseObserver;
  60835. private _onAfterDrawPhaseObserver;
  60836. private _onBeforeAnimationsObserver;
  60837. private _onBeforeParticlesRenderingObserver;
  60838. private _onAfterParticlesRenderingObserver;
  60839. private _onBeforeSpritesRenderingObserver;
  60840. private _onAfterSpritesRenderingObserver;
  60841. private _onBeforePhysicsObserver;
  60842. private _onAfterPhysicsObserver;
  60843. private _onAfterAnimationsObserver;
  60844. private _onBeforeCameraRenderObserver;
  60845. private _onAfterCameraRenderObserver;
  60846. /**
  60847. * Gets the perf counter used for active meshes evaluation time
  60848. */
  60849. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60850. /**
  60851. * Gets the active meshes evaluation time capture status
  60852. */
  60853. get captureActiveMeshesEvaluationTime(): boolean;
  60854. /**
  60855. * Enable or disable the active meshes evaluation time capture
  60856. */
  60857. set captureActiveMeshesEvaluationTime(value: boolean);
  60858. /**
  60859. * Gets the perf counter used for render targets render time
  60860. */
  60861. get renderTargetsRenderTimeCounter(): PerfCounter;
  60862. /**
  60863. * Gets the render targets render time capture status
  60864. */
  60865. get captureRenderTargetsRenderTime(): boolean;
  60866. /**
  60867. * Enable or disable the render targets render time capture
  60868. */
  60869. set captureRenderTargetsRenderTime(value: boolean);
  60870. /**
  60871. * Gets the perf counter used for particles render time
  60872. */
  60873. get particlesRenderTimeCounter(): PerfCounter;
  60874. /**
  60875. * Gets the particles render time capture status
  60876. */
  60877. get captureParticlesRenderTime(): boolean;
  60878. /**
  60879. * Enable or disable the particles render time capture
  60880. */
  60881. set captureParticlesRenderTime(value: boolean);
  60882. /**
  60883. * Gets the perf counter used for sprites render time
  60884. */
  60885. get spritesRenderTimeCounter(): PerfCounter;
  60886. /**
  60887. * Gets the sprites render time capture status
  60888. */
  60889. get captureSpritesRenderTime(): boolean;
  60890. /**
  60891. * Enable or disable the sprites render time capture
  60892. */
  60893. set captureSpritesRenderTime(value: boolean);
  60894. /**
  60895. * Gets the perf counter used for physics time
  60896. */
  60897. get physicsTimeCounter(): PerfCounter;
  60898. /**
  60899. * Gets the physics time capture status
  60900. */
  60901. get capturePhysicsTime(): boolean;
  60902. /**
  60903. * Enable or disable the physics time capture
  60904. */
  60905. set capturePhysicsTime(value: boolean);
  60906. /**
  60907. * Gets the perf counter used for animations time
  60908. */
  60909. get animationsTimeCounter(): PerfCounter;
  60910. /**
  60911. * Gets the animations time capture status
  60912. */
  60913. get captureAnimationsTime(): boolean;
  60914. /**
  60915. * Enable or disable the animations time capture
  60916. */
  60917. set captureAnimationsTime(value: boolean);
  60918. /**
  60919. * Gets the perf counter used for frame time capture
  60920. */
  60921. get frameTimeCounter(): PerfCounter;
  60922. /**
  60923. * Gets the frame time capture status
  60924. */
  60925. get captureFrameTime(): boolean;
  60926. /**
  60927. * Enable or disable the frame time capture
  60928. */
  60929. set captureFrameTime(value: boolean);
  60930. /**
  60931. * Gets the perf counter used for inter-frames time capture
  60932. */
  60933. get interFrameTimeCounter(): PerfCounter;
  60934. /**
  60935. * Gets the inter-frames time capture status
  60936. */
  60937. get captureInterFrameTime(): boolean;
  60938. /**
  60939. * Enable or disable the inter-frames time capture
  60940. */
  60941. set captureInterFrameTime(value: boolean);
  60942. /**
  60943. * Gets the perf counter used for render time capture
  60944. */
  60945. get renderTimeCounter(): PerfCounter;
  60946. /**
  60947. * Gets the render time capture status
  60948. */
  60949. get captureRenderTime(): boolean;
  60950. /**
  60951. * Enable or disable the render time capture
  60952. */
  60953. set captureRenderTime(value: boolean);
  60954. /**
  60955. * Gets the perf counter used for camera render time capture
  60956. */
  60957. get cameraRenderTimeCounter(): PerfCounter;
  60958. /**
  60959. * Gets the camera render time capture status
  60960. */
  60961. get captureCameraRenderTime(): boolean;
  60962. /**
  60963. * Enable or disable the camera render time capture
  60964. */
  60965. set captureCameraRenderTime(value: boolean);
  60966. /**
  60967. * Gets the perf counter used for draw calls
  60968. */
  60969. get drawCallsCounter(): PerfCounter;
  60970. /**
  60971. * Instantiates a new scene instrumentation.
  60972. * This class can be used to get instrumentation data from a Babylon engine
  60973. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60974. * @param scene Defines the scene to instrument
  60975. */
  60976. constructor(
  60977. /**
  60978. * Defines the scene to instrument
  60979. */
  60980. scene: Scene);
  60981. /**
  60982. * Dispose and release associated resources.
  60983. */
  60984. dispose(): void;
  60985. }
  60986. }
  60987. declare module "babylonjs/Instrumentation/index" {
  60988. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60989. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60990. export * from "babylonjs/Instrumentation/timeToken";
  60991. }
  60992. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60993. /** @hidden */
  60994. export var glowMapGenerationPixelShader: {
  60995. name: string;
  60996. shader: string;
  60997. };
  60998. }
  60999. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61000. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61001. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61002. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61003. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61004. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61007. /** @hidden */
  61008. export var glowMapGenerationVertexShader: {
  61009. name: string;
  61010. shader: string;
  61011. };
  61012. }
  61013. declare module "babylonjs/Layers/effectLayer" {
  61014. import { Observable } from "babylonjs/Misc/observable";
  61015. import { Nullable } from "babylonjs/types";
  61016. import { Camera } from "babylonjs/Cameras/camera";
  61017. import { Scene } from "babylonjs/scene";
  61018. import { ISize } from "babylonjs/Maths/math.size";
  61019. import { Color4 } from "babylonjs/Maths/math.color";
  61020. import { Engine } from "babylonjs/Engines/engine";
  61021. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61023. import { Mesh } from "babylonjs/Meshes/mesh";
  61024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61026. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61027. import { Effect } from "babylonjs/Materials/effect";
  61028. import { Material } from "babylonjs/Materials/material";
  61029. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61030. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61031. /**
  61032. * Effect layer options. This helps customizing the behaviour
  61033. * of the effect layer.
  61034. */
  61035. export interface IEffectLayerOptions {
  61036. /**
  61037. * Multiplication factor apply to the canvas size to compute the render target size
  61038. * used to generated the objects (the smaller the faster).
  61039. */
  61040. mainTextureRatio: number;
  61041. /**
  61042. * Enforces a fixed size texture to ensure effect stability across devices.
  61043. */
  61044. mainTextureFixedSize?: number;
  61045. /**
  61046. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61047. */
  61048. alphaBlendingMode: number;
  61049. /**
  61050. * The camera attached to the layer.
  61051. */
  61052. camera: Nullable<Camera>;
  61053. /**
  61054. * The rendering group to draw the layer in.
  61055. */
  61056. renderingGroupId: number;
  61057. }
  61058. /**
  61059. * The effect layer Helps adding post process effect blended with the main pass.
  61060. *
  61061. * This can be for instance use to generate glow or higlight effects on the scene.
  61062. *
  61063. * The effect layer class can not be used directly and is intented to inherited from to be
  61064. * customized per effects.
  61065. */
  61066. export abstract class EffectLayer {
  61067. private _vertexBuffers;
  61068. private _indexBuffer;
  61069. private _cachedDefines;
  61070. private _effectLayerMapGenerationEffect;
  61071. private _effectLayerOptions;
  61072. private _mergeEffect;
  61073. protected _scene: Scene;
  61074. protected _engine: Engine;
  61075. protected _maxSize: number;
  61076. protected _mainTextureDesiredSize: ISize;
  61077. protected _mainTexture: RenderTargetTexture;
  61078. protected _shouldRender: boolean;
  61079. protected _postProcesses: PostProcess[];
  61080. protected _textures: BaseTexture[];
  61081. protected _emissiveTextureAndColor: {
  61082. texture: Nullable<BaseTexture>;
  61083. color: Color4;
  61084. };
  61085. /**
  61086. * The name of the layer
  61087. */
  61088. name: string;
  61089. /**
  61090. * The clear color of the texture used to generate the glow map.
  61091. */
  61092. neutralColor: Color4;
  61093. /**
  61094. * Specifies whether the highlight layer is enabled or not.
  61095. */
  61096. isEnabled: boolean;
  61097. /**
  61098. * Gets the camera attached to the layer.
  61099. */
  61100. get camera(): Nullable<Camera>;
  61101. /**
  61102. * Gets the rendering group id the layer should render in.
  61103. */
  61104. get renderingGroupId(): number;
  61105. set renderingGroupId(renderingGroupId: number);
  61106. /**
  61107. * An event triggered when the effect layer has been disposed.
  61108. */
  61109. onDisposeObservable: Observable<EffectLayer>;
  61110. /**
  61111. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61112. */
  61113. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61114. /**
  61115. * An event triggered when the generated texture is being merged in the scene.
  61116. */
  61117. onBeforeComposeObservable: Observable<EffectLayer>;
  61118. /**
  61119. * An event triggered when the mesh is rendered into the effect render target.
  61120. */
  61121. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61122. /**
  61123. * An event triggered after the mesh has been rendered into the effect render target.
  61124. */
  61125. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61126. /**
  61127. * An event triggered when the generated texture has been merged in the scene.
  61128. */
  61129. onAfterComposeObservable: Observable<EffectLayer>;
  61130. /**
  61131. * An event triggered when the efffect layer changes its size.
  61132. */
  61133. onSizeChangedObservable: Observable<EffectLayer>;
  61134. /** @hidden */
  61135. static _SceneComponentInitialization: (scene: Scene) => void;
  61136. /**
  61137. * Instantiates a new effect Layer and references it in the scene.
  61138. * @param name The name of the layer
  61139. * @param scene The scene to use the layer in
  61140. */
  61141. constructor(
  61142. /** The Friendly of the effect in the scene */
  61143. name: string, scene: Scene);
  61144. /**
  61145. * Get the effect name of the layer.
  61146. * @return The effect name
  61147. */
  61148. abstract getEffectName(): string;
  61149. /**
  61150. * Checks for the readiness of the element composing the layer.
  61151. * @param subMesh the mesh to check for
  61152. * @param useInstances specify whether or not to use instances to render the mesh
  61153. * @return true if ready otherwise, false
  61154. */
  61155. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61156. /**
  61157. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61158. * @returns true if the effect requires stencil during the main canvas render pass.
  61159. */
  61160. abstract needStencil(): boolean;
  61161. /**
  61162. * Create the merge effect. This is the shader use to blit the information back
  61163. * to the main canvas at the end of the scene rendering.
  61164. * @returns The effect containing the shader used to merge the effect on the main canvas
  61165. */
  61166. protected abstract _createMergeEffect(): Effect;
  61167. /**
  61168. * Creates the render target textures and post processes used in the effect layer.
  61169. */
  61170. protected abstract _createTextureAndPostProcesses(): void;
  61171. /**
  61172. * Implementation specific of rendering the generating effect on the main canvas.
  61173. * @param effect The effect used to render through
  61174. */
  61175. protected abstract _internalRender(effect: Effect): void;
  61176. /**
  61177. * Sets the required values for both the emissive texture and and the main color.
  61178. */
  61179. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61180. /**
  61181. * Free any resources and references associated to a mesh.
  61182. * Internal use
  61183. * @param mesh The mesh to free.
  61184. */
  61185. abstract _disposeMesh(mesh: Mesh): void;
  61186. /**
  61187. * Serializes this layer (Glow or Highlight for example)
  61188. * @returns a serialized layer object
  61189. */
  61190. abstract serialize?(): any;
  61191. /**
  61192. * Initializes the effect layer with the required options.
  61193. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61194. */
  61195. protected _init(options: Partial<IEffectLayerOptions>): void;
  61196. /**
  61197. * Generates the index buffer of the full screen quad blending to the main canvas.
  61198. */
  61199. private _generateIndexBuffer;
  61200. /**
  61201. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61202. */
  61203. private _generateVertexBuffer;
  61204. /**
  61205. * Sets the main texture desired size which is the closest power of two
  61206. * of the engine canvas size.
  61207. */
  61208. private _setMainTextureSize;
  61209. /**
  61210. * Creates the main texture for the effect layer.
  61211. */
  61212. protected _createMainTexture(): void;
  61213. /**
  61214. * Adds specific effects defines.
  61215. * @param defines The defines to add specifics to.
  61216. */
  61217. protected _addCustomEffectDefines(defines: string[]): void;
  61218. /**
  61219. * Checks for the readiness of the element composing the layer.
  61220. * @param subMesh the mesh to check for
  61221. * @param useInstances specify whether or not to use instances to render the mesh
  61222. * @param emissiveTexture the associated emissive texture used to generate the glow
  61223. * @return true if ready otherwise, false
  61224. */
  61225. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61226. /**
  61227. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61228. */
  61229. render(): void;
  61230. /**
  61231. * Determine if a given mesh will be used in the current effect.
  61232. * @param mesh mesh to test
  61233. * @returns true if the mesh will be used
  61234. */
  61235. hasMesh(mesh: AbstractMesh): boolean;
  61236. /**
  61237. * Returns true if the layer contains information to display, otherwise false.
  61238. * @returns true if the glow layer should be rendered
  61239. */
  61240. shouldRender(): 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 _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61247. /**
  61248. * Returns true if the mesh can be rendered, otherwise false.
  61249. * @param mesh The mesh to render
  61250. * @param material The material used on the mesh
  61251. * @returns true if it can be rendered otherwise false
  61252. */
  61253. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61254. /**
  61255. * Returns true if the mesh should render, otherwise false.
  61256. * @param mesh The mesh to render
  61257. * @returns true if it should render otherwise false
  61258. */
  61259. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61260. /**
  61261. * Renders the submesh passed in parameter to the generation map.
  61262. */
  61263. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61264. /**
  61265. * Defines whether the current material of the mesh should be use to render the effect.
  61266. * @param mesh defines the current mesh to render
  61267. */
  61268. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61269. /**
  61270. * Rebuild the required buffers.
  61271. * @hidden Internal use only.
  61272. */
  61273. _rebuild(): void;
  61274. /**
  61275. * Dispose only the render target textures and post process.
  61276. */
  61277. private _disposeTextureAndPostProcesses;
  61278. /**
  61279. * Dispose the highlight layer and free resources.
  61280. */
  61281. dispose(): void;
  61282. /**
  61283. * Gets the class name of the effect layer
  61284. * @returns the string with the class name of the effect layer
  61285. */
  61286. getClassName(): string;
  61287. /**
  61288. * Creates an effect layer from parsed effect layer data
  61289. * @param parsedEffectLayer defines effect layer data
  61290. * @param scene defines the current scene
  61291. * @param rootUrl defines the root URL containing the effect layer information
  61292. * @returns a parsed effect Layer
  61293. */
  61294. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61295. }
  61296. }
  61297. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61298. import { Scene } from "babylonjs/scene";
  61299. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61300. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61301. import { AbstractScene } from "babylonjs/abstractScene";
  61302. module "babylonjs/abstractScene" {
  61303. interface AbstractScene {
  61304. /**
  61305. * The list of effect layers (highlights/glow) added to the scene
  61306. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61307. * @see https://doc.babylonjs.com/how_to/glow_layer
  61308. */
  61309. effectLayers: Array<EffectLayer>;
  61310. /**
  61311. * Removes the given effect layer from this scene.
  61312. * @param toRemove defines the effect layer to remove
  61313. * @returns the index of the removed effect layer
  61314. */
  61315. removeEffectLayer(toRemove: EffectLayer): number;
  61316. /**
  61317. * Adds the given effect layer to this scene
  61318. * @param newEffectLayer defines the effect layer to add
  61319. */
  61320. addEffectLayer(newEffectLayer: EffectLayer): void;
  61321. }
  61322. }
  61323. /**
  61324. * Defines the layer scene component responsible to manage any effect layers
  61325. * in a given scene.
  61326. */
  61327. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61328. /**
  61329. * The component name helpfull to identify the component in the list of scene components.
  61330. */
  61331. readonly name: string;
  61332. /**
  61333. * The scene the component belongs to.
  61334. */
  61335. scene: Scene;
  61336. private _engine;
  61337. private _renderEffects;
  61338. private _needStencil;
  61339. private _previousStencilState;
  61340. /**
  61341. * Creates a new instance of the component for the given scene
  61342. * @param scene Defines the scene to register the component in
  61343. */
  61344. constructor(scene: Scene);
  61345. /**
  61346. * Registers the component in a given scene
  61347. */
  61348. register(): void;
  61349. /**
  61350. * Rebuilds the elements related to this component in case of
  61351. * context lost for instance.
  61352. */
  61353. rebuild(): void;
  61354. /**
  61355. * Serializes the component data to the specified json object
  61356. * @param serializationObject The object to serialize to
  61357. */
  61358. serialize(serializationObject: any): void;
  61359. /**
  61360. * Adds all the elements from the container to the scene
  61361. * @param container the container holding the elements
  61362. */
  61363. addFromContainer(container: AbstractScene): void;
  61364. /**
  61365. * Removes all the elements in the container from the scene
  61366. * @param container contains the elements to remove
  61367. * @param dispose if the removed element should be disposed (default: false)
  61368. */
  61369. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61370. /**
  61371. * Disposes the component and the associated ressources.
  61372. */
  61373. dispose(): void;
  61374. private _isReadyForMesh;
  61375. private _renderMainTexture;
  61376. private _setStencil;
  61377. private _setStencilBack;
  61378. private _draw;
  61379. private _drawCamera;
  61380. private _drawRenderingGroup;
  61381. }
  61382. }
  61383. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61384. /** @hidden */
  61385. export var glowMapMergePixelShader: {
  61386. name: string;
  61387. shader: string;
  61388. };
  61389. }
  61390. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61391. /** @hidden */
  61392. export var glowMapMergeVertexShader: {
  61393. name: string;
  61394. shader: string;
  61395. };
  61396. }
  61397. declare module "babylonjs/Layers/glowLayer" {
  61398. import { Nullable } from "babylonjs/types";
  61399. import { Camera } from "babylonjs/Cameras/camera";
  61400. import { Scene } from "babylonjs/scene";
  61401. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61403. import { Mesh } from "babylonjs/Meshes/mesh";
  61404. import { Texture } from "babylonjs/Materials/Textures/texture";
  61405. import { Effect } from "babylonjs/Materials/effect";
  61406. import { Material } from "babylonjs/Materials/material";
  61407. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61408. import { Color4 } from "babylonjs/Maths/math.color";
  61409. import "babylonjs/Shaders/glowMapMerge.fragment";
  61410. import "babylonjs/Shaders/glowMapMerge.vertex";
  61411. import "babylonjs/Layers/effectLayerSceneComponent";
  61412. module "babylonjs/abstractScene" {
  61413. interface AbstractScene {
  61414. /**
  61415. * Return a the first highlight layer of the scene with a given name.
  61416. * @param name The name of the highlight layer to look for.
  61417. * @return The highlight layer if found otherwise null.
  61418. */
  61419. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61420. }
  61421. }
  61422. /**
  61423. * Glow layer options. This helps customizing the behaviour
  61424. * of the glow layer.
  61425. */
  61426. export interface IGlowLayerOptions {
  61427. /**
  61428. * Multiplication factor apply to the canvas size to compute the render target size
  61429. * used to generated the glowing objects (the smaller the faster).
  61430. */
  61431. mainTextureRatio: number;
  61432. /**
  61433. * Enforces a fixed size texture to ensure resize independant blur.
  61434. */
  61435. mainTextureFixedSize?: number;
  61436. /**
  61437. * How big is the kernel of the blur texture.
  61438. */
  61439. blurKernelSize: number;
  61440. /**
  61441. * The camera attached to the layer.
  61442. */
  61443. camera: Nullable<Camera>;
  61444. /**
  61445. * Enable MSAA by chosing the number of samples.
  61446. */
  61447. mainTextureSamples?: number;
  61448. /**
  61449. * The rendering group to draw the layer in.
  61450. */
  61451. renderingGroupId: number;
  61452. }
  61453. /**
  61454. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61455. *
  61456. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61457. *
  61458. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61459. */
  61460. export class GlowLayer extends EffectLayer {
  61461. /**
  61462. * Effect Name of the layer.
  61463. */
  61464. static readonly EffectName: string;
  61465. /**
  61466. * The default blur kernel size used for the glow.
  61467. */
  61468. static DefaultBlurKernelSize: number;
  61469. /**
  61470. * The default texture size ratio used for the glow.
  61471. */
  61472. static DefaultTextureRatio: number;
  61473. /**
  61474. * Sets the kernel size of the blur.
  61475. */
  61476. set blurKernelSize(value: number);
  61477. /**
  61478. * Gets the kernel size of the blur.
  61479. */
  61480. get blurKernelSize(): number;
  61481. /**
  61482. * Sets the glow intensity.
  61483. */
  61484. set intensity(value: number);
  61485. /**
  61486. * Gets the glow intensity.
  61487. */
  61488. get intensity(): number;
  61489. private _options;
  61490. private _intensity;
  61491. private _horizontalBlurPostprocess1;
  61492. private _verticalBlurPostprocess1;
  61493. private _horizontalBlurPostprocess2;
  61494. private _verticalBlurPostprocess2;
  61495. private _blurTexture1;
  61496. private _blurTexture2;
  61497. private _postProcesses1;
  61498. private _postProcesses2;
  61499. private _includedOnlyMeshes;
  61500. private _excludedMeshes;
  61501. private _meshesUsingTheirOwnMaterials;
  61502. /**
  61503. * Callback used to let the user override the color selection on a per mesh basis
  61504. */
  61505. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61506. /**
  61507. * Callback used to let the user override the texture selection on a per mesh basis
  61508. */
  61509. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61510. /**
  61511. * Instantiates a new glow Layer and references it to the scene.
  61512. * @param name The name of the layer
  61513. * @param scene The scene to use the layer in
  61514. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61515. */
  61516. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61517. /**
  61518. * Get the effect name of the layer.
  61519. * @return The effect name
  61520. */
  61521. getEffectName(): string;
  61522. /**
  61523. * Create the merge effect. This is the shader use to blit the information back
  61524. * to the main canvas at the end of the scene rendering.
  61525. */
  61526. protected _createMergeEffect(): Effect;
  61527. /**
  61528. * Creates the render target textures and post processes used in the glow layer.
  61529. */
  61530. protected _createTextureAndPostProcesses(): void;
  61531. /**
  61532. * Checks for the readiness of the element composing the layer.
  61533. * @param subMesh the mesh to check for
  61534. * @param useInstances specify wether or not to use instances to render the mesh
  61535. * @param emissiveTexture the associated emissive texture used to generate the glow
  61536. * @return true if ready otherwise, false
  61537. */
  61538. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61539. /**
  61540. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61541. */
  61542. needStencil(): boolean;
  61543. /**
  61544. * Returns true if the mesh can be rendered, otherwise false.
  61545. * @param mesh The mesh to render
  61546. * @param material The material used on the mesh
  61547. * @returns true if it can be rendered otherwise false
  61548. */
  61549. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61550. /**
  61551. * Implementation specific of rendering the generating effect on the main canvas.
  61552. * @param effect The effect used to render through
  61553. */
  61554. protected _internalRender(effect: Effect): void;
  61555. /**
  61556. * Sets the required values for both the emissive texture and and the main color.
  61557. */
  61558. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61559. /**
  61560. * Returns true if the mesh should render, otherwise false.
  61561. * @param mesh The mesh to render
  61562. * @returns true if it should render otherwise false
  61563. */
  61564. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61565. /**
  61566. * Adds specific effects defines.
  61567. * @param defines The defines to add specifics to.
  61568. */
  61569. protected _addCustomEffectDefines(defines: string[]): void;
  61570. /**
  61571. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61572. * @param mesh The mesh to exclude from the glow layer
  61573. */
  61574. addExcludedMesh(mesh: Mesh): void;
  61575. /**
  61576. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61577. * @param mesh The mesh to remove
  61578. */
  61579. removeExcludedMesh(mesh: Mesh): void;
  61580. /**
  61581. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61582. * @param mesh The mesh to include in the glow layer
  61583. */
  61584. addIncludedOnlyMesh(mesh: Mesh): void;
  61585. /**
  61586. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61587. * @param mesh The mesh to remove
  61588. */
  61589. removeIncludedOnlyMesh(mesh: Mesh): void;
  61590. /**
  61591. * Determine if a given mesh will be used in the glow layer
  61592. * @param mesh The mesh to test
  61593. * @returns true if the mesh will be highlighted by the current glow layer
  61594. */
  61595. hasMesh(mesh: AbstractMesh): boolean;
  61596. /**
  61597. * Defines whether the current material of the mesh should be use to render the effect.
  61598. * @param mesh defines the current mesh to render
  61599. */
  61600. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61601. /**
  61602. * Add a mesh to be rendered through its own material and not with emissive only.
  61603. * @param mesh The mesh for which we need to use its material
  61604. */
  61605. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61606. /**
  61607. * Remove a mesh from being rendered through its own material and not with emissive only.
  61608. * @param mesh The mesh for which we need to not use its material
  61609. */
  61610. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61611. /**
  61612. * Free any resources and references associated to a mesh.
  61613. * Internal use
  61614. * @param mesh The mesh to free.
  61615. * @hidden
  61616. */
  61617. _disposeMesh(mesh: Mesh): void;
  61618. /**
  61619. * Gets the class name of the effect layer
  61620. * @returns the string with the class name of the effect layer
  61621. */
  61622. getClassName(): string;
  61623. /**
  61624. * Serializes this glow layer
  61625. * @returns a serialized glow layer object
  61626. */
  61627. serialize(): any;
  61628. /**
  61629. * Creates a Glow Layer from parsed glow layer data
  61630. * @param parsedGlowLayer defines glow layer data
  61631. * @param scene defines the current scene
  61632. * @param rootUrl defines the root URL containing the glow layer information
  61633. * @returns a parsed Glow Layer
  61634. */
  61635. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61636. }
  61637. }
  61638. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61639. /** @hidden */
  61640. export var glowBlurPostProcessPixelShader: {
  61641. name: string;
  61642. shader: string;
  61643. };
  61644. }
  61645. declare module "babylonjs/Layers/highlightLayer" {
  61646. import { Observable } from "babylonjs/Misc/observable";
  61647. import { Nullable } from "babylonjs/types";
  61648. import { Camera } from "babylonjs/Cameras/camera";
  61649. import { Scene } from "babylonjs/scene";
  61650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61652. import { Mesh } from "babylonjs/Meshes/mesh";
  61653. import { Effect } from "babylonjs/Materials/effect";
  61654. import { Material } from "babylonjs/Materials/material";
  61655. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61656. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61657. import "babylonjs/Shaders/glowMapMerge.fragment";
  61658. import "babylonjs/Shaders/glowMapMerge.vertex";
  61659. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61660. module "babylonjs/abstractScene" {
  61661. interface AbstractScene {
  61662. /**
  61663. * Return a the first highlight layer of the scene with a given name.
  61664. * @param name The name of the highlight layer to look for.
  61665. * @return The highlight layer if found otherwise null.
  61666. */
  61667. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61668. }
  61669. }
  61670. /**
  61671. * Highlight layer options. This helps customizing the behaviour
  61672. * of the highlight layer.
  61673. */
  61674. export interface IHighlightLayerOptions {
  61675. /**
  61676. * Multiplication factor apply to the canvas size to compute the render target size
  61677. * used to generated the glowing objects (the smaller the faster).
  61678. */
  61679. mainTextureRatio: number;
  61680. /**
  61681. * Enforces a fixed size texture to ensure resize independant blur.
  61682. */
  61683. mainTextureFixedSize?: number;
  61684. /**
  61685. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61686. * of the picture to blur (the smaller the faster).
  61687. */
  61688. blurTextureSizeRatio: number;
  61689. /**
  61690. * How big in texel of the blur texture is the vertical blur.
  61691. */
  61692. blurVerticalSize: number;
  61693. /**
  61694. * How big in texel of the blur texture is the horizontal blur.
  61695. */
  61696. blurHorizontalSize: number;
  61697. /**
  61698. * Alpha blending mode used to apply the blur. Default is combine.
  61699. */
  61700. alphaBlendingMode: number;
  61701. /**
  61702. * The camera attached to the layer.
  61703. */
  61704. camera: Nullable<Camera>;
  61705. /**
  61706. * Should we display highlight as a solid stroke?
  61707. */
  61708. isStroke?: boolean;
  61709. /**
  61710. * The rendering group to draw the layer in.
  61711. */
  61712. renderingGroupId: number;
  61713. }
  61714. /**
  61715. * The highlight layer Helps adding a glow effect around a mesh.
  61716. *
  61717. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61718. * glowy meshes to your scene.
  61719. *
  61720. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61721. */
  61722. export class HighlightLayer extends EffectLayer {
  61723. name: string;
  61724. /**
  61725. * Effect Name of the highlight layer.
  61726. */
  61727. static readonly EffectName: string;
  61728. /**
  61729. * The neutral color used during the preparation of the glow effect.
  61730. * This is black by default as the blend operation is a blend operation.
  61731. */
  61732. static NeutralColor: Color4;
  61733. /**
  61734. * Stencil value used for glowing meshes.
  61735. */
  61736. static GlowingMeshStencilReference: number;
  61737. /**
  61738. * Stencil value used for the other meshes in the scene.
  61739. */
  61740. static NormalMeshStencilReference: number;
  61741. /**
  61742. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61743. */
  61744. innerGlow: boolean;
  61745. /**
  61746. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61747. */
  61748. outerGlow: boolean;
  61749. /**
  61750. * Specifies the horizontal size of the blur.
  61751. */
  61752. set blurHorizontalSize(value: number);
  61753. /**
  61754. * Specifies the vertical size of the blur.
  61755. */
  61756. set blurVerticalSize(value: number);
  61757. /**
  61758. * Gets the horizontal size of the blur.
  61759. */
  61760. get blurHorizontalSize(): number;
  61761. /**
  61762. * Gets the vertical size of the blur.
  61763. */
  61764. get blurVerticalSize(): number;
  61765. /**
  61766. * An event triggered when the highlight layer is being blurred.
  61767. */
  61768. onBeforeBlurObservable: Observable<HighlightLayer>;
  61769. /**
  61770. * An event triggered when the highlight layer has been blurred.
  61771. */
  61772. onAfterBlurObservable: Observable<HighlightLayer>;
  61773. private _instanceGlowingMeshStencilReference;
  61774. private _options;
  61775. private _downSamplePostprocess;
  61776. private _horizontalBlurPostprocess;
  61777. private _verticalBlurPostprocess;
  61778. private _blurTexture;
  61779. private _meshes;
  61780. private _excludedMeshes;
  61781. /**
  61782. * Instantiates a new highlight Layer and references it to the scene..
  61783. * @param name The name of the layer
  61784. * @param scene The scene to use the layer in
  61785. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61786. */
  61787. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61788. /**
  61789. * Get the effect name of the layer.
  61790. * @return The effect name
  61791. */
  61792. getEffectName(): string;
  61793. /**
  61794. * Create the merge effect. This is the shader use to blit the information back
  61795. * to the main canvas at the end of the scene rendering.
  61796. */
  61797. protected _createMergeEffect(): Effect;
  61798. /**
  61799. * Creates the render target textures and post processes used in the highlight layer.
  61800. */
  61801. protected _createTextureAndPostProcesses(): void;
  61802. /**
  61803. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61804. */
  61805. needStencil(): boolean;
  61806. /**
  61807. * Checks for the readiness of the element composing the layer.
  61808. * @param subMesh the mesh to check for
  61809. * @param useInstances specify wether or not to use instances to render the mesh
  61810. * @param emissiveTexture the associated emissive texture used to generate the glow
  61811. * @return true if ready otherwise, false
  61812. */
  61813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61814. /**
  61815. * Implementation specific of rendering the generating effect on the main canvas.
  61816. * @param effect The effect used to render through
  61817. */
  61818. protected _internalRender(effect: Effect): void;
  61819. /**
  61820. * Returns true if the layer contains information to display, otherwise false.
  61821. */
  61822. shouldRender(): boolean;
  61823. /**
  61824. * Returns true if the mesh should render, otherwise false.
  61825. * @param mesh The mesh to render
  61826. * @returns true if it should render otherwise false
  61827. */
  61828. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61829. /**
  61830. * Returns true if the mesh can be rendered, otherwise false.
  61831. * @param mesh The mesh to render
  61832. * @param material The material used on the mesh
  61833. * @returns true if it can be rendered otherwise false
  61834. */
  61835. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61836. /**
  61837. * Adds specific effects defines.
  61838. * @param defines The defines to add specifics to.
  61839. */
  61840. protected _addCustomEffectDefines(defines: string[]): void;
  61841. /**
  61842. * Sets the required values for both the emissive texture and and the main color.
  61843. */
  61844. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61845. /**
  61846. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61847. * @param mesh The mesh to exclude from the highlight layer
  61848. */
  61849. addExcludedMesh(mesh: Mesh): void;
  61850. /**
  61851. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61852. * @param mesh The mesh to highlight
  61853. */
  61854. removeExcludedMesh(mesh: Mesh): void;
  61855. /**
  61856. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61857. * @param mesh mesh to test
  61858. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61859. */
  61860. hasMesh(mesh: AbstractMesh): boolean;
  61861. /**
  61862. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61863. * @param mesh The mesh to highlight
  61864. * @param color The color of the highlight
  61865. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61866. */
  61867. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61868. /**
  61869. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61870. * @param mesh The mesh to highlight
  61871. */
  61872. removeMesh(mesh: Mesh): void;
  61873. /**
  61874. * Remove all the meshes currently referenced in the highlight layer
  61875. */
  61876. removeAllMeshes(): void;
  61877. /**
  61878. * Force the stencil to the normal expected value for none glowing parts
  61879. */
  61880. private _defaultStencilReference;
  61881. /**
  61882. * Free any resources and references associated to a mesh.
  61883. * Internal use
  61884. * @param mesh The mesh to free.
  61885. * @hidden
  61886. */
  61887. _disposeMesh(mesh: Mesh): void;
  61888. /**
  61889. * Dispose the highlight layer and free resources.
  61890. */
  61891. dispose(): void;
  61892. /**
  61893. * Gets the class name of the effect layer
  61894. * @returns the string with the class name of the effect layer
  61895. */
  61896. getClassName(): string;
  61897. /**
  61898. * Serializes this Highlight layer
  61899. * @returns a serialized Highlight layer object
  61900. */
  61901. serialize(): any;
  61902. /**
  61903. * Creates a Highlight layer from parsed Highlight layer data
  61904. * @param parsedHightlightLayer defines the Highlight layer data
  61905. * @param scene defines the current scene
  61906. * @param rootUrl defines the root URL containing the Highlight layer information
  61907. * @returns a parsed Highlight layer
  61908. */
  61909. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61910. }
  61911. }
  61912. declare module "babylonjs/Layers/layerSceneComponent" {
  61913. import { Scene } from "babylonjs/scene";
  61914. import { ISceneComponent } from "babylonjs/sceneComponent";
  61915. import { Layer } from "babylonjs/Layers/layer";
  61916. import { AbstractScene } from "babylonjs/abstractScene";
  61917. module "babylonjs/abstractScene" {
  61918. interface AbstractScene {
  61919. /**
  61920. * The list of layers (background and foreground) of the scene
  61921. */
  61922. layers: Array<Layer>;
  61923. }
  61924. }
  61925. /**
  61926. * Defines the layer scene component responsible to manage any layers
  61927. * in a given scene.
  61928. */
  61929. export class LayerSceneComponent implements ISceneComponent {
  61930. /**
  61931. * The component name helpfull to identify the component in the list of scene components.
  61932. */
  61933. readonly name: string;
  61934. /**
  61935. * The scene the component belongs to.
  61936. */
  61937. scene: Scene;
  61938. private _engine;
  61939. /**
  61940. * Creates a new instance of the component for the given scene
  61941. * @param scene Defines the scene to register the component in
  61942. */
  61943. constructor(scene: Scene);
  61944. /**
  61945. * Registers the component in a given scene
  61946. */
  61947. register(): void;
  61948. /**
  61949. * Rebuilds the elements related to this component in case of
  61950. * context lost for instance.
  61951. */
  61952. rebuild(): void;
  61953. /**
  61954. * Disposes the component and the associated ressources.
  61955. */
  61956. dispose(): void;
  61957. private _draw;
  61958. private _drawCameraPredicate;
  61959. private _drawCameraBackground;
  61960. private _drawCameraForeground;
  61961. private _drawRenderTargetPredicate;
  61962. private _drawRenderTargetBackground;
  61963. private _drawRenderTargetForeground;
  61964. /**
  61965. * Adds all the elements from the container to the scene
  61966. * @param container the container holding the elements
  61967. */
  61968. addFromContainer(container: AbstractScene): void;
  61969. /**
  61970. * Removes all the elements in the container from the scene
  61971. * @param container contains the elements to remove
  61972. * @param dispose if the removed element should be disposed (default: false)
  61973. */
  61974. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61975. }
  61976. }
  61977. declare module "babylonjs/Shaders/layer.fragment" {
  61978. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61979. /** @hidden */
  61980. export var layerPixelShader: {
  61981. name: string;
  61982. shader: string;
  61983. };
  61984. }
  61985. declare module "babylonjs/Shaders/layer.vertex" {
  61986. /** @hidden */
  61987. export var layerVertexShader: {
  61988. name: string;
  61989. shader: string;
  61990. };
  61991. }
  61992. declare module "babylonjs/Layers/layer" {
  61993. import { Observable } from "babylonjs/Misc/observable";
  61994. import { Nullable } from "babylonjs/types";
  61995. import { Scene } from "babylonjs/scene";
  61996. import { Vector2 } from "babylonjs/Maths/math.vector";
  61997. import { Color4 } from "babylonjs/Maths/math.color";
  61998. import { Texture } from "babylonjs/Materials/Textures/texture";
  61999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62000. import "babylonjs/Shaders/layer.fragment";
  62001. import "babylonjs/Shaders/layer.vertex";
  62002. /**
  62003. * This represents a full screen 2d layer.
  62004. * This can be useful to display a picture in the background of your scene for instance.
  62005. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62006. */
  62007. export class Layer {
  62008. /**
  62009. * Define the name of the layer.
  62010. */
  62011. name: string;
  62012. /**
  62013. * Define the texture the layer should display.
  62014. */
  62015. texture: Nullable<Texture>;
  62016. /**
  62017. * Is the layer in background or foreground.
  62018. */
  62019. isBackground: boolean;
  62020. /**
  62021. * Define the color of the layer (instead of texture).
  62022. */
  62023. color: Color4;
  62024. /**
  62025. * Define the scale of the layer in order to zoom in out of the texture.
  62026. */
  62027. scale: Vector2;
  62028. /**
  62029. * Define an offset for the layer in order to shift the texture.
  62030. */
  62031. offset: Vector2;
  62032. /**
  62033. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62034. */
  62035. alphaBlendingMode: number;
  62036. /**
  62037. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62038. * Alpha test will not mix with the background color in case of transparency.
  62039. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62040. */
  62041. alphaTest: boolean;
  62042. /**
  62043. * Define a mask to restrict the layer to only some of the scene cameras.
  62044. */
  62045. layerMask: number;
  62046. /**
  62047. * Define the list of render target the layer is visible into.
  62048. */
  62049. renderTargetTextures: RenderTargetTexture[];
  62050. /**
  62051. * Define if the layer is only used in renderTarget or if it also
  62052. * renders in the main frame buffer of the canvas.
  62053. */
  62054. renderOnlyInRenderTargetTextures: boolean;
  62055. private _scene;
  62056. private _vertexBuffers;
  62057. private _indexBuffer;
  62058. private _effect;
  62059. private _previousDefines;
  62060. /**
  62061. * An event triggered when the layer is disposed.
  62062. */
  62063. onDisposeObservable: Observable<Layer>;
  62064. private _onDisposeObserver;
  62065. /**
  62066. * Back compatibility with callback before the onDisposeObservable existed.
  62067. * The set callback will be triggered when the layer has been disposed.
  62068. */
  62069. set onDispose(callback: () => void);
  62070. /**
  62071. * An event triggered before rendering the scene
  62072. */
  62073. onBeforeRenderObservable: Observable<Layer>;
  62074. private _onBeforeRenderObserver;
  62075. /**
  62076. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62077. * The set callback will be triggered just before rendering the layer.
  62078. */
  62079. set onBeforeRender(callback: () => void);
  62080. /**
  62081. * An event triggered after rendering the scene
  62082. */
  62083. onAfterRenderObservable: Observable<Layer>;
  62084. private _onAfterRenderObserver;
  62085. /**
  62086. * Back compatibility with callback before the onAfterRenderObservable existed.
  62087. * The set callback will be triggered just after rendering the layer.
  62088. */
  62089. set onAfterRender(callback: () => void);
  62090. /**
  62091. * Instantiates a new layer.
  62092. * This represents a full screen 2d layer.
  62093. * This can be useful to display a picture in the background of your scene for instance.
  62094. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62095. * @param name Define the name of the layer in the scene
  62096. * @param imgUrl Define the url of the texture to display in the layer
  62097. * @param scene Define the scene the layer belongs to
  62098. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62099. * @param color Defines a color for the layer
  62100. */
  62101. constructor(
  62102. /**
  62103. * Define the name of the layer.
  62104. */
  62105. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62106. private _createIndexBuffer;
  62107. /** @hidden */
  62108. _rebuild(): void;
  62109. /**
  62110. * Renders the layer in the scene.
  62111. */
  62112. render(): void;
  62113. /**
  62114. * Disposes and releases the associated ressources.
  62115. */
  62116. dispose(): void;
  62117. }
  62118. }
  62119. declare module "babylonjs/Layers/index" {
  62120. export * from "babylonjs/Layers/effectLayer";
  62121. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62122. export * from "babylonjs/Layers/glowLayer";
  62123. export * from "babylonjs/Layers/highlightLayer";
  62124. export * from "babylonjs/Layers/layer";
  62125. export * from "babylonjs/Layers/layerSceneComponent";
  62126. }
  62127. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62128. /** @hidden */
  62129. export var lensFlarePixelShader: {
  62130. name: string;
  62131. shader: string;
  62132. };
  62133. }
  62134. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62135. /** @hidden */
  62136. export var lensFlareVertexShader: {
  62137. name: string;
  62138. shader: string;
  62139. };
  62140. }
  62141. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62142. import { Scene } from "babylonjs/scene";
  62143. import { Vector3 } from "babylonjs/Maths/math.vector";
  62144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62145. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62146. import "babylonjs/Shaders/lensFlare.fragment";
  62147. import "babylonjs/Shaders/lensFlare.vertex";
  62148. import { Viewport } from "babylonjs/Maths/math.viewport";
  62149. /**
  62150. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62151. * It is usually composed of several `lensFlare`.
  62152. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62153. */
  62154. export class LensFlareSystem {
  62155. /**
  62156. * Define the name of the lens flare system
  62157. */
  62158. name: string;
  62159. /**
  62160. * List of lens flares used in this system.
  62161. */
  62162. lensFlares: LensFlare[];
  62163. /**
  62164. * Define a limit from the border the lens flare can be visible.
  62165. */
  62166. borderLimit: number;
  62167. /**
  62168. * Define a viewport border we do not want to see the lens flare in.
  62169. */
  62170. viewportBorder: number;
  62171. /**
  62172. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62173. */
  62174. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62175. /**
  62176. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62177. */
  62178. layerMask: number;
  62179. /**
  62180. * Define the id of the lens flare system in the scene.
  62181. * (equal to name by default)
  62182. */
  62183. id: string;
  62184. private _scene;
  62185. private _emitter;
  62186. private _vertexBuffers;
  62187. private _indexBuffer;
  62188. private _effect;
  62189. private _positionX;
  62190. private _positionY;
  62191. private _isEnabled;
  62192. /** @hidden */
  62193. static _SceneComponentInitialization: (scene: Scene) => void;
  62194. /**
  62195. * Instantiates a lens flare system.
  62196. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62197. * It is usually composed of several `lensFlare`.
  62198. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62199. * @param name Define the name of the lens flare system in the scene
  62200. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62201. * @param scene Define the scene the lens flare system belongs to
  62202. */
  62203. constructor(
  62204. /**
  62205. * Define the name of the lens flare system
  62206. */
  62207. name: string, emitter: any, scene: Scene);
  62208. /**
  62209. * Define if the lens flare system is enabled.
  62210. */
  62211. get isEnabled(): boolean;
  62212. set isEnabled(value: boolean);
  62213. /**
  62214. * Get the scene the effects belongs to.
  62215. * @returns the scene holding the lens flare system
  62216. */
  62217. getScene(): Scene;
  62218. /**
  62219. * Get the emitter of the lens flare system.
  62220. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62221. * @returns the emitter of the lens flare system
  62222. */
  62223. getEmitter(): any;
  62224. /**
  62225. * Set the emitter of the lens flare system.
  62226. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62227. * @param newEmitter Define the new emitter of the system
  62228. */
  62229. setEmitter(newEmitter: any): void;
  62230. /**
  62231. * Get the lens flare system emitter position.
  62232. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62233. * @returns the position
  62234. */
  62235. getEmitterPosition(): Vector3;
  62236. /**
  62237. * @hidden
  62238. */
  62239. computeEffectivePosition(globalViewport: Viewport): boolean;
  62240. /** @hidden */
  62241. _isVisible(): boolean;
  62242. /**
  62243. * @hidden
  62244. */
  62245. render(): boolean;
  62246. /**
  62247. * Dispose and release the lens flare with its associated resources.
  62248. */
  62249. dispose(): void;
  62250. /**
  62251. * Parse a lens flare system from a JSON repressentation
  62252. * @param parsedLensFlareSystem Define the JSON to parse
  62253. * @param scene Define the scene the parsed system should be instantiated in
  62254. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62255. * @returns the parsed system
  62256. */
  62257. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62258. /**
  62259. * Serialize the current Lens Flare System into a JSON representation.
  62260. * @returns the serialized JSON
  62261. */
  62262. serialize(): any;
  62263. }
  62264. }
  62265. declare module "babylonjs/LensFlares/lensFlare" {
  62266. import { Nullable } from "babylonjs/types";
  62267. import { Color3 } from "babylonjs/Maths/math.color";
  62268. import { Texture } from "babylonjs/Materials/Textures/texture";
  62269. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62270. /**
  62271. * This represents one of the lens effect in a `lensFlareSystem`.
  62272. * It controls one of the indiviual texture used in the effect.
  62273. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62274. */
  62275. export class LensFlare {
  62276. /**
  62277. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62278. */
  62279. size: number;
  62280. /**
  62281. * 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.
  62282. */
  62283. position: number;
  62284. /**
  62285. * Define the lens color.
  62286. */
  62287. color: Color3;
  62288. /**
  62289. * Define the lens texture.
  62290. */
  62291. texture: Nullable<Texture>;
  62292. /**
  62293. * Define the alpha mode to render this particular lens.
  62294. */
  62295. alphaMode: number;
  62296. private _system;
  62297. /**
  62298. * Creates 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 (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. * @returns The newly created Lens Flare
  62308. */
  62309. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62310. /**
  62311. * Instantiates a new Lens Flare.
  62312. * This represents one of the lens effect in a `lensFlareSystem`.
  62313. * It controls one of the indiviual texture used in the effect.
  62314. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62315. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62316. * @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.
  62317. * @param color Define the lens color
  62318. * @param imgUrl Define the lens texture url
  62319. * @param system Define the `lensFlareSystem` this flare is part of
  62320. */
  62321. constructor(
  62322. /**
  62323. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62324. */
  62325. size: number,
  62326. /**
  62327. * 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.
  62328. */
  62329. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62330. /**
  62331. * Dispose and release the lens flare with its associated resources.
  62332. */
  62333. dispose(): void;
  62334. }
  62335. }
  62336. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62337. import { Nullable } from "babylonjs/types";
  62338. import { Scene } from "babylonjs/scene";
  62339. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62340. import { AbstractScene } from "babylonjs/abstractScene";
  62341. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62342. module "babylonjs/abstractScene" {
  62343. interface AbstractScene {
  62344. /**
  62345. * The list of lens flare system added to the scene
  62346. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62347. */
  62348. lensFlareSystems: Array<LensFlareSystem>;
  62349. /**
  62350. * Removes the given lens flare system from this scene.
  62351. * @param toRemove The lens flare system to remove
  62352. * @returns The index of the removed lens flare system
  62353. */
  62354. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62355. /**
  62356. * Adds the given lens flare system to this scene
  62357. * @param newLensFlareSystem The lens flare system to add
  62358. */
  62359. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62360. /**
  62361. * Gets a lens flare system using its name
  62362. * @param name defines the name to look for
  62363. * @returns the lens flare system or null if not found
  62364. */
  62365. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62366. /**
  62367. * Gets a lens flare system using its id
  62368. * @param id defines the id to look for
  62369. * @returns the lens flare system or null if not found
  62370. */
  62371. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62372. }
  62373. }
  62374. /**
  62375. * Defines the lens flare scene component responsible to manage any lens flares
  62376. * in a given scene.
  62377. */
  62378. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62379. /**
  62380. * The component name helpfull to identify the component in the list of scene components.
  62381. */
  62382. readonly name: string;
  62383. /**
  62384. * The scene the component belongs to.
  62385. */
  62386. scene: Scene;
  62387. /**
  62388. * Creates a new instance of the component for the given scene
  62389. * @param scene Defines the scene to register the component in
  62390. */
  62391. constructor(scene: Scene);
  62392. /**
  62393. * Registers the component in a given scene
  62394. */
  62395. register(): void;
  62396. /**
  62397. * Rebuilds the elements related to this component in case of
  62398. * context lost for instance.
  62399. */
  62400. rebuild(): void;
  62401. /**
  62402. * Adds all the elements from the container to the scene
  62403. * @param container the container holding the elements
  62404. */
  62405. addFromContainer(container: AbstractScene): void;
  62406. /**
  62407. * Removes all the elements in the container from the scene
  62408. * @param container contains the elements to remove
  62409. * @param dispose if the removed element should be disposed (default: false)
  62410. */
  62411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62412. /**
  62413. * Serializes the component data to the specified json object
  62414. * @param serializationObject The object to serialize to
  62415. */
  62416. serialize(serializationObject: any): void;
  62417. /**
  62418. * Disposes the component and the associated ressources.
  62419. */
  62420. dispose(): void;
  62421. private _draw;
  62422. }
  62423. }
  62424. declare module "babylonjs/LensFlares/index" {
  62425. export * from "babylonjs/LensFlares/lensFlare";
  62426. export * from "babylonjs/LensFlares/lensFlareSystem";
  62427. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62428. }
  62429. declare module "babylonjs/Shaders/depth.fragment" {
  62430. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62431. /** @hidden */
  62432. export var depthPixelShader: {
  62433. name: string;
  62434. shader: string;
  62435. };
  62436. }
  62437. declare module "babylonjs/Shaders/depth.vertex" {
  62438. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62440. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62441. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62443. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62444. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62445. /** @hidden */
  62446. export var depthVertexShader: {
  62447. name: string;
  62448. shader: string;
  62449. };
  62450. }
  62451. declare module "babylonjs/Rendering/depthRenderer" {
  62452. import { Nullable } from "babylonjs/types";
  62453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62454. import { Scene } from "babylonjs/scene";
  62455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62456. import { Camera } from "babylonjs/Cameras/camera";
  62457. import "babylonjs/Shaders/depth.fragment";
  62458. import "babylonjs/Shaders/depth.vertex";
  62459. /**
  62460. * This represents a depth renderer in Babylon.
  62461. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62462. */
  62463. export class DepthRenderer {
  62464. private _scene;
  62465. private _depthMap;
  62466. private _effect;
  62467. private readonly _storeNonLinearDepth;
  62468. private readonly _clearColor;
  62469. /** Get if the depth renderer is using packed depth or not */
  62470. readonly isPacked: boolean;
  62471. private _cachedDefines;
  62472. private _camera;
  62473. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62474. enabled: boolean;
  62475. /**
  62476. * Specifiess that the depth renderer will only be used within
  62477. * the camera it is created for.
  62478. * This can help forcing its rendering during the camera processing.
  62479. */
  62480. useOnlyInActiveCamera: boolean;
  62481. /** @hidden */
  62482. static _SceneComponentInitialization: (scene: Scene) => void;
  62483. /**
  62484. * Instantiates a depth renderer
  62485. * @param scene The scene the renderer belongs to
  62486. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62487. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62488. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62489. */
  62490. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62491. /**
  62492. * Creates the depth rendering effect and checks if the effect is ready.
  62493. * @param subMesh The submesh to be used to render the depth map of
  62494. * @param useInstances If multiple world instances should be used
  62495. * @returns if the depth renderer is ready to render the depth map
  62496. */
  62497. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62498. /**
  62499. * Gets the texture which the depth map will be written to.
  62500. * @returns The depth map texture
  62501. */
  62502. getDepthMap(): RenderTargetTexture;
  62503. /**
  62504. * Disposes of the depth renderer.
  62505. */
  62506. dispose(): void;
  62507. }
  62508. }
  62509. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62510. /** @hidden */
  62511. export var minmaxReduxPixelShader: {
  62512. name: string;
  62513. shader: string;
  62514. };
  62515. }
  62516. declare module "babylonjs/Misc/minMaxReducer" {
  62517. import { Nullable } from "babylonjs/types";
  62518. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62519. import { Camera } from "babylonjs/Cameras/camera";
  62520. import { Observer } from "babylonjs/Misc/observable";
  62521. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62522. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62523. import { Observable } from "babylonjs/Misc/observable";
  62524. import "babylonjs/Shaders/minmaxRedux.fragment";
  62525. /**
  62526. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62527. * and maximum values from all values of the texture.
  62528. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62529. * The source values are read from the red channel of the texture.
  62530. */
  62531. export class MinMaxReducer {
  62532. /**
  62533. * Observable triggered when the computation has been performed
  62534. */
  62535. onAfterReductionPerformed: Observable<{
  62536. min: number;
  62537. max: number;
  62538. }>;
  62539. protected _camera: Camera;
  62540. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62541. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62542. protected _postProcessManager: PostProcessManager;
  62543. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62544. protected _forceFullscreenViewport: boolean;
  62545. /**
  62546. * Creates a min/max reducer
  62547. * @param camera The camera to use for the post processes
  62548. */
  62549. constructor(camera: Camera);
  62550. /**
  62551. * Gets the texture used to read the values from.
  62552. */
  62553. get sourceTexture(): Nullable<RenderTargetTexture>;
  62554. /**
  62555. * Sets the source texture to read the values from.
  62556. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62557. * because in such textures '1' value must not be taken into account to compute the maximum
  62558. * as this value is used to clear the texture.
  62559. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62560. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62561. * @param depthRedux Indicates if the texture is a depth texture or not
  62562. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62563. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62564. */
  62565. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62566. /**
  62567. * Defines the refresh rate of the computation.
  62568. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62569. */
  62570. get refreshRate(): number;
  62571. set refreshRate(value: number);
  62572. protected _activated: boolean;
  62573. /**
  62574. * Gets the activation status of the reducer
  62575. */
  62576. get activated(): boolean;
  62577. /**
  62578. * Activates the reduction computation.
  62579. * When activated, the observers registered in onAfterReductionPerformed are
  62580. * called after the compuation is performed
  62581. */
  62582. activate(): void;
  62583. /**
  62584. * Deactivates the reduction computation.
  62585. */
  62586. deactivate(): void;
  62587. /**
  62588. * Disposes the min/max reducer
  62589. * @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.
  62590. */
  62591. dispose(disposeAll?: boolean): void;
  62592. }
  62593. }
  62594. declare module "babylonjs/Misc/depthReducer" {
  62595. import { Nullable } from "babylonjs/types";
  62596. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62597. import { Camera } from "babylonjs/Cameras/camera";
  62598. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62599. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62600. /**
  62601. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62602. */
  62603. export class DepthReducer extends MinMaxReducer {
  62604. private _depthRenderer;
  62605. private _depthRendererId;
  62606. /**
  62607. * Gets the depth renderer used for the computation.
  62608. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62609. */
  62610. get depthRenderer(): Nullable<DepthRenderer>;
  62611. /**
  62612. * Creates a depth reducer
  62613. * @param camera The camera used to render the depth texture
  62614. */
  62615. constructor(camera: Camera);
  62616. /**
  62617. * Sets the depth renderer to use to generate the depth map
  62618. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62619. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62620. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62621. */
  62622. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62623. /** @hidden */
  62624. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62625. /**
  62626. * Activates the reduction computation.
  62627. * When activated, the observers registered in onAfterReductionPerformed are
  62628. * called after the compuation is performed
  62629. */
  62630. activate(): void;
  62631. /**
  62632. * Deactivates the reduction computation.
  62633. */
  62634. deactivate(): void;
  62635. /**
  62636. * Disposes the depth reducer
  62637. * @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.
  62638. */
  62639. dispose(disposeAll?: boolean): void;
  62640. }
  62641. }
  62642. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62643. import { Nullable } from "babylonjs/types";
  62644. import { Scene } from "babylonjs/scene";
  62645. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62646. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62648. import { Effect } from "babylonjs/Materials/effect";
  62649. import "babylonjs/Shaders/shadowMap.fragment";
  62650. import "babylonjs/Shaders/shadowMap.vertex";
  62651. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62652. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62653. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62654. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62655. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62656. /**
  62657. * A CSM implementation allowing casting shadows on large scenes.
  62658. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62659. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62660. */
  62661. export class CascadedShadowGenerator extends ShadowGenerator {
  62662. private static readonly frustumCornersNDCSpace;
  62663. /**
  62664. * Name of the CSM class
  62665. */
  62666. static CLASSNAME: string;
  62667. /**
  62668. * Defines the default number of cascades used by the CSM.
  62669. */
  62670. static readonly DEFAULT_CASCADES_COUNT: number;
  62671. /**
  62672. * Defines the minimum number of cascades used by the CSM.
  62673. */
  62674. static readonly MIN_CASCADES_COUNT: number;
  62675. /**
  62676. * Defines the maximum number of cascades used by the CSM.
  62677. */
  62678. static readonly MAX_CASCADES_COUNT: number;
  62679. protected _validateFilter(filter: number): number;
  62680. /**
  62681. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62682. */
  62683. penumbraDarkness: number;
  62684. private _numCascades;
  62685. /**
  62686. * Gets or set the number of cascades used by the CSM.
  62687. */
  62688. get numCascades(): number;
  62689. set numCascades(value: number);
  62690. /**
  62691. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62692. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62693. */
  62694. stabilizeCascades: boolean;
  62695. private _freezeShadowCastersBoundingInfo;
  62696. private _freezeShadowCastersBoundingInfoObservable;
  62697. /**
  62698. * Enables or disables the shadow casters bounding info computation.
  62699. * If your shadow casters don't move, you can disable this feature.
  62700. * If it is enabled, the bounding box computation is done every frame.
  62701. */
  62702. get freezeShadowCastersBoundingInfo(): boolean;
  62703. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62704. private _scbiMin;
  62705. private _scbiMax;
  62706. protected _computeShadowCastersBoundingInfo(): void;
  62707. protected _shadowCastersBoundingInfo: BoundingInfo;
  62708. /**
  62709. * Gets or sets the shadow casters bounding info.
  62710. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62711. * so that the system won't overwrite the bounds you provide
  62712. */
  62713. get shadowCastersBoundingInfo(): BoundingInfo;
  62714. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62715. protected _breaksAreDirty: boolean;
  62716. protected _minDistance: number;
  62717. protected _maxDistance: number;
  62718. /**
  62719. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62720. *
  62721. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62722. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62723. * @param min minimal distance for the breaks (default to 0.)
  62724. * @param max maximal distance for the breaks (default to 1.)
  62725. */
  62726. setMinMaxDistance(min: number, max: number): void;
  62727. /** Gets the minimal distance used in the cascade break computation */
  62728. get minDistance(): number;
  62729. /** Gets the maximal distance used in the cascade break computation */
  62730. get maxDistance(): number;
  62731. /**
  62732. * Gets the class name of that object
  62733. * @returns "CascadedShadowGenerator"
  62734. */
  62735. getClassName(): string;
  62736. private _cascadeMinExtents;
  62737. private _cascadeMaxExtents;
  62738. /**
  62739. * Gets a cascade minimum extents
  62740. * @param cascadeIndex index of the cascade
  62741. * @returns the minimum cascade extents
  62742. */
  62743. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62744. /**
  62745. * Gets a cascade maximum extents
  62746. * @param cascadeIndex index of the cascade
  62747. * @returns the maximum cascade extents
  62748. */
  62749. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62750. private _cascades;
  62751. private _currentLayer;
  62752. private _viewSpaceFrustumsZ;
  62753. private _viewMatrices;
  62754. private _projectionMatrices;
  62755. private _transformMatrices;
  62756. private _transformMatricesAsArray;
  62757. private _frustumLengths;
  62758. private _lightSizeUVCorrection;
  62759. private _depthCorrection;
  62760. private _frustumCornersWorldSpace;
  62761. private _frustumCenter;
  62762. private _shadowCameraPos;
  62763. private _shadowMaxZ;
  62764. /**
  62765. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62766. * It defaults to camera.maxZ
  62767. */
  62768. get shadowMaxZ(): number;
  62769. /**
  62770. * Sets the shadow max z distance.
  62771. */
  62772. set shadowMaxZ(value: number);
  62773. protected _debug: boolean;
  62774. /**
  62775. * Gets or sets the debug flag.
  62776. * When enabled, the cascades are materialized by different colors on the screen.
  62777. */
  62778. get debug(): boolean;
  62779. set debug(dbg: boolean);
  62780. private _depthClamp;
  62781. /**
  62782. * Gets or sets the depth clamping value.
  62783. *
  62784. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62785. * to account for the shadow casters far away.
  62786. *
  62787. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62788. */
  62789. get depthClamp(): boolean;
  62790. set depthClamp(value: boolean);
  62791. private _cascadeBlendPercentage;
  62792. /**
  62793. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62794. * It defaults to 0.1 (10% blending).
  62795. */
  62796. get cascadeBlendPercentage(): number;
  62797. set cascadeBlendPercentage(value: number);
  62798. private _lambda;
  62799. /**
  62800. * Gets or set the lambda parameter.
  62801. * This parameter is used to split the camera frustum and create the cascades.
  62802. * 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.
  62803. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62804. */
  62805. get lambda(): number;
  62806. set lambda(value: number);
  62807. /**
  62808. * Gets the view matrix corresponding to a given cascade
  62809. * @param cascadeNum cascade to retrieve the view matrix from
  62810. * @returns the cascade view matrix
  62811. */
  62812. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62813. /**
  62814. * Gets the projection matrix corresponding to a given cascade
  62815. * @param cascadeNum cascade to retrieve the projection matrix from
  62816. * @returns the cascade projection matrix
  62817. */
  62818. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62819. /**
  62820. * Gets the transformation matrix corresponding to a given cascade
  62821. * @param cascadeNum cascade to retrieve the transformation matrix from
  62822. * @returns the cascade transformation matrix
  62823. */
  62824. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62825. private _depthRenderer;
  62826. /**
  62827. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62828. *
  62829. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62830. *
  62831. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62832. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62833. * @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
  62834. */
  62835. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62836. private _depthReducer;
  62837. private _autoCalcDepthBounds;
  62838. /**
  62839. * Gets or sets the autoCalcDepthBounds property.
  62840. *
  62841. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62842. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62843. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62844. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62845. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62846. */
  62847. get autoCalcDepthBounds(): boolean;
  62848. set autoCalcDepthBounds(value: boolean);
  62849. /**
  62850. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62851. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62852. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62853. * for setting the refresh rate on the renderer yourself!
  62854. */
  62855. get autoCalcDepthBoundsRefreshRate(): number;
  62856. set autoCalcDepthBoundsRefreshRate(value: number);
  62857. /**
  62858. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62859. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62860. * you change the camera near/far planes!
  62861. */
  62862. splitFrustum(): void;
  62863. private _splitFrustum;
  62864. private _computeMatrices;
  62865. private _computeFrustumInWorldSpace;
  62866. private _computeCascadeFrustum;
  62867. /**
  62868. * Support test.
  62869. */
  62870. static get IsSupported(): boolean;
  62871. /** @hidden */
  62872. static _SceneComponentInitialization: (scene: Scene) => void;
  62873. /**
  62874. * Creates a Cascaded Shadow Generator object.
  62875. * A ShadowGenerator is the required tool to use the shadows.
  62876. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62877. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62878. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62879. * @param light The directional light object generating the shadows.
  62880. * @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.
  62881. */
  62882. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62883. protected _initializeGenerator(): void;
  62884. protected _createTargetRenderTexture(): void;
  62885. protected _initializeShadowMap(): void;
  62886. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62887. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62888. /**
  62889. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62890. * @param defines Defines of the material we want to update
  62891. * @param lightIndex Index of the light in the enabled light list of the material
  62892. */
  62893. prepareDefines(defines: any, lightIndex: number): void;
  62894. /**
  62895. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62896. * defined in the generator but impacting the effect).
  62897. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62898. * @param effect The effect we are binfing the information for
  62899. */
  62900. bindShadowLight(lightIndex: string, effect: Effect): void;
  62901. /**
  62902. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62903. * (eq to view projection * shadow projection matrices)
  62904. * @returns The transform matrix used to create the shadow map
  62905. */
  62906. getTransformMatrix(): Matrix;
  62907. /**
  62908. * Disposes the ShadowGenerator.
  62909. * Returns nothing.
  62910. */
  62911. dispose(): void;
  62912. /**
  62913. * Serializes the shadow generator setup to a json object.
  62914. * @returns The serialized JSON object
  62915. */
  62916. serialize(): any;
  62917. /**
  62918. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62919. * @param parsedShadowGenerator The JSON object to parse
  62920. * @param scene The scene to create the shadow map for
  62921. * @returns The parsed shadow generator
  62922. */
  62923. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62924. }
  62925. }
  62926. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62927. import { Scene } from "babylonjs/scene";
  62928. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62929. import { AbstractScene } from "babylonjs/abstractScene";
  62930. /**
  62931. * Defines the shadow generator component responsible to manage any shadow generators
  62932. * in a given scene.
  62933. */
  62934. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62935. /**
  62936. * The component name helpfull to identify the component in the list of scene components.
  62937. */
  62938. readonly name: string;
  62939. /**
  62940. * The scene the component belongs to.
  62941. */
  62942. scene: Scene;
  62943. /**
  62944. * Creates a new instance of the component for the given scene
  62945. * @param scene Defines the scene to register the component in
  62946. */
  62947. constructor(scene: Scene);
  62948. /**
  62949. * Registers the component in a given scene
  62950. */
  62951. register(): void;
  62952. /**
  62953. * Rebuilds the elements related to this component in case of
  62954. * context lost for instance.
  62955. */
  62956. rebuild(): void;
  62957. /**
  62958. * Serializes the component data to the specified json object
  62959. * @param serializationObject The object to serialize to
  62960. */
  62961. serialize(serializationObject: any): void;
  62962. /**
  62963. * Adds all the elements from the container to the scene
  62964. * @param container the container holding the elements
  62965. */
  62966. addFromContainer(container: AbstractScene): void;
  62967. /**
  62968. * Removes all the elements in the container from the scene
  62969. * @param container contains the elements to remove
  62970. * @param dispose if the removed element should be disposed (default: false)
  62971. */
  62972. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62973. /**
  62974. * Rebuilds the elements related to this component in case of
  62975. * context lost for instance.
  62976. */
  62977. dispose(): void;
  62978. private _gatherRenderTargets;
  62979. }
  62980. }
  62981. declare module "babylonjs/Lights/Shadows/index" {
  62982. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62983. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62984. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62985. }
  62986. declare module "babylonjs/Lights/pointLight" {
  62987. import { Scene } from "babylonjs/scene";
  62988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62990. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62991. import { Effect } from "babylonjs/Materials/effect";
  62992. /**
  62993. * A point light is a light defined by an unique point in world space.
  62994. * The light is emitted in every direction from this point.
  62995. * A good example of a point light is a standard light bulb.
  62996. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62997. */
  62998. export class PointLight extends ShadowLight {
  62999. private _shadowAngle;
  63000. /**
  63001. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63002. * This specifies what angle the shadow will use to be created.
  63003. *
  63004. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63005. */
  63006. get shadowAngle(): number;
  63007. /**
  63008. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63009. * This specifies what angle the shadow will use to be created.
  63010. *
  63011. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63012. */
  63013. set shadowAngle(value: number);
  63014. /**
  63015. * Gets the direction if it has been set.
  63016. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63017. */
  63018. get direction(): Vector3;
  63019. /**
  63020. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63021. */
  63022. set direction(value: Vector3);
  63023. /**
  63024. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63025. * A PointLight emits the light in every direction.
  63026. * It can cast shadows.
  63027. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63028. * ```javascript
  63029. * var pointLight = new PointLight("pl", camera.position, scene);
  63030. * ```
  63031. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63032. * @param name The light friendly name
  63033. * @param position The position of the point light in the scene
  63034. * @param scene The scene the lights belongs to
  63035. */
  63036. constructor(name: string, position: Vector3, scene: Scene);
  63037. /**
  63038. * Returns the string "PointLight"
  63039. * @returns the class name
  63040. */
  63041. getClassName(): string;
  63042. /**
  63043. * Returns the integer 0.
  63044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63045. */
  63046. getTypeID(): number;
  63047. /**
  63048. * Specifies wether or not the shadowmap should be a cube texture.
  63049. * @returns true if the shadowmap needs to be a cube texture.
  63050. */
  63051. needCube(): boolean;
  63052. /**
  63053. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63054. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63055. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63056. */
  63057. getShadowDirection(faceIndex?: number): Vector3;
  63058. /**
  63059. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63060. * - fov = PI / 2
  63061. * - aspect ratio : 1.0
  63062. * - z-near and far equal to the active camera minZ and maxZ.
  63063. * Returns the PointLight.
  63064. */
  63065. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63066. protected _buildUniformLayout(): void;
  63067. /**
  63068. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63069. * @param effect The effect to update
  63070. * @param lightIndex The index of the light in the effect to update
  63071. * @returns The point light
  63072. */
  63073. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63074. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63075. /**
  63076. * Prepares the list of defines specific to the light type.
  63077. * @param defines the list of defines
  63078. * @param lightIndex defines the index of the light for the effect
  63079. */
  63080. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63081. }
  63082. }
  63083. declare module "babylonjs/Lights/index" {
  63084. export * from "babylonjs/Lights/light";
  63085. export * from "babylonjs/Lights/shadowLight";
  63086. export * from "babylonjs/Lights/Shadows/index";
  63087. export * from "babylonjs/Lights/directionalLight";
  63088. export * from "babylonjs/Lights/hemisphericLight";
  63089. export * from "babylonjs/Lights/pointLight";
  63090. export * from "babylonjs/Lights/spotLight";
  63091. }
  63092. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63093. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63094. /**
  63095. * Header information of HDR texture files.
  63096. */
  63097. export interface HDRInfo {
  63098. /**
  63099. * The height of the texture in pixels.
  63100. */
  63101. height: number;
  63102. /**
  63103. * The width of the texture in pixels.
  63104. */
  63105. width: number;
  63106. /**
  63107. * The index of the beginning of the data in the binary file.
  63108. */
  63109. dataPosition: number;
  63110. }
  63111. /**
  63112. * This groups tools to convert HDR texture to native colors array.
  63113. */
  63114. export class HDRTools {
  63115. private static Ldexp;
  63116. private static Rgbe2float;
  63117. private static readStringLine;
  63118. /**
  63119. * Reads header information from an RGBE texture stored in a native array.
  63120. * More information on this format are available here:
  63121. * https://en.wikipedia.org/wiki/RGBE_image_format
  63122. *
  63123. * @param uint8array The binary file stored in native array.
  63124. * @return The header information.
  63125. */
  63126. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63127. /**
  63128. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63129. * This RGBE texture needs to store the information as a panorama.
  63130. *
  63131. * More information on this format are available here:
  63132. * https://en.wikipedia.org/wiki/RGBE_image_format
  63133. *
  63134. * @param buffer The binary file stored in an array buffer.
  63135. * @param size The expected size of the extracted cubemap.
  63136. * @return The Cube Map information.
  63137. */
  63138. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63139. /**
  63140. * Returns the pixels data extracted from an RGBE texture.
  63141. * This pixels will be stored left to right up to down in the R G B order in one array.
  63142. *
  63143. * More information on this format are available here:
  63144. * https://en.wikipedia.org/wiki/RGBE_image_format
  63145. *
  63146. * @param uint8array The binary file stored in an array buffer.
  63147. * @param hdrInfo The header information of the file.
  63148. * @return The pixels data in RGB right to left up to down order.
  63149. */
  63150. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63151. private static RGBE_ReadPixels_RLE;
  63152. private static RGBE_ReadPixels_NOT_RLE;
  63153. }
  63154. }
  63155. declare module "babylonjs/Materials/effectRenderer" {
  63156. import { Nullable } from "babylonjs/types";
  63157. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63158. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63159. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63160. import { Viewport } from "babylonjs/Maths/math.viewport";
  63161. import { Observable } from "babylonjs/Misc/observable";
  63162. import { Effect } from "babylonjs/Materials/effect";
  63163. import "babylonjs/Shaders/postprocess.vertex";
  63164. /**
  63165. * Effect Render Options
  63166. */
  63167. export interface IEffectRendererOptions {
  63168. /**
  63169. * Defines the vertices positions.
  63170. */
  63171. positions?: number[];
  63172. /**
  63173. * Defines the indices.
  63174. */
  63175. indices?: number[];
  63176. }
  63177. /**
  63178. * Helper class to render one or more effects.
  63179. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63180. */
  63181. export class EffectRenderer {
  63182. private engine;
  63183. private static _DefaultOptions;
  63184. private _vertexBuffers;
  63185. private _indexBuffer;
  63186. private _fullscreenViewport;
  63187. /**
  63188. * Creates an effect renderer
  63189. * @param engine the engine to use for rendering
  63190. * @param options defines the options of the effect renderer
  63191. */
  63192. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63193. /**
  63194. * Sets the current viewport in normalized coordinates 0-1
  63195. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63196. */
  63197. setViewport(viewport?: Viewport): void;
  63198. /**
  63199. * Binds the embedded attributes buffer to the effect.
  63200. * @param effect Defines the effect to bind the attributes for
  63201. */
  63202. bindBuffers(effect: Effect): void;
  63203. /**
  63204. * Sets the current effect wrapper to use during draw.
  63205. * The effect needs to be ready before calling this api.
  63206. * This also sets the default full screen position attribute.
  63207. * @param effectWrapper Defines the effect to draw with
  63208. */
  63209. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63210. /**
  63211. * Restores engine states
  63212. */
  63213. restoreStates(): void;
  63214. /**
  63215. * Draws a full screen quad.
  63216. */
  63217. draw(): void;
  63218. private isRenderTargetTexture;
  63219. /**
  63220. * renders one or more effects to a specified texture
  63221. * @param effectWrapper the effect to renderer
  63222. * @param outputTexture texture to draw to, if null it will render to the screen.
  63223. */
  63224. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63225. /**
  63226. * Disposes of the effect renderer
  63227. */
  63228. dispose(): void;
  63229. }
  63230. /**
  63231. * Options to create an EffectWrapper
  63232. */
  63233. interface EffectWrapperCreationOptions {
  63234. /**
  63235. * Engine to use to create the effect
  63236. */
  63237. engine: ThinEngine;
  63238. /**
  63239. * Fragment shader for the effect
  63240. */
  63241. fragmentShader: string;
  63242. /**
  63243. * Use the shader store instead of direct source code
  63244. */
  63245. useShaderStore?: boolean;
  63246. /**
  63247. * Vertex shader for the effect
  63248. */
  63249. vertexShader?: string;
  63250. /**
  63251. * Attributes to use in the shader
  63252. */
  63253. attributeNames?: Array<string>;
  63254. /**
  63255. * Uniforms to use in the shader
  63256. */
  63257. uniformNames?: Array<string>;
  63258. /**
  63259. * Texture sampler names to use in the shader
  63260. */
  63261. samplerNames?: Array<string>;
  63262. /**
  63263. * Defines to use in the shader
  63264. */
  63265. defines?: Array<string>;
  63266. /**
  63267. * Callback when effect is compiled
  63268. */
  63269. onCompiled?: Nullable<(effect: Effect) => void>;
  63270. /**
  63271. * The friendly name of the effect displayed in Spector.
  63272. */
  63273. name?: string;
  63274. }
  63275. /**
  63276. * Wraps an effect to be used for rendering
  63277. */
  63278. export class EffectWrapper {
  63279. /**
  63280. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63281. */
  63282. onApplyObservable: Observable<{}>;
  63283. /**
  63284. * The underlying effect
  63285. */
  63286. effect: Effect;
  63287. /**
  63288. * Creates an effect to be renderer
  63289. * @param creationOptions options to create the effect
  63290. */
  63291. constructor(creationOptions: EffectWrapperCreationOptions);
  63292. /**
  63293. * Disposes of the effect wrapper
  63294. */
  63295. dispose(): void;
  63296. }
  63297. }
  63298. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63299. /** @hidden */
  63300. export var hdrFilteringVertexShader: {
  63301. name: string;
  63302. shader: string;
  63303. };
  63304. }
  63305. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63306. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63307. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63308. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63309. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63310. /** @hidden */
  63311. export var hdrFilteringPixelShader: {
  63312. name: string;
  63313. shader: string;
  63314. };
  63315. }
  63316. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63318. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63319. import { Nullable } from "babylonjs/types";
  63320. import "babylonjs/Shaders/hdrFiltering.vertex";
  63321. import "babylonjs/Shaders/hdrFiltering.fragment";
  63322. /**
  63323. * Options for texture filtering
  63324. */
  63325. interface IHDRFilteringOptions {
  63326. /**
  63327. * Scales pixel intensity for the input HDR map.
  63328. */
  63329. hdrScale?: number;
  63330. /**
  63331. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63332. */
  63333. quality?: number;
  63334. }
  63335. /**
  63336. * Filters HDR maps to get correct renderings of PBR reflections
  63337. */
  63338. export class HDRFiltering {
  63339. private _engine;
  63340. private _effectRenderer;
  63341. private _effectWrapper;
  63342. private _lodGenerationOffset;
  63343. private _lodGenerationScale;
  63344. /**
  63345. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63346. * you care about baking speed.
  63347. */
  63348. quality: number;
  63349. /**
  63350. * Scales pixel intensity for the input HDR map.
  63351. */
  63352. hdrScale: number;
  63353. /**
  63354. * Instantiates HDR filter for reflection maps
  63355. *
  63356. * @param engine Thin engine
  63357. * @param options Options
  63358. */
  63359. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63360. private _createRenderTarget;
  63361. private _prefilterInternal;
  63362. private _createEffect;
  63363. /**
  63364. * Get a value indicating if the filter is ready to be used
  63365. * @param texture Texture to filter
  63366. * @returns true if the filter is ready
  63367. */
  63368. isReady(texture: BaseTexture): boolean;
  63369. /**
  63370. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63371. * Prefiltering will be invoked at the end of next rendering pass.
  63372. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63373. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63374. * @param texture Texture to filter
  63375. * @param onFinished Callback when filtering is done
  63376. * @return Promise called when prefiltering is done
  63377. */
  63378. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63379. }
  63380. }
  63381. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63382. import { Nullable } from "babylonjs/types";
  63383. import { Scene } from "babylonjs/scene";
  63384. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63386. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63387. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63388. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63389. /**
  63390. * This represents a texture coming from an HDR input.
  63391. *
  63392. * The only supported format is currently panorama picture stored in RGBE format.
  63393. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63394. */
  63395. export class HDRCubeTexture extends BaseTexture {
  63396. private static _facesMapping;
  63397. private _generateHarmonics;
  63398. private _noMipmap;
  63399. private _prefilterOnLoad;
  63400. private _textureMatrix;
  63401. private _size;
  63402. private _onLoad;
  63403. private _onError;
  63404. /**
  63405. * The texture URL.
  63406. */
  63407. url: string;
  63408. protected _isBlocking: boolean;
  63409. /**
  63410. * Sets wether or not the texture is blocking during loading.
  63411. */
  63412. set isBlocking(value: boolean);
  63413. /**
  63414. * Gets wether or not the texture is blocking during loading.
  63415. */
  63416. get isBlocking(): boolean;
  63417. protected _rotationY: number;
  63418. /**
  63419. * Sets texture matrix rotation angle around Y axis in radians.
  63420. */
  63421. set rotationY(value: number);
  63422. /**
  63423. * Gets texture matrix rotation angle around Y axis radians.
  63424. */
  63425. get rotationY(): number;
  63426. /**
  63427. * Gets or sets the center of the bounding box associated with the cube texture
  63428. * It must define where the camera used to render the texture was set
  63429. */
  63430. boundingBoxPosition: Vector3;
  63431. private _boundingBoxSize;
  63432. /**
  63433. * Gets or sets the size of the bounding box associated with the cube texture
  63434. * When defined, the cubemap will switch to local mode
  63435. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63436. * @example https://www.babylonjs-playground.com/#RNASML
  63437. */
  63438. set boundingBoxSize(value: Vector3);
  63439. get boundingBoxSize(): Vector3;
  63440. /**
  63441. * Instantiates an HDRTexture from the following parameters.
  63442. *
  63443. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63444. * @param sceneOrEngine The scene or engine the texture will be used in
  63445. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63446. * @param noMipmap Forces to not generate the mipmap if true
  63447. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63448. * @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)
  63449. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63450. */
  63451. 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>);
  63452. /**
  63453. * Get the current class name of the texture useful for serialization or dynamic coding.
  63454. * @returns "HDRCubeTexture"
  63455. */
  63456. getClassName(): string;
  63457. /**
  63458. * Occurs when the file is raw .hdr file.
  63459. */
  63460. private loadTexture;
  63461. clone(): HDRCubeTexture;
  63462. delayLoad(): void;
  63463. /**
  63464. * Get the texture reflection matrix used to rotate/transform the reflection.
  63465. * @returns the reflection matrix
  63466. */
  63467. getReflectionTextureMatrix(): Matrix;
  63468. /**
  63469. * Set the texture reflection matrix used to rotate/transform the reflection.
  63470. * @param value Define the reflection matrix to set
  63471. */
  63472. setReflectionTextureMatrix(value: Matrix): void;
  63473. /**
  63474. * Parses a JSON representation of an HDR Texture in order to create the texture
  63475. * @param parsedTexture Define the JSON representation
  63476. * @param scene Define the scene the texture should be created in
  63477. * @param rootUrl Define the root url in case we need to load relative dependencies
  63478. * @returns the newly created texture after parsing
  63479. */
  63480. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63481. serialize(): any;
  63482. }
  63483. }
  63484. declare module "babylonjs/Physics/physicsEngine" {
  63485. import { Nullable } from "babylonjs/types";
  63486. import { Vector3 } from "babylonjs/Maths/math.vector";
  63487. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63488. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63489. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63490. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63491. /**
  63492. * Class used to control physics engine
  63493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63494. */
  63495. export class PhysicsEngine implements IPhysicsEngine {
  63496. private _physicsPlugin;
  63497. /**
  63498. * Global value used to control the smallest number supported by the simulation
  63499. */
  63500. static Epsilon: number;
  63501. private _impostors;
  63502. private _joints;
  63503. private _subTimeStep;
  63504. /**
  63505. * Gets the gravity vector used by the simulation
  63506. */
  63507. gravity: Vector3;
  63508. /**
  63509. * Factory used to create the default physics plugin.
  63510. * @returns The default physics plugin
  63511. */
  63512. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63513. /**
  63514. * Creates a new Physics Engine
  63515. * @param gravity defines the gravity vector used by the simulation
  63516. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63517. */
  63518. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63519. /**
  63520. * Sets the gravity vector used by the simulation
  63521. * @param gravity defines the gravity vector to use
  63522. */
  63523. setGravity(gravity: Vector3): void;
  63524. /**
  63525. * Set the time step of the physics engine.
  63526. * Default is 1/60.
  63527. * To slow it down, enter 1/600 for example.
  63528. * To speed it up, 1/30
  63529. * @param newTimeStep defines the new timestep to apply to this world.
  63530. */
  63531. setTimeStep(newTimeStep?: number): void;
  63532. /**
  63533. * Get the time step of the physics engine.
  63534. * @returns the current time step
  63535. */
  63536. getTimeStep(): number;
  63537. /**
  63538. * Set the sub time step of the physics engine.
  63539. * Default is 0 meaning there is no sub steps
  63540. * To increase physics resolution precision, set a small value (like 1 ms)
  63541. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63542. */
  63543. setSubTimeStep(subTimeStep?: number): void;
  63544. /**
  63545. * Get the sub time step of the physics engine.
  63546. * @returns the current sub time step
  63547. */
  63548. getSubTimeStep(): number;
  63549. /**
  63550. * Release all resources
  63551. */
  63552. dispose(): void;
  63553. /**
  63554. * Gets the name of the current physics plugin
  63555. * @returns the name of the plugin
  63556. */
  63557. getPhysicsPluginName(): string;
  63558. /**
  63559. * Adding a new impostor for the impostor tracking.
  63560. * This will be done by the impostor itself.
  63561. * @param impostor the impostor to add
  63562. */
  63563. addImpostor(impostor: PhysicsImpostor): void;
  63564. /**
  63565. * Remove an impostor from the engine.
  63566. * This impostor and its mesh will not longer be updated by the physics engine.
  63567. * @param impostor the impostor to remove
  63568. */
  63569. removeImpostor(impostor: PhysicsImpostor): void;
  63570. /**
  63571. * Add a joint to the physics engine
  63572. * @param mainImpostor defines the main impostor to which the joint is added.
  63573. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63574. * @param joint defines the joint that will connect both impostors.
  63575. */
  63576. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63577. /**
  63578. * Removes a joint from the simulation
  63579. * @param mainImpostor defines the impostor used with the joint
  63580. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63581. * @param joint defines the joint to remove
  63582. */
  63583. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63584. /**
  63585. * Called by the scene. No need to call it.
  63586. * @param delta defines the timespam between frames
  63587. */
  63588. _step(delta: number): void;
  63589. /**
  63590. * Gets the current plugin used to run the simulation
  63591. * @returns current plugin
  63592. */
  63593. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63594. /**
  63595. * Gets the list of physic impostors
  63596. * @returns an array of PhysicsImpostor
  63597. */
  63598. getImpostors(): Array<PhysicsImpostor>;
  63599. /**
  63600. * Gets the impostor for a physics enabled object
  63601. * @param object defines the object impersonated by the impostor
  63602. * @returns the PhysicsImpostor or null if not found
  63603. */
  63604. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63605. /**
  63606. * Gets the impostor for a physics body object
  63607. * @param body defines physics body used by the impostor
  63608. * @returns the PhysicsImpostor or null if not found
  63609. */
  63610. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63611. /**
  63612. * Does a raycast in the physics world
  63613. * @param from when should the ray start?
  63614. * @param to when should the ray end?
  63615. * @returns PhysicsRaycastResult
  63616. */
  63617. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63618. }
  63619. }
  63620. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63621. import { Nullable } from "babylonjs/types";
  63622. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63624. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63625. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63626. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63627. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63628. /** @hidden */
  63629. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63630. private _useDeltaForWorldStep;
  63631. world: any;
  63632. name: string;
  63633. private _physicsMaterials;
  63634. private _fixedTimeStep;
  63635. private _cannonRaycastResult;
  63636. private _raycastResult;
  63637. private _physicsBodysToRemoveAfterStep;
  63638. private _firstFrame;
  63639. BJSCANNON: any;
  63640. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63641. setGravity(gravity: Vector3): void;
  63642. setTimeStep(timeStep: number): void;
  63643. getTimeStep(): number;
  63644. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63645. private _removeMarkedPhysicsBodiesFromWorld;
  63646. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63648. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63649. private _processChildMeshes;
  63650. removePhysicsBody(impostor: PhysicsImpostor): void;
  63651. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63652. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63653. private _addMaterial;
  63654. private _checkWithEpsilon;
  63655. private _createShape;
  63656. private _createHeightmap;
  63657. private _minus90X;
  63658. private _plus90X;
  63659. private _tmpPosition;
  63660. private _tmpDeltaPosition;
  63661. private _tmpUnityRotation;
  63662. private _updatePhysicsBodyTransformation;
  63663. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63664. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63665. isSupported(): boolean;
  63666. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63667. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63668. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63669. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63671. getBodyMass(impostor: PhysicsImpostor): number;
  63672. getBodyFriction(impostor: PhysicsImpostor): number;
  63673. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63674. getBodyRestitution(impostor: PhysicsImpostor): number;
  63675. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63676. sleepBody(impostor: PhysicsImpostor): void;
  63677. wakeUpBody(impostor: PhysicsImpostor): void;
  63678. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63679. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63680. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63681. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63682. getRadius(impostor: PhysicsImpostor): number;
  63683. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63684. dispose(): void;
  63685. private _extendNamespace;
  63686. /**
  63687. * Does a raycast in the physics world
  63688. * @param from when should the ray start?
  63689. * @param to when should the ray end?
  63690. * @returns PhysicsRaycastResult
  63691. */
  63692. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63693. }
  63694. }
  63695. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63696. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63697. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63698. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63700. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63701. import { Nullable } from "babylonjs/types";
  63702. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63703. /** @hidden */
  63704. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63705. private _useDeltaForWorldStep;
  63706. world: any;
  63707. name: string;
  63708. BJSOIMO: any;
  63709. private _raycastResult;
  63710. private _fixedTimeStep;
  63711. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63712. setGravity(gravity: Vector3): void;
  63713. setTimeStep(timeStep: number): void;
  63714. getTimeStep(): number;
  63715. private _tmpImpostorsArray;
  63716. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63717. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63718. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63719. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63720. private _tmpPositionVector;
  63721. removePhysicsBody(impostor: PhysicsImpostor): void;
  63722. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63723. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63724. isSupported(): boolean;
  63725. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63726. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63732. getBodyMass(impostor: PhysicsImpostor): number;
  63733. getBodyFriction(impostor: PhysicsImpostor): number;
  63734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63735. getBodyRestitution(impostor: PhysicsImpostor): number;
  63736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63737. sleepBody(impostor: PhysicsImpostor): void;
  63738. wakeUpBody(impostor: PhysicsImpostor): void;
  63739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63740. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63743. getRadius(impostor: PhysicsImpostor): number;
  63744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63745. dispose(): void;
  63746. /**
  63747. * Does a raycast in the physics world
  63748. * @param from when should the ray start?
  63749. * @param to when should the ray end?
  63750. * @returns PhysicsRaycastResult
  63751. */
  63752. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63753. }
  63754. }
  63755. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63756. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63757. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63758. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63759. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63760. import { Nullable } from "babylonjs/types";
  63761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63762. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63763. /**
  63764. * AmmoJS Physics plugin
  63765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63766. * @see https://github.com/kripken/ammo.js/
  63767. */
  63768. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63769. private _useDeltaForWorldStep;
  63770. /**
  63771. * Reference to the Ammo library
  63772. */
  63773. bjsAMMO: any;
  63774. /**
  63775. * Created ammoJS world which physics bodies are added to
  63776. */
  63777. world: any;
  63778. /**
  63779. * Name of the plugin
  63780. */
  63781. name: string;
  63782. private _timeStep;
  63783. private _fixedTimeStep;
  63784. private _maxSteps;
  63785. private _tmpQuaternion;
  63786. private _tmpAmmoTransform;
  63787. private _tmpAmmoQuaternion;
  63788. private _tmpAmmoConcreteContactResultCallback;
  63789. private _collisionConfiguration;
  63790. private _dispatcher;
  63791. private _overlappingPairCache;
  63792. private _solver;
  63793. private _softBodySolver;
  63794. private _tmpAmmoVectorA;
  63795. private _tmpAmmoVectorB;
  63796. private _tmpAmmoVectorC;
  63797. private _tmpAmmoVectorD;
  63798. private _tmpContactCallbackResult;
  63799. private _tmpAmmoVectorRCA;
  63800. private _tmpAmmoVectorRCB;
  63801. private _raycastResult;
  63802. private static readonly DISABLE_COLLISION_FLAG;
  63803. private static readonly KINEMATIC_FLAG;
  63804. private static readonly DISABLE_DEACTIVATION_FLAG;
  63805. /**
  63806. * Initializes the ammoJS plugin
  63807. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63808. * @param ammoInjection can be used to inject your own ammo reference
  63809. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63810. */
  63811. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63812. /**
  63813. * Sets the gravity of the physics world (m/(s^2))
  63814. * @param gravity Gravity to set
  63815. */
  63816. setGravity(gravity: Vector3): void;
  63817. /**
  63818. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63819. * @param timeStep timestep to use in seconds
  63820. */
  63821. setTimeStep(timeStep: number): void;
  63822. /**
  63823. * 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)
  63824. * @param fixedTimeStep fixedTimeStep to use in seconds
  63825. */
  63826. setFixedTimeStep(fixedTimeStep: number): void;
  63827. /**
  63828. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63829. * @param maxSteps the maximum number of steps by the physics engine per frame
  63830. */
  63831. setMaxSteps(maxSteps: number): void;
  63832. /**
  63833. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63834. * @returns the current timestep in seconds
  63835. */
  63836. getTimeStep(): number;
  63837. /**
  63838. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63839. */
  63840. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63841. private _isImpostorInContact;
  63842. private _isImpostorPairInContact;
  63843. private _stepSimulation;
  63844. /**
  63845. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63846. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63847. * After the step the babylon meshes are set to the position of the physics imposters
  63848. * @param delta amount of time to step forward
  63849. * @param impostors array of imposters to update before/after the step
  63850. */
  63851. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63852. /**
  63853. * Update babylon mesh to match physics world object
  63854. * @param impostor imposter to match
  63855. */
  63856. private _afterSoftStep;
  63857. /**
  63858. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63859. * @param impostor imposter to match
  63860. */
  63861. private _ropeStep;
  63862. /**
  63863. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63864. * @param impostor imposter to match
  63865. */
  63866. private _softbodyOrClothStep;
  63867. private _tmpMatrix;
  63868. /**
  63869. * Applies an impulse on the imposter
  63870. * @param impostor imposter to apply impulse to
  63871. * @param force amount of force to be applied to the imposter
  63872. * @param contactPoint the location to apply the impulse on the imposter
  63873. */
  63874. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63875. /**
  63876. * Applies a force on the imposter
  63877. * @param impostor imposter to apply force
  63878. * @param force amount of force to be applied to the imposter
  63879. * @param contactPoint the location to apply the force on the imposter
  63880. */
  63881. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63882. /**
  63883. * Creates a physics body using the plugin
  63884. * @param impostor the imposter to create the physics body on
  63885. */
  63886. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63887. /**
  63888. * Removes the physics body from the imposter and disposes of the body's memory
  63889. * @param impostor imposter to remove the physics body from
  63890. */
  63891. removePhysicsBody(impostor: PhysicsImpostor): void;
  63892. /**
  63893. * Generates a joint
  63894. * @param impostorJoint the imposter joint to create the joint with
  63895. */
  63896. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63897. /**
  63898. * Removes a joint
  63899. * @param impostorJoint the imposter joint to remove the joint from
  63900. */
  63901. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63902. private _addMeshVerts;
  63903. /**
  63904. * Initialise the soft body vertices to match its object's (mesh) vertices
  63905. * Softbody vertices (nodes) are in world space and to match this
  63906. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63907. * @param impostor to create the softbody for
  63908. */
  63909. private _softVertexData;
  63910. /**
  63911. * Create an impostor's soft body
  63912. * @param impostor to create the softbody for
  63913. */
  63914. private _createSoftbody;
  63915. /**
  63916. * Create cloth for an impostor
  63917. * @param impostor to create the softbody for
  63918. */
  63919. private _createCloth;
  63920. /**
  63921. * Create rope for an impostor
  63922. * @param impostor to create the softbody for
  63923. */
  63924. private _createRope;
  63925. /**
  63926. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63927. * @param impostor to create the custom physics shape for
  63928. */
  63929. private _createCustom;
  63930. private _addHullVerts;
  63931. private _createShape;
  63932. /**
  63933. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63934. * @param impostor imposter containing the physics body and babylon object
  63935. */
  63936. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63937. /**
  63938. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63939. * @param impostor imposter containing the physics body and babylon object
  63940. * @param newPosition new position
  63941. * @param newRotation new rotation
  63942. */
  63943. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63944. /**
  63945. * If this plugin is supported
  63946. * @returns true if its supported
  63947. */
  63948. isSupported(): boolean;
  63949. /**
  63950. * Sets the linear velocity of the physics body
  63951. * @param impostor imposter to set the velocity on
  63952. * @param velocity velocity to set
  63953. */
  63954. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63955. /**
  63956. * Sets the angular velocity of the physics body
  63957. * @param impostor imposter to set the velocity on
  63958. * @param velocity velocity to set
  63959. */
  63960. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63961. /**
  63962. * gets the linear velocity
  63963. * @param impostor imposter to get linear velocity from
  63964. * @returns linear velocity
  63965. */
  63966. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63967. /**
  63968. * gets the angular velocity
  63969. * @param impostor imposter to get angular velocity from
  63970. * @returns angular velocity
  63971. */
  63972. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63973. /**
  63974. * Sets the mass of physics body
  63975. * @param impostor imposter to set the mass on
  63976. * @param mass mass to set
  63977. */
  63978. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63979. /**
  63980. * Gets the mass of the physics body
  63981. * @param impostor imposter to get the mass from
  63982. * @returns mass
  63983. */
  63984. getBodyMass(impostor: PhysicsImpostor): number;
  63985. /**
  63986. * Gets friction of the impostor
  63987. * @param impostor impostor to get friction from
  63988. * @returns friction value
  63989. */
  63990. getBodyFriction(impostor: PhysicsImpostor): number;
  63991. /**
  63992. * Sets friction of the impostor
  63993. * @param impostor impostor to set friction on
  63994. * @param friction friction value
  63995. */
  63996. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63997. /**
  63998. * Gets restitution of the impostor
  63999. * @param impostor impostor to get restitution from
  64000. * @returns restitution value
  64001. */
  64002. getBodyRestitution(impostor: PhysicsImpostor): number;
  64003. /**
  64004. * Sets resitution of the impostor
  64005. * @param impostor impostor to set resitution on
  64006. * @param restitution resitution value
  64007. */
  64008. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64009. /**
  64010. * Gets pressure inside the impostor
  64011. * @param impostor impostor to get pressure from
  64012. * @returns pressure value
  64013. */
  64014. getBodyPressure(impostor: PhysicsImpostor): number;
  64015. /**
  64016. * Sets pressure inside a soft body impostor
  64017. * Cloth and rope must remain 0 pressure
  64018. * @param impostor impostor to set pressure on
  64019. * @param pressure pressure value
  64020. */
  64021. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64022. /**
  64023. * Gets stiffness of the impostor
  64024. * @param impostor impostor to get stiffness from
  64025. * @returns pressure value
  64026. */
  64027. getBodyStiffness(impostor: PhysicsImpostor): number;
  64028. /**
  64029. * Sets stiffness of the impostor
  64030. * @param impostor impostor to set stiffness on
  64031. * @param stiffness stiffness value from 0 to 1
  64032. */
  64033. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64034. /**
  64035. * Gets velocityIterations of the impostor
  64036. * @param impostor impostor to get velocity iterations from
  64037. * @returns velocityIterations value
  64038. */
  64039. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64040. /**
  64041. * Sets velocityIterations of the impostor
  64042. * @param impostor impostor to set velocity iterations on
  64043. * @param velocityIterations velocityIterations value
  64044. */
  64045. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64046. /**
  64047. * Gets positionIterations of the impostor
  64048. * @param impostor impostor to get position iterations from
  64049. * @returns positionIterations value
  64050. */
  64051. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64052. /**
  64053. * Sets positionIterations of the impostor
  64054. * @param impostor impostor to set position on
  64055. * @param positionIterations positionIterations value
  64056. */
  64057. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64058. /**
  64059. * Append an anchor to a cloth object
  64060. * @param impostor is the cloth impostor to add anchor to
  64061. * @param otherImpostor is the rigid impostor to anchor to
  64062. * @param width ratio across width from 0 to 1
  64063. * @param height ratio up height from 0 to 1
  64064. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64065. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64066. */
  64067. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64068. /**
  64069. * Append an hook to a rope object
  64070. * @param impostor is the rope impostor to add hook to
  64071. * @param otherImpostor is the rigid impostor to hook to
  64072. * @param length ratio along the rope from 0 to 1
  64073. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64074. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64075. */
  64076. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64077. /**
  64078. * Sleeps the physics body and stops it from being active
  64079. * @param impostor impostor to sleep
  64080. */
  64081. sleepBody(impostor: PhysicsImpostor): void;
  64082. /**
  64083. * Activates the physics body
  64084. * @param impostor impostor to activate
  64085. */
  64086. wakeUpBody(impostor: PhysicsImpostor): void;
  64087. /**
  64088. * Updates the distance parameters of the joint
  64089. * @param joint joint to update
  64090. * @param maxDistance maximum distance of the joint
  64091. * @param minDistance minimum distance of the joint
  64092. */
  64093. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64094. /**
  64095. * Sets a motor on the joint
  64096. * @param joint joint to set motor on
  64097. * @param speed speed of the motor
  64098. * @param maxForce maximum force of the motor
  64099. * @param motorIndex index of the motor
  64100. */
  64101. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64102. /**
  64103. * Sets the motors limit
  64104. * @param joint joint to set limit on
  64105. * @param upperLimit upper limit
  64106. * @param lowerLimit lower limit
  64107. */
  64108. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64109. /**
  64110. * Syncs the position and rotation of a mesh with the impostor
  64111. * @param mesh mesh to sync
  64112. * @param impostor impostor to update the mesh with
  64113. */
  64114. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64115. /**
  64116. * Gets the radius of the impostor
  64117. * @param impostor impostor to get radius from
  64118. * @returns the radius
  64119. */
  64120. getRadius(impostor: PhysicsImpostor): number;
  64121. /**
  64122. * Gets the box size of the impostor
  64123. * @param impostor impostor to get box size from
  64124. * @param result the resulting box size
  64125. */
  64126. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64127. /**
  64128. * Disposes of the impostor
  64129. */
  64130. dispose(): void;
  64131. /**
  64132. * Does a raycast in the physics world
  64133. * @param from when should the ray start?
  64134. * @param to when should the ray end?
  64135. * @returns PhysicsRaycastResult
  64136. */
  64137. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64138. }
  64139. }
  64140. declare module "babylonjs/Probes/reflectionProbe" {
  64141. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64142. import { Vector3 } from "babylonjs/Maths/math.vector";
  64143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64144. import { Nullable } from "babylonjs/types";
  64145. import { Scene } from "babylonjs/scene";
  64146. module "babylonjs/abstractScene" {
  64147. interface AbstractScene {
  64148. /**
  64149. * The list of reflection probes added to the scene
  64150. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64151. */
  64152. reflectionProbes: Array<ReflectionProbe>;
  64153. /**
  64154. * Removes the given reflection probe from this scene.
  64155. * @param toRemove The reflection probe to remove
  64156. * @returns The index of the removed reflection probe
  64157. */
  64158. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64159. /**
  64160. * Adds the given reflection probe to this scene.
  64161. * @param newReflectionProbe The reflection probe to add
  64162. */
  64163. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64164. }
  64165. }
  64166. /**
  64167. * Class used to generate realtime reflection / refraction cube textures
  64168. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64169. */
  64170. export class ReflectionProbe {
  64171. /** defines the name of the probe */
  64172. name: string;
  64173. private _scene;
  64174. private _renderTargetTexture;
  64175. private _projectionMatrix;
  64176. private _viewMatrix;
  64177. private _target;
  64178. private _add;
  64179. private _attachedMesh;
  64180. private _invertYAxis;
  64181. /** Gets or sets probe position (center of the cube map) */
  64182. position: Vector3;
  64183. /**
  64184. * Creates a new reflection probe
  64185. * @param name defines the name of the probe
  64186. * @param size defines the texture resolution (for each face)
  64187. * @param scene defines the hosting scene
  64188. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64189. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64190. */
  64191. constructor(
  64192. /** defines the name of the probe */
  64193. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64194. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64195. get samples(): number;
  64196. set samples(value: number);
  64197. /** Gets or sets the refresh rate to use (on every frame by default) */
  64198. get refreshRate(): number;
  64199. set refreshRate(value: number);
  64200. /**
  64201. * Gets the hosting scene
  64202. * @returns a Scene
  64203. */
  64204. getScene(): Scene;
  64205. /** Gets the internal CubeTexture used to render to */
  64206. get cubeTexture(): RenderTargetTexture;
  64207. /** Gets the list of meshes to render */
  64208. get renderList(): Nullable<AbstractMesh[]>;
  64209. /**
  64210. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64211. * @param mesh defines the mesh to attach to
  64212. */
  64213. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64214. /**
  64215. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64216. * @param renderingGroupId The rendering group id corresponding to its index
  64217. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64218. */
  64219. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64220. /**
  64221. * Clean all associated resources
  64222. */
  64223. dispose(): void;
  64224. /**
  64225. * Converts the reflection probe information to a readable string for debug purpose.
  64226. * @param fullDetails Supports for multiple levels of logging within scene loading
  64227. * @returns the human readable reflection probe info
  64228. */
  64229. toString(fullDetails?: boolean): string;
  64230. /**
  64231. * Get the class name of the relfection probe.
  64232. * @returns "ReflectionProbe"
  64233. */
  64234. getClassName(): string;
  64235. /**
  64236. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64237. * @returns The JSON representation of the texture
  64238. */
  64239. serialize(): any;
  64240. /**
  64241. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64242. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64243. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64244. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64245. * @returns The parsed reflection probe if successful
  64246. */
  64247. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64248. }
  64249. }
  64250. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64251. /** @hidden */
  64252. export var _BabylonLoaderRegistered: boolean;
  64253. /**
  64254. * Helps setting up some configuration for the babylon file loader.
  64255. */
  64256. export class BabylonFileLoaderConfiguration {
  64257. /**
  64258. * The loader does not allow injecting custom physix engine into the plugins.
  64259. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64260. * So you could set this variable to your engine import to make it work.
  64261. */
  64262. static LoaderInjectedPhysicsEngine: any;
  64263. }
  64264. }
  64265. declare module "babylonjs/Loading/Plugins/index" {
  64266. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64267. }
  64268. declare module "babylonjs/Loading/index" {
  64269. export * from "babylonjs/Loading/loadingScreen";
  64270. export * from "babylonjs/Loading/Plugins/index";
  64271. export * from "babylonjs/Loading/sceneLoader";
  64272. export * from "babylonjs/Loading/sceneLoaderFlags";
  64273. }
  64274. declare module "babylonjs/Materials/Background/index" {
  64275. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64276. }
  64277. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64278. import { Scene } from "babylonjs/scene";
  64279. import { Color3 } from "babylonjs/Maths/math.color";
  64280. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64281. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64282. /**
  64283. * The Physically based simple base material of BJS.
  64284. *
  64285. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64286. * It is used as the base class for both the specGloss and metalRough conventions.
  64287. */
  64288. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64289. /**
  64290. * Number of Simultaneous lights allowed on the material.
  64291. */
  64292. maxSimultaneousLights: number;
  64293. /**
  64294. * If sets to true, disables all the lights affecting the material.
  64295. */
  64296. disableLighting: boolean;
  64297. /**
  64298. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64299. */
  64300. environmentTexture: BaseTexture;
  64301. /**
  64302. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64303. */
  64304. invertNormalMapX: boolean;
  64305. /**
  64306. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64307. */
  64308. invertNormalMapY: boolean;
  64309. /**
  64310. * Normal map used in the model.
  64311. */
  64312. normalTexture: BaseTexture;
  64313. /**
  64314. * Emissivie color used to self-illuminate the model.
  64315. */
  64316. emissiveColor: Color3;
  64317. /**
  64318. * Emissivie texture used to self-illuminate the model.
  64319. */
  64320. emissiveTexture: BaseTexture;
  64321. /**
  64322. * Occlusion Channel Strenght.
  64323. */
  64324. occlusionStrength: number;
  64325. /**
  64326. * Occlusion Texture of the material (adding extra occlusion effects).
  64327. */
  64328. occlusionTexture: BaseTexture;
  64329. /**
  64330. * Defines the alpha limits in alpha test mode.
  64331. */
  64332. alphaCutOff: number;
  64333. /**
  64334. * Gets the current double sided mode.
  64335. */
  64336. get doubleSided(): boolean;
  64337. /**
  64338. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64339. */
  64340. set doubleSided(value: boolean);
  64341. /**
  64342. * Stores the pre-calculated light information of a mesh in a texture.
  64343. */
  64344. lightmapTexture: BaseTexture;
  64345. /**
  64346. * If true, the light map contains occlusion information instead of lighting info.
  64347. */
  64348. useLightmapAsShadowmap: boolean;
  64349. /**
  64350. * Instantiates a new PBRMaterial instance.
  64351. *
  64352. * @param name The material name
  64353. * @param scene The scene the material will be use in.
  64354. */
  64355. constructor(name: string, scene: Scene);
  64356. getClassName(): string;
  64357. }
  64358. }
  64359. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64360. import { Scene } from "babylonjs/scene";
  64361. import { Color3 } from "babylonjs/Maths/math.color";
  64362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64363. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64364. /**
  64365. * The PBR material of BJS following the metal roughness convention.
  64366. *
  64367. * This fits to the PBR convention in the GLTF definition:
  64368. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64369. */
  64370. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64371. /**
  64372. * The base color has two different interpretations depending on the value of metalness.
  64373. * When the material is a metal, the base color is the specific measured reflectance value
  64374. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64375. * of the material.
  64376. */
  64377. baseColor: Color3;
  64378. /**
  64379. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64380. * well as opacity information in the alpha channel.
  64381. */
  64382. baseTexture: BaseTexture;
  64383. /**
  64384. * Specifies the metallic scalar value of the material.
  64385. * Can also be used to scale the metalness values of the metallic texture.
  64386. */
  64387. metallic: number;
  64388. /**
  64389. * Specifies the roughness scalar value of the material.
  64390. * Can also be used to scale the roughness values of the metallic texture.
  64391. */
  64392. roughness: number;
  64393. /**
  64394. * Texture containing both the metallic value in the B channel and the
  64395. * roughness value in the G channel to keep better precision.
  64396. */
  64397. metallicRoughnessTexture: BaseTexture;
  64398. /**
  64399. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64400. *
  64401. * @param name The material name
  64402. * @param scene The scene the material will be use in.
  64403. */
  64404. constructor(name: string, scene: Scene);
  64405. /**
  64406. * Return the currrent class name of the material.
  64407. */
  64408. getClassName(): string;
  64409. /**
  64410. * Makes a duplicate of the current material.
  64411. * @param name - name to use for the new material.
  64412. */
  64413. clone(name: string): PBRMetallicRoughnessMaterial;
  64414. /**
  64415. * Serialize the material to a parsable JSON object.
  64416. */
  64417. serialize(): any;
  64418. /**
  64419. * Parses a JSON object correponding to the serialize function.
  64420. */
  64421. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64422. }
  64423. }
  64424. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64425. import { Scene } from "babylonjs/scene";
  64426. import { Color3 } from "babylonjs/Maths/math.color";
  64427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64428. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64429. /**
  64430. * The PBR material of BJS following the specular glossiness convention.
  64431. *
  64432. * This fits to the PBR convention in the GLTF definition:
  64433. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64434. */
  64435. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64436. /**
  64437. * Specifies the diffuse color of the material.
  64438. */
  64439. diffuseColor: Color3;
  64440. /**
  64441. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64442. * channel.
  64443. */
  64444. diffuseTexture: BaseTexture;
  64445. /**
  64446. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64447. */
  64448. specularColor: Color3;
  64449. /**
  64450. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64451. */
  64452. glossiness: number;
  64453. /**
  64454. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64455. */
  64456. specularGlossinessTexture: BaseTexture;
  64457. /**
  64458. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64459. *
  64460. * @param name The material name
  64461. * @param scene The scene the material will be use in.
  64462. */
  64463. constructor(name: string, scene: Scene);
  64464. /**
  64465. * Return the currrent class name of the material.
  64466. */
  64467. getClassName(): string;
  64468. /**
  64469. * Makes a duplicate of the current material.
  64470. * @param name - name to use for the new material.
  64471. */
  64472. clone(name: string): PBRSpecularGlossinessMaterial;
  64473. /**
  64474. * Serialize the material to a parsable JSON object.
  64475. */
  64476. serialize(): any;
  64477. /**
  64478. * Parses a JSON object correponding to the serialize function.
  64479. */
  64480. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64481. }
  64482. }
  64483. declare module "babylonjs/Materials/PBR/index" {
  64484. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64485. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64486. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64487. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64488. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64489. }
  64490. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64491. import { Nullable } from "babylonjs/types";
  64492. import { Scene } from "babylonjs/scene";
  64493. import { Matrix } from "babylonjs/Maths/math.vector";
  64494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64495. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64496. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64497. /**
  64498. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64499. * It can help converting any input color in a desired output one. This can then be used to create effects
  64500. * from sepia, black and white to sixties or futuristic rendering...
  64501. *
  64502. * The only supported format is currently 3dl.
  64503. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64504. */
  64505. export class ColorGradingTexture extends BaseTexture {
  64506. /**
  64507. * The texture URL.
  64508. */
  64509. url: string;
  64510. /**
  64511. * Empty line regex stored for GC.
  64512. */
  64513. private static _noneEmptyLineRegex;
  64514. private _textureMatrix;
  64515. private _onLoad;
  64516. /**
  64517. * Instantiates a ColorGradingTexture from the following parameters.
  64518. *
  64519. * @param url The location of the color gradind data (currently only supporting 3dl)
  64520. * @param sceneOrEngine The scene or engine the texture will be used in
  64521. * @param onLoad defines a callback triggered when the texture has been loaded
  64522. */
  64523. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64524. /**
  64525. * Fires the onload event from the constructor if requested.
  64526. */
  64527. private _triggerOnLoad;
  64528. /**
  64529. * Returns the texture matrix used in most of the material.
  64530. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64531. */
  64532. getTextureMatrix(): Matrix;
  64533. /**
  64534. * Occurs when the file being loaded is a .3dl LUT file.
  64535. */
  64536. private load3dlTexture;
  64537. /**
  64538. * Starts the loading process of the texture.
  64539. */
  64540. private loadTexture;
  64541. /**
  64542. * Clones the color gradind texture.
  64543. */
  64544. clone(): ColorGradingTexture;
  64545. /**
  64546. * Called during delayed load for textures.
  64547. */
  64548. delayLoad(): void;
  64549. /**
  64550. * Parses a color grading texture serialized by Babylon.
  64551. * @param parsedTexture The texture information being parsedTexture
  64552. * @param scene The scene to load the texture in
  64553. * @param rootUrl The root url of the data assets to load
  64554. * @return A color gradind texture
  64555. */
  64556. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64557. /**
  64558. * Serializes the LUT texture to json format.
  64559. */
  64560. serialize(): any;
  64561. }
  64562. }
  64563. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64564. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64565. import { Scene } from "babylonjs/scene";
  64566. import { Nullable } from "babylonjs/types";
  64567. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64568. /**
  64569. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64570. */
  64571. export class EquiRectangularCubeTexture extends BaseTexture {
  64572. /** The six faces of the cube. */
  64573. private static _FacesMapping;
  64574. private _noMipmap;
  64575. private _onLoad;
  64576. private _onError;
  64577. /** The size of the cubemap. */
  64578. private _size;
  64579. /** The buffer of the image. */
  64580. private _buffer;
  64581. /** The width of the input image. */
  64582. private _width;
  64583. /** The height of the input image. */
  64584. private _height;
  64585. /** The URL to the image. */
  64586. url: string;
  64587. /**
  64588. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64589. * @param url The location of the image
  64590. * @param scene The scene the texture will be used in
  64591. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64592. * @param noMipmap Forces to not generate the mipmap if true
  64593. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64594. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64595. * @param onLoad — defines a callback called when texture is loaded
  64596. * @param onError — defines a callback called if there is an error
  64597. */
  64598. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64599. /**
  64600. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64601. */
  64602. private loadImage;
  64603. /**
  64604. * Convert the image buffer into a cubemap and create a CubeTexture.
  64605. */
  64606. private loadTexture;
  64607. /**
  64608. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64609. * @param buffer The ArrayBuffer that should be converted.
  64610. * @returns The buffer as Float32Array.
  64611. */
  64612. private getFloat32ArrayFromArrayBuffer;
  64613. /**
  64614. * Get the current class name of the texture useful for serialization or dynamic coding.
  64615. * @returns "EquiRectangularCubeTexture"
  64616. */
  64617. getClassName(): string;
  64618. /**
  64619. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64620. * @returns A clone of the current EquiRectangularCubeTexture.
  64621. */
  64622. clone(): EquiRectangularCubeTexture;
  64623. }
  64624. }
  64625. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64626. import { Nullable } from "babylonjs/types";
  64627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64628. import { Matrix } from "babylonjs/Maths/math.vector";
  64629. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64630. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64631. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64632. import { Scene } from "babylonjs/scene";
  64633. /**
  64634. * Defines the options related to the creation of an HtmlElementTexture
  64635. */
  64636. export interface IHtmlElementTextureOptions {
  64637. /**
  64638. * Defines wether mip maps should be created or not.
  64639. */
  64640. generateMipMaps?: boolean;
  64641. /**
  64642. * Defines the sampling mode of the texture.
  64643. */
  64644. samplingMode?: number;
  64645. /**
  64646. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64647. */
  64648. engine: Nullable<ThinEngine>;
  64649. /**
  64650. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64651. */
  64652. scene: Nullable<Scene>;
  64653. }
  64654. /**
  64655. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64656. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64657. * is automatically managed.
  64658. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64659. * in your application.
  64660. *
  64661. * As the update is not automatic, you need to call them manually.
  64662. */
  64663. export class HtmlElementTexture extends BaseTexture {
  64664. /**
  64665. * The texture URL.
  64666. */
  64667. element: HTMLVideoElement | HTMLCanvasElement;
  64668. private static readonly DefaultOptions;
  64669. private _textureMatrix;
  64670. private _isVideo;
  64671. private _generateMipMaps;
  64672. private _samplingMode;
  64673. /**
  64674. * Instantiates a HtmlElementTexture from the following parameters.
  64675. *
  64676. * @param name Defines the name of the texture
  64677. * @param element Defines the video or canvas the texture is filled with
  64678. * @param options Defines the other none mandatory texture creation options
  64679. */
  64680. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64681. private _createInternalTexture;
  64682. /**
  64683. * Returns the texture matrix used in most of the material.
  64684. */
  64685. getTextureMatrix(): Matrix;
  64686. /**
  64687. * Updates the content of the texture.
  64688. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64689. */
  64690. update(invertY?: Nullable<boolean>): void;
  64691. }
  64692. }
  64693. declare module "babylonjs/Misc/tga" {
  64694. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64695. /**
  64696. * Based on jsTGALoader - Javascript loader for TGA file
  64697. * By Vincent Thibault
  64698. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64699. */
  64700. export class TGATools {
  64701. private static _TYPE_INDEXED;
  64702. private static _TYPE_RGB;
  64703. private static _TYPE_GREY;
  64704. private static _TYPE_RLE_INDEXED;
  64705. private static _TYPE_RLE_RGB;
  64706. private static _TYPE_RLE_GREY;
  64707. private static _ORIGIN_MASK;
  64708. private static _ORIGIN_SHIFT;
  64709. private static _ORIGIN_BL;
  64710. private static _ORIGIN_BR;
  64711. private static _ORIGIN_UL;
  64712. private static _ORIGIN_UR;
  64713. /**
  64714. * Gets the header of a TGA file
  64715. * @param data defines the TGA data
  64716. * @returns the header
  64717. */
  64718. static GetTGAHeader(data: Uint8Array): any;
  64719. /**
  64720. * Uploads TGA content to a Babylon Texture
  64721. * @hidden
  64722. */
  64723. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64724. /** @hidden */
  64725. 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;
  64726. /** @hidden */
  64727. 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;
  64728. /** @hidden */
  64729. 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;
  64730. /** @hidden */
  64731. 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;
  64732. /** @hidden */
  64733. 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;
  64734. /** @hidden */
  64735. 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;
  64736. }
  64737. }
  64738. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64739. import { Nullable } from "babylonjs/types";
  64740. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64741. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64742. /**
  64743. * Implementation of the TGA Texture Loader.
  64744. * @hidden
  64745. */
  64746. export class _TGATextureLoader implements IInternalTextureLoader {
  64747. /**
  64748. * Defines wether the loader supports cascade loading the different faces.
  64749. */
  64750. readonly supportCascades: boolean;
  64751. /**
  64752. * This returns if the loader support the current file information.
  64753. * @param extension defines the file extension of the file being loaded
  64754. * @returns true if the loader can load the specified file
  64755. */
  64756. canLoad(extension: string): boolean;
  64757. /**
  64758. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64759. * @param data contains the texture data
  64760. * @param texture defines the BabylonJS internal texture
  64761. * @param createPolynomials will be true if polynomials have been requested
  64762. * @param onLoad defines the callback to trigger once the texture is ready
  64763. * @param onError defines the callback to trigger in case of error
  64764. */
  64765. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64766. /**
  64767. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64768. * @param data contains the texture data
  64769. * @param texture defines the BabylonJS internal texture
  64770. * @param callback defines the method to call once ready to upload
  64771. */
  64772. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64773. }
  64774. }
  64775. declare module "babylonjs/Misc/basis" {
  64776. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64777. /**
  64778. * Info about the .basis files
  64779. */
  64780. class BasisFileInfo {
  64781. /**
  64782. * If the file has alpha
  64783. */
  64784. hasAlpha: boolean;
  64785. /**
  64786. * Info about each image of the basis file
  64787. */
  64788. images: Array<{
  64789. levels: Array<{
  64790. width: number;
  64791. height: number;
  64792. transcodedPixels: ArrayBufferView;
  64793. }>;
  64794. }>;
  64795. }
  64796. /**
  64797. * Result of transcoding a basis file
  64798. */
  64799. class TranscodeResult {
  64800. /**
  64801. * Info about the .basis file
  64802. */
  64803. fileInfo: BasisFileInfo;
  64804. /**
  64805. * Format to use when loading the file
  64806. */
  64807. format: number;
  64808. }
  64809. /**
  64810. * Configuration options for the Basis transcoder
  64811. */
  64812. export class BasisTranscodeConfiguration {
  64813. /**
  64814. * Supported compression formats used to determine the supported output format of the transcoder
  64815. */
  64816. supportedCompressionFormats?: {
  64817. /**
  64818. * etc1 compression format
  64819. */
  64820. etc1?: boolean;
  64821. /**
  64822. * s3tc compression format
  64823. */
  64824. s3tc?: boolean;
  64825. /**
  64826. * pvrtc compression format
  64827. */
  64828. pvrtc?: boolean;
  64829. /**
  64830. * etc2 compression format
  64831. */
  64832. etc2?: boolean;
  64833. };
  64834. /**
  64835. * If mipmap levels should be loaded for transcoded images (Default: true)
  64836. */
  64837. loadMipmapLevels?: boolean;
  64838. /**
  64839. * Index of a single image to load (Default: all images)
  64840. */
  64841. loadSingleImage?: number;
  64842. }
  64843. /**
  64844. * Used to load .Basis files
  64845. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64846. */
  64847. export class BasisTools {
  64848. private static _IgnoreSupportedFormats;
  64849. /**
  64850. * URL to use when loading the basis transcoder
  64851. */
  64852. static JSModuleURL: string;
  64853. /**
  64854. * URL to use when loading the wasm module for the transcoder
  64855. */
  64856. static WasmModuleURL: string;
  64857. /**
  64858. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64859. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64860. * @returns internal format corresponding to the Basis format
  64861. */
  64862. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64863. private static _WorkerPromise;
  64864. private static _Worker;
  64865. private static _actionId;
  64866. private static _CreateWorkerAsync;
  64867. /**
  64868. * Transcodes a loaded image file to compressed pixel data
  64869. * @param data image data to transcode
  64870. * @param config configuration options for the transcoding
  64871. * @returns a promise resulting in the transcoded image
  64872. */
  64873. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64874. /**
  64875. * Loads a texture from the transcode result
  64876. * @param texture texture load to
  64877. * @param transcodeResult the result of transcoding the basis file to load from
  64878. */
  64879. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64880. }
  64881. }
  64882. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64883. import { Nullable } from "babylonjs/types";
  64884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64885. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64886. /**
  64887. * Loader for .basis file format
  64888. */
  64889. export class _BasisTextureLoader implements IInternalTextureLoader {
  64890. /**
  64891. * Defines whether the loader supports cascade loading the different faces.
  64892. */
  64893. readonly supportCascades: boolean;
  64894. /**
  64895. * This returns if the loader support the current file information.
  64896. * @param extension defines the file extension of the file being loaded
  64897. * @returns true if the loader can load the specified file
  64898. */
  64899. canLoad(extension: string): boolean;
  64900. /**
  64901. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64902. * @param data contains the texture data
  64903. * @param texture defines the BabylonJS internal texture
  64904. * @param createPolynomials will be true if polynomials have been requested
  64905. * @param onLoad defines the callback to trigger once the texture is ready
  64906. * @param onError defines the callback to trigger in case of error
  64907. */
  64908. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64909. /**
  64910. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64911. * @param data contains the texture data
  64912. * @param texture defines the BabylonJS internal texture
  64913. * @param callback defines the method to call once ready to upload
  64914. */
  64915. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64916. }
  64917. }
  64918. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64919. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64920. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64921. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64922. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64923. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64924. }
  64925. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64926. import { Vector2 } from "babylonjs/Maths/math.vector";
  64927. /**
  64928. * Defines the basic options interface of a TexturePacker Frame
  64929. */
  64930. export interface ITexturePackerFrame {
  64931. /**
  64932. * The frame ID
  64933. */
  64934. id: number;
  64935. /**
  64936. * The frames Scale
  64937. */
  64938. scale: Vector2;
  64939. /**
  64940. * The Frames offset
  64941. */
  64942. offset: Vector2;
  64943. }
  64944. /**
  64945. * This is a support class for frame Data on texture packer sets.
  64946. */
  64947. export class TexturePackerFrame implements ITexturePackerFrame {
  64948. /**
  64949. * The frame ID
  64950. */
  64951. id: number;
  64952. /**
  64953. * The frames Scale
  64954. */
  64955. scale: Vector2;
  64956. /**
  64957. * The Frames offset
  64958. */
  64959. offset: Vector2;
  64960. /**
  64961. * Initializes a texture package frame.
  64962. * @param id The numerical frame identifier
  64963. * @param scale Scalar Vector2 for UV frame
  64964. * @param offset Vector2 for the frame position in UV units.
  64965. * @returns TexturePackerFrame
  64966. */
  64967. constructor(id: number, scale: Vector2, offset: Vector2);
  64968. }
  64969. }
  64970. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64972. import { Scene } from "babylonjs/scene";
  64973. import { Nullable } from "babylonjs/types";
  64974. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64975. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64976. /**
  64977. * Defines the basic options interface of a TexturePacker
  64978. */
  64979. export interface ITexturePackerOptions {
  64980. /**
  64981. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64982. */
  64983. map?: string[];
  64984. /**
  64985. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64986. */
  64987. uvsIn?: string;
  64988. /**
  64989. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64990. */
  64991. uvsOut?: string;
  64992. /**
  64993. * number representing the layout style. Defaults to LAYOUT_STRIP
  64994. */
  64995. layout?: number;
  64996. /**
  64997. * number of columns if using custom column count layout(2). This defaults to 4.
  64998. */
  64999. colnum?: number;
  65000. /**
  65001. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65002. */
  65003. updateInputMeshes?: boolean;
  65004. /**
  65005. * boolean flag to dispose all the source textures. Defaults to true.
  65006. */
  65007. disposeSources?: boolean;
  65008. /**
  65009. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65010. */
  65011. fillBlanks?: boolean;
  65012. /**
  65013. * string value representing the context fill style color. Defaults to 'black'.
  65014. */
  65015. customFillColor?: string;
  65016. /**
  65017. * Width and Height Value of each Frame in the TexturePacker Sets
  65018. */
  65019. frameSize?: number;
  65020. /**
  65021. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65022. */
  65023. paddingRatio?: number;
  65024. /**
  65025. * Number that declares the fill method for the padding gutter.
  65026. */
  65027. paddingMode?: number;
  65028. /**
  65029. * If in SUBUV_COLOR padding mode what color to use.
  65030. */
  65031. paddingColor?: Color3 | Color4;
  65032. }
  65033. /**
  65034. * Defines the basic interface of a TexturePacker JSON File
  65035. */
  65036. export interface ITexturePackerJSON {
  65037. /**
  65038. * The frame ID
  65039. */
  65040. name: string;
  65041. /**
  65042. * The base64 channel data
  65043. */
  65044. sets: any;
  65045. /**
  65046. * The options of the Packer
  65047. */
  65048. options: ITexturePackerOptions;
  65049. /**
  65050. * The frame data of the Packer
  65051. */
  65052. frames: Array<number>;
  65053. }
  65054. /**
  65055. * This is a support class that generates a series of packed texture sets.
  65056. * @see https://doc.babylonjs.com/babylon101/materials
  65057. */
  65058. export class TexturePacker {
  65059. /** Packer Layout Constant 0 */
  65060. static readonly LAYOUT_STRIP: number;
  65061. /** Packer Layout Constant 1 */
  65062. static readonly LAYOUT_POWER2: number;
  65063. /** Packer Layout Constant 2 */
  65064. static readonly LAYOUT_COLNUM: number;
  65065. /** Packer Layout Constant 0 */
  65066. static readonly SUBUV_WRAP: number;
  65067. /** Packer Layout Constant 1 */
  65068. static readonly SUBUV_EXTEND: number;
  65069. /** Packer Layout Constant 2 */
  65070. static readonly SUBUV_COLOR: number;
  65071. /** The Name of the Texture Package */
  65072. name: string;
  65073. /** The scene scope of the TexturePacker */
  65074. scene: Scene;
  65075. /** The Meshes to target */
  65076. meshes: AbstractMesh[];
  65077. /** Arguments passed with the Constructor */
  65078. options: ITexturePackerOptions;
  65079. /** The promise that is started upon initialization */
  65080. promise: Nullable<Promise<TexturePacker | string>>;
  65081. /** The Container object for the channel sets that are generated */
  65082. sets: object;
  65083. /** The Container array for the frames that are generated */
  65084. frames: TexturePackerFrame[];
  65085. /** The expected number of textures the system is parsing. */
  65086. private _expecting;
  65087. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65088. private _paddingValue;
  65089. /**
  65090. * Initializes a texture package series from an array of meshes or a single mesh.
  65091. * @param name The name of the package
  65092. * @param meshes The target meshes to compose the package from
  65093. * @param options The arguments that texture packer should follow while building.
  65094. * @param scene The scene which the textures are scoped to.
  65095. * @returns TexturePacker
  65096. */
  65097. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65098. /**
  65099. * Starts the package process
  65100. * @param resolve The promises resolution function
  65101. * @returns TexturePacker
  65102. */
  65103. private _createFrames;
  65104. /**
  65105. * Calculates the Size of the Channel Sets
  65106. * @returns Vector2
  65107. */
  65108. private _calculateSize;
  65109. /**
  65110. * Calculates the UV data for the frames.
  65111. * @param baseSize the base frameSize
  65112. * @param padding the base frame padding
  65113. * @param dtSize size of the Dynamic Texture for that channel
  65114. * @param dtUnits is 1/dtSize
  65115. * @param update flag to update the input meshes
  65116. */
  65117. private _calculateMeshUVFrames;
  65118. /**
  65119. * Calculates the frames Offset.
  65120. * @param index of the frame
  65121. * @returns Vector2
  65122. */
  65123. private _getFrameOffset;
  65124. /**
  65125. * Updates a Mesh to the frame data
  65126. * @param mesh that is the target
  65127. * @param frameID or the frame index
  65128. */
  65129. private _updateMeshUV;
  65130. /**
  65131. * Updates a Meshes materials to use the texture packer channels
  65132. * @param m is the mesh to target
  65133. * @param force all channels on the packer to be set.
  65134. */
  65135. private _updateTextureReferences;
  65136. /**
  65137. * Public method to set a Mesh to a frame
  65138. * @param m that is the target
  65139. * @param frameID or the frame index
  65140. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65141. */
  65142. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65143. /**
  65144. * Starts the async promise to compile the texture packer.
  65145. * @returns Promise<void>
  65146. */
  65147. processAsync(): Promise<void>;
  65148. /**
  65149. * Disposes all textures associated with this packer
  65150. */
  65151. dispose(): void;
  65152. /**
  65153. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65154. * @param imageType is the image type to use.
  65155. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65156. */
  65157. download(imageType?: string, quality?: number): void;
  65158. /**
  65159. * Public method to load a texturePacker JSON file.
  65160. * @param data of the JSON file in string format.
  65161. */
  65162. updateFromJSON(data: string): void;
  65163. }
  65164. }
  65165. declare module "babylonjs/Materials/Textures/Packer/index" {
  65166. export * from "babylonjs/Materials/Textures/Packer/packer";
  65167. export * from "babylonjs/Materials/Textures/Packer/frame";
  65168. }
  65169. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65170. import { Scene } from "babylonjs/scene";
  65171. import { Texture } from "babylonjs/Materials/Textures/texture";
  65172. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65173. /**
  65174. * 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.
  65175. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65176. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65177. */
  65178. export class CustomProceduralTexture extends ProceduralTexture {
  65179. private _animate;
  65180. private _time;
  65181. private _config;
  65182. private _texturePath;
  65183. /**
  65184. * Instantiates a new Custom Procedural Texture.
  65185. * 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.
  65186. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65187. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65188. * @param name Define the name of the texture
  65189. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65190. * @param size Define the size of the texture to create
  65191. * @param scene Define the scene the texture belongs to
  65192. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65193. * @param generateMipMaps Define if the texture should creates mip maps or not
  65194. */
  65195. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65196. private _loadJson;
  65197. /**
  65198. * Is the texture ready to be used ? (rendered at least once)
  65199. * @returns true if ready, otherwise, false.
  65200. */
  65201. isReady(): boolean;
  65202. /**
  65203. * Render the texture to its associated render target.
  65204. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65205. */
  65206. render(useCameraPostProcess?: boolean): void;
  65207. /**
  65208. * Update the list of dependant textures samplers in the shader.
  65209. */
  65210. updateTextures(): void;
  65211. /**
  65212. * Update the uniform values of the procedural texture in the shader.
  65213. */
  65214. updateShaderUniforms(): void;
  65215. /**
  65216. * Define if the texture animates or not.
  65217. */
  65218. get animate(): boolean;
  65219. set animate(value: boolean);
  65220. }
  65221. }
  65222. declare module "babylonjs/Shaders/noise.fragment" {
  65223. /** @hidden */
  65224. export var noisePixelShader: {
  65225. name: string;
  65226. shader: string;
  65227. };
  65228. }
  65229. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65230. import { Nullable } from "babylonjs/types";
  65231. import { Scene } from "babylonjs/scene";
  65232. import { Texture } from "babylonjs/Materials/Textures/texture";
  65233. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65234. import "babylonjs/Shaders/noise.fragment";
  65235. /**
  65236. * Class used to generate noise procedural textures
  65237. */
  65238. export class NoiseProceduralTexture extends ProceduralTexture {
  65239. /** Gets or sets the start time (default is 0) */
  65240. time: number;
  65241. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65242. brightness: number;
  65243. /** Defines the number of octaves to process */
  65244. octaves: number;
  65245. /** Defines the level of persistence (0.8 by default) */
  65246. persistence: number;
  65247. /** Gets or sets animation speed factor (default is 1) */
  65248. animationSpeedFactor: number;
  65249. /**
  65250. * Creates a new NoiseProceduralTexture
  65251. * @param name defines the name fo the texture
  65252. * @param size defines the size of the texture (default is 256)
  65253. * @param scene defines the hosting scene
  65254. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65255. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65256. */
  65257. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65258. private _updateShaderUniforms;
  65259. protected _getDefines(): string;
  65260. /** Generate the current state of the procedural texture */
  65261. render(useCameraPostProcess?: boolean): void;
  65262. /**
  65263. * Serializes this noise procedural texture
  65264. * @returns a serialized noise procedural texture object
  65265. */
  65266. serialize(): any;
  65267. /**
  65268. * Clone the texture.
  65269. * @returns the cloned texture
  65270. */
  65271. clone(): NoiseProceduralTexture;
  65272. /**
  65273. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65274. * @param parsedTexture defines parsed texture data
  65275. * @param scene defines the current scene
  65276. * @param rootUrl defines the root URL containing noise procedural texture information
  65277. * @returns a parsed NoiseProceduralTexture
  65278. */
  65279. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65280. }
  65281. }
  65282. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65283. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65284. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65285. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65286. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65287. }
  65288. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65289. import { Nullable } from "babylonjs/types";
  65290. import { Scene } from "babylonjs/scene";
  65291. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65292. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65293. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65294. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65295. /**
  65296. * Raw cube texture where the raw buffers are passed in
  65297. */
  65298. export class RawCubeTexture extends CubeTexture {
  65299. /**
  65300. * Creates a cube texture where the raw buffers are passed in.
  65301. * @param scene defines the scene the texture is attached to
  65302. * @param data defines the array of data to use to create each face
  65303. * @param size defines the size of the textures
  65304. * @param format defines the format of the data
  65305. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65306. * @param generateMipMaps defines if the engine should generate the mip levels
  65307. * @param invertY defines if data must be stored with Y axis inverted
  65308. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65309. * @param compression defines the compression used (null by default)
  65310. */
  65311. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65312. /**
  65313. * Updates the raw cube texture.
  65314. * @param data defines the data to store
  65315. * @param format defines the data format
  65316. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65317. * @param invertY defines if data must be stored with Y axis inverted
  65318. * @param compression defines the compression used (null by default)
  65319. * @param level defines which level of the texture to update
  65320. */
  65321. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65322. /**
  65323. * Updates a raw cube texture with RGBD encoded data.
  65324. * @param data defines the array of data [mipmap][face] to use to create each face
  65325. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65328. * @returns a promsie that resolves when the operation is complete
  65329. */
  65330. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65331. /**
  65332. * Clones the raw cube texture.
  65333. * @return a new cube texture
  65334. */
  65335. clone(): CubeTexture;
  65336. /** @hidden */
  65337. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65338. }
  65339. }
  65340. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65341. import { Scene } from "babylonjs/scene";
  65342. import { Texture } from "babylonjs/Materials/Textures/texture";
  65343. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65344. /**
  65345. * Class used to store 2D array textures containing user data
  65346. */
  65347. export class RawTexture2DArray extends Texture {
  65348. /** Gets or sets the texture format to use */
  65349. format: number;
  65350. /**
  65351. * Create a new RawTexture2DArray
  65352. * @param data defines the data of the texture
  65353. * @param width defines the width of the texture
  65354. * @param height defines the height of the texture
  65355. * @param depth defines the number of layers of the texture
  65356. * @param format defines the texture format to use
  65357. * @param scene defines the hosting scene
  65358. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65359. * @param invertY defines if texture must be stored with Y axis inverted
  65360. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65361. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65362. */
  65363. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65364. /** Gets or sets the texture format to use */
  65365. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65366. /**
  65367. * Update the texture with new data
  65368. * @param data defines the data to store in the texture
  65369. */
  65370. update(data: ArrayBufferView): void;
  65371. }
  65372. }
  65373. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65374. import { Scene } from "babylonjs/scene";
  65375. import { Texture } from "babylonjs/Materials/Textures/texture";
  65376. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65377. /**
  65378. * Class used to store 3D textures containing user data
  65379. */
  65380. export class RawTexture3D extends Texture {
  65381. /** Gets or sets the texture format to use */
  65382. format: number;
  65383. /**
  65384. * Create a new RawTexture3D
  65385. * @param data defines the data of the texture
  65386. * @param width defines the width of the texture
  65387. * @param height defines the height of the texture
  65388. * @param depth defines the depth of the texture
  65389. * @param format defines the texture format to use
  65390. * @param scene defines the hosting scene
  65391. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65392. * @param invertY defines if texture must be stored with Y axis inverted
  65393. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65394. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65395. */
  65396. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65397. /** Gets or sets the texture format to use */
  65398. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65399. /**
  65400. * Update the texture with new data
  65401. * @param data defines the data to store in the texture
  65402. */
  65403. update(data: ArrayBufferView): void;
  65404. }
  65405. }
  65406. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65407. import { Scene } from "babylonjs/scene";
  65408. import { Plane } from "babylonjs/Maths/math.plane";
  65409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65410. /**
  65411. * Creates a refraction texture used by refraction channel of the standard material.
  65412. * It is like a mirror but to see through a material.
  65413. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65414. */
  65415. export class RefractionTexture extends RenderTargetTexture {
  65416. /**
  65417. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65418. * 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.
  65419. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65420. */
  65421. refractionPlane: Plane;
  65422. /**
  65423. * Define how deep under the surface we should see.
  65424. */
  65425. depth: number;
  65426. /**
  65427. * Creates a refraction texture used by refraction channel of the standard material.
  65428. * It is like a mirror but to see through a material.
  65429. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65430. * @param name Define the texture name
  65431. * @param size Define the size of the underlying texture
  65432. * @param scene Define the scene the refraction belongs to
  65433. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65434. */
  65435. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65436. /**
  65437. * Clone the refraction texture.
  65438. * @returns the cloned texture
  65439. */
  65440. clone(): RefractionTexture;
  65441. /**
  65442. * Serialize the texture to a JSON representation you could use in Parse later on
  65443. * @returns the serialized JSON representation
  65444. */
  65445. serialize(): any;
  65446. }
  65447. }
  65448. declare module "babylonjs/Materials/Textures/index" {
  65449. export * from "babylonjs/Materials/Textures/baseTexture";
  65450. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65451. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65452. export * from "babylonjs/Materials/Textures/cubeTexture";
  65453. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65454. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65455. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65456. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65457. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65458. export * from "babylonjs/Materials/Textures/internalTexture";
  65459. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65460. export * from "babylonjs/Materials/Textures/Loaders/index";
  65461. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65462. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65463. export * from "babylonjs/Materials/Textures/Packer/index";
  65464. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65465. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65466. export * from "babylonjs/Materials/Textures/rawTexture";
  65467. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65468. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65469. export * from "babylonjs/Materials/Textures/refractionTexture";
  65470. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65471. export * from "babylonjs/Materials/Textures/texture";
  65472. export * from "babylonjs/Materials/Textures/videoTexture";
  65473. }
  65474. declare module "babylonjs/Materials/Node/Enums/index" {
  65475. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65476. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65477. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65478. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65479. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65480. }
  65481. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65485. import { Mesh } from "babylonjs/Meshes/mesh";
  65486. import { Effect } from "babylonjs/Materials/effect";
  65487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65488. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65489. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65490. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65491. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65492. /**
  65493. * Block used to add support for vertex skinning (bones)
  65494. */
  65495. export class BonesBlock extends NodeMaterialBlock {
  65496. /**
  65497. * Creates a new BonesBlock
  65498. * @param name defines the block name
  65499. */
  65500. constructor(name: string);
  65501. /**
  65502. * Initialize the block and prepare the context for build
  65503. * @param state defines the state that will be used for the build
  65504. */
  65505. initialize(state: NodeMaterialBuildState): void;
  65506. /**
  65507. * Gets the current class name
  65508. * @returns the class name
  65509. */
  65510. getClassName(): string;
  65511. /**
  65512. * Gets the matrix indices input component
  65513. */
  65514. get matricesIndices(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the matrix weights input component
  65517. */
  65518. get matricesWeights(): NodeMaterialConnectionPoint;
  65519. /**
  65520. * Gets the extra matrix indices input component
  65521. */
  65522. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65523. /**
  65524. * Gets the extra matrix weights input component
  65525. */
  65526. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65527. /**
  65528. * Gets the world input component
  65529. */
  65530. get world(): NodeMaterialConnectionPoint;
  65531. /**
  65532. * Gets the output component
  65533. */
  65534. get output(): NodeMaterialConnectionPoint;
  65535. autoConfigure(material: NodeMaterial): void;
  65536. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65539. protected _buildBlock(state: NodeMaterialBuildState): this;
  65540. }
  65541. }
  65542. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65547. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65548. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65549. /**
  65550. * Block used to add support for instances
  65551. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65552. */
  65553. export class InstancesBlock extends NodeMaterialBlock {
  65554. /**
  65555. * Creates a new InstancesBlock
  65556. * @param name defines the block name
  65557. */
  65558. constructor(name: string);
  65559. /**
  65560. * Gets the current class name
  65561. * @returns the class name
  65562. */
  65563. getClassName(): string;
  65564. /**
  65565. * Gets the first world row input component
  65566. */
  65567. get world0(): NodeMaterialConnectionPoint;
  65568. /**
  65569. * Gets the second world row input component
  65570. */
  65571. get world1(): NodeMaterialConnectionPoint;
  65572. /**
  65573. * Gets the third world row input component
  65574. */
  65575. get world2(): NodeMaterialConnectionPoint;
  65576. /**
  65577. * Gets the forth world row input component
  65578. */
  65579. get world3(): NodeMaterialConnectionPoint;
  65580. /**
  65581. * Gets the world input component
  65582. */
  65583. get world(): NodeMaterialConnectionPoint;
  65584. /**
  65585. * Gets the output component
  65586. */
  65587. get output(): NodeMaterialConnectionPoint;
  65588. /**
  65589. * Gets the isntanceID component
  65590. */
  65591. get instanceID(): NodeMaterialConnectionPoint;
  65592. autoConfigure(material: NodeMaterial): void;
  65593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65594. protected _buildBlock(state: NodeMaterialBuildState): this;
  65595. }
  65596. }
  65597. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65602. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65603. import { Effect } from "babylonjs/Materials/effect";
  65604. import { Mesh } from "babylonjs/Meshes/mesh";
  65605. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65606. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65607. /**
  65608. * Block used to add morph targets support to vertex shader
  65609. */
  65610. export class MorphTargetsBlock extends NodeMaterialBlock {
  65611. private _repeatableContentAnchor;
  65612. /**
  65613. * Create a new MorphTargetsBlock
  65614. * @param name defines the block name
  65615. */
  65616. constructor(name: string);
  65617. /**
  65618. * Gets the current class name
  65619. * @returns the class name
  65620. */
  65621. getClassName(): string;
  65622. /**
  65623. * Gets the position input component
  65624. */
  65625. get position(): NodeMaterialConnectionPoint;
  65626. /**
  65627. * Gets the normal input component
  65628. */
  65629. get normal(): NodeMaterialConnectionPoint;
  65630. /**
  65631. * Gets the tangent input component
  65632. */
  65633. get tangent(): NodeMaterialConnectionPoint;
  65634. /**
  65635. * Gets the tangent input component
  65636. */
  65637. get uv(): NodeMaterialConnectionPoint;
  65638. /**
  65639. * Gets the position output component
  65640. */
  65641. get positionOutput(): NodeMaterialConnectionPoint;
  65642. /**
  65643. * Gets the normal output component
  65644. */
  65645. get normalOutput(): NodeMaterialConnectionPoint;
  65646. /**
  65647. * Gets the tangent output component
  65648. */
  65649. get tangentOutput(): NodeMaterialConnectionPoint;
  65650. /**
  65651. * Gets the tangent output component
  65652. */
  65653. get uvOutput(): NodeMaterialConnectionPoint;
  65654. initialize(state: NodeMaterialBuildState): void;
  65655. autoConfigure(material: NodeMaterial): void;
  65656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65658. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65659. protected _buildBlock(state: NodeMaterialBuildState): this;
  65660. }
  65661. }
  65662. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65666. import { Nullable } from "babylonjs/types";
  65667. import { Scene } from "babylonjs/scene";
  65668. import { Effect } from "babylonjs/Materials/effect";
  65669. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65670. import { Mesh } from "babylonjs/Meshes/mesh";
  65671. import { Light } from "babylonjs/Lights/light";
  65672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65673. /**
  65674. * Block used to get data information from a light
  65675. */
  65676. export class LightInformationBlock extends NodeMaterialBlock {
  65677. private _lightDataUniformName;
  65678. private _lightColorUniformName;
  65679. private _lightTypeDefineName;
  65680. /**
  65681. * Gets or sets the light associated with this block
  65682. */
  65683. light: Nullable<Light>;
  65684. /**
  65685. * Creates a new LightInformationBlock
  65686. * @param name defines the block name
  65687. */
  65688. constructor(name: string);
  65689. /**
  65690. * Gets the current class name
  65691. * @returns the class name
  65692. */
  65693. getClassName(): string;
  65694. /**
  65695. * Gets the world position input component
  65696. */
  65697. get worldPosition(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the direction output component
  65700. */
  65701. get direction(): NodeMaterialConnectionPoint;
  65702. /**
  65703. * Gets the direction output component
  65704. */
  65705. get color(): NodeMaterialConnectionPoint;
  65706. /**
  65707. * Gets the direction output component
  65708. */
  65709. get intensity(): NodeMaterialConnectionPoint;
  65710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65712. protected _buildBlock(state: NodeMaterialBuildState): this;
  65713. serialize(): any;
  65714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65715. }
  65716. }
  65717. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65718. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65719. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65720. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65721. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65722. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65723. }
  65724. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65729. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65730. import { Effect } from "babylonjs/Materials/effect";
  65731. import { Mesh } from "babylonjs/Meshes/mesh";
  65732. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65733. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65734. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65735. /**
  65736. * Block used to add image processing support to fragment shader
  65737. */
  65738. export class ImageProcessingBlock extends NodeMaterialBlock {
  65739. /**
  65740. * Create a new ImageProcessingBlock
  65741. * @param name defines the block name
  65742. */
  65743. constructor(name: string);
  65744. /**
  65745. * Gets the current class name
  65746. * @returns the class name
  65747. */
  65748. getClassName(): string;
  65749. /**
  65750. * Gets the color input component
  65751. */
  65752. get color(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Gets the output component
  65755. */
  65756. get output(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Initialize the block and prepare the context for build
  65759. * @param state defines the state that will be used for the build
  65760. */
  65761. initialize(state: NodeMaterialBuildState): void;
  65762. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65764. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65765. protected _buildBlock(state: NodeMaterialBuildState): this;
  65766. }
  65767. }
  65768. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65772. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65774. import { Effect } from "babylonjs/Materials/effect";
  65775. import { Mesh } from "babylonjs/Meshes/mesh";
  65776. import { Scene } from "babylonjs/scene";
  65777. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65778. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65779. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65780. /**
  65781. * Block used to pertub normals based on a normal map
  65782. */
  65783. export class PerturbNormalBlock extends NodeMaterialBlock {
  65784. private _tangentSpaceParameterName;
  65785. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65786. invertX: boolean;
  65787. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65788. invertY: boolean;
  65789. /**
  65790. * Create a new PerturbNormalBlock
  65791. * @param name defines the block name
  65792. */
  65793. constructor(name: string);
  65794. /**
  65795. * Gets the current class name
  65796. * @returns the class name
  65797. */
  65798. getClassName(): string;
  65799. /**
  65800. * Gets the world position input component
  65801. */
  65802. get worldPosition(): NodeMaterialConnectionPoint;
  65803. /**
  65804. * Gets the world normal input component
  65805. */
  65806. get worldNormal(): NodeMaterialConnectionPoint;
  65807. /**
  65808. * Gets the world tangent input component
  65809. */
  65810. get worldTangent(): NodeMaterialConnectionPoint;
  65811. /**
  65812. * Gets the uv input component
  65813. */
  65814. get uv(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the normal map color input component
  65817. */
  65818. get normalMapColor(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the strength input component
  65821. */
  65822. get strength(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the output component
  65825. */
  65826. get output(): NodeMaterialConnectionPoint;
  65827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65829. autoConfigure(material: NodeMaterial): void;
  65830. protected _buildBlock(state: NodeMaterialBuildState): this;
  65831. protected _dumpPropertiesCode(): string;
  65832. serialize(): any;
  65833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65834. }
  65835. }
  65836. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65840. /**
  65841. * Block used to discard a pixel if a value is smaller than a cutoff
  65842. */
  65843. export class DiscardBlock extends NodeMaterialBlock {
  65844. /**
  65845. * Create a new DiscardBlock
  65846. * @param name defines the block name
  65847. */
  65848. constructor(name: string);
  65849. /**
  65850. * Gets the current class name
  65851. * @returns the class name
  65852. */
  65853. getClassName(): string;
  65854. /**
  65855. * Gets the color input component
  65856. */
  65857. get value(): NodeMaterialConnectionPoint;
  65858. /**
  65859. * Gets the cutoff input component
  65860. */
  65861. get cutoff(): NodeMaterialConnectionPoint;
  65862. protected _buildBlock(state: NodeMaterialBuildState): this;
  65863. }
  65864. }
  65865. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65869. /**
  65870. * Block used to test if the fragment shader is front facing
  65871. */
  65872. export class FrontFacingBlock extends NodeMaterialBlock {
  65873. /**
  65874. * Creates a new FrontFacingBlock
  65875. * @param name defines the block name
  65876. */
  65877. constructor(name: string);
  65878. /**
  65879. * Gets the current class name
  65880. * @returns the class name
  65881. */
  65882. getClassName(): string;
  65883. /**
  65884. * Gets the output component
  65885. */
  65886. get output(): NodeMaterialConnectionPoint;
  65887. protected _buildBlock(state: NodeMaterialBuildState): this;
  65888. }
  65889. }
  65890. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65891. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65892. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65894. /**
  65895. * Block used to get the derivative value on x and y of a given input
  65896. */
  65897. export class DerivativeBlock extends NodeMaterialBlock {
  65898. /**
  65899. * Create a new DerivativeBlock
  65900. * @param name defines the block name
  65901. */
  65902. constructor(name: string);
  65903. /**
  65904. * Gets the current class name
  65905. * @returns the class name
  65906. */
  65907. getClassName(): string;
  65908. /**
  65909. * Gets the input component
  65910. */
  65911. get input(): NodeMaterialConnectionPoint;
  65912. /**
  65913. * Gets the derivative output on x
  65914. */
  65915. get dx(): NodeMaterialConnectionPoint;
  65916. /**
  65917. * Gets the derivative output on y
  65918. */
  65919. get dy(): NodeMaterialConnectionPoint;
  65920. protected _buildBlock(state: NodeMaterialBuildState): this;
  65921. }
  65922. }
  65923. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65927. /**
  65928. * Block used to make gl_FragCoord available
  65929. */
  65930. export class FragCoordBlock extends NodeMaterialBlock {
  65931. /**
  65932. * Creates a new FragCoordBlock
  65933. * @param name defines the block name
  65934. */
  65935. constructor(name: string);
  65936. /**
  65937. * Gets the current class name
  65938. * @returns the class name
  65939. */
  65940. getClassName(): string;
  65941. /**
  65942. * Gets the xy component
  65943. */
  65944. get xy(): NodeMaterialConnectionPoint;
  65945. /**
  65946. * Gets the xyz component
  65947. */
  65948. get xyz(): NodeMaterialConnectionPoint;
  65949. /**
  65950. * Gets the xyzw component
  65951. */
  65952. get xyzw(): NodeMaterialConnectionPoint;
  65953. /**
  65954. * Gets the x component
  65955. */
  65956. get x(): NodeMaterialConnectionPoint;
  65957. /**
  65958. * Gets the y component
  65959. */
  65960. get y(): NodeMaterialConnectionPoint;
  65961. /**
  65962. * Gets the z component
  65963. */
  65964. get z(): NodeMaterialConnectionPoint;
  65965. /**
  65966. * Gets the w component
  65967. */
  65968. get output(): NodeMaterialConnectionPoint;
  65969. protected writeOutputs(state: NodeMaterialBuildState): string;
  65970. protected _buildBlock(state: NodeMaterialBuildState): this;
  65971. }
  65972. }
  65973. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65976. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65977. import { Effect } from "babylonjs/Materials/effect";
  65978. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65979. import { Mesh } from "babylonjs/Meshes/mesh";
  65980. /**
  65981. * Block used to get the screen sizes
  65982. */
  65983. export class ScreenSizeBlock extends NodeMaterialBlock {
  65984. private _varName;
  65985. private _scene;
  65986. /**
  65987. * Creates a new ScreenSizeBlock
  65988. * @param name defines the block name
  65989. */
  65990. constructor(name: string);
  65991. /**
  65992. * Gets the current class name
  65993. * @returns the class name
  65994. */
  65995. getClassName(): string;
  65996. /**
  65997. * Gets the xy component
  65998. */
  65999. get xy(): NodeMaterialConnectionPoint;
  66000. /**
  66001. * Gets the x component
  66002. */
  66003. get x(): NodeMaterialConnectionPoint;
  66004. /**
  66005. * Gets the y component
  66006. */
  66007. get y(): NodeMaterialConnectionPoint;
  66008. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66009. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66010. protected _buildBlock(state: NodeMaterialBuildState): this;
  66011. }
  66012. }
  66013. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66014. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66015. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66016. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66017. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66018. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66019. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66020. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66021. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66022. }
  66023. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66026. import { Mesh } from "babylonjs/Meshes/mesh";
  66027. import { Effect } from "babylonjs/Materials/effect";
  66028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66030. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66032. /**
  66033. * Block used to add support for scene fog
  66034. */
  66035. export class FogBlock extends NodeMaterialBlock {
  66036. private _fogDistanceName;
  66037. private _fogParameters;
  66038. /**
  66039. * Create a new FogBlock
  66040. * @param name defines the block name
  66041. */
  66042. constructor(name: string);
  66043. /**
  66044. * Gets the current class name
  66045. * @returns the class name
  66046. */
  66047. getClassName(): string;
  66048. /**
  66049. * Gets the world position input component
  66050. */
  66051. get worldPosition(): NodeMaterialConnectionPoint;
  66052. /**
  66053. * Gets the view input component
  66054. */
  66055. get view(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the color input component
  66058. */
  66059. get input(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the fog color input component
  66062. */
  66063. get fogColor(): NodeMaterialConnectionPoint;
  66064. /**
  66065. * Gets the output component
  66066. */
  66067. get output(): NodeMaterialConnectionPoint;
  66068. autoConfigure(material: NodeMaterial): void;
  66069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66071. protected _buildBlock(state: NodeMaterialBuildState): this;
  66072. }
  66073. }
  66074. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66079. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66080. import { Effect } from "babylonjs/Materials/effect";
  66081. import { Mesh } from "babylonjs/Meshes/mesh";
  66082. import { Light } from "babylonjs/Lights/light";
  66083. import { Nullable } from "babylonjs/types";
  66084. import { Scene } from "babylonjs/scene";
  66085. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66086. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66087. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66089. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66090. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66091. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66092. /**
  66093. * Block used to add light in the fragment shader
  66094. */
  66095. export class LightBlock extends NodeMaterialBlock {
  66096. private _lightId;
  66097. /**
  66098. * Gets or sets the light associated with this block
  66099. */
  66100. light: Nullable<Light>;
  66101. /**
  66102. * Create a new LightBlock
  66103. * @param name defines the block name
  66104. */
  66105. constructor(name: string);
  66106. /**
  66107. * Gets the current class name
  66108. * @returns the class name
  66109. */
  66110. getClassName(): string;
  66111. /**
  66112. * Gets the world position input component
  66113. */
  66114. get worldPosition(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the world normal input component
  66117. */
  66118. get worldNormal(): NodeMaterialConnectionPoint;
  66119. /**
  66120. * Gets the camera (or eye) position component
  66121. */
  66122. get cameraPosition(): NodeMaterialConnectionPoint;
  66123. /**
  66124. * Gets the glossiness component
  66125. */
  66126. get glossiness(): NodeMaterialConnectionPoint;
  66127. /**
  66128. * Gets the glossinness power component
  66129. */
  66130. get glossPower(): NodeMaterialConnectionPoint;
  66131. /**
  66132. * Gets the diffuse color component
  66133. */
  66134. get diffuseColor(): NodeMaterialConnectionPoint;
  66135. /**
  66136. * Gets the specular color component
  66137. */
  66138. get specularColor(): NodeMaterialConnectionPoint;
  66139. /**
  66140. * Gets the diffuse output component
  66141. */
  66142. get diffuseOutput(): NodeMaterialConnectionPoint;
  66143. /**
  66144. * Gets the specular output component
  66145. */
  66146. get specularOutput(): NodeMaterialConnectionPoint;
  66147. /**
  66148. * Gets the shadow output component
  66149. */
  66150. get shadow(): NodeMaterialConnectionPoint;
  66151. autoConfigure(material: NodeMaterial): void;
  66152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66153. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66154. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66155. private _injectVertexCode;
  66156. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66157. serialize(): any;
  66158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66159. }
  66160. }
  66161. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66164. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66165. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66166. /**
  66167. * Block used to read a reflection texture from a sampler
  66168. */
  66169. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66170. /**
  66171. * Create a new ReflectionTextureBlock
  66172. * @param name defines the block name
  66173. */
  66174. constructor(name: string);
  66175. /**
  66176. * Gets the current class name
  66177. * @returns the class name
  66178. */
  66179. getClassName(): string;
  66180. /**
  66181. * Gets the world position input component
  66182. */
  66183. get position(): NodeMaterialConnectionPoint;
  66184. /**
  66185. * Gets the world position input component
  66186. */
  66187. get worldPosition(): NodeMaterialConnectionPoint;
  66188. /**
  66189. * Gets the world normal input component
  66190. */
  66191. get worldNormal(): NodeMaterialConnectionPoint;
  66192. /**
  66193. * Gets the world input component
  66194. */
  66195. get world(): NodeMaterialConnectionPoint;
  66196. /**
  66197. * Gets the camera (or eye) position component
  66198. */
  66199. get cameraPosition(): NodeMaterialConnectionPoint;
  66200. /**
  66201. * Gets the view input component
  66202. */
  66203. get view(): NodeMaterialConnectionPoint;
  66204. /**
  66205. * Gets the rgb output component
  66206. */
  66207. get rgb(): NodeMaterialConnectionPoint;
  66208. /**
  66209. * Gets the rgba output component
  66210. */
  66211. get rgba(): NodeMaterialConnectionPoint;
  66212. /**
  66213. * Gets the r output component
  66214. */
  66215. get r(): NodeMaterialConnectionPoint;
  66216. /**
  66217. * Gets the g output component
  66218. */
  66219. get g(): NodeMaterialConnectionPoint;
  66220. /**
  66221. * Gets the b output component
  66222. */
  66223. get b(): NodeMaterialConnectionPoint;
  66224. /**
  66225. * Gets the a output component
  66226. */
  66227. get a(): NodeMaterialConnectionPoint;
  66228. autoConfigure(material: NodeMaterial): void;
  66229. protected _buildBlock(state: NodeMaterialBuildState): this;
  66230. }
  66231. }
  66232. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66233. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66234. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66235. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66236. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66237. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66238. }
  66239. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66240. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66241. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66242. }
  66243. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66247. /**
  66248. * Block used to add 2 vectors
  66249. */
  66250. export class AddBlock extends NodeMaterialBlock {
  66251. /**
  66252. * Creates a new AddBlock
  66253. * @param name defines the block name
  66254. */
  66255. constructor(name: string);
  66256. /**
  66257. * Gets the current class name
  66258. * @returns the class name
  66259. */
  66260. getClassName(): string;
  66261. /**
  66262. * Gets the left operand input component
  66263. */
  66264. get left(): NodeMaterialConnectionPoint;
  66265. /**
  66266. * Gets the right operand input component
  66267. */
  66268. get right(): NodeMaterialConnectionPoint;
  66269. /**
  66270. * Gets the output component
  66271. */
  66272. get output(): NodeMaterialConnectionPoint;
  66273. protected _buildBlock(state: NodeMaterialBuildState): this;
  66274. }
  66275. }
  66276. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66280. /**
  66281. * Block used to scale a vector by a float
  66282. */
  66283. export class ScaleBlock extends NodeMaterialBlock {
  66284. /**
  66285. * Creates a new ScaleBlock
  66286. * @param name defines the block name
  66287. */
  66288. constructor(name: string);
  66289. /**
  66290. * Gets the current class name
  66291. * @returns the class name
  66292. */
  66293. getClassName(): string;
  66294. /**
  66295. * Gets the input component
  66296. */
  66297. get input(): NodeMaterialConnectionPoint;
  66298. /**
  66299. * Gets the factor input component
  66300. */
  66301. get factor(): NodeMaterialConnectionPoint;
  66302. /**
  66303. * Gets the output component
  66304. */
  66305. get output(): NodeMaterialConnectionPoint;
  66306. protected _buildBlock(state: NodeMaterialBuildState): this;
  66307. }
  66308. }
  66309. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66311. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66312. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66313. import { Scene } from "babylonjs/scene";
  66314. /**
  66315. * Block used to clamp a float
  66316. */
  66317. export class ClampBlock extends NodeMaterialBlock {
  66318. /** Gets or sets the minimum range */
  66319. minimum: number;
  66320. /** Gets or sets the maximum range */
  66321. maximum: number;
  66322. /**
  66323. * Creates a new ClampBlock
  66324. * @param name defines the block name
  66325. */
  66326. constructor(name: string);
  66327. /**
  66328. * Gets the current class name
  66329. * @returns the class name
  66330. */
  66331. getClassName(): string;
  66332. /**
  66333. * Gets the value input component
  66334. */
  66335. get value(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the output component
  66338. */
  66339. get output(): NodeMaterialConnectionPoint;
  66340. protected _buildBlock(state: NodeMaterialBuildState): this;
  66341. protected _dumpPropertiesCode(): string;
  66342. serialize(): any;
  66343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66344. }
  66345. }
  66346. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66350. /**
  66351. * Block used to apply a cross product between 2 vectors
  66352. */
  66353. export class CrossBlock extends NodeMaterialBlock {
  66354. /**
  66355. * Creates a new CrossBlock
  66356. * @param name defines the block name
  66357. */
  66358. constructor(name: string);
  66359. /**
  66360. * Gets the current class name
  66361. * @returns the class name
  66362. */
  66363. getClassName(): string;
  66364. /**
  66365. * Gets the left operand input component
  66366. */
  66367. get left(): NodeMaterialConnectionPoint;
  66368. /**
  66369. * Gets the right operand input component
  66370. */
  66371. get right(): NodeMaterialConnectionPoint;
  66372. /**
  66373. * Gets the output component
  66374. */
  66375. get output(): NodeMaterialConnectionPoint;
  66376. protected _buildBlock(state: NodeMaterialBuildState): this;
  66377. }
  66378. }
  66379. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66383. /**
  66384. * Block used to apply a dot product between 2 vectors
  66385. */
  66386. export class DotBlock extends NodeMaterialBlock {
  66387. /**
  66388. * Creates a new DotBlock
  66389. * @param name defines the block name
  66390. */
  66391. constructor(name: string);
  66392. /**
  66393. * Gets the current class name
  66394. * @returns the class name
  66395. */
  66396. getClassName(): string;
  66397. /**
  66398. * Gets the left operand input component
  66399. */
  66400. get left(): NodeMaterialConnectionPoint;
  66401. /**
  66402. * Gets the right operand input component
  66403. */
  66404. get right(): NodeMaterialConnectionPoint;
  66405. /**
  66406. * Gets the output component
  66407. */
  66408. get output(): NodeMaterialConnectionPoint;
  66409. protected _buildBlock(state: NodeMaterialBuildState): this;
  66410. }
  66411. }
  66412. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66416. /**
  66417. * Block used to normalize a vector
  66418. */
  66419. export class NormalizeBlock extends NodeMaterialBlock {
  66420. /**
  66421. * Creates a new NormalizeBlock
  66422. * @param name defines the block name
  66423. */
  66424. constructor(name: string);
  66425. /**
  66426. * Gets the current class name
  66427. * @returns the class name
  66428. */
  66429. getClassName(): string;
  66430. /**
  66431. * Gets the input component
  66432. */
  66433. get input(): NodeMaterialConnectionPoint;
  66434. /**
  66435. * Gets the output component
  66436. */
  66437. get output(): NodeMaterialConnectionPoint;
  66438. protected _buildBlock(state: NodeMaterialBuildState): this;
  66439. }
  66440. }
  66441. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66445. /**
  66446. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66447. */
  66448. export class ColorMergerBlock extends NodeMaterialBlock {
  66449. /**
  66450. * Create a new ColorMergerBlock
  66451. * @param name defines the block name
  66452. */
  66453. constructor(name: string);
  66454. /**
  66455. * Gets the current class name
  66456. * @returns the class name
  66457. */
  66458. getClassName(): string;
  66459. /**
  66460. * Gets the rgb component (input)
  66461. */
  66462. get rgbIn(): NodeMaterialConnectionPoint;
  66463. /**
  66464. * Gets the r component (input)
  66465. */
  66466. get r(): NodeMaterialConnectionPoint;
  66467. /**
  66468. * Gets the g component (input)
  66469. */
  66470. get g(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the b component (input)
  66473. */
  66474. get b(): NodeMaterialConnectionPoint;
  66475. /**
  66476. * Gets the a component (input)
  66477. */
  66478. get a(): NodeMaterialConnectionPoint;
  66479. /**
  66480. * Gets the rgba component (output)
  66481. */
  66482. get rgba(): NodeMaterialConnectionPoint;
  66483. /**
  66484. * Gets the rgb component (output)
  66485. */
  66486. get rgbOut(): NodeMaterialConnectionPoint;
  66487. /**
  66488. * Gets the rgb component (output)
  66489. * @deprecated Please use rgbOut instead.
  66490. */
  66491. get rgb(): NodeMaterialConnectionPoint;
  66492. protected _buildBlock(state: NodeMaterialBuildState): this;
  66493. }
  66494. }
  66495. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66499. /**
  66500. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66501. */
  66502. export class VectorSplitterBlock extends NodeMaterialBlock {
  66503. /**
  66504. * Create a new VectorSplitterBlock
  66505. * @param name defines the block name
  66506. */
  66507. constructor(name: string);
  66508. /**
  66509. * Gets the current class name
  66510. * @returns the class name
  66511. */
  66512. getClassName(): string;
  66513. /**
  66514. * Gets the xyzw component (input)
  66515. */
  66516. get xyzw(): NodeMaterialConnectionPoint;
  66517. /**
  66518. * Gets the xyz component (input)
  66519. */
  66520. get xyzIn(): NodeMaterialConnectionPoint;
  66521. /**
  66522. * Gets the xy component (input)
  66523. */
  66524. get xyIn(): NodeMaterialConnectionPoint;
  66525. /**
  66526. * Gets the xyz component (output)
  66527. */
  66528. get xyzOut(): NodeMaterialConnectionPoint;
  66529. /**
  66530. * Gets the xy component (output)
  66531. */
  66532. get xyOut(): NodeMaterialConnectionPoint;
  66533. /**
  66534. * Gets the x component (output)
  66535. */
  66536. get x(): NodeMaterialConnectionPoint;
  66537. /**
  66538. * Gets the y component (output)
  66539. */
  66540. get y(): NodeMaterialConnectionPoint;
  66541. /**
  66542. * Gets the z component (output)
  66543. */
  66544. get z(): NodeMaterialConnectionPoint;
  66545. /**
  66546. * Gets the w component (output)
  66547. */
  66548. get w(): NodeMaterialConnectionPoint;
  66549. protected _inputRename(name: string): string;
  66550. protected _outputRename(name: string): string;
  66551. protected _buildBlock(state: NodeMaterialBuildState): this;
  66552. }
  66553. }
  66554. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66558. /**
  66559. * Block used to lerp between 2 values
  66560. */
  66561. export class LerpBlock extends NodeMaterialBlock {
  66562. /**
  66563. * Creates a new LerpBlock
  66564. * @param name defines the block name
  66565. */
  66566. constructor(name: string);
  66567. /**
  66568. * Gets the current class name
  66569. * @returns the class name
  66570. */
  66571. getClassName(): string;
  66572. /**
  66573. * Gets the left operand input component
  66574. */
  66575. get left(): NodeMaterialConnectionPoint;
  66576. /**
  66577. * Gets the right operand input component
  66578. */
  66579. get right(): NodeMaterialConnectionPoint;
  66580. /**
  66581. * Gets the gradient operand input component
  66582. */
  66583. get gradient(): NodeMaterialConnectionPoint;
  66584. /**
  66585. * Gets the output component
  66586. */
  66587. get output(): NodeMaterialConnectionPoint;
  66588. protected _buildBlock(state: NodeMaterialBuildState): this;
  66589. }
  66590. }
  66591. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66595. /**
  66596. * Block used to divide 2 vectors
  66597. */
  66598. export class DivideBlock extends NodeMaterialBlock {
  66599. /**
  66600. * Creates a new DivideBlock
  66601. * @param name defines the block name
  66602. */
  66603. constructor(name: string);
  66604. /**
  66605. * Gets the current class name
  66606. * @returns the class name
  66607. */
  66608. getClassName(): string;
  66609. /**
  66610. * Gets the left operand input component
  66611. */
  66612. get left(): NodeMaterialConnectionPoint;
  66613. /**
  66614. * Gets the right operand input component
  66615. */
  66616. get right(): NodeMaterialConnectionPoint;
  66617. /**
  66618. * Gets the output component
  66619. */
  66620. get output(): NodeMaterialConnectionPoint;
  66621. protected _buildBlock(state: NodeMaterialBuildState): this;
  66622. }
  66623. }
  66624. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66628. /**
  66629. * Block used to subtract 2 vectors
  66630. */
  66631. export class SubtractBlock extends NodeMaterialBlock {
  66632. /**
  66633. * Creates a new SubtractBlock
  66634. * @param name defines the block name
  66635. */
  66636. constructor(name: string);
  66637. /**
  66638. * Gets the current class name
  66639. * @returns the class name
  66640. */
  66641. getClassName(): string;
  66642. /**
  66643. * Gets the left operand input component
  66644. */
  66645. get left(): NodeMaterialConnectionPoint;
  66646. /**
  66647. * Gets the right operand input component
  66648. */
  66649. get right(): NodeMaterialConnectionPoint;
  66650. /**
  66651. * Gets the output component
  66652. */
  66653. get output(): NodeMaterialConnectionPoint;
  66654. protected _buildBlock(state: NodeMaterialBuildState): this;
  66655. }
  66656. }
  66657. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66661. /**
  66662. * Block used to step a value
  66663. */
  66664. export class StepBlock extends NodeMaterialBlock {
  66665. /**
  66666. * Creates a new StepBlock
  66667. * @param name defines the block name
  66668. */
  66669. constructor(name: string);
  66670. /**
  66671. * Gets the current class name
  66672. * @returns the class name
  66673. */
  66674. getClassName(): string;
  66675. /**
  66676. * Gets the value operand input component
  66677. */
  66678. get value(): NodeMaterialConnectionPoint;
  66679. /**
  66680. * Gets the edge operand input component
  66681. */
  66682. get edge(): NodeMaterialConnectionPoint;
  66683. /**
  66684. * Gets the output component
  66685. */
  66686. get output(): NodeMaterialConnectionPoint;
  66687. protected _buildBlock(state: NodeMaterialBuildState): this;
  66688. }
  66689. }
  66690. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66694. /**
  66695. * Block used to get the opposite (1 - x) of a value
  66696. */
  66697. export class OneMinusBlock extends NodeMaterialBlock {
  66698. /**
  66699. * Creates a new OneMinusBlock
  66700. * @param name defines the block name
  66701. */
  66702. constructor(name: string);
  66703. /**
  66704. * Gets the current class name
  66705. * @returns the class name
  66706. */
  66707. getClassName(): string;
  66708. /**
  66709. * Gets the input component
  66710. */
  66711. get input(): NodeMaterialConnectionPoint;
  66712. /**
  66713. * Gets the output component
  66714. */
  66715. get output(): NodeMaterialConnectionPoint;
  66716. protected _buildBlock(state: NodeMaterialBuildState): this;
  66717. }
  66718. }
  66719. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66723. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66724. /**
  66725. * Block used to get the view direction
  66726. */
  66727. export class ViewDirectionBlock extends NodeMaterialBlock {
  66728. /**
  66729. * Creates a new ViewDirectionBlock
  66730. * @param name defines the block name
  66731. */
  66732. constructor(name: string);
  66733. /**
  66734. * Gets the current class name
  66735. * @returns the class name
  66736. */
  66737. getClassName(): string;
  66738. /**
  66739. * Gets the world position component
  66740. */
  66741. get worldPosition(): NodeMaterialConnectionPoint;
  66742. /**
  66743. * Gets the camera position component
  66744. */
  66745. get cameraPosition(): NodeMaterialConnectionPoint;
  66746. /**
  66747. * Gets the output component
  66748. */
  66749. get output(): NodeMaterialConnectionPoint;
  66750. autoConfigure(material: NodeMaterial): void;
  66751. protected _buildBlock(state: NodeMaterialBuildState): this;
  66752. }
  66753. }
  66754. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66758. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66759. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66760. /**
  66761. * Block used to compute fresnel value
  66762. */
  66763. export class FresnelBlock extends NodeMaterialBlock {
  66764. /**
  66765. * Create a new FresnelBlock
  66766. * @param name defines the block name
  66767. */
  66768. constructor(name: string);
  66769. /**
  66770. * Gets the current class name
  66771. * @returns the class name
  66772. */
  66773. getClassName(): string;
  66774. /**
  66775. * Gets the world normal input component
  66776. */
  66777. get worldNormal(): NodeMaterialConnectionPoint;
  66778. /**
  66779. * Gets the view direction input component
  66780. */
  66781. get viewDirection(): NodeMaterialConnectionPoint;
  66782. /**
  66783. * Gets the bias input component
  66784. */
  66785. get bias(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the camera (or eye) position component
  66788. */
  66789. get power(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the fresnel output component
  66792. */
  66793. get fresnel(): NodeMaterialConnectionPoint;
  66794. autoConfigure(material: NodeMaterial): void;
  66795. protected _buildBlock(state: NodeMaterialBuildState): this;
  66796. }
  66797. }
  66798. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66802. /**
  66803. * Block used to get the max of 2 values
  66804. */
  66805. export class MaxBlock extends NodeMaterialBlock {
  66806. /**
  66807. * Creates a new MaxBlock
  66808. * @param name defines the block name
  66809. */
  66810. constructor(name: string);
  66811. /**
  66812. * Gets the current class name
  66813. * @returns the class name
  66814. */
  66815. getClassName(): string;
  66816. /**
  66817. * Gets the left operand input component
  66818. */
  66819. get left(): NodeMaterialConnectionPoint;
  66820. /**
  66821. * Gets the right operand input component
  66822. */
  66823. get right(): NodeMaterialConnectionPoint;
  66824. /**
  66825. * Gets the output component
  66826. */
  66827. get output(): NodeMaterialConnectionPoint;
  66828. protected _buildBlock(state: NodeMaterialBuildState): this;
  66829. }
  66830. }
  66831. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66835. /**
  66836. * Block used to get the min of 2 values
  66837. */
  66838. export class MinBlock extends NodeMaterialBlock {
  66839. /**
  66840. * Creates a new MinBlock
  66841. * @param name defines the block name
  66842. */
  66843. constructor(name: string);
  66844. /**
  66845. * Gets the current class name
  66846. * @returns the class name
  66847. */
  66848. getClassName(): string;
  66849. /**
  66850. * Gets the left operand input component
  66851. */
  66852. get left(): NodeMaterialConnectionPoint;
  66853. /**
  66854. * Gets the right operand input component
  66855. */
  66856. get right(): NodeMaterialConnectionPoint;
  66857. /**
  66858. * Gets the output component
  66859. */
  66860. get output(): NodeMaterialConnectionPoint;
  66861. protected _buildBlock(state: NodeMaterialBuildState): this;
  66862. }
  66863. }
  66864. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66868. /**
  66869. * Block used to get the distance between 2 values
  66870. */
  66871. export class DistanceBlock extends NodeMaterialBlock {
  66872. /**
  66873. * Creates a new DistanceBlock
  66874. * @param name defines the block name
  66875. */
  66876. constructor(name: string);
  66877. /**
  66878. * Gets the current class name
  66879. * @returns the class name
  66880. */
  66881. getClassName(): string;
  66882. /**
  66883. * Gets the left operand input component
  66884. */
  66885. get left(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the right operand input component
  66888. */
  66889. get right(): NodeMaterialConnectionPoint;
  66890. /**
  66891. * Gets the output component
  66892. */
  66893. get output(): NodeMaterialConnectionPoint;
  66894. protected _buildBlock(state: NodeMaterialBuildState): this;
  66895. }
  66896. }
  66897. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66901. /**
  66902. * Block used to get the length of a vector
  66903. */
  66904. export class LengthBlock extends NodeMaterialBlock {
  66905. /**
  66906. * Creates a new LengthBlock
  66907. * @param name defines the block name
  66908. */
  66909. constructor(name: string);
  66910. /**
  66911. * Gets the current class name
  66912. * @returns the class name
  66913. */
  66914. getClassName(): string;
  66915. /**
  66916. * Gets the value input component
  66917. */
  66918. get value(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the output component
  66921. */
  66922. get output(): NodeMaterialConnectionPoint;
  66923. protected _buildBlock(state: NodeMaterialBuildState): this;
  66924. }
  66925. }
  66926. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66930. /**
  66931. * Block used to get negative version of a value (i.e. x * -1)
  66932. */
  66933. export class NegateBlock extends NodeMaterialBlock {
  66934. /**
  66935. * Creates a new NegateBlock
  66936. * @param name defines the block name
  66937. */
  66938. constructor(name: string);
  66939. /**
  66940. * Gets the current class name
  66941. * @returns the class name
  66942. */
  66943. getClassName(): string;
  66944. /**
  66945. * Gets the value input component
  66946. */
  66947. get value(): NodeMaterialConnectionPoint;
  66948. /**
  66949. * Gets the output component
  66950. */
  66951. get output(): NodeMaterialConnectionPoint;
  66952. protected _buildBlock(state: NodeMaterialBuildState): this;
  66953. }
  66954. }
  66955. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66959. /**
  66960. * Block used to get the value of the first parameter raised to the power of the second
  66961. */
  66962. export class PowBlock extends NodeMaterialBlock {
  66963. /**
  66964. * Creates a new PowBlock
  66965. * @param name defines the block name
  66966. */
  66967. constructor(name: string);
  66968. /**
  66969. * Gets the current class name
  66970. * @returns the class name
  66971. */
  66972. getClassName(): string;
  66973. /**
  66974. * Gets the value operand input component
  66975. */
  66976. get value(): NodeMaterialConnectionPoint;
  66977. /**
  66978. * Gets the power operand input component
  66979. */
  66980. get power(): NodeMaterialConnectionPoint;
  66981. /**
  66982. * Gets the output component
  66983. */
  66984. get output(): NodeMaterialConnectionPoint;
  66985. protected _buildBlock(state: NodeMaterialBuildState): this;
  66986. }
  66987. }
  66988. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66992. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66993. /**
  66994. * Block used to get a random number
  66995. */
  66996. export class RandomNumberBlock extends NodeMaterialBlock {
  66997. /**
  66998. * Creates a new RandomNumberBlock
  66999. * @param name defines the block name
  67000. */
  67001. constructor(name: string);
  67002. /**
  67003. * Gets the current class name
  67004. * @returns the class name
  67005. */
  67006. getClassName(): string;
  67007. /**
  67008. * Gets the seed input component
  67009. */
  67010. get seed(): NodeMaterialConnectionPoint;
  67011. /**
  67012. * Gets the output component
  67013. */
  67014. get output(): NodeMaterialConnectionPoint;
  67015. protected _buildBlock(state: NodeMaterialBuildState): this;
  67016. }
  67017. }
  67018. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67022. /**
  67023. * Block used to compute arc tangent of 2 values
  67024. */
  67025. export class ArcTan2Block extends NodeMaterialBlock {
  67026. /**
  67027. * Creates a new ArcTan2Block
  67028. * @param name defines the block name
  67029. */
  67030. constructor(name: string);
  67031. /**
  67032. * Gets the current class name
  67033. * @returns the class name
  67034. */
  67035. getClassName(): string;
  67036. /**
  67037. * Gets the x operand input component
  67038. */
  67039. get x(): NodeMaterialConnectionPoint;
  67040. /**
  67041. * Gets the y operand input component
  67042. */
  67043. get y(): NodeMaterialConnectionPoint;
  67044. /**
  67045. * Gets the output component
  67046. */
  67047. get output(): NodeMaterialConnectionPoint;
  67048. protected _buildBlock(state: NodeMaterialBuildState): this;
  67049. }
  67050. }
  67051. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67055. /**
  67056. * Block used to smooth step a value
  67057. */
  67058. export class SmoothStepBlock extends NodeMaterialBlock {
  67059. /**
  67060. * Creates a new SmoothStepBlock
  67061. * @param name defines the block name
  67062. */
  67063. constructor(name: string);
  67064. /**
  67065. * Gets the current class name
  67066. * @returns the class name
  67067. */
  67068. getClassName(): string;
  67069. /**
  67070. * Gets the value operand input component
  67071. */
  67072. get value(): NodeMaterialConnectionPoint;
  67073. /**
  67074. * Gets the first edge operand input component
  67075. */
  67076. get edge0(): NodeMaterialConnectionPoint;
  67077. /**
  67078. * Gets the second edge operand input component
  67079. */
  67080. get edge1(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the output component
  67083. */
  67084. get output(): NodeMaterialConnectionPoint;
  67085. protected _buildBlock(state: NodeMaterialBuildState): this;
  67086. }
  67087. }
  67088. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67092. /**
  67093. * Block used to get the reciprocal (1 / x) of a value
  67094. */
  67095. export class ReciprocalBlock extends NodeMaterialBlock {
  67096. /**
  67097. * Creates a new ReciprocalBlock
  67098. * @param name defines the block name
  67099. */
  67100. constructor(name: string);
  67101. /**
  67102. * Gets the current class name
  67103. * @returns the class name
  67104. */
  67105. getClassName(): string;
  67106. /**
  67107. * Gets the input component
  67108. */
  67109. get input(): NodeMaterialConnectionPoint;
  67110. /**
  67111. * Gets the output component
  67112. */
  67113. get output(): NodeMaterialConnectionPoint;
  67114. protected _buildBlock(state: NodeMaterialBuildState): this;
  67115. }
  67116. }
  67117. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67121. /**
  67122. * Block used to replace a color by another one
  67123. */
  67124. export class ReplaceColorBlock extends NodeMaterialBlock {
  67125. /**
  67126. * Creates a new ReplaceColorBlock
  67127. * @param name defines the block name
  67128. */
  67129. constructor(name: string);
  67130. /**
  67131. * Gets the current class name
  67132. * @returns the class name
  67133. */
  67134. getClassName(): string;
  67135. /**
  67136. * Gets the value input component
  67137. */
  67138. get value(): NodeMaterialConnectionPoint;
  67139. /**
  67140. * Gets the reference input component
  67141. */
  67142. get reference(): NodeMaterialConnectionPoint;
  67143. /**
  67144. * Gets the distance input component
  67145. */
  67146. get distance(): NodeMaterialConnectionPoint;
  67147. /**
  67148. * Gets the replacement input component
  67149. */
  67150. get replacement(): NodeMaterialConnectionPoint;
  67151. /**
  67152. * Gets the output component
  67153. */
  67154. get output(): NodeMaterialConnectionPoint;
  67155. protected _buildBlock(state: NodeMaterialBuildState): this;
  67156. }
  67157. }
  67158. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67159. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67160. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67161. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67162. /**
  67163. * Block used to posterize a value
  67164. * @see https://en.wikipedia.org/wiki/Posterization
  67165. */
  67166. export class PosterizeBlock extends NodeMaterialBlock {
  67167. /**
  67168. * Creates a new PosterizeBlock
  67169. * @param name defines the block name
  67170. */
  67171. constructor(name: string);
  67172. /**
  67173. * Gets the current class name
  67174. * @returns the class name
  67175. */
  67176. getClassName(): string;
  67177. /**
  67178. * Gets the value input component
  67179. */
  67180. get value(): NodeMaterialConnectionPoint;
  67181. /**
  67182. * Gets the steps input component
  67183. */
  67184. get steps(): NodeMaterialConnectionPoint;
  67185. /**
  67186. * Gets the output component
  67187. */
  67188. get output(): NodeMaterialConnectionPoint;
  67189. protected _buildBlock(state: NodeMaterialBuildState): this;
  67190. }
  67191. }
  67192. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67196. import { Scene } from "babylonjs/scene";
  67197. /**
  67198. * Operations supported by the Wave block
  67199. */
  67200. export enum WaveBlockKind {
  67201. /** SawTooth */
  67202. SawTooth = 0,
  67203. /** Square */
  67204. Square = 1,
  67205. /** Triangle */
  67206. Triangle = 2
  67207. }
  67208. /**
  67209. * Block used to apply wave operation to floats
  67210. */
  67211. export class WaveBlock extends NodeMaterialBlock {
  67212. /**
  67213. * Gets or sets the kibnd of wave to be applied by the block
  67214. */
  67215. kind: WaveBlockKind;
  67216. /**
  67217. * Creates a new WaveBlock
  67218. * @param name defines the block name
  67219. */
  67220. constructor(name: string);
  67221. /**
  67222. * Gets the current class name
  67223. * @returns the class name
  67224. */
  67225. getClassName(): string;
  67226. /**
  67227. * Gets the input component
  67228. */
  67229. get input(): NodeMaterialConnectionPoint;
  67230. /**
  67231. * Gets the output component
  67232. */
  67233. get output(): NodeMaterialConnectionPoint;
  67234. protected _buildBlock(state: NodeMaterialBuildState): this;
  67235. serialize(): any;
  67236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67237. }
  67238. }
  67239. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67243. import { Color3 } from "babylonjs/Maths/math.color";
  67244. import { Scene } from "babylonjs/scene";
  67245. import { Observable } from "babylonjs/Misc/observable";
  67246. /**
  67247. * Class used to store a color step for the GradientBlock
  67248. */
  67249. export class GradientBlockColorStep {
  67250. private _step;
  67251. /**
  67252. * Gets value indicating which step this color is associated with (between 0 and 1)
  67253. */
  67254. get step(): number;
  67255. /**
  67256. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67257. */
  67258. set step(val: number);
  67259. private _color;
  67260. /**
  67261. * Gets the color associated with this step
  67262. */
  67263. get color(): Color3;
  67264. /**
  67265. * Sets the color associated with this step
  67266. */
  67267. set color(val: Color3);
  67268. /**
  67269. * Creates a new GradientBlockColorStep
  67270. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67271. * @param color defines the color associated with this step
  67272. */
  67273. constructor(step: number, color: Color3);
  67274. }
  67275. /**
  67276. * Block used to return a color from a gradient based on an input value between 0 and 1
  67277. */
  67278. export class GradientBlock extends NodeMaterialBlock {
  67279. /**
  67280. * Gets or sets the list of color steps
  67281. */
  67282. colorSteps: GradientBlockColorStep[];
  67283. /** Gets an observable raised when the value is changed */
  67284. onValueChangedObservable: Observable<GradientBlock>;
  67285. /** calls observable when the value is changed*/
  67286. colorStepsUpdated(): void;
  67287. /**
  67288. * Creates a new GradientBlock
  67289. * @param name defines the block name
  67290. */
  67291. constructor(name: string);
  67292. /**
  67293. * Gets the current class name
  67294. * @returns the class name
  67295. */
  67296. getClassName(): string;
  67297. /**
  67298. * Gets the gradient input component
  67299. */
  67300. get gradient(): NodeMaterialConnectionPoint;
  67301. /**
  67302. * Gets the output component
  67303. */
  67304. get output(): NodeMaterialConnectionPoint;
  67305. private _writeColorConstant;
  67306. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67307. serialize(): any;
  67308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67309. protected _dumpPropertiesCode(): string;
  67310. }
  67311. }
  67312. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67316. /**
  67317. * Block used to normalize lerp between 2 values
  67318. */
  67319. export class NLerpBlock extends NodeMaterialBlock {
  67320. /**
  67321. * Creates a new NLerpBlock
  67322. * @param name defines the block name
  67323. */
  67324. constructor(name: string);
  67325. /**
  67326. * Gets the current class name
  67327. * @returns the class name
  67328. */
  67329. getClassName(): string;
  67330. /**
  67331. * Gets the left operand input component
  67332. */
  67333. get left(): NodeMaterialConnectionPoint;
  67334. /**
  67335. * Gets the right operand input component
  67336. */
  67337. get right(): NodeMaterialConnectionPoint;
  67338. /**
  67339. * Gets the gradient operand input component
  67340. */
  67341. get gradient(): NodeMaterialConnectionPoint;
  67342. /**
  67343. * Gets the output component
  67344. */
  67345. get output(): NodeMaterialConnectionPoint;
  67346. protected _buildBlock(state: NodeMaterialBuildState): this;
  67347. }
  67348. }
  67349. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67353. import { Scene } from "babylonjs/scene";
  67354. /**
  67355. * block used to Generate a Worley Noise 3D Noise Pattern
  67356. */
  67357. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67358. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67359. manhattanDistance: boolean;
  67360. /**
  67361. * Creates a new WorleyNoise3DBlock
  67362. * @param name defines the block name
  67363. */
  67364. constructor(name: string);
  67365. /**
  67366. * Gets the current class name
  67367. * @returns the class name
  67368. */
  67369. getClassName(): string;
  67370. /**
  67371. * Gets the seed input component
  67372. */
  67373. get seed(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the jitter input component
  67376. */
  67377. get jitter(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the output component
  67380. */
  67381. get output(): NodeMaterialConnectionPoint;
  67382. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67383. /**
  67384. * Exposes the properties to the UI?
  67385. */
  67386. protected _dumpPropertiesCode(): string;
  67387. /**
  67388. * Exposes the properties to the Seralize?
  67389. */
  67390. serialize(): any;
  67391. /**
  67392. * Exposes the properties to the deseralize?
  67393. */
  67394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67395. }
  67396. }
  67397. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67398. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67399. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67400. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67401. /**
  67402. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67403. */
  67404. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67405. /**
  67406. * Creates a new SimplexPerlin3DBlock
  67407. * @param name defines the block name
  67408. */
  67409. constructor(name: string);
  67410. /**
  67411. * Gets the current class name
  67412. * @returns the class name
  67413. */
  67414. getClassName(): string;
  67415. /**
  67416. * Gets the seed operand input component
  67417. */
  67418. get seed(): NodeMaterialConnectionPoint;
  67419. /**
  67420. * Gets the output component
  67421. */
  67422. get output(): NodeMaterialConnectionPoint;
  67423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67424. }
  67425. }
  67426. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67430. /**
  67431. * Block used to blend normals
  67432. */
  67433. export class NormalBlendBlock extends NodeMaterialBlock {
  67434. /**
  67435. * Creates a new NormalBlendBlock
  67436. * @param name defines the block name
  67437. */
  67438. constructor(name: string);
  67439. /**
  67440. * Gets the current class name
  67441. * @returns the class name
  67442. */
  67443. getClassName(): string;
  67444. /**
  67445. * Gets the first input component
  67446. */
  67447. get normalMap0(): NodeMaterialConnectionPoint;
  67448. /**
  67449. * Gets the second input component
  67450. */
  67451. get normalMap1(): NodeMaterialConnectionPoint;
  67452. /**
  67453. * Gets the output component
  67454. */
  67455. get output(): NodeMaterialConnectionPoint;
  67456. protected _buildBlock(state: NodeMaterialBuildState): this;
  67457. }
  67458. }
  67459. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67463. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67464. /**
  67465. * Block used to rotate a 2d vector by a given angle
  67466. */
  67467. export class Rotate2dBlock extends NodeMaterialBlock {
  67468. /**
  67469. * Creates a new Rotate2dBlock
  67470. * @param name defines the block name
  67471. */
  67472. constructor(name: string);
  67473. /**
  67474. * Gets the current class name
  67475. * @returns the class name
  67476. */
  67477. getClassName(): string;
  67478. /**
  67479. * Gets the input vector
  67480. */
  67481. get input(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the input angle
  67484. */
  67485. get angle(): NodeMaterialConnectionPoint;
  67486. /**
  67487. * Gets the output component
  67488. */
  67489. get output(): NodeMaterialConnectionPoint;
  67490. autoConfigure(material: NodeMaterial): void;
  67491. protected _buildBlock(state: NodeMaterialBuildState): this;
  67492. }
  67493. }
  67494. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67498. /**
  67499. * Block used to get the reflected vector from a direction and a normal
  67500. */
  67501. export class ReflectBlock extends NodeMaterialBlock {
  67502. /**
  67503. * Creates a new ReflectBlock
  67504. * @param name defines the block name
  67505. */
  67506. constructor(name: string);
  67507. /**
  67508. * Gets the current class name
  67509. * @returns the class name
  67510. */
  67511. getClassName(): string;
  67512. /**
  67513. * Gets the incident component
  67514. */
  67515. get incident(): NodeMaterialConnectionPoint;
  67516. /**
  67517. * Gets the normal component
  67518. */
  67519. get normal(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the output component
  67522. */
  67523. get output(): NodeMaterialConnectionPoint;
  67524. protected _buildBlock(state: NodeMaterialBuildState): this;
  67525. }
  67526. }
  67527. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67531. /**
  67532. * Block used to get the refracted vector from a direction and a normal
  67533. */
  67534. export class RefractBlock extends NodeMaterialBlock {
  67535. /**
  67536. * Creates a new RefractBlock
  67537. * @param name defines the block name
  67538. */
  67539. constructor(name: string);
  67540. /**
  67541. * Gets the current class name
  67542. * @returns the class name
  67543. */
  67544. getClassName(): string;
  67545. /**
  67546. * Gets the incident component
  67547. */
  67548. get incident(): NodeMaterialConnectionPoint;
  67549. /**
  67550. * Gets the normal component
  67551. */
  67552. get normal(): NodeMaterialConnectionPoint;
  67553. /**
  67554. * Gets the index of refraction component
  67555. */
  67556. get ior(): NodeMaterialConnectionPoint;
  67557. /**
  67558. * Gets the output component
  67559. */
  67560. get output(): NodeMaterialConnectionPoint;
  67561. protected _buildBlock(state: NodeMaterialBuildState): this;
  67562. }
  67563. }
  67564. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67568. /**
  67569. * Block used to desaturate a color
  67570. */
  67571. export class DesaturateBlock extends NodeMaterialBlock {
  67572. /**
  67573. * Creates a new DesaturateBlock
  67574. * @param name defines the block name
  67575. */
  67576. constructor(name: string);
  67577. /**
  67578. * Gets the current class name
  67579. * @returns the class name
  67580. */
  67581. getClassName(): string;
  67582. /**
  67583. * Gets the color operand input component
  67584. */
  67585. get color(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the level operand input component
  67588. */
  67589. get level(): NodeMaterialConnectionPoint;
  67590. /**
  67591. * Gets the output component
  67592. */
  67593. get output(): NodeMaterialConnectionPoint;
  67594. protected _buildBlock(state: NodeMaterialBuildState): this;
  67595. }
  67596. }
  67597. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67601. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67602. import { Nullable } from "babylonjs/types";
  67603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67604. import { Scene } from "babylonjs/scene";
  67605. /**
  67606. * Block used to implement the ambient occlusion module of the PBR material
  67607. */
  67608. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67609. /**
  67610. * Create a new AmbientOcclusionBlock
  67611. * @param name defines the block name
  67612. */
  67613. constructor(name: string);
  67614. /**
  67615. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67616. */
  67617. useAmbientInGrayScale: boolean;
  67618. /**
  67619. * Initialize the block and prepare the context for build
  67620. * @param state defines the state that will be used for the build
  67621. */
  67622. initialize(state: NodeMaterialBuildState): void;
  67623. /**
  67624. * Gets the current class name
  67625. * @returns the class name
  67626. */
  67627. getClassName(): string;
  67628. /**
  67629. * Gets the texture input component
  67630. */
  67631. get texture(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the texture intensity component
  67634. */
  67635. get intensity(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the direct light intensity input component
  67638. */
  67639. get directLightIntensity(): NodeMaterialConnectionPoint;
  67640. /**
  67641. * Gets the ambient occlusion object output component
  67642. */
  67643. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67644. /**
  67645. * Gets the main code of the block (fragment side)
  67646. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67647. * @returns the shader code
  67648. */
  67649. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67651. protected _buildBlock(state: NodeMaterialBuildState): this;
  67652. protected _dumpPropertiesCode(): string;
  67653. serialize(): any;
  67654. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67655. }
  67656. }
  67657. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67660. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67661. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67663. import { Nullable } from "babylonjs/types";
  67664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67665. import { Mesh } from "babylonjs/Meshes/mesh";
  67666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67667. import { Effect } from "babylonjs/Materials/effect";
  67668. import { Scene } from "babylonjs/scene";
  67669. /**
  67670. * Block used to implement the reflection module of the PBR material
  67671. */
  67672. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67673. /** @hidden */
  67674. _defineLODReflectionAlpha: string;
  67675. /** @hidden */
  67676. _defineLinearSpecularReflection: string;
  67677. private _vEnvironmentIrradianceName;
  67678. /** @hidden */
  67679. _vReflectionMicrosurfaceInfosName: string;
  67680. /** @hidden */
  67681. _vReflectionInfosName: string;
  67682. /** @hidden */
  67683. _vReflectionFilteringInfoName: string;
  67684. private _scene;
  67685. /**
  67686. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67687. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67688. * It's less burden on the user side in the editor part.
  67689. */
  67690. /** @hidden */
  67691. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67692. /** @hidden */
  67693. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67694. /** @hidden */
  67695. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67696. /**
  67697. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67698. * diffuse part of the IBL.
  67699. */
  67700. useSphericalHarmonics: boolean;
  67701. /**
  67702. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67703. */
  67704. forceIrradianceInFragment: boolean;
  67705. /**
  67706. * Create a new ReflectionBlock
  67707. * @param name defines the block name
  67708. */
  67709. constructor(name: string);
  67710. /**
  67711. * Gets the current class name
  67712. * @returns the class name
  67713. */
  67714. getClassName(): string;
  67715. /**
  67716. * Gets the position input component
  67717. */
  67718. get position(): NodeMaterialConnectionPoint;
  67719. /**
  67720. * Gets the world position input component
  67721. */
  67722. get worldPosition(): NodeMaterialConnectionPoint;
  67723. /**
  67724. * Gets the world normal input component
  67725. */
  67726. get worldNormal(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the world input component
  67729. */
  67730. get world(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the camera (or eye) position component
  67733. */
  67734. get cameraPosition(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the view input component
  67737. */
  67738. get view(): NodeMaterialConnectionPoint;
  67739. /**
  67740. * Gets the color input component
  67741. */
  67742. get color(): NodeMaterialConnectionPoint;
  67743. /**
  67744. * Gets the reflection object output component
  67745. */
  67746. get reflection(): NodeMaterialConnectionPoint;
  67747. /**
  67748. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67749. */
  67750. get hasTexture(): boolean;
  67751. /**
  67752. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67753. */
  67754. get reflectionColor(): string;
  67755. protected _getTexture(): Nullable<BaseTexture>;
  67756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67757. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67758. /**
  67759. * Gets the code to inject in the vertex shader
  67760. * @param state current state of the node material building
  67761. * @returns the shader code
  67762. */
  67763. handleVertexSide(state: NodeMaterialBuildState): string;
  67764. /**
  67765. * Gets the main code of the block (fragment side)
  67766. * @param state current state of the node material building
  67767. * @param normalVarName name of the existing variable corresponding to the normal
  67768. * @returns the shader code
  67769. */
  67770. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67771. protected _buildBlock(state: NodeMaterialBuildState): this;
  67772. protected _dumpPropertiesCode(): string;
  67773. serialize(): any;
  67774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67775. }
  67776. }
  67777. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67781. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67783. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67784. import { Scene } from "babylonjs/scene";
  67785. import { Nullable } from "babylonjs/types";
  67786. /**
  67787. * Block used to implement the sheen module of the PBR material
  67788. */
  67789. export class SheenBlock extends NodeMaterialBlock {
  67790. /**
  67791. * Create a new SheenBlock
  67792. * @param name defines the block name
  67793. */
  67794. constructor(name: string);
  67795. /**
  67796. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67797. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67798. * making it easier to setup and tweak the effect
  67799. */
  67800. albedoScaling: boolean;
  67801. /**
  67802. * Defines if the sheen is linked to the sheen color.
  67803. */
  67804. linkSheenWithAlbedo: boolean;
  67805. /**
  67806. * Initialize the block and prepare the context for build
  67807. * @param state defines the state that will be used for the build
  67808. */
  67809. initialize(state: NodeMaterialBuildState): void;
  67810. /**
  67811. * Gets the current class name
  67812. * @returns the class name
  67813. */
  67814. getClassName(): string;
  67815. /**
  67816. * Gets the intensity input component
  67817. */
  67818. get intensity(): NodeMaterialConnectionPoint;
  67819. /**
  67820. * Gets the color input component
  67821. */
  67822. get color(): NodeMaterialConnectionPoint;
  67823. /**
  67824. * Gets the roughness input component
  67825. */
  67826. get roughness(): NodeMaterialConnectionPoint;
  67827. /**
  67828. * Gets the sheen object output component
  67829. */
  67830. get sheen(): NodeMaterialConnectionPoint;
  67831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67832. /**
  67833. * Gets the main code of the block (fragment side)
  67834. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67835. * @returns the shader code
  67836. */
  67837. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67838. protected _buildBlock(state: NodeMaterialBuildState): this;
  67839. protected _dumpPropertiesCode(): string;
  67840. serialize(): any;
  67841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67842. }
  67843. }
  67844. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67845. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67850. import { Scene } from "babylonjs/scene";
  67851. import { Nullable } from "babylonjs/types";
  67852. import { Mesh } from "babylonjs/Meshes/mesh";
  67853. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67854. import { Effect } from "babylonjs/Materials/effect";
  67855. /**
  67856. * Block used to implement the reflectivity module of the PBR material
  67857. */
  67858. export class ReflectivityBlock extends NodeMaterialBlock {
  67859. private _metallicReflectanceColor;
  67860. private _metallicF0Factor;
  67861. /** @hidden */
  67862. _vMetallicReflectanceFactorsName: string;
  67863. /**
  67864. * The property below is set by the main PBR block prior to calling methods of this class.
  67865. */
  67866. /** @hidden */
  67867. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67868. /**
  67869. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67870. */
  67871. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67872. /**
  67873. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67874. */
  67875. useMetallnessFromMetallicTextureBlue: boolean;
  67876. /**
  67877. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67878. */
  67879. useRoughnessFromMetallicTextureAlpha: boolean;
  67880. /**
  67881. * Specifies if the metallic texture contains the roughness information in its green channel.
  67882. */
  67883. useRoughnessFromMetallicTextureGreen: boolean;
  67884. /**
  67885. * Create a new ReflectivityBlock
  67886. * @param name defines the block name
  67887. */
  67888. constructor(name: string);
  67889. /**
  67890. * Initialize the block and prepare the context for build
  67891. * @param state defines the state that will be used for the build
  67892. */
  67893. initialize(state: NodeMaterialBuildState): void;
  67894. /**
  67895. * Gets the current class name
  67896. * @returns the class name
  67897. */
  67898. getClassName(): string;
  67899. /**
  67900. * Gets the metallic input component
  67901. */
  67902. get metallic(): NodeMaterialConnectionPoint;
  67903. /**
  67904. * Gets the roughness input component
  67905. */
  67906. get roughness(): NodeMaterialConnectionPoint;
  67907. /**
  67908. * Gets the texture input component
  67909. */
  67910. get texture(): NodeMaterialConnectionPoint;
  67911. /**
  67912. * Gets the reflectivity object output component
  67913. */
  67914. get reflectivity(): NodeMaterialConnectionPoint;
  67915. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67916. /**
  67917. * Gets the main code of the block (fragment side)
  67918. * @param state current state of the node material building
  67919. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67920. * @returns the shader code
  67921. */
  67922. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67924. protected _buildBlock(state: NodeMaterialBuildState): this;
  67925. protected _dumpPropertiesCode(): string;
  67926. serialize(): any;
  67927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67928. }
  67929. }
  67930. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67931. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67936. /**
  67937. * Block used to implement the anisotropy module of the PBR material
  67938. */
  67939. export class AnisotropyBlock extends NodeMaterialBlock {
  67940. /**
  67941. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67942. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67943. * It's less burden on the user side in the editor part.
  67944. */
  67945. /** @hidden */
  67946. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67947. /** @hidden */
  67948. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67949. /**
  67950. * Create a new AnisotropyBlock
  67951. * @param name defines the block name
  67952. */
  67953. constructor(name: string);
  67954. /**
  67955. * Initialize the block and prepare the context for build
  67956. * @param state defines the state that will be used for the build
  67957. */
  67958. initialize(state: NodeMaterialBuildState): void;
  67959. /**
  67960. * Gets the current class name
  67961. * @returns the class name
  67962. */
  67963. getClassName(): string;
  67964. /**
  67965. * Gets the intensity input component
  67966. */
  67967. get intensity(): NodeMaterialConnectionPoint;
  67968. /**
  67969. * Gets the direction input component
  67970. */
  67971. get direction(): NodeMaterialConnectionPoint;
  67972. /**
  67973. * Gets the texture input component
  67974. */
  67975. get texture(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the uv input component
  67978. */
  67979. get uv(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the worldTangent input component
  67982. */
  67983. get worldTangent(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the anisotropy object output component
  67986. */
  67987. get anisotropy(): NodeMaterialConnectionPoint;
  67988. private _generateTBNSpace;
  67989. /**
  67990. * Gets the main code of the block (fragment side)
  67991. * @param state current state of the node material building
  67992. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67993. * @returns the shader code
  67994. */
  67995. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67997. protected _buildBlock(state: NodeMaterialBuildState): this;
  67998. }
  67999. }
  68000. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68004. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68006. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68007. import { Nullable } from "babylonjs/types";
  68008. import { Mesh } from "babylonjs/Meshes/mesh";
  68009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68010. import { Effect } from "babylonjs/Materials/effect";
  68011. /**
  68012. * Block used to implement the clear coat module of the PBR material
  68013. */
  68014. export class ClearCoatBlock extends NodeMaterialBlock {
  68015. private _scene;
  68016. /**
  68017. * Create a new ClearCoatBlock
  68018. * @param name defines the block name
  68019. */
  68020. constructor(name: string);
  68021. /**
  68022. * Initialize the block and prepare the context for build
  68023. * @param state defines the state that will be used for the build
  68024. */
  68025. initialize(state: NodeMaterialBuildState): void;
  68026. /**
  68027. * Gets the current class name
  68028. * @returns the class name
  68029. */
  68030. getClassName(): string;
  68031. /**
  68032. * Gets the intensity input component
  68033. */
  68034. get intensity(): NodeMaterialConnectionPoint;
  68035. /**
  68036. * Gets the roughness input component
  68037. */
  68038. get roughness(): NodeMaterialConnectionPoint;
  68039. /**
  68040. * Gets the ior input component
  68041. */
  68042. get ior(): NodeMaterialConnectionPoint;
  68043. /**
  68044. * Gets the texture input component
  68045. */
  68046. get texture(): NodeMaterialConnectionPoint;
  68047. /**
  68048. * Gets the bump texture input component
  68049. */
  68050. get bumpTexture(): NodeMaterialConnectionPoint;
  68051. /**
  68052. * Gets the uv input component
  68053. */
  68054. get uv(): NodeMaterialConnectionPoint;
  68055. /**
  68056. * Gets the tint color input component
  68057. */
  68058. get tintColor(): NodeMaterialConnectionPoint;
  68059. /**
  68060. * Gets the tint "at distance" input component
  68061. */
  68062. get tintAtDistance(): NodeMaterialConnectionPoint;
  68063. /**
  68064. * Gets the tint thickness input component
  68065. */
  68066. get tintThickness(): NodeMaterialConnectionPoint;
  68067. /**
  68068. * Gets the world tangent input component
  68069. */
  68070. get worldTangent(): NodeMaterialConnectionPoint;
  68071. /**
  68072. * Gets the clear coat object output component
  68073. */
  68074. get clearcoat(): NodeMaterialConnectionPoint;
  68075. autoConfigure(material: NodeMaterial): void;
  68076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68078. private _generateTBNSpace;
  68079. /**
  68080. * Gets the main code of the block (fragment side)
  68081. * @param state current state of the node material building
  68082. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68083. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68084. * @param worldPosVarName name of the variable holding the world position
  68085. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68086. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68087. * @param worldNormalVarName name of the variable holding the world normal
  68088. * @returns the shader code
  68089. */
  68090. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68091. protected _buildBlock(state: NodeMaterialBuildState): this;
  68092. }
  68093. }
  68094. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68098. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68100. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68101. import { Nullable } from "babylonjs/types";
  68102. /**
  68103. * Block used to implement the sub surface module of the PBR material
  68104. */
  68105. export class SubSurfaceBlock extends NodeMaterialBlock {
  68106. /**
  68107. * Create a new SubSurfaceBlock
  68108. * @param name defines the block name
  68109. */
  68110. constructor(name: string);
  68111. /**
  68112. * Stores the intensity of the different subsurface effects in the thickness texture.
  68113. * * the green channel is the translucency intensity.
  68114. * * the blue channel is the scattering intensity.
  68115. * * the alpha channel is the refraction intensity.
  68116. */
  68117. useMaskFromThicknessTexture: boolean;
  68118. /**
  68119. * Initialize the block and prepare the context for build
  68120. * @param state defines the state that will be used for the build
  68121. */
  68122. initialize(state: NodeMaterialBuildState): void;
  68123. /**
  68124. * Gets the current class name
  68125. * @returns the class name
  68126. */
  68127. getClassName(): string;
  68128. /**
  68129. * Gets the min thickness input component
  68130. */
  68131. get minThickness(): NodeMaterialConnectionPoint;
  68132. /**
  68133. * Gets the max thickness input component
  68134. */
  68135. get maxThickness(): NodeMaterialConnectionPoint;
  68136. /**
  68137. * Gets the thickness texture component
  68138. */
  68139. get thicknessTexture(): NodeMaterialConnectionPoint;
  68140. /**
  68141. * Gets the tint color input component
  68142. */
  68143. get tintColor(): NodeMaterialConnectionPoint;
  68144. /**
  68145. * Gets the translucency intensity input component
  68146. */
  68147. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68148. /**
  68149. * Gets the translucency diffusion distance input component
  68150. */
  68151. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68152. /**
  68153. * Gets the refraction object parameters
  68154. */
  68155. get refraction(): NodeMaterialConnectionPoint;
  68156. /**
  68157. * Gets the sub surface object output component
  68158. */
  68159. get subsurface(): NodeMaterialConnectionPoint;
  68160. autoConfigure(material: NodeMaterial): void;
  68161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68162. /**
  68163. * Gets the main code of the block (fragment side)
  68164. * @param state current state of the node material building
  68165. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68166. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68167. * @param worldPosVarName name of the variable holding the world position
  68168. * @returns the shader code
  68169. */
  68170. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68171. protected _buildBlock(state: NodeMaterialBuildState): this;
  68172. }
  68173. }
  68174. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68178. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68179. import { Light } from "babylonjs/Lights/light";
  68180. import { Nullable } from "babylonjs/types";
  68181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68182. import { Effect } from "babylonjs/Materials/effect";
  68183. import { Mesh } from "babylonjs/Meshes/mesh";
  68184. import { Scene } from "babylonjs/scene";
  68185. /**
  68186. * Block used to implement the PBR metallic/roughness model
  68187. */
  68188. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68189. /**
  68190. * Gets or sets the light associated with this block
  68191. */
  68192. light: Nullable<Light>;
  68193. private _lightId;
  68194. private _scene;
  68195. private _environmentBRDFTexture;
  68196. private _environmentBrdfSamplerName;
  68197. private _vNormalWName;
  68198. private _invertNormalName;
  68199. /**
  68200. * Create a new ReflectionBlock
  68201. * @param name defines the block name
  68202. */
  68203. constructor(name: string);
  68204. /**
  68205. * Intensity of the direct lights e.g. the four lights available in your scene.
  68206. * This impacts both the direct diffuse and specular highlights.
  68207. */
  68208. directIntensity: number;
  68209. /**
  68210. * Intensity of the environment e.g. how much the environment will light the object
  68211. * either through harmonics for rough material or through the refelction for shiny ones.
  68212. */
  68213. environmentIntensity: number;
  68214. /**
  68215. * This is a special control allowing the reduction of the specular highlights coming from the
  68216. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68217. */
  68218. specularIntensity: number;
  68219. /**
  68220. * Defines the falloff type used in this material.
  68221. * It by default is Physical.
  68222. */
  68223. lightFalloff: number;
  68224. /**
  68225. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68226. */
  68227. useAlphaFromAlbedoTexture: boolean;
  68228. /**
  68229. * Specifies that alpha test should be used
  68230. */
  68231. useAlphaTest: boolean;
  68232. /**
  68233. * Defines the alpha limits in alpha test mode.
  68234. */
  68235. alphaTestCutoff: number;
  68236. /**
  68237. * Specifies that alpha blending should be used
  68238. */
  68239. useAlphaBlending: boolean;
  68240. /**
  68241. * Defines if the alpha value should be determined via the rgb values.
  68242. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68243. */
  68244. opacityRGB: boolean;
  68245. /**
  68246. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68247. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68248. */
  68249. useRadianceOverAlpha: boolean;
  68250. /**
  68251. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68252. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68253. */
  68254. useSpecularOverAlpha: boolean;
  68255. /**
  68256. * Enables specular anti aliasing in the PBR shader.
  68257. * It will both interacts on the Geometry for analytical and IBL lighting.
  68258. * It also prefilter the roughness map based on the bump values.
  68259. */
  68260. enableSpecularAntiAliasing: boolean;
  68261. /**
  68262. * Enables realtime filtering on the texture.
  68263. */
  68264. realTimeFiltering: boolean;
  68265. /**
  68266. * Quality switch for realtime filtering
  68267. */
  68268. realTimeFilteringQuality: number;
  68269. /**
  68270. * Defines if the material uses energy conservation.
  68271. */
  68272. useEnergyConservation: boolean;
  68273. /**
  68274. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68275. * too much the area relying on ambient texture to define their ambient occlusion.
  68276. */
  68277. useRadianceOcclusion: boolean;
  68278. /**
  68279. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68280. * makes the reflect vector face the model (under horizon).
  68281. */
  68282. useHorizonOcclusion: boolean;
  68283. /**
  68284. * If set to true, no lighting calculations will be applied.
  68285. */
  68286. unlit: boolean;
  68287. /**
  68288. * Force normal to face away from face.
  68289. */
  68290. forceNormalForward: boolean;
  68291. /**
  68292. * Defines the material debug mode.
  68293. * It helps seeing only some components of the material while troubleshooting.
  68294. */
  68295. debugMode: number;
  68296. /**
  68297. * Specify from where on screen the debug mode should start.
  68298. * The value goes from -1 (full screen) to 1 (not visible)
  68299. * It helps with side by side comparison against the final render
  68300. * This defaults to 0
  68301. */
  68302. debugLimit: number;
  68303. /**
  68304. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68305. * You can use the factor to better multiply the final value.
  68306. */
  68307. debugFactor: number;
  68308. /**
  68309. * Initialize the block and prepare the context for build
  68310. * @param state defines the state that will be used for the build
  68311. */
  68312. initialize(state: NodeMaterialBuildState): void;
  68313. /**
  68314. * Gets the current class name
  68315. * @returns the class name
  68316. */
  68317. getClassName(): string;
  68318. /**
  68319. * Gets the world position input component
  68320. */
  68321. get worldPosition(): NodeMaterialConnectionPoint;
  68322. /**
  68323. * Gets the world normal input component
  68324. */
  68325. get worldNormal(): NodeMaterialConnectionPoint;
  68326. /**
  68327. * Gets the perturbed normal input component
  68328. */
  68329. get perturbedNormal(): NodeMaterialConnectionPoint;
  68330. /**
  68331. * Gets the camera position input component
  68332. */
  68333. get cameraPosition(): NodeMaterialConnectionPoint;
  68334. /**
  68335. * Gets the base color input component
  68336. */
  68337. get baseColor(): NodeMaterialConnectionPoint;
  68338. /**
  68339. * Gets the opacity texture input component
  68340. */
  68341. get opacityTexture(): NodeMaterialConnectionPoint;
  68342. /**
  68343. * Gets the ambient color input component
  68344. */
  68345. get ambientColor(): NodeMaterialConnectionPoint;
  68346. /**
  68347. * Gets the reflectivity object parameters
  68348. */
  68349. get reflectivity(): NodeMaterialConnectionPoint;
  68350. /**
  68351. * Gets the ambient occlusion object parameters
  68352. */
  68353. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68354. /**
  68355. * Gets the reflection object parameters
  68356. */
  68357. get reflection(): NodeMaterialConnectionPoint;
  68358. /**
  68359. * Gets the sheen object parameters
  68360. */
  68361. get sheen(): NodeMaterialConnectionPoint;
  68362. /**
  68363. * Gets the clear coat object parameters
  68364. */
  68365. get clearcoat(): NodeMaterialConnectionPoint;
  68366. /**
  68367. * Gets the sub surface object parameters
  68368. */
  68369. get subsurface(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the anisotropy object parameters
  68372. */
  68373. get anisotropy(): NodeMaterialConnectionPoint;
  68374. /**
  68375. * Gets the ambient output component
  68376. */
  68377. get ambient(): NodeMaterialConnectionPoint;
  68378. /**
  68379. * Gets the diffuse output component
  68380. */
  68381. get diffuse(): NodeMaterialConnectionPoint;
  68382. /**
  68383. * Gets the specular output component
  68384. */
  68385. get specular(): NodeMaterialConnectionPoint;
  68386. /**
  68387. * Gets the sheen output component
  68388. */
  68389. get sheenDir(): NodeMaterialConnectionPoint;
  68390. /**
  68391. * Gets the clear coat output component
  68392. */
  68393. get clearcoatDir(): NodeMaterialConnectionPoint;
  68394. /**
  68395. * Gets the indirect diffuse output component
  68396. */
  68397. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68398. /**
  68399. * Gets the indirect specular output component
  68400. */
  68401. get specularIndirect(): NodeMaterialConnectionPoint;
  68402. /**
  68403. * Gets the indirect sheen output component
  68404. */
  68405. get sheenIndirect(): NodeMaterialConnectionPoint;
  68406. /**
  68407. * Gets the indirect clear coat output component
  68408. */
  68409. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68410. /**
  68411. * Gets the refraction output component
  68412. */
  68413. get refraction(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Gets the global lighting output component
  68416. */
  68417. get lighting(): NodeMaterialConnectionPoint;
  68418. /**
  68419. * Gets the shadow output component
  68420. */
  68421. get shadow(): NodeMaterialConnectionPoint;
  68422. /**
  68423. * Gets the alpha output component
  68424. */
  68425. get alpha(): NodeMaterialConnectionPoint;
  68426. autoConfigure(material: NodeMaterial): void;
  68427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68428. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68430. private _injectVertexCode;
  68431. /**
  68432. * Gets the code corresponding to the albedo/opacity module
  68433. * @returns the shader code
  68434. */
  68435. getAlbedoOpacityCode(): string;
  68436. protected _buildBlock(state: NodeMaterialBuildState): this;
  68437. protected _dumpPropertiesCode(): string;
  68438. serialize(): any;
  68439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68440. }
  68441. }
  68442. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68443. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68444. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68445. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68446. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68447. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68448. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68449. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68450. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68451. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68452. }
  68453. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68454. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68455. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68456. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68457. }
  68458. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68462. /**
  68463. * Block used to compute value of one parameter modulo another
  68464. */
  68465. export class ModBlock extends NodeMaterialBlock {
  68466. /**
  68467. * Creates a new ModBlock
  68468. * @param name defines the block name
  68469. */
  68470. constructor(name: string);
  68471. /**
  68472. * Gets the current class name
  68473. * @returns the class name
  68474. */
  68475. getClassName(): string;
  68476. /**
  68477. * Gets the left operand input component
  68478. */
  68479. get left(): NodeMaterialConnectionPoint;
  68480. /**
  68481. * Gets the right operand input component
  68482. */
  68483. get right(): NodeMaterialConnectionPoint;
  68484. /**
  68485. * Gets the output component
  68486. */
  68487. get output(): NodeMaterialConnectionPoint;
  68488. protected _buildBlock(state: NodeMaterialBuildState): this;
  68489. }
  68490. }
  68491. declare module "babylonjs/Materials/Node/Blocks/index" {
  68492. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68493. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68494. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68495. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68496. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68497. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68498. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68499. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68500. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68501. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68502. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68503. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68504. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68505. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68506. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68507. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68508. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68509. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68510. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68511. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68512. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68513. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68514. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68515. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68516. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68517. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68518. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68519. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68520. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68521. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68522. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68523. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68524. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68525. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68526. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68527. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68528. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68529. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68530. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68531. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68532. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68533. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68534. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68535. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68536. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68537. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68538. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68539. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68540. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68541. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68542. }
  68543. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68544. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68545. }
  68546. declare module "babylonjs/Materials/Node/index" {
  68547. export * from "babylonjs/Materials/Node/Enums/index";
  68548. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68549. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68550. export * from "babylonjs/Materials/Node/nodeMaterial";
  68551. export * from "babylonjs/Materials/Node/Blocks/index";
  68552. export * from "babylonjs/Materials/Node/Optimizers/index";
  68553. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68554. }
  68555. declare module "babylonjs/Materials/index" {
  68556. export * from "babylonjs/Materials/Background/index";
  68557. export * from "babylonjs/Materials/colorCurves";
  68558. export * from "babylonjs/Materials/iEffectFallbacks";
  68559. export * from "babylonjs/Materials/effectFallbacks";
  68560. export * from "babylonjs/Materials/effect";
  68561. export * from "babylonjs/Materials/fresnelParameters";
  68562. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68563. export * from "babylonjs/Materials/material";
  68564. export * from "babylonjs/Materials/materialDefines";
  68565. export * from "babylonjs/Materials/thinMaterialHelper";
  68566. export * from "babylonjs/Materials/materialHelper";
  68567. export * from "babylonjs/Materials/multiMaterial";
  68568. export * from "babylonjs/Materials/PBR/index";
  68569. export * from "babylonjs/Materials/pushMaterial";
  68570. export * from "babylonjs/Materials/shaderMaterial";
  68571. export * from "babylonjs/Materials/standardMaterial";
  68572. export * from "babylonjs/Materials/Textures/index";
  68573. export * from "babylonjs/Materials/uniformBuffer";
  68574. export * from "babylonjs/Materials/materialFlags";
  68575. export * from "babylonjs/Materials/Node/index";
  68576. export * from "babylonjs/Materials/effectRenderer";
  68577. export * from "babylonjs/Materials/shadowDepthWrapper";
  68578. }
  68579. declare module "babylonjs/Maths/index" {
  68580. export * from "babylonjs/Maths/math.scalar";
  68581. export * from "babylonjs/Maths/math";
  68582. export * from "babylonjs/Maths/sphericalPolynomial";
  68583. }
  68584. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68585. import { IDisposable } from "babylonjs/scene";
  68586. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68587. /**
  68588. * Configuration for Draco compression
  68589. */
  68590. export interface IDracoCompressionConfiguration {
  68591. /**
  68592. * Configuration for the decoder.
  68593. */
  68594. decoder: {
  68595. /**
  68596. * The url to the WebAssembly module.
  68597. */
  68598. wasmUrl?: string;
  68599. /**
  68600. * The url to the WebAssembly binary.
  68601. */
  68602. wasmBinaryUrl?: string;
  68603. /**
  68604. * The url to the fallback JavaScript module.
  68605. */
  68606. fallbackUrl?: string;
  68607. };
  68608. }
  68609. /**
  68610. * Draco compression (https://google.github.io/draco/)
  68611. *
  68612. * This class wraps the Draco module.
  68613. *
  68614. * **Encoder**
  68615. *
  68616. * The encoder is not currently implemented.
  68617. *
  68618. * **Decoder**
  68619. *
  68620. * 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.
  68621. *
  68622. * To update the configuration, use the following code:
  68623. * ```javascript
  68624. * DracoCompression.Configuration = {
  68625. * decoder: {
  68626. * wasmUrl: "<url to the WebAssembly library>",
  68627. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68628. * fallbackUrl: "<url to the fallback JavaScript library>",
  68629. * }
  68630. * };
  68631. * ```
  68632. *
  68633. * 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.
  68634. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68635. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68636. *
  68637. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68638. * ```javascript
  68639. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68640. * ```
  68641. *
  68642. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68643. */
  68644. export class DracoCompression implements IDisposable {
  68645. private _workerPoolPromise?;
  68646. private _decoderModulePromise?;
  68647. /**
  68648. * The configuration. Defaults to the following urls:
  68649. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68650. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68651. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68652. */
  68653. static Configuration: IDracoCompressionConfiguration;
  68654. /**
  68655. * Returns true if the decoder configuration is available.
  68656. */
  68657. static get DecoderAvailable(): boolean;
  68658. /**
  68659. * Default number of workers to create when creating the draco compression object.
  68660. */
  68661. static DefaultNumWorkers: number;
  68662. private static GetDefaultNumWorkers;
  68663. private static _Default;
  68664. /**
  68665. * Default instance for the draco compression object.
  68666. */
  68667. static get Default(): DracoCompression;
  68668. /**
  68669. * Constructor
  68670. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68671. */
  68672. constructor(numWorkers?: number);
  68673. /**
  68674. * Stop all async operations and release resources.
  68675. */
  68676. dispose(): void;
  68677. /**
  68678. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68679. * @returns a promise that resolves when ready
  68680. */
  68681. whenReadyAsync(): Promise<void>;
  68682. /**
  68683. * Decode Draco compressed mesh data to vertex data.
  68684. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68685. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68686. * @returns A promise that resolves with the decoded vertex data
  68687. */
  68688. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68689. [kind: string]: number;
  68690. }): Promise<VertexData>;
  68691. }
  68692. }
  68693. declare module "babylonjs/Meshes/Compression/index" {
  68694. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68695. }
  68696. declare module "babylonjs/Meshes/csg" {
  68697. import { Nullable } from "babylonjs/types";
  68698. import { Scene } from "babylonjs/scene";
  68699. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68700. import { Mesh } from "babylonjs/Meshes/mesh";
  68701. import { Material } from "babylonjs/Materials/material";
  68702. /**
  68703. * Class for building Constructive Solid Geometry
  68704. */
  68705. export class CSG {
  68706. private polygons;
  68707. /**
  68708. * The world matrix
  68709. */
  68710. matrix: Matrix;
  68711. /**
  68712. * Stores the position
  68713. */
  68714. position: Vector3;
  68715. /**
  68716. * Stores the rotation
  68717. */
  68718. rotation: Vector3;
  68719. /**
  68720. * Stores the rotation quaternion
  68721. */
  68722. rotationQuaternion: Nullable<Quaternion>;
  68723. /**
  68724. * Stores the scaling vector
  68725. */
  68726. scaling: Vector3;
  68727. /**
  68728. * Convert the Mesh to CSG
  68729. * @param mesh The Mesh to convert to CSG
  68730. * @returns A new CSG from the Mesh
  68731. */
  68732. static FromMesh(mesh: Mesh): CSG;
  68733. /**
  68734. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68735. * @param polygons Polygons used to construct a CSG solid
  68736. */
  68737. private static FromPolygons;
  68738. /**
  68739. * Clones, or makes a deep copy, of the CSG
  68740. * @returns A new CSG
  68741. */
  68742. clone(): CSG;
  68743. /**
  68744. * Unions this CSG with another CSG
  68745. * @param csg The CSG to union against this CSG
  68746. * @returns The unioned CSG
  68747. */
  68748. union(csg: CSG): CSG;
  68749. /**
  68750. * Unions this CSG with another CSG in place
  68751. * @param csg The CSG to union against this CSG
  68752. */
  68753. unionInPlace(csg: CSG): void;
  68754. /**
  68755. * Subtracts this CSG with another CSG
  68756. * @param csg The CSG to subtract against this CSG
  68757. * @returns A new CSG
  68758. */
  68759. subtract(csg: CSG): CSG;
  68760. /**
  68761. * Subtracts this CSG with another CSG in place
  68762. * @param csg The CSG to subtact against this CSG
  68763. */
  68764. subtractInPlace(csg: CSG): void;
  68765. /**
  68766. * Intersect this CSG with another CSG
  68767. * @param csg The CSG to intersect against this CSG
  68768. * @returns A new CSG
  68769. */
  68770. intersect(csg: CSG): CSG;
  68771. /**
  68772. * Intersects this CSG with another CSG in place
  68773. * @param csg The CSG to intersect against this CSG
  68774. */
  68775. intersectInPlace(csg: CSG): void;
  68776. /**
  68777. * Return a new CSG solid with solid and empty space switched. This solid is
  68778. * not modified.
  68779. * @returns A new CSG solid with solid and empty space switched
  68780. */
  68781. inverse(): CSG;
  68782. /**
  68783. * Inverses the CSG in place
  68784. */
  68785. inverseInPlace(): void;
  68786. /**
  68787. * This is used to keep meshes transformations so they can be restored
  68788. * when we build back a Babylon Mesh
  68789. * NB : All CSG operations are performed in world coordinates
  68790. * @param csg The CSG to copy the transform attributes from
  68791. * @returns This CSG
  68792. */
  68793. copyTransformAttributes(csg: CSG): CSG;
  68794. /**
  68795. * Build Raw mesh from CSG
  68796. * Coordinates here are in world space
  68797. * @param name The name of the mesh geometry
  68798. * @param scene The Scene
  68799. * @param keepSubMeshes Specifies if the submeshes should be kept
  68800. * @returns A new Mesh
  68801. */
  68802. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68803. /**
  68804. * Build Mesh from CSG taking material and transforms into account
  68805. * @param name The name of the Mesh
  68806. * @param material The material of the Mesh
  68807. * @param scene The Scene
  68808. * @param keepSubMeshes Specifies if submeshes should be kept
  68809. * @returns The new Mesh
  68810. */
  68811. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68812. }
  68813. }
  68814. declare module "babylonjs/Meshes/trailMesh" {
  68815. import { Mesh } from "babylonjs/Meshes/mesh";
  68816. import { Scene } from "babylonjs/scene";
  68817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68818. /**
  68819. * Class used to create a trail following a mesh
  68820. */
  68821. export class TrailMesh extends Mesh {
  68822. private _generator;
  68823. private _autoStart;
  68824. private _running;
  68825. private _diameter;
  68826. private _length;
  68827. private _sectionPolygonPointsCount;
  68828. private _sectionVectors;
  68829. private _sectionNormalVectors;
  68830. private _beforeRenderObserver;
  68831. /**
  68832. * @constructor
  68833. * @param name The value used by scene.getMeshByName() to do a lookup.
  68834. * @param generator The mesh or transform node to generate a trail.
  68835. * @param scene The scene to add this mesh to.
  68836. * @param diameter Diameter of trailing mesh. Default is 1.
  68837. * @param length Length of trailing mesh. Default is 60.
  68838. * @param autoStart Automatically start trailing mesh. Default true.
  68839. */
  68840. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68841. /**
  68842. * "TrailMesh"
  68843. * @returns "TrailMesh"
  68844. */
  68845. getClassName(): string;
  68846. private _createMesh;
  68847. /**
  68848. * Start trailing mesh.
  68849. */
  68850. start(): void;
  68851. /**
  68852. * Stop trailing mesh.
  68853. */
  68854. stop(): void;
  68855. /**
  68856. * Update trailing mesh geometry.
  68857. */
  68858. update(): void;
  68859. /**
  68860. * Returns a new TrailMesh object.
  68861. * @param name is a string, the name given to the new mesh
  68862. * @param newGenerator use new generator object for cloned trail mesh
  68863. * @returns a new mesh
  68864. */
  68865. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68866. /**
  68867. * Serializes this trail mesh
  68868. * @param serializationObject object to write serialization to
  68869. */
  68870. serialize(serializationObject: any): void;
  68871. /**
  68872. * Parses a serialized trail mesh
  68873. * @param parsedMesh the serialized mesh
  68874. * @param scene the scene to create the trail mesh in
  68875. * @returns the created trail mesh
  68876. */
  68877. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68878. }
  68879. }
  68880. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68881. import { Nullable } from "babylonjs/types";
  68882. import { Scene } from "babylonjs/scene";
  68883. import { Vector4 } from "babylonjs/Maths/math.vector";
  68884. import { Color4 } from "babylonjs/Maths/math.color";
  68885. import { Mesh } from "babylonjs/Meshes/mesh";
  68886. /**
  68887. * Class containing static functions to help procedurally build meshes
  68888. */
  68889. export class TiledBoxBuilder {
  68890. /**
  68891. * Creates a box mesh
  68892. * 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)
  68893. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68897. * @param name defines the name of the mesh
  68898. * @param options defines the options used to create the mesh
  68899. * @param scene defines the hosting scene
  68900. * @returns the box mesh
  68901. */
  68902. static CreateTiledBox(name: string, options: {
  68903. pattern?: number;
  68904. width?: number;
  68905. height?: number;
  68906. depth?: number;
  68907. tileSize?: number;
  68908. tileWidth?: number;
  68909. tileHeight?: number;
  68910. alignHorizontal?: number;
  68911. alignVertical?: number;
  68912. faceUV?: Vector4[];
  68913. faceColors?: Color4[];
  68914. sideOrientation?: number;
  68915. updatable?: boolean;
  68916. }, scene?: Nullable<Scene>): Mesh;
  68917. }
  68918. }
  68919. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68920. import { Vector4 } from "babylonjs/Maths/math.vector";
  68921. import { Mesh } from "babylonjs/Meshes/mesh";
  68922. /**
  68923. * Class containing static functions to help procedurally build meshes
  68924. */
  68925. export class TorusKnotBuilder {
  68926. /**
  68927. * Creates a torus knot mesh
  68928. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68929. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68930. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68931. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68935. * @param name defines the name of the mesh
  68936. * @param options defines the options used to create the mesh
  68937. * @param scene defines the hosting scene
  68938. * @returns the torus knot mesh
  68939. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68940. */
  68941. static CreateTorusKnot(name: string, options: {
  68942. radius?: number;
  68943. tube?: number;
  68944. radialSegments?: number;
  68945. tubularSegments?: number;
  68946. p?: number;
  68947. q?: number;
  68948. updatable?: boolean;
  68949. sideOrientation?: number;
  68950. frontUVs?: Vector4;
  68951. backUVs?: Vector4;
  68952. }, scene: any): Mesh;
  68953. }
  68954. }
  68955. declare module "babylonjs/Meshes/polygonMesh" {
  68956. import { Scene } from "babylonjs/scene";
  68957. import { Vector2 } from "babylonjs/Maths/math.vector";
  68958. import { Mesh } from "babylonjs/Meshes/mesh";
  68959. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68960. import { Path2 } from "babylonjs/Maths/math.path";
  68961. /**
  68962. * Polygon
  68963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68964. */
  68965. export class Polygon {
  68966. /**
  68967. * Creates a rectangle
  68968. * @param xmin bottom X coord
  68969. * @param ymin bottom Y coord
  68970. * @param xmax top X coord
  68971. * @param ymax top Y coord
  68972. * @returns points that make the resulting rectation
  68973. */
  68974. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68975. /**
  68976. * Creates a circle
  68977. * @param radius radius of circle
  68978. * @param cx scale in x
  68979. * @param cy scale in y
  68980. * @param numberOfSides number of sides that make up the circle
  68981. * @returns points that make the resulting circle
  68982. */
  68983. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68984. /**
  68985. * Creates a polygon from input string
  68986. * @param input Input polygon data
  68987. * @returns the parsed points
  68988. */
  68989. static Parse(input: string): Vector2[];
  68990. /**
  68991. * Starts building a polygon from x and y coordinates
  68992. * @param x x coordinate
  68993. * @param y y coordinate
  68994. * @returns the started path2
  68995. */
  68996. static StartingAt(x: number, y: number): Path2;
  68997. }
  68998. /**
  68999. * Builds a polygon
  69000. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69001. */
  69002. export class PolygonMeshBuilder {
  69003. private _points;
  69004. private _outlinepoints;
  69005. private _holes;
  69006. private _name;
  69007. private _scene;
  69008. private _epoints;
  69009. private _eholes;
  69010. private _addToepoint;
  69011. /**
  69012. * Babylon reference to the earcut plugin.
  69013. */
  69014. bjsEarcut: any;
  69015. /**
  69016. * Creates a PolygonMeshBuilder
  69017. * @param name name of the builder
  69018. * @param contours Path of the polygon
  69019. * @param scene scene to add to when creating the mesh
  69020. * @param earcutInjection can be used to inject your own earcut reference
  69021. */
  69022. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69023. /**
  69024. * Adds a whole within the polygon
  69025. * @param hole Array of points defining the hole
  69026. * @returns this
  69027. */
  69028. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69029. /**
  69030. * Creates the polygon
  69031. * @param updatable If the mesh should be updatable
  69032. * @param depth The depth of the mesh created
  69033. * @returns the created mesh
  69034. */
  69035. build(updatable?: boolean, depth?: number): Mesh;
  69036. /**
  69037. * Creates the polygon
  69038. * @param depth The depth of the mesh created
  69039. * @returns the created VertexData
  69040. */
  69041. buildVertexData(depth?: number): VertexData;
  69042. /**
  69043. * Adds a side to the polygon
  69044. * @param positions points that make the polygon
  69045. * @param normals normals of the polygon
  69046. * @param uvs uvs of the polygon
  69047. * @param indices indices of the polygon
  69048. * @param bounds bounds of the polygon
  69049. * @param points points of the polygon
  69050. * @param depth depth of the polygon
  69051. * @param flip flip of the polygon
  69052. */
  69053. private addSide;
  69054. }
  69055. }
  69056. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69057. import { Scene } from "babylonjs/scene";
  69058. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69059. import { Color4 } from "babylonjs/Maths/math.color";
  69060. import { Mesh } from "babylonjs/Meshes/mesh";
  69061. import { Nullable } from "babylonjs/types";
  69062. /**
  69063. * Class containing static functions to help procedurally build meshes
  69064. */
  69065. export class PolygonBuilder {
  69066. /**
  69067. * Creates a polygon mesh
  69068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69069. * * 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
  69070. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69073. * * Remember you can only change the shape positions, not their number when updating a polygon
  69074. * @param name defines the name of the mesh
  69075. * @param options defines the options used to create the mesh
  69076. * @param scene defines the hosting scene
  69077. * @param earcutInjection can be used to inject your own earcut reference
  69078. * @returns the polygon mesh
  69079. */
  69080. static CreatePolygon(name: string, options: {
  69081. shape: Vector3[];
  69082. holes?: Vector3[][];
  69083. depth?: number;
  69084. faceUV?: Vector4[];
  69085. faceColors?: Color4[];
  69086. updatable?: boolean;
  69087. sideOrientation?: number;
  69088. frontUVs?: Vector4;
  69089. backUVs?: Vector4;
  69090. wrap?: boolean;
  69091. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69092. /**
  69093. * Creates an extruded polygon mesh, with depth in the Y direction.
  69094. * * 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)
  69095. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69096. * @param name defines the name of the mesh
  69097. * @param options defines the options used to create the mesh
  69098. * @param scene defines the hosting scene
  69099. * @param earcutInjection can be used to inject your own earcut reference
  69100. * @returns the polygon mesh
  69101. */
  69102. static ExtrudePolygon(name: string, options: {
  69103. shape: Vector3[];
  69104. holes?: Vector3[][];
  69105. depth?: number;
  69106. faceUV?: Vector4[];
  69107. faceColors?: Color4[];
  69108. updatable?: boolean;
  69109. sideOrientation?: number;
  69110. frontUVs?: Vector4;
  69111. backUVs?: Vector4;
  69112. wrap?: boolean;
  69113. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69114. }
  69115. }
  69116. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69117. import { Scene } from "babylonjs/scene";
  69118. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69119. import { Mesh } from "babylonjs/Meshes/mesh";
  69120. import { Nullable } from "babylonjs/types";
  69121. /**
  69122. * Class containing static functions to help procedurally build meshes
  69123. */
  69124. export class LatheBuilder {
  69125. /**
  69126. * Creates lathe mesh.
  69127. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69128. * * 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
  69129. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69130. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69131. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69132. * * 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
  69133. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69134. * * 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
  69135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69137. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69139. * @param name defines the name of the mesh
  69140. * @param options defines the options used to create the mesh
  69141. * @param scene defines the hosting scene
  69142. * @returns the lathe mesh
  69143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69144. */
  69145. static CreateLathe(name: string, options: {
  69146. shape: Vector3[];
  69147. radius?: number;
  69148. tessellation?: number;
  69149. clip?: number;
  69150. arc?: number;
  69151. closed?: boolean;
  69152. updatable?: boolean;
  69153. sideOrientation?: number;
  69154. frontUVs?: Vector4;
  69155. backUVs?: Vector4;
  69156. cap?: number;
  69157. invertUV?: boolean;
  69158. }, scene?: Nullable<Scene>): Mesh;
  69159. }
  69160. }
  69161. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69162. import { Nullable } from "babylonjs/types";
  69163. import { Scene } from "babylonjs/scene";
  69164. import { Vector4 } from "babylonjs/Maths/math.vector";
  69165. import { Mesh } from "babylonjs/Meshes/mesh";
  69166. /**
  69167. * Class containing static functions to help procedurally build meshes
  69168. */
  69169. export class TiledPlaneBuilder {
  69170. /**
  69171. * Creates a tiled plane mesh
  69172. * * The parameter `pattern` will, depending on value, do nothing or
  69173. * * * flip (reflect about central vertical) alternate tiles across and up
  69174. * * * flip every tile on alternate rows
  69175. * * * rotate (180 degs) alternate tiles across and up
  69176. * * * rotate every tile on alternate rows
  69177. * * * flip and rotate alternate tiles across and up
  69178. * * * flip and rotate every tile on alternate rows
  69179. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69180. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69183. * * 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)
  69184. * * 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)
  69185. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69186. * @param name defines the name of the mesh
  69187. * @param options defines the options used to create the mesh
  69188. * @param scene defines the hosting scene
  69189. * @returns the box mesh
  69190. */
  69191. static CreateTiledPlane(name: string, options: {
  69192. pattern?: number;
  69193. tileSize?: number;
  69194. tileWidth?: number;
  69195. tileHeight?: number;
  69196. size?: number;
  69197. width?: number;
  69198. height?: number;
  69199. alignHorizontal?: number;
  69200. alignVertical?: number;
  69201. sideOrientation?: number;
  69202. frontUVs?: Vector4;
  69203. backUVs?: Vector4;
  69204. updatable?: boolean;
  69205. }, scene?: Nullable<Scene>): Mesh;
  69206. }
  69207. }
  69208. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69209. import { Nullable } from "babylonjs/types";
  69210. import { Scene } from "babylonjs/scene";
  69211. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69212. import { Mesh } from "babylonjs/Meshes/mesh";
  69213. /**
  69214. * Class containing static functions to help procedurally build meshes
  69215. */
  69216. export class TubeBuilder {
  69217. /**
  69218. * Creates a tube mesh.
  69219. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69220. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69221. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69222. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69223. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69224. * * 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)
  69225. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69226. * * 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
  69227. * * 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
  69228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69230. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69232. * @param name defines the name of the mesh
  69233. * @param options defines the options used to create the mesh
  69234. * @param scene defines the hosting scene
  69235. * @returns the tube mesh
  69236. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69237. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69238. */
  69239. static CreateTube(name: string, options: {
  69240. path: Vector3[];
  69241. radius?: number;
  69242. tessellation?: number;
  69243. radiusFunction?: {
  69244. (i: number, distance: number): number;
  69245. };
  69246. cap?: number;
  69247. arc?: number;
  69248. updatable?: boolean;
  69249. sideOrientation?: number;
  69250. frontUVs?: Vector4;
  69251. backUVs?: Vector4;
  69252. instance?: Mesh;
  69253. invertUV?: boolean;
  69254. }, scene?: Nullable<Scene>): Mesh;
  69255. }
  69256. }
  69257. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69258. import { Scene } from "babylonjs/scene";
  69259. import { Vector4 } from "babylonjs/Maths/math.vector";
  69260. import { Mesh } from "babylonjs/Meshes/mesh";
  69261. import { Nullable } from "babylonjs/types";
  69262. /**
  69263. * Class containing static functions to help procedurally build meshes
  69264. */
  69265. export class IcoSphereBuilder {
  69266. /**
  69267. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69268. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69269. * * 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`)
  69270. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69271. * * 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
  69272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69275. * @param name defines the name of the mesh
  69276. * @param options defines the options used to create the mesh
  69277. * @param scene defines the hosting scene
  69278. * @returns the icosahedron mesh
  69279. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69280. */
  69281. static CreateIcoSphere(name: string, options: {
  69282. radius?: number;
  69283. radiusX?: number;
  69284. radiusY?: number;
  69285. radiusZ?: number;
  69286. flat?: boolean;
  69287. subdivisions?: number;
  69288. sideOrientation?: number;
  69289. frontUVs?: Vector4;
  69290. backUVs?: Vector4;
  69291. updatable?: boolean;
  69292. }, scene?: Nullable<Scene>): Mesh;
  69293. }
  69294. }
  69295. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69296. import { Vector3 } from "babylonjs/Maths/math.vector";
  69297. import { Mesh } from "babylonjs/Meshes/mesh";
  69298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69299. /**
  69300. * Class containing static functions to help procedurally build meshes
  69301. */
  69302. export class DecalBuilder {
  69303. /**
  69304. * Creates a decal mesh.
  69305. * 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
  69306. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69307. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69308. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69309. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69310. * @param name defines the name of the mesh
  69311. * @param sourceMesh defines the mesh where the decal must be applied
  69312. * @param options defines the options used to create the mesh
  69313. * @param scene defines the hosting scene
  69314. * @returns the decal mesh
  69315. * @see https://doc.babylonjs.com/how_to/decals
  69316. */
  69317. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69318. position?: Vector3;
  69319. normal?: Vector3;
  69320. size?: Vector3;
  69321. angle?: number;
  69322. }): Mesh;
  69323. }
  69324. }
  69325. declare module "babylonjs/Meshes/meshBuilder" {
  69326. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69327. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69328. import { Nullable } from "babylonjs/types";
  69329. import { Scene } from "babylonjs/scene";
  69330. import { Mesh } from "babylonjs/Meshes/mesh";
  69331. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69332. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69334. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69335. import { Plane } from "babylonjs/Maths/math.plane";
  69336. /**
  69337. * Class containing static functions to help procedurally build meshes
  69338. */
  69339. export class MeshBuilder {
  69340. /**
  69341. * Creates a box mesh
  69342. * * The parameter `size` sets the size (float) of each box side (default 1)
  69343. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69344. * * 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)
  69345. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69349. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69350. * @param name defines the name of the mesh
  69351. * @param options defines the options used to create the mesh
  69352. * @param scene defines the hosting scene
  69353. * @returns the box mesh
  69354. */
  69355. static CreateBox(name: string, options: {
  69356. size?: number;
  69357. width?: number;
  69358. height?: number;
  69359. depth?: number;
  69360. faceUV?: Vector4[];
  69361. faceColors?: Color4[];
  69362. sideOrientation?: number;
  69363. frontUVs?: Vector4;
  69364. backUVs?: Vector4;
  69365. wrap?: boolean;
  69366. topBaseAt?: number;
  69367. bottomBaseAt?: number;
  69368. updatable?: boolean;
  69369. }, scene?: Nullable<Scene>): Mesh;
  69370. /**
  69371. * Creates a tiled box mesh
  69372. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69374. * @param name defines the name of the mesh
  69375. * @param options defines the options used to create the mesh
  69376. * @param scene defines the hosting scene
  69377. * @returns the tiled box mesh
  69378. */
  69379. static CreateTiledBox(name: string, options: {
  69380. pattern?: number;
  69381. size?: number;
  69382. width?: number;
  69383. height?: number;
  69384. depth: number;
  69385. tileSize?: number;
  69386. tileWidth?: number;
  69387. tileHeight?: number;
  69388. faceUV?: Vector4[];
  69389. faceColors?: Color4[];
  69390. alignHorizontal?: number;
  69391. alignVertical?: number;
  69392. sideOrientation?: number;
  69393. updatable?: boolean;
  69394. }, scene?: Nullable<Scene>): Mesh;
  69395. /**
  69396. * Creates a sphere mesh
  69397. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69398. * * 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`)
  69399. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69400. * * 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
  69401. * * 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)
  69402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69405. * @param name defines the name of the mesh
  69406. * @param options defines the options used to create the mesh
  69407. * @param scene defines the hosting scene
  69408. * @returns the sphere mesh
  69409. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69410. */
  69411. static CreateSphere(name: string, options: {
  69412. segments?: number;
  69413. diameter?: number;
  69414. diameterX?: number;
  69415. diameterY?: number;
  69416. diameterZ?: number;
  69417. arc?: number;
  69418. slice?: number;
  69419. sideOrientation?: number;
  69420. frontUVs?: Vector4;
  69421. backUVs?: Vector4;
  69422. updatable?: boolean;
  69423. }, scene?: Nullable<Scene>): Mesh;
  69424. /**
  69425. * Creates a plane polygonal mesh. By default, this is a disc
  69426. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69427. * * 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
  69428. * * 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
  69429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69432. * @param name defines the name of the mesh
  69433. * @param options defines the options used to create the mesh
  69434. * @param scene defines the hosting scene
  69435. * @returns the plane polygonal mesh
  69436. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69437. */
  69438. static CreateDisc(name: string, options: {
  69439. radius?: number;
  69440. tessellation?: number;
  69441. arc?: number;
  69442. updatable?: boolean;
  69443. sideOrientation?: number;
  69444. frontUVs?: Vector4;
  69445. backUVs?: Vector4;
  69446. }, scene?: Nullable<Scene>): Mesh;
  69447. /**
  69448. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69449. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69450. * * 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`)
  69451. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69452. * * 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
  69453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69456. * @param name defines the name of the mesh
  69457. * @param options defines the options used to create the mesh
  69458. * @param scene defines the hosting scene
  69459. * @returns the icosahedron mesh
  69460. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69461. */
  69462. static CreateIcoSphere(name: string, options: {
  69463. radius?: number;
  69464. radiusX?: number;
  69465. radiusY?: number;
  69466. radiusZ?: number;
  69467. flat?: boolean;
  69468. subdivisions?: number;
  69469. sideOrientation?: number;
  69470. frontUVs?: Vector4;
  69471. backUVs?: Vector4;
  69472. updatable?: boolean;
  69473. }, scene?: Nullable<Scene>): Mesh;
  69474. /**
  69475. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69476. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69477. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69478. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69479. * * 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
  69480. * * 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
  69481. * * 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
  69482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69485. * * 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
  69486. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69487. * * 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
  69488. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69490. * @param name defines the name of the mesh
  69491. * @param options defines the options used to create the mesh
  69492. * @param scene defines the hosting scene
  69493. * @returns the ribbon mesh
  69494. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69495. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69496. */
  69497. static CreateRibbon(name: string, options: {
  69498. pathArray: Vector3[][];
  69499. closeArray?: boolean;
  69500. closePath?: boolean;
  69501. offset?: number;
  69502. updatable?: boolean;
  69503. sideOrientation?: number;
  69504. frontUVs?: Vector4;
  69505. backUVs?: Vector4;
  69506. instance?: Mesh;
  69507. invertUV?: boolean;
  69508. uvs?: Vector2[];
  69509. colors?: Color4[];
  69510. }, scene?: Nullable<Scene>): Mesh;
  69511. /**
  69512. * Creates a cylinder or a cone mesh
  69513. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69514. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69515. * * 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.
  69516. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69517. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69518. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69519. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69520. * * 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).
  69521. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69522. * * 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).
  69523. * * 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
  69524. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69525. * * 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
  69526. * * 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.
  69527. * * If `enclose` is false, a ring surface is one element.
  69528. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69529. * * 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
  69530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69533. * @param name defines the name of the mesh
  69534. * @param options defines the options used to create the mesh
  69535. * @param scene defines the hosting scene
  69536. * @returns the cylinder mesh
  69537. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69538. */
  69539. static CreateCylinder(name: string, options: {
  69540. height?: number;
  69541. diameterTop?: number;
  69542. diameterBottom?: number;
  69543. diameter?: number;
  69544. tessellation?: number;
  69545. subdivisions?: number;
  69546. arc?: number;
  69547. faceColors?: Color4[];
  69548. faceUV?: Vector4[];
  69549. updatable?: boolean;
  69550. hasRings?: boolean;
  69551. enclose?: boolean;
  69552. cap?: number;
  69553. sideOrientation?: number;
  69554. frontUVs?: Vector4;
  69555. backUVs?: Vector4;
  69556. }, scene?: Nullable<Scene>): Mesh;
  69557. /**
  69558. * Creates a torus mesh
  69559. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69560. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69561. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69565. * @param name defines the name of the mesh
  69566. * @param options defines the options used to create the mesh
  69567. * @param scene defines the hosting scene
  69568. * @returns the torus mesh
  69569. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69570. */
  69571. static CreateTorus(name: string, options: {
  69572. diameter?: number;
  69573. thickness?: number;
  69574. tessellation?: number;
  69575. updatable?: boolean;
  69576. sideOrientation?: number;
  69577. frontUVs?: Vector4;
  69578. backUVs?: Vector4;
  69579. }, scene?: Nullable<Scene>): Mesh;
  69580. /**
  69581. * Creates a torus knot mesh
  69582. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69583. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69584. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69585. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69589. * @param name defines the name of the mesh
  69590. * @param options defines the options used to create the mesh
  69591. * @param scene defines the hosting scene
  69592. * @returns the torus knot mesh
  69593. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69594. */
  69595. static CreateTorusKnot(name: string, options: {
  69596. radius?: number;
  69597. tube?: number;
  69598. radialSegments?: number;
  69599. tubularSegments?: number;
  69600. p?: number;
  69601. q?: number;
  69602. updatable?: boolean;
  69603. sideOrientation?: number;
  69604. frontUVs?: Vector4;
  69605. backUVs?: Vector4;
  69606. }, scene?: Nullable<Scene>): Mesh;
  69607. /**
  69608. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69609. * * 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
  69610. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69611. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69612. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69613. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69614. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69615. * * 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
  69616. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69619. * @param name defines the name of the new line system
  69620. * @param options defines the options used to create the line system
  69621. * @param scene defines the hosting scene
  69622. * @returns a new line system mesh
  69623. */
  69624. static CreateLineSystem(name: string, options: {
  69625. lines: Vector3[][];
  69626. updatable?: boolean;
  69627. instance?: Nullable<LinesMesh>;
  69628. colors?: Nullable<Color4[][]>;
  69629. useVertexAlpha?: boolean;
  69630. }, scene: Nullable<Scene>): LinesMesh;
  69631. /**
  69632. * Creates a line mesh
  69633. * 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
  69634. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69635. * * The parameter `points` is an array successive Vector3
  69636. * * 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
  69637. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69638. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69639. * * When updating an instance, remember that only point positions can change, not the number of points
  69640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69642. * @param name defines the name of the new line system
  69643. * @param options defines the options used to create the line system
  69644. * @param scene defines the hosting scene
  69645. * @returns a new line mesh
  69646. */
  69647. static CreateLines(name: string, options: {
  69648. points: Vector3[];
  69649. updatable?: boolean;
  69650. instance?: Nullable<LinesMesh>;
  69651. colors?: Color4[];
  69652. useVertexAlpha?: boolean;
  69653. }, scene?: Nullable<Scene>): LinesMesh;
  69654. /**
  69655. * Creates a dashed line mesh
  69656. * * 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
  69657. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69658. * * The parameter `points` is an array successive Vector3
  69659. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69660. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69661. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69662. * * 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
  69663. * * When updating an instance, remember that only point positions can change, not the number of points
  69664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69665. * @param name defines the name of the mesh
  69666. * @param options defines the options used to create the mesh
  69667. * @param scene defines the hosting scene
  69668. * @returns the dashed line mesh
  69669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69670. */
  69671. static CreateDashedLines(name: string, options: {
  69672. points: Vector3[];
  69673. dashSize?: number;
  69674. gapSize?: number;
  69675. dashNb?: number;
  69676. updatable?: boolean;
  69677. instance?: LinesMesh;
  69678. }, scene?: Nullable<Scene>): LinesMesh;
  69679. /**
  69680. * 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.
  69681. * * 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.
  69682. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69683. * * 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.
  69684. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69685. * * 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
  69686. * * 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
  69687. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69690. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69692. * @param name defines the name of the mesh
  69693. * @param options defines the options used to create the mesh
  69694. * @param scene defines the hosting scene
  69695. * @returns the extruded shape mesh
  69696. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69698. */
  69699. static ExtrudeShape(name: string, options: {
  69700. shape: Vector3[];
  69701. path: Vector3[];
  69702. scale?: number;
  69703. rotation?: number;
  69704. cap?: number;
  69705. updatable?: boolean;
  69706. sideOrientation?: number;
  69707. frontUVs?: Vector4;
  69708. backUVs?: Vector4;
  69709. instance?: Mesh;
  69710. invertUV?: boolean;
  69711. }, scene?: Nullable<Scene>): Mesh;
  69712. /**
  69713. * Creates an custom extruded shape mesh.
  69714. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69715. * * 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.
  69716. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69717. * * 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
  69718. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69719. * * 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
  69720. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69721. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69722. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69723. * * 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
  69724. * * 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
  69725. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69730. * @param name defines the name of the mesh
  69731. * @param options defines the options used to create the mesh
  69732. * @param scene defines the hosting scene
  69733. * @returns the custom extruded shape mesh
  69734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69735. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69737. */
  69738. static ExtrudeShapeCustom(name: string, options: {
  69739. shape: Vector3[];
  69740. path: Vector3[];
  69741. scaleFunction?: any;
  69742. rotationFunction?: any;
  69743. ribbonCloseArray?: boolean;
  69744. ribbonClosePath?: boolean;
  69745. cap?: number;
  69746. updatable?: boolean;
  69747. sideOrientation?: number;
  69748. frontUVs?: Vector4;
  69749. backUVs?: Vector4;
  69750. instance?: Mesh;
  69751. invertUV?: boolean;
  69752. }, scene?: Nullable<Scene>): Mesh;
  69753. /**
  69754. * Creates lathe mesh.
  69755. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69756. * * 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
  69757. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69758. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69759. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69760. * * 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
  69761. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69762. * * 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
  69763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69767. * @param name defines the name of the mesh
  69768. * @param options defines the options used to create the mesh
  69769. * @param scene defines the hosting scene
  69770. * @returns the lathe mesh
  69771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69772. */
  69773. static CreateLathe(name: string, options: {
  69774. shape: Vector3[];
  69775. radius?: number;
  69776. tessellation?: number;
  69777. clip?: number;
  69778. arc?: number;
  69779. closed?: boolean;
  69780. updatable?: boolean;
  69781. sideOrientation?: number;
  69782. frontUVs?: Vector4;
  69783. backUVs?: Vector4;
  69784. cap?: number;
  69785. invertUV?: boolean;
  69786. }, scene?: Nullable<Scene>): Mesh;
  69787. /**
  69788. * Creates a tiled plane mesh
  69789. * * You can set a limited pattern arrangement with the tiles
  69790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69793. * @param name defines the name of the mesh
  69794. * @param options defines the options used to create the mesh
  69795. * @param scene defines the hosting scene
  69796. * @returns the plane mesh
  69797. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69798. */
  69799. static CreateTiledPlane(name: string, options: {
  69800. pattern?: number;
  69801. tileSize?: number;
  69802. tileWidth?: number;
  69803. tileHeight?: number;
  69804. size?: number;
  69805. width?: number;
  69806. height?: number;
  69807. alignHorizontal?: number;
  69808. alignVertical?: number;
  69809. sideOrientation?: number;
  69810. frontUVs?: Vector4;
  69811. backUVs?: Vector4;
  69812. updatable?: boolean;
  69813. }, scene?: Nullable<Scene>): Mesh;
  69814. /**
  69815. * Creates a plane mesh
  69816. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69817. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69818. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69822. * @param name defines the name of the mesh
  69823. * @param options defines the options used to create the mesh
  69824. * @param scene defines the hosting scene
  69825. * @returns the plane mesh
  69826. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69827. */
  69828. static CreatePlane(name: string, options: {
  69829. size?: number;
  69830. width?: number;
  69831. height?: number;
  69832. sideOrientation?: number;
  69833. frontUVs?: Vector4;
  69834. backUVs?: Vector4;
  69835. updatable?: boolean;
  69836. sourcePlane?: Plane;
  69837. }, scene?: Nullable<Scene>): Mesh;
  69838. /**
  69839. * Creates a ground mesh
  69840. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69841. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69843. * @param name defines the name of the mesh
  69844. * @param options defines the options used to create the mesh
  69845. * @param scene defines the hosting scene
  69846. * @returns the ground mesh
  69847. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69848. */
  69849. static CreateGround(name: string, options: {
  69850. width?: number;
  69851. height?: number;
  69852. subdivisions?: number;
  69853. subdivisionsX?: number;
  69854. subdivisionsY?: number;
  69855. updatable?: boolean;
  69856. }, scene?: Nullable<Scene>): Mesh;
  69857. /**
  69858. * Creates a tiled ground mesh
  69859. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69860. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69861. * * 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
  69862. * * 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
  69863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69864. * @param name defines the name of the mesh
  69865. * @param options defines the options used to create the mesh
  69866. * @param scene defines the hosting scene
  69867. * @returns the tiled ground mesh
  69868. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69869. */
  69870. static CreateTiledGround(name: string, options: {
  69871. xmin: number;
  69872. zmin: number;
  69873. xmax: number;
  69874. zmax: number;
  69875. subdivisions?: {
  69876. w: number;
  69877. h: number;
  69878. };
  69879. precision?: {
  69880. w: number;
  69881. h: number;
  69882. };
  69883. updatable?: boolean;
  69884. }, scene?: Nullable<Scene>): Mesh;
  69885. /**
  69886. * Creates a ground mesh from a height map
  69887. * * The parameter `url` sets the URL of the height map image resource.
  69888. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69889. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69890. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69891. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69892. * * 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.
  69893. * * 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).
  69894. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69896. * @param name defines the name of the mesh
  69897. * @param url defines the url to the height map
  69898. * @param options defines the options used to create the mesh
  69899. * @param scene defines the hosting scene
  69900. * @returns the ground mesh
  69901. * @see https://doc.babylonjs.com/babylon101/height_map
  69902. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69903. */
  69904. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69905. width?: number;
  69906. height?: number;
  69907. subdivisions?: number;
  69908. minHeight?: number;
  69909. maxHeight?: number;
  69910. colorFilter?: Color3;
  69911. alphaFilter?: number;
  69912. updatable?: boolean;
  69913. onReady?: (mesh: GroundMesh) => void;
  69914. }, scene?: Nullable<Scene>): GroundMesh;
  69915. /**
  69916. * Creates a polygon mesh
  69917. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69918. * * 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
  69919. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69922. * * Remember you can only change the shape positions, not their number when updating a polygon
  69923. * @param name defines the name of the mesh
  69924. * @param options defines the options used to create the mesh
  69925. * @param scene defines the hosting scene
  69926. * @param earcutInjection can be used to inject your own earcut reference
  69927. * @returns the polygon mesh
  69928. */
  69929. static CreatePolygon(name: string, options: {
  69930. shape: Vector3[];
  69931. holes?: Vector3[][];
  69932. depth?: number;
  69933. faceUV?: Vector4[];
  69934. faceColors?: Color4[];
  69935. updatable?: boolean;
  69936. sideOrientation?: number;
  69937. frontUVs?: Vector4;
  69938. backUVs?: Vector4;
  69939. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69940. /**
  69941. * Creates an extruded polygon mesh, with depth in the Y direction.
  69942. * * 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)
  69943. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69944. * @param name defines the name of the mesh
  69945. * @param options defines the options used to create the mesh
  69946. * @param scene defines the hosting scene
  69947. * @param earcutInjection can be used to inject your own earcut reference
  69948. * @returns the polygon mesh
  69949. */
  69950. static ExtrudePolygon(name: string, options: {
  69951. shape: Vector3[];
  69952. holes?: Vector3[][];
  69953. depth?: number;
  69954. faceUV?: Vector4[];
  69955. faceColors?: Color4[];
  69956. updatable?: boolean;
  69957. sideOrientation?: number;
  69958. frontUVs?: Vector4;
  69959. backUVs?: Vector4;
  69960. wrap?: boolean;
  69961. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69962. /**
  69963. * Creates a tube mesh.
  69964. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69965. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69966. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69967. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69968. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69969. * * 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)
  69970. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69971. * * 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
  69972. * * 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
  69973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69977. * @param name defines the name of the mesh
  69978. * @param options defines the options used to create the mesh
  69979. * @param scene defines the hosting scene
  69980. * @returns the tube mesh
  69981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69982. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69983. */
  69984. static CreateTube(name: string, options: {
  69985. path: Vector3[];
  69986. radius?: number;
  69987. tessellation?: number;
  69988. radiusFunction?: {
  69989. (i: number, distance: number): number;
  69990. };
  69991. cap?: number;
  69992. arc?: number;
  69993. updatable?: boolean;
  69994. sideOrientation?: number;
  69995. frontUVs?: Vector4;
  69996. backUVs?: Vector4;
  69997. instance?: Mesh;
  69998. invertUV?: boolean;
  69999. }, scene?: Nullable<Scene>): Mesh;
  70000. /**
  70001. * Creates a polyhedron mesh
  70002. * * 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
  70003. * * The parameter `size` (positive float, default 1) sets the polygon size
  70004. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70005. * * 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`
  70006. * * 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
  70007. * * 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)`)
  70008. * * 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
  70009. * * 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
  70010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70013. * @param name defines the name of the mesh
  70014. * @param options defines the options used to create the mesh
  70015. * @param scene defines the hosting scene
  70016. * @returns the polyhedron mesh
  70017. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70018. */
  70019. static CreatePolyhedron(name: string, options: {
  70020. type?: number;
  70021. size?: number;
  70022. sizeX?: number;
  70023. sizeY?: number;
  70024. sizeZ?: number;
  70025. custom?: any;
  70026. faceUV?: Vector4[];
  70027. faceColors?: Color4[];
  70028. flat?: boolean;
  70029. updatable?: boolean;
  70030. sideOrientation?: number;
  70031. frontUVs?: Vector4;
  70032. backUVs?: Vector4;
  70033. }, scene?: Nullable<Scene>): Mesh;
  70034. /**
  70035. * Creates a decal mesh.
  70036. * 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
  70037. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70038. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70039. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70040. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70041. * @param name defines the name of the mesh
  70042. * @param sourceMesh defines the mesh where the decal must be applied
  70043. * @param options defines the options used to create the mesh
  70044. * @param scene defines the hosting scene
  70045. * @returns the decal mesh
  70046. * @see https://doc.babylonjs.com/how_to/decals
  70047. */
  70048. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70049. position?: Vector3;
  70050. normal?: Vector3;
  70051. size?: Vector3;
  70052. angle?: number;
  70053. }): Mesh;
  70054. /**
  70055. * Creates a Capsule Mesh
  70056. * @param name defines the name of the mesh.
  70057. * @param options the constructors options used to shape the mesh.
  70058. * @param scene defines the scene the mesh is scoped to.
  70059. * @returns the capsule mesh
  70060. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70061. */
  70062. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70063. }
  70064. }
  70065. declare module "babylonjs/Meshes/meshSimplification" {
  70066. import { Mesh } from "babylonjs/Meshes/mesh";
  70067. /**
  70068. * A simplifier interface for future simplification implementations
  70069. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70070. */
  70071. export interface ISimplifier {
  70072. /**
  70073. * Simplification of a given mesh according to the given settings.
  70074. * Since this requires computation, it is assumed that the function runs async.
  70075. * @param settings The settings of the simplification, including quality and distance
  70076. * @param successCallback A callback that will be called after the mesh was simplified.
  70077. * @param errorCallback in case of an error, this callback will be called. optional.
  70078. */
  70079. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70080. }
  70081. /**
  70082. * Expected simplification settings.
  70083. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70084. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70085. */
  70086. export interface ISimplificationSettings {
  70087. /**
  70088. * Gets or sets the expected quality
  70089. */
  70090. quality: number;
  70091. /**
  70092. * Gets or sets the distance when this optimized version should be used
  70093. */
  70094. distance: number;
  70095. /**
  70096. * Gets an already optimized mesh
  70097. */
  70098. optimizeMesh?: boolean;
  70099. }
  70100. /**
  70101. * Class used to specify simplification options
  70102. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70103. */
  70104. export class SimplificationSettings implements ISimplificationSettings {
  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. * Creates a SimplificationSettings
  70113. * @param quality expected quality
  70114. * @param distance distance when this optimized version should be used
  70115. * @param optimizeMesh already optimized mesh
  70116. */
  70117. constructor(
  70118. /** expected quality */
  70119. quality: number,
  70120. /** distance when this optimized version should be used */
  70121. distance: number,
  70122. /** already optimized mesh */
  70123. optimizeMesh?: boolean | undefined);
  70124. }
  70125. /**
  70126. * Interface used to define a simplification task
  70127. */
  70128. export interface ISimplificationTask {
  70129. /**
  70130. * Array of settings
  70131. */
  70132. settings: Array<ISimplificationSettings>;
  70133. /**
  70134. * Simplification type
  70135. */
  70136. simplificationType: SimplificationType;
  70137. /**
  70138. * Mesh to simplify
  70139. */
  70140. mesh: Mesh;
  70141. /**
  70142. * Callback called on success
  70143. */
  70144. successCallback?: () => void;
  70145. /**
  70146. * Defines if parallel processing can be used
  70147. */
  70148. parallelProcessing: boolean;
  70149. }
  70150. /**
  70151. * Queue used to order the simplification tasks
  70152. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70153. */
  70154. export class SimplificationQueue {
  70155. private _simplificationArray;
  70156. /**
  70157. * Gets a boolean indicating that the process is still running
  70158. */
  70159. running: boolean;
  70160. /**
  70161. * Creates a new queue
  70162. */
  70163. constructor();
  70164. /**
  70165. * Adds a new simplification task
  70166. * @param task defines a task to add
  70167. */
  70168. addTask(task: ISimplificationTask): void;
  70169. /**
  70170. * Execute next task
  70171. */
  70172. executeNext(): void;
  70173. /**
  70174. * Execute a simplification task
  70175. * @param task defines the task to run
  70176. */
  70177. runSimplification(task: ISimplificationTask): void;
  70178. private getSimplifier;
  70179. }
  70180. /**
  70181. * The implemented types of simplification
  70182. * At the moment only Quadratic Error Decimation is implemented
  70183. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70184. */
  70185. export enum SimplificationType {
  70186. /** Quadratic error decimation */
  70187. QUADRATIC = 0
  70188. }
  70189. /**
  70190. * An implementation of the Quadratic Error simplification algorithm.
  70191. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70192. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70193. * @author RaananW
  70194. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70195. */
  70196. export class QuadraticErrorSimplification implements ISimplifier {
  70197. private _mesh;
  70198. private triangles;
  70199. private vertices;
  70200. private references;
  70201. private _reconstructedMesh;
  70202. /** Gets or sets the number pf sync interations */
  70203. syncIterations: number;
  70204. /** Gets or sets the aggressiveness of the simplifier */
  70205. aggressiveness: number;
  70206. /** Gets or sets the number of allowed iterations for decimation */
  70207. decimationIterations: number;
  70208. /** Gets or sets the espilon to use for bounding box computation */
  70209. boundingBoxEpsilon: number;
  70210. /**
  70211. * Creates a new QuadraticErrorSimplification
  70212. * @param _mesh defines the target mesh
  70213. */
  70214. constructor(_mesh: Mesh);
  70215. /**
  70216. * Simplification of a given mesh according to the given settings.
  70217. * Since this requires computation, it is assumed that the function runs async.
  70218. * @param settings The settings of the simplification, including quality and distance
  70219. * @param successCallback A callback that will be called after the mesh was simplified.
  70220. */
  70221. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70222. private runDecimation;
  70223. private initWithMesh;
  70224. private init;
  70225. private reconstructMesh;
  70226. private initDecimatedMesh;
  70227. private isFlipped;
  70228. private updateTriangles;
  70229. private identifyBorder;
  70230. private updateMesh;
  70231. private vertexError;
  70232. private calculateError;
  70233. }
  70234. }
  70235. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70236. import { Scene } from "babylonjs/scene";
  70237. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70238. import { ISceneComponent } from "babylonjs/sceneComponent";
  70239. module "babylonjs/scene" {
  70240. interface Scene {
  70241. /** @hidden (Backing field) */
  70242. _simplificationQueue: SimplificationQueue;
  70243. /**
  70244. * Gets or sets the simplification queue attached to the scene
  70245. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70246. */
  70247. simplificationQueue: SimplificationQueue;
  70248. }
  70249. }
  70250. module "babylonjs/Meshes/mesh" {
  70251. interface Mesh {
  70252. /**
  70253. * Simplify the mesh according to the given array of settings.
  70254. * Function will return immediately and will simplify async
  70255. * @param settings a collection of simplification settings
  70256. * @param parallelProcessing should all levels calculate parallel or one after the other
  70257. * @param simplificationType the type of simplification to run
  70258. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70259. * @returns the current mesh
  70260. */
  70261. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70262. }
  70263. }
  70264. /**
  70265. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70266. * created in a scene
  70267. */
  70268. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70269. /**
  70270. * The component name helpfull to identify the component in the list of scene components.
  70271. */
  70272. readonly name: string;
  70273. /**
  70274. * The scene the component belongs to.
  70275. */
  70276. scene: Scene;
  70277. /**
  70278. * Creates a new instance of the component for the given scene
  70279. * @param scene Defines the scene to register the component in
  70280. */
  70281. constructor(scene: Scene);
  70282. /**
  70283. * Registers the component in a given scene
  70284. */
  70285. register(): void;
  70286. /**
  70287. * Rebuilds the elements related to this component in case of
  70288. * context lost for instance.
  70289. */
  70290. rebuild(): void;
  70291. /**
  70292. * Disposes the component and the associated ressources
  70293. */
  70294. dispose(): void;
  70295. private _beforeCameraUpdate;
  70296. }
  70297. }
  70298. declare module "babylonjs/Meshes/Builders/index" {
  70299. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70300. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70301. export * from "babylonjs/Meshes/Builders/discBuilder";
  70302. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70303. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70304. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70305. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70306. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70307. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70308. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70309. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70310. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70311. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70312. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70313. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70314. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70315. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70316. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70317. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70318. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70319. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70320. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70321. }
  70322. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70323. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70324. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70325. import { Matrix } from "babylonjs/Maths/math.vector";
  70326. module "babylonjs/Meshes/mesh" {
  70327. interface Mesh {
  70328. /**
  70329. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70330. */
  70331. thinInstanceEnablePicking: boolean;
  70332. /**
  70333. * Creates a new thin instance
  70334. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70335. * @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
  70336. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70337. */
  70338. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70339. /**
  70340. * Adds the transformation (matrix) of the current mesh as a thin instance
  70341. * @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
  70342. * @returns the thin instance index number
  70343. */
  70344. thinInstanceAddSelf(refresh: boolean): number;
  70345. /**
  70346. * Registers a custom attribute to be used with thin instances
  70347. * @param kind name of the attribute
  70348. * @param stride size in floats of the attribute
  70349. */
  70350. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70351. /**
  70352. * Sets the matrix of a thin instance
  70353. * @param index index of the thin instance
  70354. * @param matrix matrix to set
  70355. * @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
  70356. */
  70357. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70358. /**
  70359. * Sets the value of a custom attribute for a thin instance
  70360. * @param kind name of the attribute
  70361. * @param index index of the thin instance
  70362. * @param value value to set
  70363. * @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
  70364. */
  70365. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70366. /**
  70367. * 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.
  70368. */
  70369. thinInstanceCount: number;
  70370. /**
  70371. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70372. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70373. * @param buffer buffer to set
  70374. * @param stride size in floats of each value of the buffer
  70375. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70376. */
  70377. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70378. /**
  70379. * Gets the list of world matrices
  70380. * @return an array containing all the world matrices from the thin instances
  70381. */
  70382. thinInstanceGetWorldMatrices(): Matrix[];
  70383. /**
  70384. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70385. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70386. */
  70387. thinInstanceBufferUpdated(kind: string): void;
  70388. /**
  70389. * Applies a partial update to a buffer directly on the GPU
  70390. * 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
  70391. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70392. * @param data the data to set in the GPU buffer
  70393. * @param offset the offset in the GPU buffer where to update the data
  70394. */
  70395. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70396. /**
  70397. * Refreshes the bounding info, taking into account all the thin instances defined
  70398. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70399. */
  70400. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70401. /** @hidden */
  70402. _thinInstanceInitializeUserStorage(): void;
  70403. /** @hidden */
  70404. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70405. /** @hidden */
  70406. _userThinInstanceBuffersStorage: {
  70407. data: {
  70408. [key: string]: Float32Array;
  70409. };
  70410. sizes: {
  70411. [key: string]: number;
  70412. };
  70413. vertexBuffers: {
  70414. [key: string]: Nullable<VertexBuffer>;
  70415. };
  70416. strides: {
  70417. [key: string]: number;
  70418. };
  70419. };
  70420. }
  70421. }
  70422. }
  70423. declare module "babylonjs/Meshes/index" {
  70424. export * from "babylonjs/Meshes/abstractMesh";
  70425. export * from "babylonjs/Meshes/buffer";
  70426. export * from "babylonjs/Meshes/Compression/index";
  70427. export * from "babylonjs/Meshes/csg";
  70428. export * from "babylonjs/Meshes/geometry";
  70429. export * from "babylonjs/Meshes/groundMesh";
  70430. export * from "babylonjs/Meshes/trailMesh";
  70431. export * from "babylonjs/Meshes/instancedMesh";
  70432. export * from "babylonjs/Meshes/linesMesh";
  70433. export * from "babylonjs/Meshes/mesh";
  70434. export * from "babylonjs/Meshes/mesh.vertexData";
  70435. export * from "babylonjs/Meshes/meshBuilder";
  70436. export * from "babylonjs/Meshes/meshSimplification";
  70437. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70438. export * from "babylonjs/Meshes/polygonMesh";
  70439. export * from "babylonjs/Meshes/subMesh";
  70440. export * from "babylonjs/Meshes/meshLODLevel";
  70441. export * from "babylonjs/Meshes/transformNode";
  70442. export * from "babylonjs/Meshes/Builders/index";
  70443. export * from "babylonjs/Meshes/dataBuffer";
  70444. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70445. import "babylonjs/Meshes/thinInstanceMesh";
  70446. export * from "babylonjs/Meshes/thinInstanceMesh";
  70447. }
  70448. declare module "babylonjs/Morph/index" {
  70449. export * from "babylonjs/Morph/morphTarget";
  70450. export * from "babylonjs/Morph/morphTargetManager";
  70451. }
  70452. declare module "babylonjs/Navigation/INavigationEngine" {
  70453. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70454. import { Vector3 } from "babylonjs/Maths/math";
  70455. import { Mesh } from "babylonjs/Meshes/mesh";
  70456. import { Scene } from "babylonjs/scene";
  70457. /**
  70458. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70459. */
  70460. export interface INavigationEnginePlugin {
  70461. /**
  70462. * plugin name
  70463. */
  70464. name: string;
  70465. /**
  70466. * Creates a navigation mesh
  70467. * @param meshes array of all the geometry used to compute the navigatio mesh
  70468. * @param parameters bunch of parameters used to filter geometry
  70469. */
  70470. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70471. /**
  70472. * Create a navigation mesh debug mesh
  70473. * @param scene is where the mesh will be added
  70474. * @returns debug display mesh
  70475. */
  70476. createDebugNavMesh(scene: Scene): Mesh;
  70477. /**
  70478. * Get a navigation mesh constrained position, closest to the parameter position
  70479. * @param position world position
  70480. * @returns the closest point to position constrained by the navigation mesh
  70481. */
  70482. getClosestPoint(position: Vector3): Vector3;
  70483. /**
  70484. * Get a navigation mesh constrained position, closest to the parameter position
  70485. * @param position world position
  70486. * @param result output the closest point to position constrained by the navigation mesh
  70487. */
  70488. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70489. /**
  70490. * Get a navigation mesh constrained position, within a particular radius
  70491. * @param position world position
  70492. * @param maxRadius the maximum distance to the constrained world position
  70493. * @returns the closest point to position constrained by the navigation mesh
  70494. */
  70495. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70496. /**
  70497. * Get a navigation mesh constrained position, within a particular radius
  70498. * @param position world position
  70499. * @param maxRadius the maximum distance to the constrained world position
  70500. * @param result output the closest point to position constrained by the navigation mesh
  70501. */
  70502. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70503. /**
  70504. * Compute the final position from a segment made of destination-position
  70505. * @param position world position
  70506. * @param destination world position
  70507. * @returns the resulting point along the navmesh
  70508. */
  70509. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70510. /**
  70511. * Compute the final position from a segment made of destination-position
  70512. * @param position world position
  70513. * @param destination world position
  70514. * @param result output the resulting point along the navmesh
  70515. */
  70516. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70517. /**
  70518. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70519. * @param start world position
  70520. * @param end world position
  70521. * @returns array containing world position composing the path
  70522. */
  70523. computePath(start: Vector3, end: Vector3): Vector3[];
  70524. /**
  70525. * If this plugin is supported
  70526. * @returns true if plugin is supported
  70527. */
  70528. isSupported(): boolean;
  70529. /**
  70530. * Create a new Crowd so you can add agents
  70531. * @param maxAgents the maximum agent count in the crowd
  70532. * @param maxAgentRadius the maximum radius an agent can have
  70533. * @param scene to attach the crowd to
  70534. * @returns the crowd you can add agents to
  70535. */
  70536. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70537. /**
  70538. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70539. * The queries will try to find a solution within those bounds
  70540. * default is (1,1,1)
  70541. * @param extent x,y,z value that define the extent around the queries point of reference
  70542. */
  70543. setDefaultQueryExtent(extent: Vector3): void;
  70544. /**
  70545. * Get the Bounding box extent specified by setDefaultQueryExtent
  70546. * @returns the box extent values
  70547. */
  70548. getDefaultQueryExtent(): Vector3;
  70549. /**
  70550. * build the navmesh from a previously saved state using getNavmeshData
  70551. * @param data the Uint8Array returned by getNavmeshData
  70552. */
  70553. buildFromNavmeshData(data: Uint8Array): void;
  70554. /**
  70555. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70556. * @returns data the Uint8Array that can be saved and reused
  70557. */
  70558. getNavmeshData(): Uint8Array;
  70559. /**
  70560. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70561. * @param result output the box extent values
  70562. */
  70563. getDefaultQueryExtentToRef(result: Vector3): void;
  70564. /**
  70565. * Release all resources
  70566. */
  70567. dispose(): void;
  70568. }
  70569. /**
  70570. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70571. */
  70572. export interface ICrowd {
  70573. /**
  70574. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70575. * You can attach anything to that node. The node position is updated in the scene update tick.
  70576. * @param pos world position that will be constrained by the navigation mesh
  70577. * @param parameters agent parameters
  70578. * @param transform hooked to the agent that will be update by the scene
  70579. * @returns agent index
  70580. */
  70581. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70582. /**
  70583. * Returns the agent position in world space
  70584. * @param index agent index returned by addAgent
  70585. * @returns world space position
  70586. */
  70587. getAgentPosition(index: number): Vector3;
  70588. /**
  70589. * Gets the agent position result in world space
  70590. * @param index agent index returned by addAgent
  70591. * @param result output world space position
  70592. */
  70593. getAgentPositionToRef(index: number, result: Vector3): void;
  70594. /**
  70595. * Gets the agent velocity in world space
  70596. * @param index agent index returned by addAgent
  70597. * @returns world space velocity
  70598. */
  70599. getAgentVelocity(index: number): Vector3;
  70600. /**
  70601. * Gets the agent velocity result in world space
  70602. * @param index agent index returned by addAgent
  70603. * @param result output world space velocity
  70604. */
  70605. getAgentVelocityToRef(index: number, result: Vector3): void;
  70606. /**
  70607. * remove a particular agent previously created
  70608. * @param index agent index returned by addAgent
  70609. */
  70610. removeAgent(index: number): void;
  70611. /**
  70612. * get the list of all agents attached to this crowd
  70613. * @returns list of agent indices
  70614. */
  70615. getAgents(): number[];
  70616. /**
  70617. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70618. * @param deltaTime in seconds
  70619. */
  70620. update(deltaTime: number): void;
  70621. /**
  70622. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70623. * @param index agent index returned by addAgent
  70624. * @param destination targeted world position
  70625. */
  70626. agentGoto(index: number, destination: Vector3): void;
  70627. /**
  70628. * Teleport the agent to a new position
  70629. * @param index agent index returned by addAgent
  70630. * @param destination targeted world position
  70631. */
  70632. agentTeleport(index: number, destination: Vector3): void;
  70633. /**
  70634. * Update agent parameters
  70635. * @param index agent index returned by addAgent
  70636. * @param parameters agent parameters
  70637. */
  70638. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70639. /**
  70640. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70641. * The queries will try to find a solution within those bounds
  70642. * default is (1,1,1)
  70643. * @param extent x,y,z value that define the extent around the queries point of reference
  70644. */
  70645. setDefaultQueryExtent(extent: Vector3): void;
  70646. /**
  70647. * Get the Bounding box extent specified by setDefaultQueryExtent
  70648. * @returns the box extent values
  70649. */
  70650. getDefaultQueryExtent(): Vector3;
  70651. /**
  70652. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70653. * @param result output the box extent values
  70654. */
  70655. getDefaultQueryExtentToRef(result: Vector3): void;
  70656. /**
  70657. * Release all resources
  70658. */
  70659. dispose(): void;
  70660. }
  70661. /**
  70662. * Configures an agent
  70663. */
  70664. export interface IAgentParameters {
  70665. /**
  70666. * Agent radius. [Limit: >= 0]
  70667. */
  70668. radius: number;
  70669. /**
  70670. * Agent height. [Limit: > 0]
  70671. */
  70672. height: number;
  70673. /**
  70674. * Maximum allowed acceleration. [Limit: >= 0]
  70675. */
  70676. maxAcceleration: number;
  70677. /**
  70678. * Maximum allowed speed. [Limit: >= 0]
  70679. */
  70680. maxSpeed: number;
  70681. /**
  70682. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70683. */
  70684. collisionQueryRange: number;
  70685. /**
  70686. * The path visibility optimization range. [Limit: > 0]
  70687. */
  70688. pathOptimizationRange: number;
  70689. /**
  70690. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70691. */
  70692. separationWeight: number;
  70693. }
  70694. /**
  70695. * Configures the navigation mesh creation
  70696. */
  70697. export interface INavMeshParameters {
  70698. /**
  70699. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70700. */
  70701. cs: number;
  70702. /**
  70703. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70704. */
  70705. ch: number;
  70706. /**
  70707. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70708. */
  70709. walkableSlopeAngle: number;
  70710. /**
  70711. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70712. * be considered walkable. [Limit: >= 3] [Units: vx]
  70713. */
  70714. walkableHeight: number;
  70715. /**
  70716. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70717. */
  70718. walkableClimb: number;
  70719. /**
  70720. * The distance to erode/shrink the walkable area of the heightfield away from
  70721. * obstructions. [Limit: >=0] [Units: vx]
  70722. */
  70723. walkableRadius: number;
  70724. /**
  70725. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70726. */
  70727. maxEdgeLen: number;
  70728. /**
  70729. * The maximum distance a simplfied contour's border edges should deviate
  70730. * the original raw contour. [Limit: >=0] [Units: vx]
  70731. */
  70732. maxSimplificationError: number;
  70733. /**
  70734. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70735. */
  70736. minRegionArea: number;
  70737. /**
  70738. * Any regions with a span count smaller than this value will, if possible,
  70739. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70740. */
  70741. mergeRegionArea: number;
  70742. /**
  70743. * The maximum number of vertices allowed for polygons generated during the
  70744. * contour to polygon conversion process. [Limit: >= 3]
  70745. */
  70746. maxVertsPerPoly: number;
  70747. /**
  70748. * Sets the sampling distance to use when generating the detail mesh.
  70749. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70750. */
  70751. detailSampleDist: number;
  70752. /**
  70753. * The maximum distance the detail mesh surface should deviate from heightfield
  70754. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70755. */
  70756. detailSampleMaxError: number;
  70757. }
  70758. }
  70759. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70760. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70761. import { Mesh } from "babylonjs/Meshes/mesh";
  70762. import { Scene } from "babylonjs/scene";
  70763. import { Vector3 } from "babylonjs/Maths/math";
  70764. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70765. /**
  70766. * RecastJS navigation plugin
  70767. */
  70768. export class RecastJSPlugin implements INavigationEnginePlugin {
  70769. /**
  70770. * Reference to the Recast library
  70771. */
  70772. bjsRECAST: any;
  70773. /**
  70774. * plugin name
  70775. */
  70776. name: string;
  70777. /**
  70778. * the first navmesh created. We might extend this to support multiple navmeshes
  70779. */
  70780. navMesh: any;
  70781. /**
  70782. * Initializes the recastJS plugin
  70783. * @param recastInjection can be used to inject your own recast reference
  70784. */
  70785. constructor(recastInjection?: any);
  70786. /**
  70787. * Creates a navigation mesh
  70788. * @param meshes array of all the geometry used to compute the navigatio mesh
  70789. * @param parameters bunch of parameters used to filter geometry
  70790. */
  70791. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70792. /**
  70793. * Create a navigation mesh debug mesh
  70794. * @param scene is where the mesh will be added
  70795. * @returns debug display mesh
  70796. */
  70797. createDebugNavMesh(scene: Scene): Mesh;
  70798. /**
  70799. * Get a navigation mesh constrained position, closest to the parameter position
  70800. * @param position world position
  70801. * @returns the closest point to position constrained by the navigation mesh
  70802. */
  70803. getClosestPoint(position: Vector3): Vector3;
  70804. /**
  70805. * Get a navigation mesh constrained position, closest to the parameter position
  70806. * @param position world position
  70807. * @param result output the closest point to position constrained by the navigation mesh
  70808. */
  70809. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70810. /**
  70811. * Get a navigation mesh constrained position, within a particular radius
  70812. * @param position world position
  70813. * @param maxRadius the maximum distance to the constrained world position
  70814. * @returns the closest point to position constrained by the navigation mesh
  70815. */
  70816. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70817. /**
  70818. * Get a navigation mesh constrained position, within a particular radius
  70819. * @param position world position
  70820. * @param maxRadius the maximum distance to the constrained world position
  70821. * @param result output the closest point to position constrained by the navigation mesh
  70822. */
  70823. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70824. /**
  70825. * Compute the final position from a segment made of destination-position
  70826. * @param position world position
  70827. * @param destination world position
  70828. * @returns the resulting point along the navmesh
  70829. */
  70830. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70831. /**
  70832. * Compute the final position from a segment made of destination-position
  70833. * @param position world position
  70834. * @param destination world position
  70835. * @param result output the resulting point along the navmesh
  70836. */
  70837. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70838. /**
  70839. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70840. * @param start world position
  70841. * @param end world position
  70842. * @returns array containing world position composing the path
  70843. */
  70844. computePath(start: Vector3, end: Vector3): Vector3[];
  70845. /**
  70846. * Create a new Crowd so you can add agents
  70847. * @param maxAgents the maximum agent count in the crowd
  70848. * @param maxAgentRadius the maximum radius an agent can have
  70849. * @param scene to attach the crowd to
  70850. * @returns the crowd you can add agents to
  70851. */
  70852. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70853. /**
  70854. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70855. * The queries will try to find a solution within those bounds
  70856. * default is (1,1,1)
  70857. * @param extent x,y,z value that define the extent around the queries point of reference
  70858. */
  70859. setDefaultQueryExtent(extent: Vector3): void;
  70860. /**
  70861. * Get the Bounding box extent specified by setDefaultQueryExtent
  70862. * @returns the box extent values
  70863. */
  70864. getDefaultQueryExtent(): Vector3;
  70865. /**
  70866. * build the navmesh from a previously saved state using getNavmeshData
  70867. * @param data the Uint8Array returned by getNavmeshData
  70868. */
  70869. buildFromNavmeshData(data: Uint8Array): void;
  70870. /**
  70871. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70872. * @returns data the Uint8Array that can be saved and reused
  70873. */
  70874. getNavmeshData(): Uint8Array;
  70875. /**
  70876. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70877. * @param result output the box extent values
  70878. */
  70879. getDefaultQueryExtentToRef(result: Vector3): void;
  70880. /**
  70881. * Disposes
  70882. */
  70883. dispose(): void;
  70884. /**
  70885. * If this plugin is supported
  70886. * @returns true if plugin is supported
  70887. */
  70888. isSupported(): boolean;
  70889. }
  70890. /**
  70891. * Recast detour crowd implementation
  70892. */
  70893. export class RecastJSCrowd implements ICrowd {
  70894. /**
  70895. * Recast/detour plugin
  70896. */
  70897. bjsRECASTPlugin: RecastJSPlugin;
  70898. /**
  70899. * Link to the detour crowd
  70900. */
  70901. recastCrowd: any;
  70902. /**
  70903. * One transform per agent
  70904. */
  70905. transforms: TransformNode[];
  70906. /**
  70907. * All agents created
  70908. */
  70909. agents: number[];
  70910. /**
  70911. * Link to the scene is kept to unregister the crowd from the scene
  70912. */
  70913. private _scene;
  70914. /**
  70915. * Observer for crowd updates
  70916. */
  70917. private _onBeforeAnimationsObserver;
  70918. /**
  70919. * Constructor
  70920. * @param plugin recastJS plugin
  70921. * @param maxAgents the maximum agent count in the crowd
  70922. * @param maxAgentRadius the maximum radius an agent can have
  70923. * @param scene to attach the crowd to
  70924. * @returns the crowd you can add agents to
  70925. */
  70926. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70927. /**
  70928. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70929. * You can attach anything to that node. The node position is updated in the scene update tick.
  70930. * @param pos world position that will be constrained by the navigation mesh
  70931. * @param parameters agent parameters
  70932. * @param transform hooked to the agent that will be update by the scene
  70933. * @returns agent index
  70934. */
  70935. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70936. /**
  70937. * Returns the agent position in world space
  70938. * @param index agent index returned by addAgent
  70939. * @returns world space position
  70940. */
  70941. getAgentPosition(index: number): Vector3;
  70942. /**
  70943. * Returns the agent position result in world space
  70944. * @param index agent index returned by addAgent
  70945. * @param result output world space position
  70946. */
  70947. getAgentPositionToRef(index: number, result: Vector3): void;
  70948. /**
  70949. * Returns the agent velocity in world space
  70950. * @param index agent index returned by addAgent
  70951. * @returns world space velocity
  70952. */
  70953. getAgentVelocity(index: number): Vector3;
  70954. /**
  70955. * Returns the agent velocity result in world space
  70956. * @param index agent index returned by addAgent
  70957. * @param result output world space velocity
  70958. */
  70959. getAgentVelocityToRef(index: number, result: Vector3): void;
  70960. /**
  70961. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70962. * @param index agent index returned by addAgent
  70963. * @param destination targeted world position
  70964. */
  70965. agentGoto(index: number, destination: Vector3): void;
  70966. /**
  70967. * Teleport the agent to a new position
  70968. * @param index agent index returned by addAgent
  70969. * @param destination targeted world position
  70970. */
  70971. agentTeleport(index: number, destination: Vector3): void;
  70972. /**
  70973. * Update agent parameters
  70974. * @param index agent index returned by addAgent
  70975. * @param parameters agent parameters
  70976. */
  70977. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70978. /**
  70979. * remove a particular agent previously created
  70980. * @param index agent index returned by addAgent
  70981. */
  70982. removeAgent(index: number): void;
  70983. /**
  70984. * get the list of all agents attached to this crowd
  70985. * @returns list of agent indices
  70986. */
  70987. getAgents(): number[];
  70988. /**
  70989. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70990. * @param deltaTime in seconds
  70991. */
  70992. update(deltaTime: number): void;
  70993. /**
  70994. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70995. * The queries will try to find a solution within those bounds
  70996. * default is (1,1,1)
  70997. * @param extent x,y,z value that define the extent around the queries point of reference
  70998. */
  70999. setDefaultQueryExtent(extent: Vector3): void;
  71000. /**
  71001. * Get the Bounding box extent specified by setDefaultQueryExtent
  71002. * @returns the box extent values
  71003. */
  71004. getDefaultQueryExtent(): Vector3;
  71005. /**
  71006. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71007. * @param result output the box extent values
  71008. */
  71009. getDefaultQueryExtentToRef(result: Vector3): void;
  71010. /**
  71011. * Release all resources
  71012. */
  71013. dispose(): void;
  71014. }
  71015. }
  71016. declare module "babylonjs/Navigation/Plugins/index" {
  71017. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71018. }
  71019. declare module "babylonjs/Navigation/index" {
  71020. export * from "babylonjs/Navigation/INavigationEngine";
  71021. export * from "babylonjs/Navigation/Plugins/index";
  71022. }
  71023. declare module "babylonjs/Offline/database" {
  71024. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71025. /**
  71026. * Class used to enable access to IndexedDB
  71027. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71028. */
  71029. export class Database implements IOfflineProvider {
  71030. private _callbackManifestChecked;
  71031. private _currentSceneUrl;
  71032. private _db;
  71033. private _enableSceneOffline;
  71034. private _enableTexturesOffline;
  71035. private _manifestVersionFound;
  71036. private _mustUpdateRessources;
  71037. private _hasReachedQuota;
  71038. private _isSupported;
  71039. private _idbFactory;
  71040. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71041. private static IsUASupportingBlobStorage;
  71042. /**
  71043. * Gets a boolean indicating if Database storate is enabled (off by default)
  71044. */
  71045. static IDBStorageEnabled: boolean;
  71046. /**
  71047. * Gets a boolean indicating if scene must be saved in the database
  71048. */
  71049. get enableSceneOffline(): boolean;
  71050. /**
  71051. * Gets a boolean indicating if textures must be saved in the database
  71052. */
  71053. get enableTexturesOffline(): boolean;
  71054. /**
  71055. * Creates a new Database
  71056. * @param urlToScene defines the url to load the scene
  71057. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71058. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71059. */
  71060. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71061. private static _ParseURL;
  71062. private static _ReturnFullUrlLocation;
  71063. private _checkManifestFile;
  71064. /**
  71065. * Open the database and make it available
  71066. * @param successCallback defines the callback to call on success
  71067. * @param errorCallback defines the callback to call on error
  71068. */
  71069. open(successCallback: () => void, errorCallback: () => void): void;
  71070. /**
  71071. * Loads an image from the database
  71072. * @param url defines the url to load from
  71073. * @param image defines the target DOM image
  71074. */
  71075. loadImage(url: string, image: HTMLImageElement): void;
  71076. private _loadImageFromDBAsync;
  71077. private _saveImageIntoDBAsync;
  71078. private _checkVersionFromDB;
  71079. private _loadVersionFromDBAsync;
  71080. private _saveVersionIntoDBAsync;
  71081. /**
  71082. * Loads a file from database
  71083. * @param url defines the URL to load from
  71084. * @param sceneLoaded defines a callback to call on success
  71085. * @param progressCallBack defines a callback to call when progress changed
  71086. * @param errorCallback defines a callback to call on error
  71087. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71088. */
  71089. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71090. private _loadFileAsync;
  71091. private _saveFileAsync;
  71092. /**
  71093. * Validates if xhr data is correct
  71094. * @param xhr defines the request to validate
  71095. * @param dataType defines the expected data type
  71096. * @returns true if data is correct
  71097. */
  71098. private static _ValidateXHRData;
  71099. }
  71100. }
  71101. declare module "babylonjs/Offline/index" {
  71102. export * from "babylonjs/Offline/database";
  71103. export * from "babylonjs/Offline/IOfflineProvider";
  71104. }
  71105. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71106. /** @hidden */
  71107. export var gpuUpdateParticlesPixelShader: {
  71108. name: string;
  71109. shader: string;
  71110. };
  71111. }
  71112. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71113. /** @hidden */
  71114. export var gpuUpdateParticlesVertexShader: {
  71115. name: string;
  71116. shader: string;
  71117. };
  71118. }
  71119. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71120. /** @hidden */
  71121. export var clipPlaneFragmentDeclaration2: {
  71122. name: string;
  71123. shader: string;
  71124. };
  71125. }
  71126. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71127. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71128. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71130. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71131. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71132. /** @hidden */
  71133. export var gpuRenderParticlesPixelShader: {
  71134. name: string;
  71135. shader: string;
  71136. };
  71137. }
  71138. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71139. /** @hidden */
  71140. export var clipPlaneVertexDeclaration2: {
  71141. name: string;
  71142. shader: string;
  71143. };
  71144. }
  71145. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71146. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71147. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71148. /** @hidden */
  71149. export var gpuRenderParticlesVertexShader: {
  71150. name: string;
  71151. shader: string;
  71152. };
  71153. }
  71154. declare module "babylonjs/Particles/gpuParticleSystem" {
  71155. import { Nullable } from "babylonjs/types";
  71156. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71157. import { Observable } from "babylonjs/Misc/observable";
  71158. import { Matrix } from "babylonjs/Maths/math.vector";
  71159. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71160. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71161. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71162. import { IDisposable } from "babylonjs/scene";
  71163. import { Effect } from "babylonjs/Materials/effect";
  71164. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71165. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71166. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71167. import { Scene } from "babylonjs/scene";
  71168. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71169. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71170. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71171. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71172. /**
  71173. * This represents a GPU particle system in Babylon
  71174. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71175. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71176. */
  71177. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71178. /**
  71179. * The layer mask we are rendering the particles through.
  71180. */
  71181. layerMask: number;
  71182. private _capacity;
  71183. private _activeCount;
  71184. private _currentActiveCount;
  71185. private _accumulatedCount;
  71186. private _renderEffect;
  71187. private _updateEffect;
  71188. private _buffer0;
  71189. private _buffer1;
  71190. private _spriteBuffer;
  71191. private _updateVAO;
  71192. private _renderVAO;
  71193. private _targetIndex;
  71194. private _sourceBuffer;
  71195. private _targetBuffer;
  71196. private _currentRenderId;
  71197. private _started;
  71198. private _stopped;
  71199. private _timeDelta;
  71200. private _randomTexture;
  71201. private _randomTexture2;
  71202. private _attributesStrideSize;
  71203. private _updateEffectOptions;
  71204. private _randomTextureSize;
  71205. private _actualFrame;
  71206. private _customEffect;
  71207. private readonly _rawTextureWidth;
  71208. /**
  71209. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71210. */
  71211. static get IsSupported(): boolean;
  71212. /**
  71213. * An event triggered when the system is disposed.
  71214. */
  71215. onDisposeObservable: Observable<IParticleSystem>;
  71216. /**
  71217. * Gets the maximum number of particles active at the same time.
  71218. * @returns The max number of active particles.
  71219. */
  71220. getCapacity(): number;
  71221. /**
  71222. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71223. * to override the particles.
  71224. */
  71225. forceDepthWrite: boolean;
  71226. /**
  71227. * Gets or set the number of active particles
  71228. */
  71229. get activeParticleCount(): number;
  71230. set activeParticleCount(value: number);
  71231. private _preWarmDone;
  71232. /**
  71233. * Specifies if the particles are updated in emitter local space or world space.
  71234. */
  71235. isLocal: boolean;
  71236. /** Gets or sets a matrix to use to compute projection */
  71237. defaultProjectionMatrix: Matrix;
  71238. /**
  71239. * Is this system ready to be used/rendered
  71240. * @return true if the system is ready
  71241. */
  71242. isReady(): boolean;
  71243. /**
  71244. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71245. * @returns True if it has been started, otherwise false.
  71246. */
  71247. isStarted(): boolean;
  71248. /**
  71249. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71250. * @returns True if it has been stopped, otherwise false.
  71251. */
  71252. isStopped(): boolean;
  71253. /**
  71254. * Gets a boolean indicating that the system is stopping
  71255. * @returns true if the system is currently stopping
  71256. */
  71257. isStopping(): boolean;
  71258. /**
  71259. * Gets the number of particles active at the same time.
  71260. * @returns The number of active particles.
  71261. */
  71262. getActiveCount(): number;
  71263. /**
  71264. * Starts the particle system and begins to emit
  71265. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71266. */
  71267. start(delay?: number): void;
  71268. /**
  71269. * Stops the particle system.
  71270. */
  71271. stop(): void;
  71272. /**
  71273. * Remove all active particles
  71274. */
  71275. reset(): void;
  71276. /**
  71277. * Returns the string "GPUParticleSystem"
  71278. * @returns a string containing the class name
  71279. */
  71280. getClassName(): string;
  71281. /**
  71282. * Gets the custom effect used to render the particles
  71283. * @param blendMode Blend mode for which the effect should be retrieved
  71284. * @returns The effect
  71285. */
  71286. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71287. /**
  71288. * Sets the custom effect used to render the particles
  71289. * @param effect The effect to set
  71290. * @param blendMode Blend mode for which the effect should be set
  71291. */
  71292. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71293. /** @hidden */
  71294. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71295. /**
  71296. * Observable that will be called just before the particles are drawn
  71297. */
  71298. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71299. /**
  71300. * Gets the name of the particle vertex shader
  71301. */
  71302. get vertexShaderName(): string;
  71303. private _colorGradientsTexture;
  71304. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71305. /**
  71306. * Adds a new color gradient
  71307. * @param gradient defines the gradient to use (between 0 and 1)
  71308. * @param color1 defines the color to affect to the specified gradient
  71309. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71310. * @returns the current particle system
  71311. */
  71312. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71313. private _refreshColorGradient;
  71314. /** Force the system to rebuild all gradients that need to be resync */
  71315. forceRefreshGradients(): void;
  71316. /**
  71317. * Remove a specific color gradient
  71318. * @param gradient defines the gradient to remove
  71319. * @returns the current particle system
  71320. */
  71321. removeColorGradient(gradient: number): GPUParticleSystem;
  71322. private _angularSpeedGradientsTexture;
  71323. private _sizeGradientsTexture;
  71324. private _velocityGradientsTexture;
  71325. private _limitVelocityGradientsTexture;
  71326. private _dragGradientsTexture;
  71327. private _addFactorGradient;
  71328. /**
  71329. * Adds a new size gradient
  71330. * @param gradient defines the gradient to use (between 0 and 1)
  71331. * @param factor defines the size factor to affect to the specified gradient
  71332. * @returns the current particle system
  71333. */
  71334. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71335. /**
  71336. * Remove a specific size gradient
  71337. * @param gradient defines the gradient to remove
  71338. * @returns the current particle system
  71339. */
  71340. removeSizeGradient(gradient: number): GPUParticleSystem;
  71341. private _refreshFactorGradient;
  71342. /**
  71343. * Adds a new angular speed gradient
  71344. * @param gradient defines the gradient to use (between 0 and 1)
  71345. * @param factor defines the angular speed to affect to the specified gradient
  71346. * @returns the current particle system
  71347. */
  71348. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71349. /**
  71350. * Remove a specific angular speed gradient
  71351. * @param gradient defines the gradient to remove
  71352. * @returns the current particle system
  71353. */
  71354. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71355. /**
  71356. * Adds a new velocity gradient
  71357. * @param gradient defines the gradient to use (between 0 and 1)
  71358. * @param factor defines the velocity to affect to the specified gradient
  71359. * @returns the current particle system
  71360. */
  71361. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71362. /**
  71363. * Remove a specific velocity gradient
  71364. * @param gradient defines the gradient to remove
  71365. * @returns the current particle system
  71366. */
  71367. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71368. /**
  71369. * Adds a new limit velocity gradient
  71370. * @param gradient defines the gradient to use (between 0 and 1)
  71371. * @param factor defines the limit velocity value to affect to the specified gradient
  71372. * @returns the current particle system
  71373. */
  71374. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71375. /**
  71376. * Remove a specific limit velocity gradient
  71377. * @param gradient defines the gradient to remove
  71378. * @returns the current particle system
  71379. */
  71380. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71381. /**
  71382. * Adds a new drag gradient
  71383. * @param gradient defines the gradient to use (between 0 and 1)
  71384. * @param factor defines the drag value to affect to the specified gradient
  71385. * @returns the current particle system
  71386. */
  71387. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71388. /**
  71389. * Remove a specific drag gradient
  71390. * @param gradient defines the gradient to remove
  71391. * @returns the current particle system
  71392. */
  71393. removeDragGradient(gradient: number): GPUParticleSystem;
  71394. /**
  71395. * Not supported by GPUParticleSystem
  71396. * @param gradient defines the gradient to use (between 0 and 1)
  71397. * @param factor defines the emit rate value to affect to the specified gradient
  71398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71399. * @returns the current particle system
  71400. */
  71401. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71402. /**
  71403. * Not supported by GPUParticleSystem
  71404. * @param gradient defines the gradient to remove
  71405. * @returns the current particle system
  71406. */
  71407. removeEmitRateGradient(gradient: number): IParticleSystem;
  71408. /**
  71409. * Not supported by GPUParticleSystem
  71410. * @param gradient defines the gradient to use (between 0 and 1)
  71411. * @param factor defines the start size value to affect to the specified gradient
  71412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71413. * @returns the current particle system
  71414. */
  71415. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71416. /**
  71417. * Not supported by GPUParticleSystem
  71418. * @param gradient defines the gradient to remove
  71419. * @returns the current particle system
  71420. */
  71421. removeStartSizeGradient(gradient: number): IParticleSystem;
  71422. /**
  71423. * Not supported by GPUParticleSystem
  71424. * @param gradient defines the gradient to use (between 0 and 1)
  71425. * @param min defines the color remap minimal range
  71426. * @param max defines the color remap maximal range
  71427. * @returns the current particle system
  71428. */
  71429. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71430. /**
  71431. * Not supported by GPUParticleSystem
  71432. * @param gradient defines the gradient to remove
  71433. * @returns the current particle system
  71434. */
  71435. removeColorRemapGradient(): IParticleSystem;
  71436. /**
  71437. * Not supported by GPUParticleSystem
  71438. * @param gradient defines the gradient to use (between 0 and 1)
  71439. * @param min defines the alpha remap minimal range
  71440. * @param max defines the alpha remap maximal range
  71441. * @returns the current particle system
  71442. */
  71443. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71444. /**
  71445. * Not supported by GPUParticleSystem
  71446. * @param gradient defines the gradient to remove
  71447. * @returns the current particle system
  71448. */
  71449. removeAlphaRemapGradient(): IParticleSystem;
  71450. /**
  71451. * Not supported by GPUParticleSystem
  71452. * @param gradient defines the gradient to use (between 0 and 1)
  71453. * @param color defines the color to affect to the specified gradient
  71454. * @returns the current particle system
  71455. */
  71456. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71457. /**
  71458. * Not supported by GPUParticleSystem
  71459. * @param gradient defines the gradient to remove
  71460. * @returns the current particle system
  71461. */
  71462. removeRampGradient(): IParticleSystem;
  71463. /**
  71464. * Not supported by GPUParticleSystem
  71465. * @returns the list of ramp gradients
  71466. */
  71467. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71468. /**
  71469. * Not supported by GPUParticleSystem
  71470. * Gets or sets a boolean indicating that ramp gradients must be used
  71471. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71472. */
  71473. get useRampGradients(): boolean;
  71474. set useRampGradients(value: boolean);
  71475. /**
  71476. * Not supported by GPUParticleSystem
  71477. * @param gradient defines the gradient to use (between 0 and 1)
  71478. * @param factor defines the life time factor to affect to the specified gradient
  71479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71480. * @returns the current particle system
  71481. */
  71482. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71483. /**
  71484. * Not supported by GPUParticleSystem
  71485. * @param gradient defines the gradient to remove
  71486. * @returns the current particle system
  71487. */
  71488. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71489. /**
  71490. * Instantiates a GPU particle system.
  71491. * 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.
  71492. * @param name The name of the particle system
  71493. * @param options The options used to create the system
  71494. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71495. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71496. * @param customEffect a custom effect used to change the way particles are rendered by default
  71497. */
  71498. constructor(name: string, options: Partial<{
  71499. capacity: number;
  71500. randomTextureSize: number;
  71501. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71502. protected _reset(): void;
  71503. private _createUpdateVAO;
  71504. private _createRenderVAO;
  71505. private _initialize;
  71506. /** @hidden */
  71507. _recreateUpdateEffect(): void;
  71508. private _getEffect;
  71509. /**
  71510. * Fill the defines array according to the current settings of the particle system
  71511. * @param defines Array to be updated
  71512. * @param blendMode blend mode to take into account when updating the array
  71513. */
  71514. fillDefines(defines: Array<string>, blendMode?: number): void;
  71515. /**
  71516. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71517. * @param uniforms Uniforms array to fill
  71518. * @param attributes Attributes array to fill
  71519. * @param samplers Samplers array to fill
  71520. */
  71521. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71522. /** @hidden */
  71523. _recreateRenderEffect(): Effect;
  71524. /**
  71525. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71526. * @param preWarm defines if we are in the pre-warmimg phase
  71527. */
  71528. animate(preWarm?: boolean): void;
  71529. private _createFactorGradientTexture;
  71530. private _createSizeGradientTexture;
  71531. private _createAngularSpeedGradientTexture;
  71532. private _createVelocityGradientTexture;
  71533. private _createLimitVelocityGradientTexture;
  71534. private _createDragGradientTexture;
  71535. private _createColorGradientTexture;
  71536. /**
  71537. * Renders the particle system in its current state
  71538. * @param preWarm defines if the system should only update the particles but not render them
  71539. * @returns the current number of particles
  71540. */
  71541. render(preWarm?: boolean): number;
  71542. /**
  71543. * Rebuilds the particle system
  71544. */
  71545. rebuild(): void;
  71546. private _releaseBuffers;
  71547. private _releaseVAOs;
  71548. /**
  71549. * Disposes the particle system and free the associated resources
  71550. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71551. */
  71552. dispose(disposeTexture?: boolean): void;
  71553. /**
  71554. * Clones the particle system.
  71555. * @param name The name of the cloned object
  71556. * @param newEmitter The new emitter to use
  71557. * @returns the cloned particle system
  71558. */
  71559. clone(name: string, newEmitter: any): GPUParticleSystem;
  71560. /**
  71561. * Serializes the particle system to a JSON object
  71562. * @param serializeTexture defines if the texture must be serialized as well
  71563. * @returns the JSON object
  71564. */
  71565. serialize(serializeTexture?: boolean): any;
  71566. /**
  71567. * Parses a JSON object to create a GPU particle system.
  71568. * @param parsedParticleSystem The JSON object to parse
  71569. * @param sceneOrEngine The scene or the engine to create the particle system in
  71570. * @param rootUrl The root url to use to load external dependencies like texture
  71571. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71572. * @returns the parsed GPU particle system
  71573. */
  71574. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71575. }
  71576. }
  71577. declare module "babylonjs/Particles/particleSystemSet" {
  71578. import { Nullable } from "babylonjs/types";
  71579. import { Color3 } from "babylonjs/Maths/math.color";
  71580. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71582. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71583. import { Scene, IDisposable } from "babylonjs/scene";
  71584. /**
  71585. * Represents a set of particle systems working together to create a specific effect
  71586. */
  71587. export class ParticleSystemSet implements IDisposable {
  71588. /**
  71589. * Gets or sets base Assets URL
  71590. */
  71591. static BaseAssetsUrl: string;
  71592. private _emitterCreationOptions;
  71593. private _emitterNode;
  71594. /**
  71595. * Gets the particle system list
  71596. */
  71597. systems: IParticleSystem[];
  71598. /**
  71599. * Gets the emitter node used with this set
  71600. */
  71601. get emitterNode(): Nullable<TransformNode>;
  71602. /**
  71603. * Creates a new emitter mesh as a sphere
  71604. * @param options defines the options used to create the sphere
  71605. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71606. * @param scene defines the hosting scene
  71607. */
  71608. setEmitterAsSphere(options: {
  71609. diameter: number;
  71610. segments: number;
  71611. color: Color3;
  71612. }, renderingGroupId: number, scene: Scene): void;
  71613. /**
  71614. * Starts all particle systems of the set
  71615. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71616. */
  71617. start(emitter?: AbstractMesh): void;
  71618. /**
  71619. * Release all associated resources
  71620. */
  71621. dispose(): void;
  71622. /**
  71623. * Serialize the set into a JSON compatible object
  71624. * @param serializeTexture defines if the texture must be serialized as well
  71625. * @returns a JSON compatible representation of the set
  71626. */
  71627. serialize(serializeTexture?: boolean): any;
  71628. /**
  71629. * Parse a new ParticleSystemSet from a serialized source
  71630. * @param data defines a JSON compatible representation of the set
  71631. * @param scene defines the hosting scene
  71632. * @param gpu defines if we want GPU particles or CPU particles
  71633. * @returns a new ParticleSystemSet
  71634. */
  71635. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71636. }
  71637. }
  71638. declare module "babylonjs/Particles/particleHelper" {
  71639. import { Nullable } from "babylonjs/types";
  71640. import { Scene } from "babylonjs/scene";
  71641. import { Vector3 } from "babylonjs/Maths/math.vector";
  71642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71643. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71644. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71645. /**
  71646. * This class is made for on one-liner static method to help creating particle system set.
  71647. */
  71648. export class ParticleHelper {
  71649. /**
  71650. * Gets or sets base Assets URL
  71651. */
  71652. static BaseAssetsUrl: string;
  71653. /** Define the Url to load snippets */
  71654. static SnippetUrl: string;
  71655. /**
  71656. * Create a default particle system that you can tweak
  71657. * @param emitter defines the emitter to use
  71658. * @param capacity defines the system capacity (default is 500 particles)
  71659. * @param scene defines the hosting scene
  71660. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71661. * @returns the new Particle system
  71662. */
  71663. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71664. /**
  71665. * This is the main static method (one-liner) of this helper to create different particle systems
  71666. * @param type This string represents the type to the particle system to create
  71667. * @param scene The scene where the particle system should live
  71668. * @param gpu If the system will use gpu
  71669. * @returns the ParticleSystemSet created
  71670. */
  71671. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71672. /**
  71673. * Static function used to export a particle system to a ParticleSystemSet variable.
  71674. * Please note that the emitter shape is not exported
  71675. * @param systems defines the particle systems to export
  71676. * @returns the created particle system set
  71677. */
  71678. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71679. /**
  71680. * Creates a particle system from a snippet saved in a remote file
  71681. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71682. * @param url defines the url to load from
  71683. * @param scene defines the hosting scene
  71684. * @param gpu If the system will use gpu
  71685. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71686. * @returns a promise that will resolve to the new particle system
  71687. */
  71688. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71689. /**
  71690. * Creates a particle system from a snippet saved by the particle system editor
  71691. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71692. * @param scene defines the hosting scene
  71693. * @param gpu If the system will use gpu
  71694. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71695. * @returns a promise that will resolve to the new particle system
  71696. */
  71697. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71698. }
  71699. }
  71700. declare module "babylonjs/Particles/particleSystemComponent" {
  71701. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71702. import { Effect } from "babylonjs/Materials/effect";
  71703. import "babylonjs/Shaders/particles.vertex";
  71704. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71705. module "babylonjs/Engines/engine" {
  71706. interface Engine {
  71707. /**
  71708. * Create an effect to use with particle systems.
  71709. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71710. * the particle system for which you want to create a custom effect in the last parameter
  71711. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71712. * @param uniformsNames defines a list of attribute names
  71713. * @param samplers defines an array of string used to represent textures
  71714. * @param defines defines the string containing the defines to use to compile the shaders
  71715. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71716. * @param onCompiled defines a function to call when the effect creation is successful
  71717. * @param onError defines a function to call when the effect creation has failed
  71718. * @param particleSystem the particle system you want to create the effect for
  71719. * @returns the new Effect
  71720. */
  71721. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71722. }
  71723. }
  71724. module "babylonjs/Meshes/mesh" {
  71725. interface Mesh {
  71726. /**
  71727. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71728. * @returns an array of IParticleSystem
  71729. */
  71730. getEmittedParticleSystems(): IParticleSystem[];
  71731. /**
  71732. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71733. * @returns an array of IParticleSystem
  71734. */
  71735. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71736. }
  71737. }
  71738. }
  71739. declare module "babylonjs/Particles/pointsCloudSystem" {
  71740. import { Color4 } from "babylonjs/Maths/math";
  71741. import { Mesh } from "babylonjs/Meshes/mesh";
  71742. import { Scene, IDisposable } from "babylonjs/scene";
  71743. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71744. /** Defines the 4 color options */
  71745. export enum PointColor {
  71746. /** color value */
  71747. Color = 2,
  71748. /** uv value */
  71749. UV = 1,
  71750. /** random value */
  71751. Random = 0,
  71752. /** stated value */
  71753. Stated = 3
  71754. }
  71755. /**
  71756. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71757. * 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.
  71758. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71759. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71760. *
  71761. * Full documentation here : TO BE ENTERED
  71762. */
  71763. export class PointsCloudSystem implements IDisposable {
  71764. /**
  71765. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71766. * Example : var p = SPS.particles[i];
  71767. */
  71768. particles: CloudPoint[];
  71769. /**
  71770. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71771. */
  71772. nbParticles: number;
  71773. /**
  71774. * This a counter for your own usage. It's not set by any SPS functions.
  71775. */
  71776. counter: number;
  71777. /**
  71778. * The PCS name. This name is also given to the underlying mesh.
  71779. */
  71780. name: string;
  71781. /**
  71782. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71783. */
  71784. mesh: Mesh;
  71785. /**
  71786. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71787. * Please read :
  71788. */
  71789. vars: any;
  71790. /**
  71791. * @hidden
  71792. */
  71793. _size: number;
  71794. private _scene;
  71795. private _promises;
  71796. private _positions;
  71797. private _indices;
  71798. private _normals;
  71799. private _colors;
  71800. private _uvs;
  71801. private _indices32;
  71802. private _positions32;
  71803. private _colors32;
  71804. private _uvs32;
  71805. private _updatable;
  71806. private _isVisibilityBoxLocked;
  71807. private _alwaysVisible;
  71808. private _groups;
  71809. private _groupCounter;
  71810. private _computeParticleColor;
  71811. private _computeParticleTexture;
  71812. private _computeParticleRotation;
  71813. private _computeBoundingBox;
  71814. private _isReady;
  71815. /**
  71816. * Creates a PCS (Points Cloud System) object
  71817. * @param name (String) is the PCS name, this will be the underlying mesh name
  71818. * @param pointSize (number) is the size for each point
  71819. * @param scene (Scene) is the scene in which the PCS is added
  71820. * @param options defines the options of the PCS e.g.
  71821. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71822. */
  71823. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71824. updatable?: boolean;
  71825. });
  71826. /**
  71827. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71828. * If no points were added to the PCS, the returned mesh is just a single point.
  71829. * @returns a promise for the created mesh
  71830. */
  71831. buildMeshAsync(): Promise<Mesh>;
  71832. /**
  71833. * @hidden
  71834. */
  71835. private _buildMesh;
  71836. private _addParticle;
  71837. private _randomUnitVector;
  71838. private _getColorIndicesForCoord;
  71839. private _setPointsColorOrUV;
  71840. private _colorFromTexture;
  71841. private _calculateDensity;
  71842. /**
  71843. * Adds points to the PCS in random positions within a unit sphere
  71844. * @param nb (positive integer) the number of particles to be created from this model
  71845. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71846. * @returns the number of groups in the system
  71847. */
  71848. addPoints(nb: number, pointFunction?: any): number;
  71849. /**
  71850. * Adds points to the PCS from the surface of the model shape
  71851. * @param mesh is any Mesh object that will be used as a surface model for the points
  71852. * @param nb (positive integer) the number of particles to be created from this model
  71853. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71854. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71855. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71856. * @returns the number of groups in the system
  71857. */
  71858. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71859. /**
  71860. * Adds points to the PCS inside the model shape
  71861. * @param mesh is any Mesh object that will be used as a surface model for the points
  71862. * @param nb (positive integer) the number of particles to be created from this model
  71863. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71864. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71865. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71866. * @returns the number of groups in the system
  71867. */
  71868. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71869. /**
  71870. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71871. * This method calls `updateParticle()` for each particle of the SPS.
  71872. * For an animated SPS, it is usually called within the render loop.
  71873. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71874. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71875. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71876. * @returns the PCS.
  71877. */
  71878. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71879. /**
  71880. * Disposes the PCS.
  71881. */
  71882. dispose(): void;
  71883. /**
  71884. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71885. * doc :
  71886. * @returns the PCS.
  71887. */
  71888. refreshVisibleSize(): PointsCloudSystem;
  71889. /**
  71890. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71891. * @param size the size (float) of the visibility box
  71892. * note : this doesn't lock the PCS mesh bounding box.
  71893. * doc :
  71894. */
  71895. setVisibilityBox(size: number): void;
  71896. /**
  71897. * Gets whether the PCS is always visible or not
  71898. * doc :
  71899. */
  71900. get isAlwaysVisible(): boolean;
  71901. /**
  71902. * Sets the PCS as always visible or not
  71903. * doc :
  71904. */
  71905. set isAlwaysVisible(val: boolean);
  71906. /**
  71907. * Tells to `setParticles()` to compute the particle rotations or not
  71908. * Default value : false. The PCS is faster when it's set to false
  71909. * Note : particle rotations are only applied to parent particles
  71910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71911. */
  71912. set computeParticleRotation(val: boolean);
  71913. /**
  71914. * Tells to `setParticles()` to compute the particle colors or not.
  71915. * Default value : true. The PCS is faster when it's set to false.
  71916. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71917. */
  71918. set computeParticleColor(val: boolean);
  71919. set computeParticleTexture(val: boolean);
  71920. /**
  71921. * Gets if `setParticles()` computes the particle colors or not.
  71922. * Default value : false. The PCS is faster when it's set to false.
  71923. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71924. */
  71925. get computeParticleColor(): boolean;
  71926. /**
  71927. * Gets if `setParticles()` computes the particle textures or not.
  71928. * Default value : false. The PCS is faster when it's set to false.
  71929. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71930. */
  71931. get computeParticleTexture(): boolean;
  71932. /**
  71933. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71934. */
  71935. set computeBoundingBox(val: boolean);
  71936. /**
  71937. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71938. */
  71939. get computeBoundingBox(): boolean;
  71940. /**
  71941. * This function does nothing. It may be overwritten to set all the particle first values.
  71942. * The PCS doesn't call this function, you may have to call it by your own.
  71943. * doc :
  71944. */
  71945. initParticles(): void;
  71946. /**
  71947. * This function does nothing. It may be overwritten to recycle a particle
  71948. * The PCS doesn't call this function, you can to call it
  71949. * doc :
  71950. * @param particle The particle to recycle
  71951. * @returns the recycled particle
  71952. */
  71953. recycleParticle(particle: CloudPoint): CloudPoint;
  71954. /**
  71955. * Updates a particle : this function should be overwritten by the user.
  71956. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71957. * doc :
  71958. * @example : just set a particle position or velocity and recycle conditions
  71959. * @param particle The particle to update
  71960. * @returns the updated particle
  71961. */
  71962. updateParticle(particle: CloudPoint): CloudPoint;
  71963. /**
  71964. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71965. * This does nothing and may be overwritten by the user.
  71966. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71968. * @param update the boolean update value actually passed to setParticles()
  71969. */
  71970. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71971. /**
  71972. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71973. * This will be passed three parameters.
  71974. * This does nothing and may be overwritten by the user.
  71975. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71977. * @param update the boolean update value actually passed to setParticles()
  71978. */
  71979. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71980. }
  71981. }
  71982. declare module "babylonjs/Particles/cloudPoint" {
  71983. import { Nullable } from "babylonjs/types";
  71984. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71985. import { Mesh } from "babylonjs/Meshes/mesh";
  71986. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71987. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71988. /**
  71989. * Represents one particle of a points cloud system.
  71990. */
  71991. export class CloudPoint {
  71992. /**
  71993. * particle global index
  71994. */
  71995. idx: number;
  71996. /**
  71997. * The color of the particle
  71998. */
  71999. color: Nullable<Color4>;
  72000. /**
  72001. * The world space position of the particle.
  72002. */
  72003. position: Vector3;
  72004. /**
  72005. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72006. */
  72007. rotation: Vector3;
  72008. /**
  72009. * The world space rotation quaternion of the particle.
  72010. */
  72011. rotationQuaternion: Nullable<Quaternion>;
  72012. /**
  72013. * The uv of the particle.
  72014. */
  72015. uv: Nullable<Vector2>;
  72016. /**
  72017. * The current speed of the particle.
  72018. */
  72019. velocity: Vector3;
  72020. /**
  72021. * The pivot point in the particle local space.
  72022. */
  72023. pivot: Vector3;
  72024. /**
  72025. * Must the particle be translated from its pivot point in its local space ?
  72026. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72027. * Default : false
  72028. */
  72029. translateFromPivot: boolean;
  72030. /**
  72031. * Index of this particle in the global "positions" array (Internal use)
  72032. * @hidden
  72033. */
  72034. _pos: number;
  72035. /**
  72036. * @hidden Index of this particle in the global "indices" array (Internal use)
  72037. */
  72038. _ind: number;
  72039. /**
  72040. * Group this particle belongs to
  72041. */
  72042. _group: PointsGroup;
  72043. /**
  72044. * Group id of this particle
  72045. */
  72046. groupId: number;
  72047. /**
  72048. * Index of the particle in its group id (Internal use)
  72049. */
  72050. idxInGroup: number;
  72051. /**
  72052. * @hidden Particle BoundingInfo object (Internal use)
  72053. */
  72054. _boundingInfo: BoundingInfo;
  72055. /**
  72056. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72057. */
  72058. _pcs: PointsCloudSystem;
  72059. /**
  72060. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72061. */
  72062. _stillInvisible: boolean;
  72063. /**
  72064. * @hidden Last computed particle rotation matrix
  72065. */
  72066. _rotationMatrix: number[];
  72067. /**
  72068. * Parent particle Id, if any.
  72069. * Default null.
  72070. */
  72071. parentId: Nullable<number>;
  72072. /**
  72073. * @hidden Internal global position in the PCS.
  72074. */
  72075. _globalPosition: Vector3;
  72076. /**
  72077. * Creates a Point Cloud object.
  72078. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72079. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72080. * @param group (PointsGroup) is the group the particle belongs to
  72081. * @param groupId (integer) is the group identifier in the PCS.
  72082. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72083. * @param pcs defines the PCS it is associated to
  72084. */
  72085. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72086. /**
  72087. * get point size
  72088. */
  72089. get size(): Vector3;
  72090. /**
  72091. * Set point size
  72092. */
  72093. set size(scale: Vector3);
  72094. /**
  72095. * Legacy support, changed quaternion to rotationQuaternion
  72096. */
  72097. get quaternion(): Nullable<Quaternion>;
  72098. /**
  72099. * Legacy support, changed quaternion to rotationQuaternion
  72100. */
  72101. set quaternion(q: Nullable<Quaternion>);
  72102. /**
  72103. * Returns a boolean. True if the particle intersects a mesh, else false
  72104. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72105. * @param target is the object (point or mesh) what the intersection is computed against
  72106. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72107. * @returns true if it intersects
  72108. */
  72109. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72110. /**
  72111. * get the rotation matrix of the particle
  72112. * @hidden
  72113. */
  72114. getRotationMatrix(m: Matrix): void;
  72115. }
  72116. /**
  72117. * Represents a group of points in a points cloud system
  72118. * * PCS internal tool, don't use it manually.
  72119. */
  72120. export class PointsGroup {
  72121. /**
  72122. * The group id
  72123. * @hidden
  72124. */
  72125. groupID: number;
  72126. /**
  72127. * image data for group (internal use)
  72128. * @hidden
  72129. */
  72130. _groupImageData: Nullable<ArrayBufferView>;
  72131. /**
  72132. * Image Width (internal use)
  72133. * @hidden
  72134. */
  72135. _groupImgWidth: number;
  72136. /**
  72137. * Image Height (internal use)
  72138. * @hidden
  72139. */
  72140. _groupImgHeight: number;
  72141. /**
  72142. * Custom position function (internal use)
  72143. * @hidden
  72144. */
  72145. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72146. /**
  72147. * density per facet for surface points
  72148. * @hidden
  72149. */
  72150. _groupDensity: number[];
  72151. /**
  72152. * Only when points are colored by texture carries pointer to texture list array
  72153. * @hidden
  72154. */
  72155. _textureNb: number;
  72156. /**
  72157. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72158. * PCS internal tool, don't use it manually.
  72159. * @hidden
  72160. */
  72161. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72162. }
  72163. }
  72164. declare module "babylonjs/Particles/index" {
  72165. export * from "babylonjs/Particles/baseParticleSystem";
  72166. export * from "babylonjs/Particles/EmitterTypes/index";
  72167. export * from "babylonjs/Particles/gpuParticleSystem";
  72168. export * from "babylonjs/Particles/IParticleSystem";
  72169. export * from "babylonjs/Particles/particle";
  72170. export * from "babylonjs/Particles/particleHelper";
  72171. export * from "babylonjs/Particles/particleSystem";
  72172. import "babylonjs/Particles/particleSystemComponent";
  72173. export * from "babylonjs/Particles/particleSystemComponent";
  72174. export * from "babylonjs/Particles/particleSystemSet";
  72175. export * from "babylonjs/Particles/solidParticle";
  72176. export * from "babylonjs/Particles/solidParticleSystem";
  72177. export * from "babylonjs/Particles/cloudPoint";
  72178. export * from "babylonjs/Particles/pointsCloudSystem";
  72179. export * from "babylonjs/Particles/subEmitter";
  72180. }
  72181. declare module "babylonjs/Physics/physicsEngineComponent" {
  72182. import { Nullable } from "babylonjs/types";
  72183. import { Observable, Observer } from "babylonjs/Misc/observable";
  72184. import { Vector3 } from "babylonjs/Maths/math.vector";
  72185. import { Mesh } from "babylonjs/Meshes/mesh";
  72186. import { ISceneComponent } from "babylonjs/sceneComponent";
  72187. import { Scene } from "babylonjs/scene";
  72188. import { Node } from "babylonjs/node";
  72189. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72190. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72191. module "babylonjs/scene" {
  72192. interface Scene {
  72193. /** @hidden (Backing field) */
  72194. _physicsEngine: Nullable<IPhysicsEngine>;
  72195. /** @hidden */
  72196. _physicsTimeAccumulator: number;
  72197. /**
  72198. * Gets the current physics engine
  72199. * @returns a IPhysicsEngine or null if none attached
  72200. */
  72201. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72202. /**
  72203. * Enables physics to the current scene
  72204. * @param gravity defines the scene's gravity for the physics engine
  72205. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72206. * @return a boolean indicating if the physics engine was initialized
  72207. */
  72208. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72209. /**
  72210. * Disables and disposes the physics engine associated with the scene
  72211. */
  72212. disablePhysicsEngine(): void;
  72213. /**
  72214. * Gets a boolean indicating if there is an active physics engine
  72215. * @returns a boolean indicating if there is an active physics engine
  72216. */
  72217. isPhysicsEnabled(): boolean;
  72218. /**
  72219. * Deletes a physics compound impostor
  72220. * @param compound defines the compound to delete
  72221. */
  72222. deleteCompoundImpostor(compound: any): void;
  72223. /**
  72224. * An event triggered when physic simulation is about to be run
  72225. */
  72226. onBeforePhysicsObservable: Observable<Scene>;
  72227. /**
  72228. * An event triggered when physic simulation has been done
  72229. */
  72230. onAfterPhysicsObservable: Observable<Scene>;
  72231. }
  72232. }
  72233. module "babylonjs/Meshes/abstractMesh" {
  72234. interface AbstractMesh {
  72235. /** @hidden */
  72236. _physicsImpostor: Nullable<PhysicsImpostor>;
  72237. /**
  72238. * Gets or sets impostor used for physic simulation
  72239. * @see https://doc.babylonjs.com/features/physics_engine
  72240. */
  72241. physicsImpostor: Nullable<PhysicsImpostor>;
  72242. /**
  72243. * Gets the current physics impostor
  72244. * @see https://doc.babylonjs.com/features/physics_engine
  72245. * @returns a physics impostor or null
  72246. */
  72247. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72248. /** Apply a physic impulse to the mesh
  72249. * @param force defines the force to apply
  72250. * @param contactPoint defines where to apply the force
  72251. * @returns the current mesh
  72252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72253. */
  72254. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72255. /**
  72256. * Creates a physic joint between two meshes
  72257. * @param otherMesh defines the other mesh to use
  72258. * @param pivot1 defines the pivot to use on this mesh
  72259. * @param pivot2 defines the pivot to use on the other mesh
  72260. * @param options defines additional options (can be plugin dependent)
  72261. * @returns the current mesh
  72262. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72263. */
  72264. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72265. /** @hidden */
  72266. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72267. }
  72268. }
  72269. /**
  72270. * Defines the physics engine scene component responsible to manage a physics engine
  72271. */
  72272. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72273. /**
  72274. * The component name helpful to identify the component in the list of scene components.
  72275. */
  72276. readonly name: string;
  72277. /**
  72278. * The scene the component belongs to.
  72279. */
  72280. scene: Scene;
  72281. /**
  72282. * Creates a new instance of the component for the given scene
  72283. * @param scene Defines the scene to register the component in
  72284. */
  72285. constructor(scene: Scene);
  72286. /**
  72287. * Registers the component in a given scene
  72288. */
  72289. register(): void;
  72290. /**
  72291. * Rebuilds the elements related to this component in case of
  72292. * context lost for instance.
  72293. */
  72294. rebuild(): void;
  72295. /**
  72296. * Disposes the component and the associated ressources
  72297. */
  72298. dispose(): void;
  72299. }
  72300. }
  72301. declare module "babylonjs/Physics/physicsHelper" {
  72302. import { Nullable } from "babylonjs/types";
  72303. import { Vector3 } from "babylonjs/Maths/math.vector";
  72304. import { Mesh } from "babylonjs/Meshes/mesh";
  72305. import { Scene } from "babylonjs/scene";
  72306. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72307. /**
  72308. * A helper for physics simulations
  72309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72310. */
  72311. export class PhysicsHelper {
  72312. private _scene;
  72313. private _physicsEngine;
  72314. /**
  72315. * Initializes the Physics helper
  72316. * @param scene Babylon.js scene
  72317. */
  72318. constructor(scene: Scene);
  72319. /**
  72320. * Applies a radial explosion impulse
  72321. * @param origin the origin of the explosion
  72322. * @param radiusOrEventOptions the radius or the options of radial explosion
  72323. * @param strength the explosion strength
  72324. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72325. * @returns A physics radial explosion event, or null
  72326. */
  72327. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72328. /**
  72329. * Applies a radial explosion force
  72330. * @param origin the origin of the explosion
  72331. * @param radiusOrEventOptions the radius or the options of radial explosion
  72332. * @param strength the explosion strength
  72333. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72334. * @returns A physics radial explosion event, or null
  72335. */
  72336. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72337. /**
  72338. * Creates a gravitational field
  72339. * @param origin the origin of the explosion
  72340. * @param radiusOrEventOptions the radius or the options of radial explosion
  72341. * @param strength the explosion strength
  72342. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72343. * @returns A physics gravitational field event, or null
  72344. */
  72345. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72346. /**
  72347. * Creates a physics updraft event
  72348. * @param origin the origin of the updraft
  72349. * @param radiusOrEventOptions the radius or the options of the updraft
  72350. * @param strength the strength of the updraft
  72351. * @param height the height of the updraft
  72352. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72353. * @returns A physics updraft event, or null
  72354. */
  72355. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72356. /**
  72357. * Creates a physics vortex event
  72358. * @param origin the of the vortex
  72359. * @param radiusOrEventOptions the radius or the options of the vortex
  72360. * @param strength the strength of the vortex
  72361. * @param height the height of the vortex
  72362. * @returns a Physics vortex event, or null
  72363. * A physics vortex event or null
  72364. */
  72365. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72366. }
  72367. /**
  72368. * Represents a physics radial explosion event
  72369. */
  72370. class PhysicsRadialExplosionEvent {
  72371. private _scene;
  72372. private _options;
  72373. private _sphere;
  72374. private _dataFetched;
  72375. /**
  72376. * Initializes a radial explosioin event
  72377. * @param _scene BabylonJS scene
  72378. * @param _options The options for the vortex event
  72379. */
  72380. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72381. /**
  72382. * Returns the data related to the radial explosion event (sphere).
  72383. * @returns The radial explosion event data
  72384. */
  72385. getData(): PhysicsRadialExplosionEventData;
  72386. /**
  72387. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72388. * @param impostor A physics imposter
  72389. * @param origin the origin of the explosion
  72390. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72391. */
  72392. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72393. /**
  72394. * Triggers affecterd impostors callbacks
  72395. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72396. */
  72397. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72398. /**
  72399. * Disposes the sphere.
  72400. * @param force Specifies if the sphere should be disposed by force
  72401. */
  72402. dispose(force?: boolean): void;
  72403. /*** Helpers ***/
  72404. private _prepareSphere;
  72405. private _intersectsWithSphere;
  72406. }
  72407. /**
  72408. * Represents a gravitational field event
  72409. */
  72410. class PhysicsGravitationalFieldEvent {
  72411. private _physicsHelper;
  72412. private _scene;
  72413. private _origin;
  72414. private _options;
  72415. private _tickCallback;
  72416. private _sphere;
  72417. private _dataFetched;
  72418. /**
  72419. * Initializes the physics gravitational field event
  72420. * @param _physicsHelper A physics helper
  72421. * @param _scene BabylonJS scene
  72422. * @param _origin The origin position of the gravitational field event
  72423. * @param _options The options for the vortex event
  72424. */
  72425. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72426. /**
  72427. * Returns the data related to the gravitational field event (sphere).
  72428. * @returns A gravitational field event
  72429. */
  72430. getData(): PhysicsGravitationalFieldEventData;
  72431. /**
  72432. * Enables the gravitational field.
  72433. */
  72434. enable(): void;
  72435. /**
  72436. * Disables the gravitational field.
  72437. */
  72438. disable(): void;
  72439. /**
  72440. * Disposes the sphere.
  72441. * @param force The force to dispose from the gravitational field event
  72442. */
  72443. dispose(force?: boolean): void;
  72444. private _tick;
  72445. }
  72446. /**
  72447. * Represents a physics updraft event
  72448. */
  72449. class PhysicsUpdraftEvent {
  72450. private _scene;
  72451. private _origin;
  72452. private _options;
  72453. private _physicsEngine;
  72454. private _originTop;
  72455. private _originDirection;
  72456. private _tickCallback;
  72457. private _cylinder;
  72458. private _cylinderPosition;
  72459. private _dataFetched;
  72460. /**
  72461. * Initializes the physics updraft event
  72462. * @param _scene BabylonJS scene
  72463. * @param _origin The origin position of the updraft
  72464. * @param _options The options for the updraft event
  72465. */
  72466. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72467. /**
  72468. * Returns the data related to the updraft event (cylinder).
  72469. * @returns A physics updraft event
  72470. */
  72471. getData(): PhysicsUpdraftEventData;
  72472. /**
  72473. * Enables the updraft.
  72474. */
  72475. enable(): void;
  72476. /**
  72477. * Disables the updraft.
  72478. */
  72479. disable(): void;
  72480. /**
  72481. * Disposes the cylinder.
  72482. * @param force Specifies if the updraft should be disposed by force
  72483. */
  72484. dispose(force?: boolean): void;
  72485. private getImpostorHitData;
  72486. private _tick;
  72487. /*** Helpers ***/
  72488. private _prepareCylinder;
  72489. private _intersectsWithCylinder;
  72490. }
  72491. /**
  72492. * Represents a physics vortex event
  72493. */
  72494. class PhysicsVortexEvent {
  72495. private _scene;
  72496. private _origin;
  72497. private _options;
  72498. private _physicsEngine;
  72499. private _originTop;
  72500. private _tickCallback;
  72501. private _cylinder;
  72502. private _cylinderPosition;
  72503. private _dataFetched;
  72504. /**
  72505. * Initializes the physics vortex event
  72506. * @param _scene The BabylonJS scene
  72507. * @param _origin The origin position of the vortex
  72508. * @param _options The options for the vortex event
  72509. */
  72510. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72511. /**
  72512. * Returns the data related to the vortex event (cylinder).
  72513. * @returns The physics vortex event data
  72514. */
  72515. getData(): PhysicsVortexEventData;
  72516. /**
  72517. * Enables the vortex.
  72518. */
  72519. enable(): void;
  72520. /**
  72521. * Disables the cortex.
  72522. */
  72523. disable(): void;
  72524. /**
  72525. * Disposes the sphere.
  72526. * @param force
  72527. */
  72528. dispose(force?: boolean): void;
  72529. private getImpostorHitData;
  72530. private _tick;
  72531. /*** Helpers ***/
  72532. private _prepareCylinder;
  72533. private _intersectsWithCylinder;
  72534. }
  72535. /**
  72536. * Options fot the radial explosion event
  72537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72538. */
  72539. export class PhysicsRadialExplosionEventOptions {
  72540. /**
  72541. * The radius of the sphere for the radial explosion.
  72542. */
  72543. radius: number;
  72544. /**
  72545. * The strenth of the explosion.
  72546. */
  72547. strength: number;
  72548. /**
  72549. * The strenght of the force in correspondence to the distance of the affected object
  72550. */
  72551. falloff: PhysicsRadialImpulseFalloff;
  72552. /**
  72553. * Sphere options for the radial explosion.
  72554. */
  72555. sphere: {
  72556. segments: number;
  72557. diameter: number;
  72558. };
  72559. /**
  72560. * Sphere options for the radial explosion.
  72561. */
  72562. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72563. }
  72564. /**
  72565. * Options fot the updraft event
  72566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72567. */
  72568. export class PhysicsUpdraftEventOptions {
  72569. /**
  72570. * The radius of the cylinder for the vortex
  72571. */
  72572. radius: number;
  72573. /**
  72574. * The strenth of the updraft.
  72575. */
  72576. strength: number;
  72577. /**
  72578. * The height of the cylinder for the updraft.
  72579. */
  72580. height: number;
  72581. /**
  72582. * The mode for the the updraft.
  72583. */
  72584. updraftMode: PhysicsUpdraftMode;
  72585. }
  72586. /**
  72587. * Options fot the vortex event
  72588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72589. */
  72590. export class PhysicsVortexEventOptions {
  72591. /**
  72592. * The radius of the cylinder for the vortex
  72593. */
  72594. radius: number;
  72595. /**
  72596. * The strenth of the vortex.
  72597. */
  72598. strength: number;
  72599. /**
  72600. * The height of the cylinder for the vortex.
  72601. */
  72602. height: number;
  72603. /**
  72604. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72605. */
  72606. centripetalForceThreshold: number;
  72607. /**
  72608. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72609. */
  72610. centripetalForceMultiplier: number;
  72611. /**
  72612. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72613. */
  72614. centrifugalForceMultiplier: number;
  72615. /**
  72616. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72617. */
  72618. updraftForceMultiplier: number;
  72619. }
  72620. /**
  72621. * The strenght of the force in correspondence to the distance of the affected object
  72622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72623. */
  72624. export enum PhysicsRadialImpulseFalloff {
  72625. /** Defines that impulse is constant in strength across it's whole radius */
  72626. Constant = 0,
  72627. /** Defines that impulse gets weaker if it's further from the origin */
  72628. Linear = 1
  72629. }
  72630. /**
  72631. * The strength of the force in correspondence to the distance of the affected object
  72632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72633. */
  72634. export enum PhysicsUpdraftMode {
  72635. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72636. Center = 0,
  72637. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72638. Perpendicular = 1
  72639. }
  72640. /**
  72641. * Interface for a physics hit data
  72642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72643. */
  72644. export interface PhysicsHitData {
  72645. /**
  72646. * The force applied at the contact point
  72647. */
  72648. force: Vector3;
  72649. /**
  72650. * The contact point
  72651. */
  72652. contactPoint: Vector3;
  72653. /**
  72654. * The distance from the origin to the contact point
  72655. */
  72656. distanceFromOrigin: number;
  72657. }
  72658. /**
  72659. * Interface for radial explosion event data
  72660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72661. */
  72662. export interface PhysicsRadialExplosionEventData {
  72663. /**
  72664. * A sphere used for the radial explosion event
  72665. */
  72666. sphere: Mesh;
  72667. }
  72668. /**
  72669. * Interface for gravitational field event data
  72670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72671. */
  72672. export interface PhysicsGravitationalFieldEventData {
  72673. /**
  72674. * A sphere mesh used for the gravitational field event
  72675. */
  72676. sphere: Mesh;
  72677. }
  72678. /**
  72679. * Interface for updraft event data
  72680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72681. */
  72682. export interface PhysicsUpdraftEventData {
  72683. /**
  72684. * A cylinder used for the updraft event
  72685. */
  72686. cylinder: Mesh;
  72687. }
  72688. /**
  72689. * Interface for vortex event data
  72690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72691. */
  72692. export interface PhysicsVortexEventData {
  72693. /**
  72694. * A cylinder used for the vortex event
  72695. */
  72696. cylinder: Mesh;
  72697. }
  72698. /**
  72699. * Interface for an affected physics impostor
  72700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72701. */
  72702. export interface PhysicsAffectedImpostorWithData {
  72703. /**
  72704. * The impostor affected by the effect
  72705. */
  72706. impostor: PhysicsImpostor;
  72707. /**
  72708. * The data about the hit/horce from the explosion
  72709. */
  72710. hitData: PhysicsHitData;
  72711. }
  72712. }
  72713. declare module "babylonjs/Physics/Plugins/index" {
  72714. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72715. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72716. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72717. }
  72718. declare module "babylonjs/Physics/index" {
  72719. export * from "babylonjs/Physics/IPhysicsEngine";
  72720. export * from "babylonjs/Physics/physicsEngine";
  72721. export * from "babylonjs/Physics/physicsEngineComponent";
  72722. export * from "babylonjs/Physics/physicsHelper";
  72723. export * from "babylonjs/Physics/physicsImpostor";
  72724. export * from "babylonjs/Physics/physicsJoint";
  72725. export * from "babylonjs/Physics/Plugins/index";
  72726. }
  72727. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72728. /** @hidden */
  72729. export var blackAndWhitePixelShader: {
  72730. name: string;
  72731. shader: string;
  72732. };
  72733. }
  72734. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72735. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72736. import { Camera } from "babylonjs/Cameras/camera";
  72737. import { Engine } from "babylonjs/Engines/engine";
  72738. import "babylonjs/Shaders/blackAndWhite.fragment";
  72739. import { Nullable } from "babylonjs/types";
  72740. import { Scene } from "babylonjs/scene";
  72741. /**
  72742. * Post process used to render in black and white
  72743. */
  72744. export class BlackAndWhitePostProcess extends PostProcess {
  72745. /**
  72746. * Linear about to convert he result to black and white (default: 1)
  72747. */
  72748. degree: number;
  72749. /**
  72750. * Gets a string identifying the name of the class
  72751. * @returns "BlackAndWhitePostProcess" string
  72752. */
  72753. getClassName(): string;
  72754. /**
  72755. * Creates a black and white post process
  72756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72757. * @param name The name of the effect.
  72758. * @param options The required width/height ratio to downsize to before computing the render pass.
  72759. * @param camera The camera to apply the render pass to.
  72760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72761. * @param engine The engine which the post process will be applied. (default: current engine)
  72762. * @param reusable If the post process can be reused on the same frame. (default: false)
  72763. */
  72764. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72765. /** @hidden */
  72766. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72767. }
  72768. }
  72769. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72770. import { Nullable } from "babylonjs/types";
  72771. import { Camera } from "babylonjs/Cameras/camera";
  72772. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72773. import { Engine } from "babylonjs/Engines/engine";
  72774. /**
  72775. * This represents a set of one or more post processes in Babylon.
  72776. * A post process can be used to apply a shader to a texture after it is rendered.
  72777. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72778. */
  72779. export class PostProcessRenderEffect {
  72780. private _postProcesses;
  72781. private _getPostProcesses;
  72782. private _singleInstance;
  72783. private _cameras;
  72784. private _indicesForCamera;
  72785. /**
  72786. * Name of the effect
  72787. * @hidden
  72788. */
  72789. _name: string;
  72790. /**
  72791. * Instantiates a post process render effect.
  72792. * A post process can be used to apply a shader to a texture after it is rendered.
  72793. * @param engine The engine the effect is tied to
  72794. * @param name The name of the effect
  72795. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72796. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72797. */
  72798. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72799. /**
  72800. * Checks if all the post processes in the effect are supported.
  72801. */
  72802. get isSupported(): boolean;
  72803. /**
  72804. * Updates the current state of the effect
  72805. * @hidden
  72806. */
  72807. _update(): void;
  72808. /**
  72809. * Attaches the effect on cameras
  72810. * @param cameras The camera to attach to.
  72811. * @hidden
  72812. */
  72813. _attachCameras(cameras: Camera): void;
  72814. /**
  72815. * Attaches the effect on cameras
  72816. * @param cameras The camera to attach to.
  72817. * @hidden
  72818. */
  72819. _attachCameras(cameras: Camera[]): void;
  72820. /**
  72821. * Detaches the effect on cameras
  72822. * @param cameras The camera to detatch from.
  72823. * @hidden
  72824. */
  72825. _detachCameras(cameras: Camera): void;
  72826. /**
  72827. * Detatches the effect on cameras
  72828. * @param cameras The camera to detatch from.
  72829. * @hidden
  72830. */
  72831. _detachCameras(cameras: Camera[]): void;
  72832. /**
  72833. * Enables the effect on given cameras
  72834. * @param cameras The camera to enable.
  72835. * @hidden
  72836. */
  72837. _enable(cameras: Camera): void;
  72838. /**
  72839. * Enables the effect on given cameras
  72840. * @param cameras The camera to enable.
  72841. * @hidden
  72842. */
  72843. _enable(cameras: Nullable<Camera[]>): void;
  72844. /**
  72845. * Disables the effect on the given cameras
  72846. * @param cameras The camera to disable.
  72847. * @hidden
  72848. */
  72849. _disable(cameras: Camera): void;
  72850. /**
  72851. * Disables the effect on the given cameras
  72852. * @param cameras The camera to disable.
  72853. * @hidden
  72854. */
  72855. _disable(cameras: Nullable<Camera[]>): void;
  72856. /**
  72857. * Gets a list of the post processes contained in the effect.
  72858. * @param camera The camera to get the post processes on.
  72859. * @returns The list of the post processes in the effect.
  72860. */
  72861. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72862. }
  72863. }
  72864. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72866. /** @hidden */
  72867. export var extractHighlightsPixelShader: {
  72868. name: string;
  72869. shader: string;
  72870. };
  72871. }
  72872. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72873. import { Nullable } from "babylonjs/types";
  72874. import { Camera } from "babylonjs/Cameras/camera";
  72875. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72876. import { Engine } from "babylonjs/Engines/engine";
  72877. import "babylonjs/Shaders/extractHighlights.fragment";
  72878. /**
  72879. * 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.
  72880. */
  72881. export class ExtractHighlightsPostProcess extends PostProcess {
  72882. /**
  72883. * The luminance threshold, pixels below this value will be set to black.
  72884. */
  72885. threshold: number;
  72886. /** @hidden */
  72887. _exposure: number;
  72888. /**
  72889. * Post process which has the input texture to be used when performing highlight extraction
  72890. * @hidden
  72891. */
  72892. _inputPostProcess: Nullable<PostProcess>;
  72893. /**
  72894. * Gets a string identifying the name of the class
  72895. * @returns "ExtractHighlightsPostProcess" string
  72896. */
  72897. getClassName(): string;
  72898. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72899. }
  72900. }
  72901. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72902. /** @hidden */
  72903. export var bloomMergePixelShader: {
  72904. name: string;
  72905. shader: string;
  72906. };
  72907. }
  72908. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72910. import { Nullable } from "babylonjs/types";
  72911. import { Engine } from "babylonjs/Engines/engine";
  72912. import { Camera } from "babylonjs/Cameras/camera";
  72913. import "babylonjs/Shaders/bloomMerge.fragment";
  72914. /**
  72915. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72916. */
  72917. export class BloomMergePostProcess extends PostProcess {
  72918. /** Weight of the bloom to be added to the original input. */
  72919. weight: number;
  72920. /**
  72921. * Gets a string identifying the name of the class
  72922. * @returns "BloomMergePostProcess" string
  72923. */
  72924. getClassName(): string;
  72925. /**
  72926. * Creates a new instance of @see BloomMergePostProcess
  72927. * @param name The name of the effect.
  72928. * @param originalFromInput Post process which's input will be used for the merge.
  72929. * @param blurred Blurred highlights post process which's output will be used.
  72930. * @param weight Weight of the bloom to be added to the original input.
  72931. * @param options The required width/height ratio to downsize to before computing the render pass.
  72932. * @param camera The camera to apply the render pass to.
  72933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72934. * @param engine The engine which the post process will be applied. (default: current engine)
  72935. * @param reusable If the post process can be reused on the same frame. (default: false)
  72936. * @param textureType Type of textures used when performing the post process. (default: 0)
  72937. * @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)
  72938. */
  72939. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72940. /** Weight of the bloom to be added to the original input. */
  72941. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72942. }
  72943. }
  72944. declare module "babylonjs/PostProcesses/bloomEffect" {
  72945. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72946. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72947. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72948. import { Camera } from "babylonjs/Cameras/camera";
  72949. import { Scene } from "babylonjs/scene";
  72950. /**
  72951. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72952. */
  72953. export class BloomEffect extends PostProcessRenderEffect {
  72954. private bloomScale;
  72955. /**
  72956. * @hidden Internal
  72957. */
  72958. _effects: Array<PostProcess>;
  72959. /**
  72960. * @hidden Internal
  72961. */
  72962. _downscale: ExtractHighlightsPostProcess;
  72963. private _blurX;
  72964. private _blurY;
  72965. private _merge;
  72966. /**
  72967. * The luminance threshold to find bright areas of the image to bloom.
  72968. */
  72969. get threshold(): number;
  72970. set threshold(value: number);
  72971. /**
  72972. * The strength of the bloom.
  72973. */
  72974. get weight(): number;
  72975. set weight(value: number);
  72976. /**
  72977. * Specifies the size of the bloom blur kernel, relative to the final output size
  72978. */
  72979. get kernel(): number;
  72980. set kernel(value: number);
  72981. /**
  72982. * Creates a new instance of @see BloomEffect
  72983. * @param scene The scene the effect belongs to.
  72984. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72985. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72986. * @param bloomWeight The the strength of bloom.
  72987. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72988. * @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)
  72989. */
  72990. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72991. /**
  72992. * Disposes each of the internal effects for a given camera.
  72993. * @param camera The camera to dispose the effect on.
  72994. */
  72995. disposeEffects(camera: Camera): void;
  72996. /**
  72997. * @hidden Internal
  72998. */
  72999. _updateEffects(): void;
  73000. /**
  73001. * Internal
  73002. * @returns if all the contained post processes are ready.
  73003. * @hidden
  73004. */
  73005. _isReady(): boolean;
  73006. }
  73007. }
  73008. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73009. /** @hidden */
  73010. export var chromaticAberrationPixelShader: {
  73011. name: string;
  73012. shader: string;
  73013. };
  73014. }
  73015. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73016. import { Vector2 } from "babylonjs/Maths/math.vector";
  73017. import { Nullable } from "babylonjs/types";
  73018. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73019. import { Camera } from "babylonjs/Cameras/camera";
  73020. import { Engine } from "babylonjs/Engines/engine";
  73021. import "babylonjs/Shaders/chromaticAberration.fragment";
  73022. import { Scene } from "babylonjs/scene";
  73023. /**
  73024. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73025. */
  73026. export class ChromaticAberrationPostProcess extends PostProcess {
  73027. /**
  73028. * The amount of seperation of rgb channels (default: 30)
  73029. */
  73030. aberrationAmount: number;
  73031. /**
  73032. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73033. */
  73034. radialIntensity: number;
  73035. /**
  73036. * 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))
  73037. */
  73038. direction: Vector2;
  73039. /**
  73040. * 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))
  73041. */
  73042. centerPosition: Vector2;
  73043. /** The width of the screen to apply the effect on */
  73044. screenWidth: number;
  73045. /** The height of the screen to apply the effect on */
  73046. screenHeight: number;
  73047. /**
  73048. * Gets a string identifying the name of the class
  73049. * @returns "ChromaticAberrationPostProcess" string
  73050. */
  73051. getClassName(): string;
  73052. /**
  73053. * Creates a new instance ChromaticAberrationPostProcess
  73054. * @param name The name of the effect.
  73055. * @param screenWidth The width of the screen to apply the effect on.
  73056. * @param screenHeight The height of the screen to apply the effect on.
  73057. * @param options The required width/height ratio to downsize to before computing the render pass.
  73058. * @param camera The camera to apply the render pass to.
  73059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73060. * @param engine The engine which the post process will be applied. (default: current engine)
  73061. * @param reusable If the post process can be reused on the same frame. (default: false)
  73062. * @param textureType Type of textures used when performing the post process. (default: 0)
  73063. * @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)
  73064. */
  73065. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73066. /** @hidden */
  73067. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73068. }
  73069. }
  73070. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73071. /** @hidden */
  73072. export var circleOfConfusionPixelShader: {
  73073. name: string;
  73074. shader: string;
  73075. };
  73076. }
  73077. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73078. import { Nullable } from "babylonjs/types";
  73079. import { Engine } from "babylonjs/Engines/engine";
  73080. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73082. import { Camera } from "babylonjs/Cameras/camera";
  73083. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73084. /**
  73085. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73086. */
  73087. export class CircleOfConfusionPostProcess extends PostProcess {
  73088. /**
  73089. * 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.
  73090. */
  73091. lensSize: number;
  73092. /**
  73093. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73094. */
  73095. fStop: number;
  73096. /**
  73097. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73098. */
  73099. focusDistance: number;
  73100. /**
  73101. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73102. */
  73103. focalLength: number;
  73104. /**
  73105. * Gets a string identifying the name of the class
  73106. * @returns "CircleOfConfusionPostProcess" string
  73107. */
  73108. getClassName(): string;
  73109. private _depthTexture;
  73110. /**
  73111. * Creates a new instance CircleOfConfusionPostProcess
  73112. * @param name The name of the effect.
  73113. * @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.
  73114. * @param options The required width/height ratio to downsize to before computing the render pass.
  73115. * @param camera The camera to apply the render pass to.
  73116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73117. * @param engine The engine which the post process will be applied. (default: current engine)
  73118. * @param reusable If the post process can be reused on the same frame. (default: false)
  73119. * @param textureType Type of textures used when performing the post process. (default: 0)
  73120. * @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)
  73121. */
  73122. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73123. /**
  73124. * 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.
  73125. */
  73126. set depthTexture(value: RenderTargetTexture);
  73127. }
  73128. }
  73129. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73130. /** @hidden */
  73131. export var colorCorrectionPixelShader: {
  73132. name: string;
  73133. shader: string;
  73134. };
  73135. }
  73136. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73137. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73138. import { Engine } from "babylonjs/Engines/engine";
  73139. import { Camera } from "babylonjs/Cameras/camera";
  73140. import "babylonjs/Shaders/colorCorrection.fragment";
  73141. import { Nullable } from "babylonjs/types";
  73142. import { Scene } from "babylonjs/scene";
  73143. /**
  73144. *
  73145. * This post-process allows the modification of rendered colors by using
  73146. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73147. *
  73148. * The object needs to be provided an url to a texture containing the color
  73149. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73150. * Use an image editing software to tweak the LUT to match your needs.
  73151. *
  73152. * For an example of a color LUT, see here:
  73153. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73154. * For explanations on color grading, see here:
  73155. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73156. *
  73157. */
  73158. export class ColorCorrectionPostProcess extends PostProcess {
  73159. private _colorTableTexture;
  73160. /**
  73161. * Gets the color table url used to create the LUT texture
  73162. */
  73163. colorTableUrl: string;
  73164. /**
  73165. * Gets a string identifying the name of the class
  73166. * @returns "ColorCorrectionPostProcess" string
  73167. */
  73168. getClassName(): string;
  73169. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73170. /** @hidden */
  73171. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73172. }
  73173. }
  73174. declare module "babylonjs/Shaders/convolution.fragment" {
  73175. /** @hidden */
  73176. export var convolutionPixelShader: {
  73177. name: string;
  73178. shader: string;
  73179. };
  73180. }
  73181. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73182. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73183. import { Nullable } from "babylonjs/types";
  73184. import { Camera } from "babylonjs/Cameras/camera";
  73185. import { Engine } from "babylonjs/Engines/engine";
  73186. import "babylonjs/Shaders/convolution.fragment";
  73187. import { Scene } from "babylonjs/scene";
  73188. /**
  73189. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73190. * input texture to perform effects such as edge detection or sharpening
  73191. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73192. */
  73193. export class ConvolutionPostProcess extends PostProcess {
  73194. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73195. kernel: number[];
  73196. /**
  73197. * Gets a string identifying the name of the class
  73198. * @returns "ConvolutionPostProcess" string
  73199. */
  73200. getClassName(): string;
  73201. /**
  73202. * Creates a new instance ConvolutionPostProcess
  73203. * @param name The name of the effect.
  73204. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73205. * @param options The required width/height ratio to downsize to before computing the render pass.
  73206. * @param camera The camera to apply the render pass to.
  73207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73208. * @param engine The engine which the post process will be applied. (default: current engine)
  73209. * @param reusable If the post process can be reused on the same frame. (default: false)
  73210. * @param textureType Type of textures used when performing the post process. (default: 0)
  73211. */
  73212. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73213. /** @hidden */
  73214. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73215. /**
  73216. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73217. */
  73218. static EdgeDetect0Kernel: number[];
  73219. /**
  73220. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73221. */
  73222. static EdgeDetect1Kernel: number[];
  73223. /**
  73224. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73225. */
  73226. static EdgeDetect2Kernel: number[];
  73227. /**
  73228. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73229. */
  73230. static SharpenKernel: number[];
  73231. /**
  73232. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73233. */
  73234. static EmbossKernel: number[];
  73235. /**
  73236. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73237. */
  73238. static GaussianKernel: number[];
  73239. }
  73240. }
  73241. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73242. import { Nullable } from "babylonjs/types";
  73243. import { Vector2 } from "babylonjs/Maths/math.vector";
  73244. import { Camera } from "babylonjs/Cameras/camera";
  73245. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73246. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73247. import { Engine } from "babylonjs/Engines/engine";
  73248. import { Scene } from "babylonjs/scene";
  73249. /**
  73250. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73251. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73252. * based on samples that have a large difference in distance than the center pixel.
  73253. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73254. */
  73255. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73256. /**
  73257. * The direction the blur should be applied
  73258. */
  73259. direction: Vector2;
  73260. /**
  73261. * Gets a string identifying the name of the class
  73262. * @returns "DepthOfFieldBlurPostProcess" string
  73263. */
  73264. getClassName(): string;
  73265. /**
  73266. * Creates a new instance CircleOfConfusionPostProcess
  73267. * @param name The name of the effect.
  73268. * @param scene The scene the effect belongs to.
  73269. * @param direction The direction the blur should be applied.
  73270. * @param kernel The size of the kernel used to blur.
  73271. * @param options The required width/height ratio to downsize to before computing the render pass.
  73272. * @param camera The camera to apply the render pass to.
  73273. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73274. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73276. * @param engine The engine which the post process will be applied. (default: current engine)
  73277. * @param reusable If the post process can be reused on the same frame. (default: false)
  73278. * @param textureType Type of textures used when performing the post process. (default: 0)
  73279. * @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)
  73280. */
  73281. 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);
  73282. }
  73283. }
  73284. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73285. /** @hidden */
  73286. export var depthOfFieldMergePixelShader: {
  73287. name: string;
  73288. shader: string;
  73289. };
  73290. }
  73291. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73292. import { Nullable } from "babylonjs/types";
  73293. import { Camera } from "babylonjs/Cameras/camera";
  73294. import { Effect } from "babylonjs/Materials/effect";
  73295. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73296. import { Engine } from "babylonjs/Engines/engine";
  73297. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73298. /**
  73299. * Options to be set when merging outputs from the default pipeline.
  73300. */
  73301. export class DepthOfFieldMergePostProcessOptions {
  73302. /**
  73303. * The original image to merge on top of
  73304. */
  73305. originalFromInput: PostProcess;
  73306. /**
  73307. * Parameters to perform the merge of the depth of field effect
  73308. */
  73309. depthOfField?: {
  73310. circleOfConfusion: PostProcess;
  73311. blurSteps: Array<PostProcess>;
  73312. };
  73313. /**
  73314. * Parameters to perform the merge of bloom effect
  73315. */
  73316. bloom?: {
  73317. blurred: PostProcess;
  73318. weight: number;
  73319. };
  73320. }
  73321. /**
  73322. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73323. */
  73324. export class DepthOfFieldMergePostProcess extends PostProcess {
  73325. private blurSteps;
  73326. /**
  73327. * Gets a string identifying the name of the class
  73328. * @returns "DepthOfFieldMergePostProcess" string
  73329. */
  73330. getClassName(): string;
  73331. /**
  73332. * Creates a new instance of DepthOfFieldMergePostProcess
  73333. * @param name The name of the effect.
  73334. * @param originalFromInput Post process which's input will be used for the merge.
  73335. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73336. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73337. * @param options The required width/height ratio to downsize to before computing the render pass.
  73338. * @param camera The camera to apply the render pass to.
  73339. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73340. * @param engine The engine which the post process will be applied. (default: current engine)
  73341. * @param reusable If the post process can be reused on the same frame. (default: false)
  73342. * @param textureType Type of textures used when performing the post process. (default: 0)
  73343. * @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)
  73344. */
  73345. 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);
  73346. /**
  73347. * Updates the effect with the current post process compile time values and recompiles the shader.
  73348. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73349. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73350. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73351. * @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
  73352. * @param onCompiled Called when the shader has been compiled.
  73353. * @param onError Called if there is an error when compiling a shader.
  73354. */
  73355. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73356. }
  73357. }
  73358. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73359. import { Nullable } from "babylonjs/types";
  73360. import { Camera } from "babylonjs/Cameras/camera";
  73361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73362. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73363. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73364. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73365. import { Scene } from "babylonjs/scene";
  73366. /**
  73367. * Specifies the level of max blur that should be applied when using the depth of field effect
  73368. */
  73369. export enum DepthOfFieldEffectBlurLevel {
  73370. /**
  73371. * Subtle blur
  73372. */
  73373. Low = 0,
  73374. /**
  73375. * Medium blur
  73376. */
  73377. Medium = 1,
  73378. /**
  73379. * Large blur
  73380. */
  73381. High = 2
  73382. }
  73383. /**
  73384. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73385. */
  73386. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73387. private _circleOfConfusion;
  73388. /**
  73389. * @hidden Internal, blurs from high to low
  73390. */
  73391. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73392. private _depthOfFieldBlurY;
  73393. private _dofMerge;
  73394. /**
  73395. * @hidden Internal post processes in depth of field effect
  73396. */
  73397. _effects: Array<PostProcess>;
  73398. /**
  73399. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73400. */
  73401. set focalLength(value: number);
  73402. get focalLength(): number;
  73403. /**
  73404. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73405. */
  73406. set fStop(value: number);
  73407. get fStop(): number;
  73408. /**
  73409. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73410. */
  73411. set focusDistance(value: number);
  73412. get focusDistance(): number;
  73413. /**
  73414. * 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.
  73415. */
  73416. set lensSize(value: number);
  73417. get lensSize(): number;
  73418. /**
  73419. * Creates a new instance DepthOfFieldEffect
  73420. * @param scene The scene the effect belongs to.
  73421. * @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.
  73422. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73423. * @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)
  73424. */
  73425. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73426. /**
  73427. * Get the current class name of the current effet
  73428. * @returns "DepthOfFieldEffect"
  73429. */
  73430. getClassName(): string;
  73431. /**
  73432. * 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.
  73433. */
  73434. set depthTexture(value: RenderTargetTexture);
  73435. /**
  73436. * Disposes each of the internal effects for a given camera.
  73437. * @param camera The camera to dispose the effect on.
  73438. */
  73439. disposeEffects(camera: Camera): void;
  73440. /**
  73441. * @hidden Internal
  73442. */
  73443. _updateEffects(): void;
  73444. /**
  73445. * Internal
  73446. * @returns if all the contained post processes are ready.
  73447. * @hidden
  73448. */
  73449. _isReady(): boolean;
  73450. }
  73451. }
  73452. declare module "babylonjs/Shaders/displayPass.fragment" {
  73453. /** @hidden */
  73454. export var displayPassPixelShader: {
  73455. name: string;
  73456. shader: string;
  73457. };
  73458. }
  73459. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73460. import { Nullable } from "babylonjs/types";
  73461. import { Camera } from "babylonjs/Cameras/camera";
  73462. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73463. import { Engine } from "babylonjs/Engines/engine";
  73464. import "babylonjs/Shaders/displayPass.fragment";
  73465. import { Scene } from "babylonjs/scene";
  73466. /**
  73467. * DisplayPassPostProcess which produces an output the same as it's input
  73468. */
  73469. export class DisplayPassPostProcess extends PostProcess {
  73470. /**
  73471. * Gets a string identifying the name of the class
  73472. * @returns "DisplayPassPostProcess" string
  73473. */
  73474. getClassName(): string;
  73475. /**
  73476. * Creates the DisplayPassPostProcess
  73477. * @param name The name of the effect.
  73478. * @param options The required width/height ratio to downsize to before computing the render pass.
  73479. * @param camera The camera to apply the render pass to.
  73480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73481. * @param engine The engine which the post process will be applied. (default: current engine)
  73482. * @param reusable If the post process can be reused on the same frame. (default: false)
  73483. */
  73484. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73485. /** @hidden */
  73486. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73487. }
  73488. }
  73489. declare module "babylonjs/Shaders/filter.fragment" {
  73490. /** @hidden */
  73491. export var filterPixelShader: {
  73492. name: string;
  73493. shader: string;
  73494. };
  73495. }
  73496. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73497. import { Nullable } from "babylonjs/types";
  73498. import { Matrix } from "babylonjs/Maths/math.vector";
  73499. import { Camera } from "babylonjs/Cameras/camera";
  73500. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73501. import { Engine } from "babylonjs/Engines/engine";
  73502. import "babylonjs/Shaders/filter.fragment";
  73503. import { Scene } from "babylonjs/scene";
  73504. /**
  73505. * Applies a kernel filter to the image
  73506. */
  73507. export class FilterPostProcess extends PostProcess {
  73508. /** The matrix to be applied to the image */
  73509. kernelMatrix: Matrix;
  73510. /**
  73511. * Gets a string identifying the name of the class
  73512. * @returns "FilterPostProcess" string
  73513. */
  73514. getClassName(): string;
  73515. /**
  73516. *
  73517. * @param name The name of the effect.
  73518. * @param kernelMatrix The matrix to be applied to the image
  73519. * @param options The required width/height ratio to downsize to before computing the render pass.
  73520. * @param camera The camera to apply the render pass to.
  73521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73522. * @param engine The engine which the post process will be applied. (default: current engine)
  73523. * @param reusable If the post process can be reused on the same frame. (default: false)
  73524. */
  73525. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73526. /** @hidden */
  73527. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73528. }
  73529. }
  73530. declare module "babylonjs/Shaders/fxaa.fragment" {
  73531. /** @hidden */
  73532. export var fxaaPixelShader: {
  73533. name: string;
  73534. shader: string;
  73535. };
  73536. }
  73537. declare module "babylonjs/Shaders/fxaa.vertex" {
  73538. /** @hidden */
  73539. export var fxaaVertexShader: {
  73540. name: string;
  73541. shader: string;
  73542. };
  73543. }
  73544. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73545. import { Nullable } from "babylonjs/types";
  73546. import { Camera } from "babylonjs/Cameras/camera";
  73547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73548. import { Engine } from "babylonjs/Engines/engine";
  73549. import "babylonjs/Shaders/fxaa.fragment";
  73550. import "babylonjs/Shaders/fxaa.vertex";
  73551. import { Scene } from "babylonjs/scene";
  73552. /**
  73553. * Fxaa post process
  73554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73555. */
  73556. export class FxaaPostProcess extends PostProcess {
  73557. /**
  73558. * Gets a string identifying the name of the class
  73559. * @returns "FxaaPostProcess" string
  73560. */
  73561. getClassName(): string;
  73562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73563. private _getDefines;
  73564. /** @hidden */
  73565. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73566. }
  73567. }
  73568. declare module "babylonjs/Shaders/grain.fragment" {
  73569. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73570. /** @hidden */
  73571. export var grainPixelShader: {
  73572. name: string;
  73573. shader: string;
  73574. };
  73575. }
  73576. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73577. import { Nullable } from "babylonjs/types";
  73578. import { Camera } from "babylonjs/Cameras/camera";
  73579. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73580. import { Engine } from "babylonjs/Engines/engine";
  73581. import "babylonjs/Shaders/grain.fragment";
  73582. import { Scene } from "babylonjs/scene";
  73583. /**
  73584. * The GrainPostProcess adds noise to the image at mid luminance levels
  73585. */
  73586. export class GrainPostProcess extends PostProcess {
  73587. /**
  73588. * The intensity of the grain added (default: 30)
  73589. */
  73590. intensity: number;
  73591. /**
  73592. * If the grain should be randomized on every frame
  73593. */
  73594. animated: boolean;
  73595. /**
  73596. * Gets a string identifying the name of the class
  73597. * @returns "GrainPostProcess" string
  73598. */
  73599. getClassName(): string;
  73600. /**
  73601. * Creates a new instance of @see GrainPostProcess
  73602. * @param name The name of the effect.
  73603. * @param options The required width/height ratio to downsize to before computing the render pass.
  73604. * @param camera The camera to apply the render pass to.
  73605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73606. * @param engine The engine which the post process will be applied. (default: current engine)
  73607. * @param reusable If the post process can be reused on the same frame. (default: false)
  73608. * @param textureType Type of textures used when performing the post process. (default: 0)
  73609. * @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)
  73610. */
  73611. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73612. /** @hidden */
  73613. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73614. }
  73615. }
  73616. declare module "babylonjs/Shaders/highlights.fragment" {
  73617. /** @hidden */
  73618. export var highlightsPixelShader: {
  73619. name: string;
  73620. shader: string;
  73621. };
  73622. }
  73623. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73624. import { Nullable } from "babylonjs/types";
  73625. import { Camera } from "babylonjs/Cameras/camera";
  73626. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73627. import { Engine } from "babylonjs/Engines/engine";
  73628. import "babylonjs/Shaders/highlights.fragment";
  73629. /**
  73630. * Extracts highlights from the image
  73631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73632. */
  73633. export class HighlightsPostProcess extends PostProcess {
  73634. /**
  73635. * Gets a string identifying the name of the class
  73636. * @returns "HighlightsPostProcess" string
  73637. */
  73638. getClassName(): string;
  73639. /**
  73640. * Extracts highlights from the image
  73641. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73642. * @param name The name of the effect.
  73643. * @param options The required width/height ratio to downsize to before computing the render pass.
  73644. * @param camera The camera to apply the render pass to.
  73645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73646. * @param engine The engine which the post process will be applied. (default: current engine)
  73647. * @param reusable If the post process can be reused on the same frame. (default: false)
  73648. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73649. */
  73650. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73651. }
  73652. }
  73653. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73654. /** @hidden */
  73655. export var mrtFragmentDeclaration: {
  73656. name: string;
  73657. shader: string;
  73658. };
  73659. }
  73660. declare module "babylonjs/Shaders/geometry.fragment" {
  73661. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73662. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73663. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73664. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73665. /** @hidden */
  73666. export var geometryPixelShader: {
  73667. name: string;
  73668. shader: string;
  73669. };
  73670. }
  73671. declare module "babylonjs/Shaders/geometry.vertex" {
  73672. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73673. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73674. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73675. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73676. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73677. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73678. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73679. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73680. /** @hidden */
  73681. export var geometryVertexShader: {
  73682. name: string;
  73683. shader: string;
  73684. };
  73685. }
  73686. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73687. import { Matrix } from "babylonjs/Maths/math.vector";
  73688. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73689. import { Mesh } from "babylonjs/Meshes/mesh";
  73690. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73691. import { Effect } from "babylonjs/Materials/effect";
  73692. import { Scene } from "babylonjs/scene";
  73693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73694. import "babylonjs/Shaders/geometry.fragment";
  73695. import "babylonjs/Shaders/geometry.vertex";
  73696. /** @hidden */
  73697. interface ISavedTransformationMatrix {
  73698. world: Matrix;
  73699. viewProjection: Matrix;
  73700. }
  73701. /**
  73702. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73703. */
  73704. export class GeometryBufferRenderer {
  73705. /**
  73706. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73707. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73708. */
  73709. static readonly POSITION_TEXTURE_TYPE: number;
  73710. /**
  73711. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73712. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73713. */
  73714. static readonly VELOCITY_TEXTURE_TYPE: number;
  73715. /**
  73716. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73717. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73718. */
  73719. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73720. /**
  73721. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73722. * in order to compute objects velocities when enableVelocity is set to "true"
  73723. * @hidden
  73724. */
  73725. _previousTransformationMatrices: {
  73726. [index: number]: ISavedTransformationMatrix;
  73727. };
  73728. /**
  73729. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73730. * in order to compute objects velocities when enableVelocity is set to "true"
  73731. * @hidden
  73732. */
  73733. _previousBonesTransformationMatrices: {
  73734. [index: number]: Float32Array;
  73735. };
  73736. /**
  73737. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73738. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73739. */
  73740. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73741. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73742. renderTransparentMeshes: boolean;
  73743. private _scene;
  73744. private _resizeObserver;
  73745. private _multiRenderTarget;
  73746. private _ratio;
  73747. private _enablePosition;
  73748. private _enableVelocity;
  73749. private _enableReflectivity;
  73750. private _positionIndex;
  73751. private _velocityIndex;
  73752. private _reflectivityIndex;
  73753. protected _effect: Effect;
  73754. protected _cachedDefines: string;
  73755. /**
  73756. * Set the render list (meshes to be rendered) used in the G buffer.
  73757. */
  73758. set renderList(meshes: Mesh[]);
  73759. /**
  73760. * Gets wether or not G buffer are supported by the running hardware.
  73761. * This requires draw buffer supports
  73762. */
  73763. get isSupported(): boolean;
  73764. /**
  73765. * Returns the index of the given texture type in the G-Buffer textures array
  73766. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73767. * @returns the index of the given texture type in the G-Buffer textures array
  73768. */
  73769. getTextureIndex(textureType: number): number;
  73770. /**
  73771. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73772. */
  73773. get enablePosition(): boolean;
  73774. /**
  73775. * Sets whether or not objects positions are enabled for the G buffer.
  73776. */
  73777. set enablePosition(enable: boolean);
  73778. /**
  73779. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73780. */
  73781. get enableVelocity(): boolean;
  73782. /**
  73783. * Sets wether or not objects velocities are enabled for the G buffer.
  73784. */
  73785. set enableVelocity(enable: boolean);
  73786. /**
  73787. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73788. */
  73789. get enableReflectivity(): boolean;
  73790. /**
  73791. * Sets wether or not objects roughness are enabled for the G buffer.
  73792. */
  73793. set enableReflectivity(enable: boolean);
  73794. /**
  73795. * Gets the scene associated with the buffer.
  73796. */
  73797. get scene(): Scene;
  73798. /**
  73799. * Gets the ratio used by the buffer during its creation.
  73800. * How big is the buffer related to the main canvas.
  73801. */
  73802. get ratio(): number;
  73803. /** @hidden */
  73804. static _SceneComponentInitialization: (scene: Scene) => void;
  73805. /**
  73806. * Creates a new G Buffer for the scene
  73807. * @param scene The scene the buffer belongs to
  73808. * @param ratio How big is the buffer related to the main canvas.
  73809. */
  73810. constructor(scene: Scene, ratio?: number);
  73811. /**
  73812. * Checks wether everything is ready to render a submesh to the G buffer.
  73813. * @param subMesh the submesh to check readiness for
  73814. * @param useInstances is the mesh drawn using instance or not
  73815. * @returns true if ready otherwise false
  73816. */
  73817. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73818. /**
  73819. * Gets the current underlying G Buffer.
  73820. * @returns the buffer
  73821. */
  73822. getGBuffer(): MultiRenderTarget;
  73823. /**
  73824. * Gets the number of samples used to render the buffer (anti aliasing).
  73825. */
  73826. get samples(): number;
  73827. /**
  73828. * Sets the number of samples used to render the buffer (anti aliasing).
  73829. */
  73830. set samples(value: number);
  73831. /**
  73832. * Disposes the renderer and frees up associated resources.
  73833. */
  73834. dispose(): void;
  73835. protected _createRenderTargets(): void;
  73836. private _copyBonesTransformationMatrices;
  73837. }
  73838. }
  73839. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73840. import { Nullable } from "babylonjs/types";
  73841. import { Scene } from "babylonjs/scene";
  73842. import { ISceneComponent } from "babylonjs/sceneComponent";
  73843. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73844. module "babylonjs/scene" {
  73845. interface Scene {
  73846. /** @hidden (Backing field) */
  73847. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73848. /**
  73849. * Gets or Sets the current geometry buffer associated to the scene.
  73850. */
  73851. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73852. /**
  73853. * Enables a GeometryBufferRender and associates it with the scene
  73854. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73855. * @returns the GeometryBufferRenderer
  73856. */
  73857. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73858. /**
  73859. * Disables the GeometryBufferRender associated with the scene
  73860. */
  73861. disableGeometryBufferRenderer(): void;
  73862. }
  73863. }
  73864. /**
  73865. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73866. * in several rendering techniques.
  73867. */
  73868. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73869. /**
  73870. * The component name helpful to identify the component in the list of scene components.
  73871. */
  73872. readonly name: string;
  73873. /**
  73874. * The scene the component belongs to.
  73875. */
  73876. scene: Scene;
  73877. /**
  73878. * Creates a new instance of the component for the given scene
  73879. * @param scene Defines the scene to register the component in
  73880. */
  73881. constructor(scene: Scene);
  73882. /**
  73883. * Registers the component in a given scene
  73884. */
  73885. register(): void;
  73886. /**
  73887. * Rebuilds the elements related to this component in case of
  73888. * context lost for instance.
  73889. */
  73890. rebuild(): void;
  73891. /**
  73892. * Disposes the component and the associated ressources
  73893. */
  73894. dispose(): void;
  73895. private _gatherRenderTargets;
  73896. }
  73897. }
  73898. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73899. /** @hidden */
  73900. export var motionBlurPixelShader: {
  73901. name: string;
  73902. shader: string;
  73903. };
  73904. }
  73905. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73906. import { Nullable } from "babylonjs/types";
  73907. import { Camera } from "babylonjs/Cameras/camera";
  73908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73910. import "babylonjs/Animations/animatable";
  73911. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73912. import "babylonjs/Shaders/motionBlur.fragment";
  73913. import { Engine } from "babylonjs/Engines/engine";
  73914. import { Scene } from "babylonjs/scene";
  73915. /**
  73916. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73917. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73918. * As an example, all you have to do is to create the post-process:
  73919. * var mb = new BABYLON.MotionBlurPostProcess(
  73920. * 'mb', // The name of the effect.
  73921. * scene, // The scene containing the objects to blur according to their velocity.
  73922. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73923. * camera // The camera to apply the render pass to.
  73924. * );
  73925. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73926. */
  73927. export class MotionBlurPostProcess extends PostProcess {
  73928. /**
  73929. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73930. */
  73931. motionStrength: number;
  73932. /**
  73933. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73934. */
  73935. get motionBlurSamples(): number;
  73936. /**
  73937. * Sets the number of iterations to be used for motion blur quality
  73938. */
  73939. set motionBlurSamples(samples: number);
  73940. private _motionBlurSamples;
  73941. private _geometryBufferRenderer;
  73942. /**
  73943. * Gets a string identifying the name of the class
  73944. * @returns "MotionBlurPostProcess" string
  73945. */
  73946. getClassName(): string;
  73947. /**
  73948. * Creates a new instance MotionBlurPostProcess
  73949. * @param name The name of the effect.
  73950. * @param scene The scene containing the objects to blur according to their velocity.
  73951. * @param options The required width/height ratio to downsize to before computing the render pass.
  73952. * @param camera The camera to apply the render pass to.
  73953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73954. * @param engine The engine which the post process will be applied. (default: current engine)
  73955. * @param reusable If the post process can be reused on the same frame. (default: false)
  73956. * @param textureType Type of textures used when performing the post process. (default: 0)
  73957. * @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)
  73958. */
  73959. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73960. /**
  73961. * Excludes the given skinned mesh from computing bones velocities.
  73962. * 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.
  73963. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73964. */
  73965. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73966. /**
  73967. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73968. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73969. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73970. */
  73971. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73972. /**
  73973. * Disposes the post process.
  73974. * @param camera The camera to dispose the post process on.
  73975. */
  73976. dispose(camera?: Camera): void;
  73977. /** @hidden */
  73978. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73979. }
  73980. }
  73981. declare module "babylonjs/Shaders/refraction.fragment" {
  73982. /** @hidden */
  73983. export var refractionPixelShader: {
  73984. name: string;
  73985. shader: string;
  73986. };
  73987. }
  73988. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73989. import { Color3 } from "babylonjs/Maths/math.color";
  73990. import { Camera } from "babylonjs/Cameras/camera";
  73991. import { Texture } from "babylonjs/Materials/Textures/texture";
  73992. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73993. import { Engine } from "babylonjs/Engines/engine";
  73994. import "babylonjs/Shaders/refraction.fragment";
  73995. import { Scene } from "babylonjs/scene";
  73996. /**
  73997. * Post process which applies a refractin texture
  73998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73999. */
  74000. export class RefractionPostProcess extends PostProcess {
  74001. private _refTexture;
  74002. private _ownRefractionTexture;
  74003. /** the base color of the refraction (used to taint the rendering) */
  74004. color: Color3;
  74005. /** simulated refraction depth */
  74006. depth: number;
  74007. /** the coefficient of the base color (0 to remove base color tainting) */
  74008. colorLevel: number;
  74009. /** Gets the url used to load the refraction texture */
  74010. refractionTextureUrl: string;
  74011. /**
  74012. * Gets or sets the refraction texture
  74013. * Please note that you are responsible for disposing the texture if you set it manually
  74014. */
  74015. get refractionTexture(): Texture;
  74016. set refractionTexture(value: Texture);
  74017. /**
  74018. * Gets a string identifying the name of the class
  74019. * @returns "RefractionPostProcess" string
  74020. */
  74021. getClassName(): string;
  74022. /**
  74023. * Initializes the RefractionPostProcess
  74024. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74025. * @param name The name of the effect.
  74026. * @param refractionTextureUrl Url of the refraction texture to use
  74027. * @param color the base color of the refraction (used to taint the rendering)
  74028. * @param depth simulated refraction depth
  74029. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74030. * @param camera The camera to apply the render pass to.
  74031. * @param options The required width/height ratio to downsize to before computing the render pass.
  74032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74033. * @param engine The engine which the post process will be applied. (default: current engine)
  74034. * @param reusable If the post process can be reused on the same frame. (default: false)
  74035. */
  74036. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74037. /**
  74038. * Disposes of the post process
  74039. * @param camera Camera to dispose post process on
  74040. */
  74041. dispose(camera: Camera): void;
  74042. /** @hidden */
  74043. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74044. }
  74045. }
  74046. declare module "babylonjs/Shaders/sharpen.fragment" {
  74047. /** @hidden */
  74048. export var sharpenPixelShader: {
  74049. name: string;
  74050. shader: string;
  74051. };
  74052. }
  74053. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74054. import { Nullable } from "babylonjs/types";
  74055. import { Camera } from "babylonjs/Cameras/camera";
  74056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74057. import "babylonjs/Shaders/sharpen.fragment";
  74058. import { Engine } from "babylonjs/Engines/engine";
  74059. import { Scene } from "babylonjs/scene";
  74060. /**
  74061. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74062. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74063. */
  74064. export class SharpenPostProcess extends PostProcess {
  74065. /**
  74066. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74067. */
  74068. colorAmount: number;
  74069. /**
  74070. * How much sharpness should be applied (default: 0.3)
  74071. */
  74072. edgeAmount: number;
  74073. /**
  74074. * Gets a string identifying the name of the class
  74075. * @returns "SharpenPostProcess" string
  74076. */
  74077. getClassName(): string;
  74078. /**
  74079. * Creates a new instance ConvolutionPostProcess
  74080. * @param name The name of the effect.
  74081. * @param options The required width/height ratio to downsize to before computing the render pass.
  74082. * @param camera The camera to apply the render pass to.
  74083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74084. * @param engine The engine which the post process will be applied. (default: current engine)
  74085. * @param reusable If the post process can be reused on the same frame. (default: false)
  74086. * @param textureType Type of textures used when performing the post process. (default: 0)
  74087. * @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)
  74088. */
  74089. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74090. /** @hidden */
  74091. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74092. }
  74093. }
  74094. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74095. import { Nullable } from "babylonjs/types";
  74096. import { Camera } from "babylonjs/Cameras/camera";
  74097. import { Engine } from "babylonjs/Engines/engine";
  74098. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74099. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74100. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74101. /**
  74102. * PostProcessRenderPipeline
  74103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74104. */
  74105. export class PostProcessRenderPipeline {
  74106. private engine;
  74107. private _renderEffects;
  74108. private _renderEffectsForIsolatedPass;
  74109. /**
  74110. * List of inspectable custom properties (used by the Inspector)
  74111. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74112. */
  74113. inspectableCustomProperties: IInspectable[];
  74114. /**
  74115. * @hidden
  74116. */
  74117. protected _cameras: Camera[];
  74118. /** @hidden */
  74119. _name: string;
  74120. /**
  74121. * Gets pipeline name
  74122. */
  74123. get name(): string;
  74124. /** Gets the list of attached cameras */
  74125. get cameras(): Camera[];
  74126. /**
  74127. * Initializes a PostProcessRenderPipeline
  74128. * @param engine engine to add the pipeline to
  74129. * @param name name of the pipeline
  74130. */
  74131. constructor(engine: Engine, name: string);
  74132. /**
  74133. * Gets the class name
  74134. * @returns "PostProcessRenderPipeline"
  74135. */
  74136. getClassName(): string;
  74137. /**
  74138. * If all the render effects in the pipeline are supported
  74139. */
  74140. get isSupported(): boolean;
  74141. /**
  74142. * Adds an effect to the pipeline
  74143. * @param renderEffect the effect to add
  74144. */
  74145. addEffect(renderEffect: PostProcessRenderEffect): void;
  74146. /** @hidden */
  74147. _rebuild(): void;
  74148. /** @hidden */
  74149. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74150. /** @hidden */
  74151. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74152. /** @hidden */
  74153. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74154. /** @hidden */
  74155. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74156. /** @hidden */
  74157. _attachCameras(cameras: Camera, unique: boolean): void;
  74158. /** @hidden */
  74159. _attachCameras(cameras: Camera[], unique: boolean): void;
  74160. /** @hidden */
  74161. _detachCameras(cameras: Camera): void;
  74162. /** @hidden */
  74163. _detachCameras(cameras: Nullable<Camera[]>): void;
  74164. /** @hidden */
  74165. _update(): void;
  74166. /** @hidden */
  74167. _reset(): void;
  74168. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74169. /**
  74170. * Sets the required values to the prepass renderer.
  74171. * @param prePassRenderer defines the prepass renderer to setup.
  74172. * @returns true if the pre pass is needed.
  74173. */
  74174. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74175. /**
  74176. * Disposes of the pipeline
  74177. */
  74178. dispose(): void;
  74179. }
  74180. }
  74181. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74182. import { Camera } from "babylonjs/Cameras/camera";
  74183. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74184. /**
  74185. * PostProcessRenderPipelineManager class
  74186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74187. */
  74188. export class PostProcessRenderPipelineManager {
  74189. private _renderPipelines;
  74190. /**
  74191. * Initializes a PostProcessRenderPipelineManager
  74192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74193. */
  74194. constructor();
  74195. /**
  74196. * Gets the list of supported render pipelines
  74197. */
  74198. get supportedPipelines(): PostProcessRenderPipeline[];
  74199. /**
  74200. * Adds a pipeline to the manager
  74201. * @param renderPipeline The pipeline to add
  74202. */
  74203. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74204. /**
  74205. * Attaches a camera to the pipeline
  74206. * @param renderPipelineName The name of the pipeline to attach to
  74207. * @param cameras the camera to attach
  74208. * @param unique if the camera can be attached multiple times to the pipeline
  74209. */
  74210. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74211. /**
  74212. * Detaches a camera from the pipeline
  74213. * @param renderPipelineName The name of the pipeline to detach from
  74214. * @param cameras the camera to detach
  74215. */
  74216. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74217. /**
  74218. * Enables an effect by name on a pipeline
  74219. * @param renderPipelineName the name of the pipeline to enable the effect in
  74220. * @param renderEffectName the name of the effect to enable
  74221. * @param cameras the cameras that the effect should be enabled on
  74222. */
  74223. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74224. /**
  74225. * Disables an effect by name on a pipeline
  74226. * @param renderPipelineName the name of the pipeline to disable the effect in
  74227. * @param renderEffectName the name of the effect to disable
  74228. * @param cameras the cameras that the effect should be disabled on
  74229. */
  74230. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74231. /**
  74232. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74233. */
  74234. update(): void;
  74235. /** @hidden */
  74236. _rebuild(): void;
  74237. /**
  74238. * Disposes of the manager and pipelines
  74239. */
  74240. dispose(): void;
  74241. }
  74242. }
  74243. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74244. import { ISceneComponent } from "babylonjs/sceneComponent";
  74245. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74246. import { Scene } from "babylonjs/scene";
  74247. module "babylonjs/scene" {
  74248. interface Scene {
  74249. /** @hidden (Backing field) */
  74250. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74251. /**
  74252. * Gets the postprocess render pipeline manager
  74253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74254. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74255. */
  74256. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74257. }
  74258. }
  74259. /**
  74260. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74261. */
  74262. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74263. /**
  74264. * The component name helpfull to identify the component in the list of scene components.
  74265. */
  74266. readonly name: string;
  74267. /**
  74268. * The scene the component belongs to.
  74269. */
  74270. scene: Scene;
  74271. /**
  74272. * Creates a new instance of the component for the given scene
  74273. * @param scene Defines the scene to register the component in
  74274. */
  74275. constructor(scene: Scene);
  74276. /**
  74277. * Registers the component in a given scene
  74278. */
  74279. register(): void;
  74280. /**
  74281. * Rebuilds the elements related to this component in case of
  74282. * context lost for instance.
  74283. */
  74284. rebuild(): void;
  74285. /**
  74286. * Disposes the component and the associated ressources
  74287. */
  74288. dispose(): void;
  74289. private _gatherRenderTargets;
  74290. }
  74291. }
  74292. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74293. import { Nullable } from "babylonjs/types";
  74294. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74295. import { Camera } from "babylonjs/Cameras/camera";
  74296. import { IDisposable } from "babylonjs/scene";
  74297. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74298. import { Scene } from "babylonjs/scene";
  74299. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74300. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74301. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74302. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74303. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74304. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74305. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74306. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74307. import { Animation } from "babylonjs/Animations/animation";
  74308. /**
  74309. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74310. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74311. */
  74312. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74313. private _scene;
  74314. private _camerasToBeAttached;
  74315. /**
  74316. * ID of the sharpen post process,
  74317. */
  74318. private readonly SharpenPostProcessId;
  74319. /**
  74320. * @ignore
  74321. * ID of the image processing post process;
  74322. */
  74323. readonly ImageProcessingPostProcessId: string;
  74324. /**
  74325. * @ignore
  74326. * ID of the Fast Approximate Anti-Aliasing post process;
  74327. */
  74328. readonly FxaaPostProcessId: string;
  74329. /**
  74330. * ID of the chromatic aberration post process,
  74331. */
  74332. private readonly ChromaticAberrationPostProcessId;
  74333. /**
  74334. * ID of the grain post process
  74335. */
  74336. private readonly GrainPostProcessId;
  74337. /**
  74338. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74339. */
  74340. sharpen: SharpenPostProcess;
  74341. private _sharpenEffect;
  74342. private bloom;
  74343. /**
  74344. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74345. */
  74346. depthOfField: DepthOfFieldEffect;
  74347. /**
  74348. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74349. */
  74350. fxaa: FxaaPostProcess;
  74351. /**
  74352. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74353. */
  74354. imageProcessing: ImageProcessingPostProcess;
  74355. /**
  74356. * Chromatic aberration post process which will shift rgb colors in the image
  74357. */
  74358. chromaticAberration: ChromaticAberrationPostProcess;
  74359. private _chromaticAberrationEffect;
  74360. /**
  74361. * Grain post process which add noise to the image
  74362. */
  74363. grain: GrainPostProcess;
  74364. private _grainEffect;
  74365. /**
  74366. * Glow post process which adds a glow to emissive areas of the image
  74367. */
  74368. private _glowLayer;
  74369. /**
  74370. * Animations which can be used to tweak settings over a period of time
  74371. */
  74372. animations: Animation[];
  74373. private _imageProcessingConfigurationObserver;
  74374. private _sharpenEnabled;
  74375. private _bloomEnabled;
  74376. private _depthOfFieldEnabled;
  74377. private _depthOfFieldBlurLevel;
  74378. private _fxaaEnabled;
  74379. private _imageProcessingEnabled;
  74380. private _defaultPipelineTextureType;
  74381. private _bloomScale;
  74382. private _chromaticAberrationEnabled;
  74383. private _grainEnabled;
  74384. private _buildAllowed;
  74385. /**
  74386. * Gets active scene
  74387. */
  74388. get scene(): Scene;
  74389. /**
  74390. * Enable or disable the sharpen process from the pipeline
  74391. */
  74392. set sharpenEnabled(enabled: boolean);
  74393. get sharpenEnabled(): boolean;
  74394. private _resizeObserver;
  74395. private _hardwareScaleLevel;
  74396. private _bloomKernel;
  74397. /**
  74398. * Specifies the size of the bloom blur kernel, relative to the final output size
  74399. */
  74400. get bloomKernel(): number;
  74401. set bloomKernel(value: number);
  74402. /**
  74403. * Specifies the weight of the bloom in the final rendering
  74404. */
  74405. private _bloomWeight;
  74406. /**
  74407. * Specifies the luma threshold for the area that will be blurred by the bloom
  74408. */
  74409. private _bloomThreshold;
  74410. private _hdr;
  74411. /**
  74412. * The strength of the bloom.
  74413. */
  74414. set bloomWeight(value: number);
  74415. get bloomWeight(): number;
  74416. /**
  74417. * The strength of the bloom.
  74418. */
  74419. set bloomThreshold(value: number);
  74420. get bloomThreshold(): number;
  74421. /**
  74422. * The scale of the bloom, lower value will provide better performance.
  74423. */
  74424. set bloomScale(value: number);
  74425. get bloomScale(): number;
  74426. /**
  74427. * Enable or disable the bloom from the pipeline
  74428. */
  74429. set bloomEnabled(enabled: boolean);
  74430. get bloomEnabled(): boolean;
  74431. private _rebuildBloom;
  74432. /**
  74433. * If the depth of field is enabled.
  74434. */
  74435. get depthOfFieldEnabled(): boolean;
  74436. set depthOfFieldEnabled(enabled: boolean);
  74437. /**
  74438. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74439. */
  74440. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74441. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74442. /**
  74443. * If the anti aliasing is enabled.
  74444. */
  74445. set fxaaEnabled(enabled: boolean);
  74446. get fxaaEnabled(): boolean;
  74447. private _samples;
  74448. /**
  74449. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74450. */
  74451. set samples(sampleCount: number);
  74452. get samples(): number;
  74453. /**
  74454. * If image processing is enabled.
  74455. */
  74456. set imageProcessingEnabled(enabled: boolean);
  74457. get imageProcessingEnabled(): boolean;
  74458. /**
  74459. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74460. */
  74461. set glowLayerEnabled(enabled: boolean);
  74462. get glowLayerEnabled(): boolean;
  74463. /**
  74464. * Gets the glow layer (or null if not defined)
  74465. */
  74466. get glowLayer(): Nullable<GlowLayer>;
  74467. /**
  74468. * Enable or disable the chromaticAberration process from the pipeline
  74469. */
  74470. set chromaticAberrationEnabled(enabled: boolean);
  74471. get chromaticAberrationEnabled(): boolean;
  74472. /**
  74473. * Enable or disable the grain process from the pipeline
  74474. */
  74475. set grainEnabled(enabled: boolean);
  74476. get grainEnabled(): boolean;
  74477. /**
  74478. * @constructor
  74479. * @param name - The rendering pipeline name (default: "")
  74480. * @param hdr - If high dynamic range textures should be used (default: true)
  74481. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74482. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74483. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74484. */
  74485. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74486. /**
  74487. * Get the class name
  74488. * @returns "DefaultRenderingPipeline"
  74489. */
  74490. getClassName(): string;
  74491. /**
  74492. * Force the compilation of the entire pipeline.
  74493. */
  74494. prepare(): void;
  74495. private _hasCleared;
  74496. private _prevPostProcess;
  74497. private _prevPrevPostProcess;
  74498. private _setAutoClearAndTextureSharing;
  74499. private _depthOfFieldSceneObserver;
  74500. private _buildPipeline;
  74501. private _disposePostProcesses;
  74502. /**
  74503. * Adds a camera to the pipeline
  74504. * @param camera the camera to be added
  74505. */
  74506. addCamera(camera: Camera): void;
  74507. /**
  74508. * Removes a camera from the pipeline
  74509. * @param camera the camera to remove
  74510. */
  74511. removeCamera(camera: Camera): void;
  74512. /**
  74513. * Dispose of the pipeline and stop all post processes
  74514. */
  74515. dispose(): void;
  74516. /**
  74517. * Serialize the rendering pipeline (Used when exporting)
  74518. * @returns the serialized object
  74519. */
  74520. serialize(): any;
  74521. /**
  74522. * Parse the serialized pipeline
  74523. * @param source Source pipeline.
  74524. * @param scene The scene to load the pipeline to.
  74525. * @param rootUrl The URL of the serialized pipeline.
  74526. * @returns An instantiated pipeline from the serialized object.
  74527. */
  74528. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74529. }
  74530. }
  74531. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74532. /** @hidden */
  74533. export var lensHighlightsPixelShader: {
  74534. name: string;
  74535. shader: string;
  74536. };
  74537. }
  74538. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74539. /** @hidden */
  74540. export var depthOfFieldPixelShader: {
  74541. name: string;
  74542. shader: string;
  74543. };
  74544. }
  74545. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74546. import { Camera } from "babylonjs/Cameras/camera";
  74547. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74548. import { Scene } from "babylonjs/scene";
  74549. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74550. import "babylonjs/Shaders/chromaticAberration.fragment";
  74551. import "babylonjs/Shaders/lensHighlights.fragment";
  74552. import "babylonjs/Shaders/depthOfField.fragment";
  74553. /**
  74554. * BABYLON.JS Chromatic Aberration GLSL Shader
  74555. * Author: Olivier Guyot
  74556. * Separates very slightly R, G and B colors on the edges of the screen
  74557. * Inspired by Francois Tarlier & Martins Upitis
  74558. */
  74559. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74560. /**
  74561. * @ignore
  74562. * The chromatic aberration PostProcess id in the pipeline
  74563. */
  74564. LensChromaticAberrationEffect: string;
  74565. /**
  74566. * @ignore
  74567. * The highlights enhancing PostProcess id in the pipeline
  74568. */
  74569. HighlightsEnhancingEffect: string;
  74570. /**
  74571. * @ignore
  74572. * The depth-of-field PostProcess id in the pipeline
  74573. */
  74574. LensDepthOfFieldEffect: string;
  74575. private _scene;
  74576. private _depthTexture;
  74577. private _grainTexture;
  74578. private _chromaticAberrationPostProcess;
  74579. private _highlightsPostProcess;
  74580. private _depthOfFieldPostProcess;
  74581. private _edgeBlur;
  74582. private _grainAmount;
  74583. private _chromaticAberration;
  74584. private _distortion;
  74585. private _highlightsGain;
  74586. private _highlightsThreshold;
  74587. private _dofDistance;
  74588. private _dofAperture;
  74589. private _dofDarken;
  74590. private _dofPentagon;
  74591. private _blurNoise;
  74592. /**
  74593. * @constructor
  74594. *
  74595. * Effect parameters are as follow:
  74596. * {
  74597. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74598. * edge_blur: number; // from 0 to x (1 for realism)
  74599. * distortion: number; // from 0 to x (1 for realism)
  74600. * grain_amount: number; // from 0 to 1
  74601. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74602. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74603. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74604. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74605. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74606. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74607. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74608. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74609. * }
  74610. * Note: if an effect parameter is unset, effect is disabled
  74611. *
  74612. * @param name The rendering pipeline name
  74613. * @param parameters - An object containing all parameters (see above)
  74614. * @param scene The scene linked to this pipeline
  74615. * @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)
  74616. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74617. */
  74618. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74619. /**
  74620. * Get the class name
  74621. * @returns "LensRenderingPipeline"
  74622. */
  74623. getClassName(): string;
  74624. /**
  74625. * Gets associated scene
  74626. */
  74627. get scene(): Scene;
  74628. /**
  74629. * Gets or sets the edge blur
  74630. */
  74631. get edgeBlur(): number;
  74632. set edgeBlur(value: number);
  74633. /**
  74634. * Gets or sets the grain amount
  74635. */
  74636. get grainAmount(): number;
  74637. set grainAmount(value: number);
  74638. /**
  74639. * Gets or sets the chromatic aberration amount
  74640. */
  74641. get chromaticAberration(): number;
  74642. set chromaticAberration(value: number);
  74643. /**
  74644. * Gets or sets the depth of field aperture
  74645. */
  74646. get dofAperture(): number;
  74647. set dofAperture(value: number);
  74648. /**
  74649. * Gets or sets the edge distortion
  74650. */
  74651. get edgeDistortion(): number;
  74652. set edgeDistortion(value: number);
  74653. /**
  74654. * Gets or sets the depth of field distortion
  74655. */
  74656. get dofDistortion(): number;
  74657. set dofDistortion(value: number);
  74658. /**
  74659. * Gets or sets the darken out of focus amount
  74660. */
  74661. get darkenOutOfFocus(): number;
  74662. set darkenOutOfFocus(value: number);
  74663. /**
  74664. * Gets or sets a boolean indicating if blur noise is enabled
  74665. */
  74666. get blurNoise(): boolean;
  74667. set blurNoise(value: boolean);
  74668. /**
  74669. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74670. */
  74671. get pentagonBokeh(): boolean;
  74672. set pentagonBokeh(value: boolean);
  74673. /**
  74674. * Gets or sets the highlight grain amount
  74675. */
  74676. get highlightsGain(): number;
  74677. set highlightsGain(value: number);
  74678. /**
  74679. * Gets or sets the highlight threshold
  74680. */
  74681. get highlightsThreshold(): number;
  74682. set highlightsThreshold(value: number);
  74683. /**
  74684. * Sets the amount of blur at the edges
  74685. * @param amount blur amount
  74686. */
  74687. setEdgeBlur(amount: number): void;
  74688. /**
  74689. * Sets edge blur to 0
  74690. */
  74691. disableEdgeBlur(): void;
  74692. /**
  74693. * Sets the amout of grain
  74694. * @param amount Amount of grain
  74695. */
  74696. setGrainAmount(amount: number): void;
  74697. /**
  74698. * Set grain amount to 0
  74699. */
  74700. disableGrain(): void;
  74701. /**
  74702. * Sets the chromatic aberration amount
  74703. * @param amount amount of chromatic aberration
  74704. */
  74705. setChromaticAberration(amount: number): void;
  74706. /**
  74707. * Sets chromatic aberration amount to 0
  74708. */
  74709. disableChromaticAberration(): void;
  74710. /**
  74711. * Sets the EdgeDistortion amount
  74712. * @param amount amount of EdgeDistortion
  74713. */
  74714. setEdgeDistortion(amount: number): void;
  74715. /**
  74716. * Sets edge distortion to 0
  74717. */
  74718. disableEdgeDistortion(): void;
  74719. /**
  74720. * Sets the FocusDistance amount
  74721. * @param amount amount of FocusDistance
  74722. */
  74723. setFocusDistance(amount: number): void;
  74724. /**
  74725. * Disables depth of field
  74726. */
  74727. disableDepthOfField(): void;
  74728. /**
  74729. * Sets the Aperture amount
  74730. * @param amount amount of Aperture
  74731. */
  74732. setAperture(amount: number): void;
  74733. /**
  74734. * Sets the DarkenOutOfFocus amount
  74735. * @param amount amount of DarkenOutOfFocus
  74736. */
  74737. setDarkenOutOfFocus(amount: number): void;
  74738. private _pentagonBokehIsEnabled;
  74739. /**
  74740. * Creates a pentagon bokeh effect
  74741. */
  74742. enablePentagonBokeh(): void;
  74743. /**
  74744. * Disables the pentagon bokeh effect
  74745. */
  74746. disablePentagonBokeh(): void;
  74747. /**
  74748. * Enables noise blur
  74749. */
  74750. enableNoiseBlur(): void;
  74751. /**
  74752. * Disables noise blur
  74753. */
  74754. disableNoiseBlur(): void;
  74755. /**
  74756. * Sets the HighlightsGain amount
  74757. * @param amount amount of HighlightsGain
  74758. */
  74759. setHighlightsGain(amount: number): void;
  74760. /**
  74761. * Sets the HighlightsThreshold amount
  74762. * @param amount amount of HighlightsThreshold
  74763. */
  74764. setHighlightsThreshold(amount: number): void;
  74765. /**
  74766. * Disables highlights
  74767. */
  74768. disableHighlights(): void;
  74769. /**
  74770. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74771. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74772. */
  74773. dispose(disableDepthRender?: boolean): void;
  74774. private _createChromaticAberrationPostProcess;
  74775. private _createHighlightsPostProcess;
  74776. private _createDepthOfFieldPostProcess;
  74777. private _createGrainTexture;
  74778. }
  74779. }
  74780. declare module "babylonjs/Rendering/ssao2Configuration" {
  74781. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74782. /**
  74783. * Contains all parameters needed for the prepass to perform
  74784. * screen space subsurface scattering
  74785. */
  74786. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74787. /**
  74788. * Is subsurface enabled
  74789. */
  74790. enabled: boolean;
  74791. /**
  74792. * Name of the configuration
  74793. */
  74794. name: string;
  74795. /**
  74796. * Textures that should be present in the MRT for this effect to work
  74797. */
  74798. readonly texturesRequired: number[];
  74799. /**
  74800. * Builds a ssao2 configuration object
  74801. * @param scene The scene
  74802. */
  74803. constructor();
  74804. /**
  74805. * Disposes the configuration
  74806. */
  74807. dispose(): void;
  74808. }
  74809. }
  74810. declare module "babylonjs/Shaders/ssao2.fragment" {
  74811. /** @hidden */
  74812. export var ssao2PixelShader: {
  74813. name: string;
  74814. shader: string;
  74815. };
  74816. }
  74817. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74818. /** @hidden */
  74819. export var ssaoCombinePixelShader: {
  74820. name: string;
  74821. shader: string;
  74822. };
  74823. }
  74824. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74825. import { Camera } from "babylonjs/Cameras/camera";
  74826. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74827. import { Scene } from "babylonjs/scene";
  74828. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74829. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74830. import "babylonjs/Shaders/ssao2.fragment";
  74831. import "babylonjs/Shaders/ssaoCombine.fragment";
  74832. /**
  74833. * Render pipeline to produce ssao effect
  74834. */
  74835. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74836. /**
  74837. * @ignore
  74838. * The PassPostProcess id in the pipeline that contains the original scene color
  74839. */
  74840. SSAOOriginalSceneColorEffect: string;
  74841. /**
  74842. * @ignore
  74843. * The SSAO PostProcess id in the pipeline
  74844. */
  74845. SSAORenderEffect: string;
  74846. /**
  74847. * @ignore
  74848. * The horizontal blur PostProcess id in the pipeline
  74849. */
  74850. SSAOBlurHRenderEffect: string;
  74851. /**
  74852. * @ignore
  74853. * The vertical blur PostProcess id in the pipeline
  74854. */
  74855. SSAOBlurVRenderEffect: string;
  74856. /**
  74857. * @ignore
  74858. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74859. */
  74860. SSAOCombineRenderEffect: string;
  74861. /**
  74862. * The output strength of the SSAO post-process. Default value is 1.0.
  74863. */
  74864. totalStrength: number;
  74865. /**
  74866. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74867. */
  74868. maxZ: number;
  74869. /**
  74870. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74871. */
  74872. minZAspect: number;
  74873. private _samples;
  74874. /**
  74875. * Number of samples used for the SSAO calculations. Default value is 8
  74876. */
  74877. set samples(n: number);
  74878. get samples(): number;
  74879. private _textureSamples;
  74880. /**
  74881. * Number of samples to use for antialiasing
  74882. */
  74883. set textureSamples(n: number);
  74884. get textureSamples(): number;
  74885. /**
  74886. * Force rendering the geometry through geometry buffer
  74887. */
  74888. private _forceGeometryBuffer;
  74889. /**
  74890. * Ratio object used for SSAO ratio and blur ratio
  74891. */
  74892. private _ratio;
  74893. /**
  74894. * Dynamically generated sphere sampler.
  74895. */
  74896. private _sampleSphere;
  74897. private _ssao2PrePassConfiguration;
  74898. /**
  74899. * Blur filter offsets
  74900. */
  74901. private _samplerOffsets;
  74902. private _expensiveBlur;
  74903. /**
  74904. * If bilateral blur should be used
  74905. */
  74906. set expensiveBlur(b: boolean);
  74907. get expensiveBlur(): boolean;
  74908. /**
  74909. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74910. */
  74911. radius: number;
  74912. /**
  74913. * The base color of the SSAO post-process
  74914. * The final result is "base + ssao" between [0, 1]
  74915. */
  74916. base: number;
  74917. /**
  74918. * Support test.
  74919. */
  74920. static get IsSupported(): boolean;
  74921. private _scene;
  74922. private _randomTexture;
  74923. private _originalColorPostProcess;
  74924. private _ssaoPostProcess;
  74925. private _blurHPostProcess;
  74926. private _blurVPostProcess;
  74927. private _ssaoCombinePostProcess;
  74928. private _prePassRenderer;
  74929. /**
  74930. * Gets active scene
  74931. */
  74932. get scene(): Scene;
  74933. /**
  74934. * @constructor
  74935. * @param name The rendering pipeline name
  74936. * @param scene The scene linked to this pipeline
  74937. * @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 }
  74938. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74939. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74940. */
  74941. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74942. /**
  74943. * Get the class name
  74944. * @returns "SSAO2RenderingPipeline"
  74945. */
  74946. getClassName(): string;
  74947. /**
  74948. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74949. */
  74950. dispose(disableGeometryBufferRenderer?: boolean): void;
  74951. private _createBlurPostProcess;
  74952. /** @hidden */
  74953. _rebuild(): void;
  74954. private _bits;
  74955. private _radicalInverse_VdC;
  74956. private _hammersley;
  74957. private _hemisphereSample_uniform;
  74958. private _generateHemisphere;
  74959. private _getDefinesForSSAO;
  74960. private _createSSAOPostProcess;
  74961. private _createSSAOCombinePostProcess;
  74962. private _createRandomTexture;
  74963. /**
  74964. * Serialize the rendering pipeline (Used when exporting)
  74965. * @returns the serialized object
  74966. */
  74967. serialize(): any;
  74968. /**
  74969. * Parse the serialized pipeline
  74970. * @param source Source pipeline.
  74971. * @param scene The scene to load the pipeline to.
  74972. * @param rootUrl The URL of the serialized pipeline.
  74973. * @returns An instantiated pipeline from the serialized object.
  74974. */
  74975. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74976. /**
  74977. * Sets the required values to the prepass renderer.
  74978. * @param prePassRenderer defines the prepass renderer to setup
  74979. * @returns true if the pre pass is needed.
  74980. */
  74981. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74982. }
  74983. }
  74984. declare module "babylonjs/Shaders/ssao.fragment" {
  74985. /** @hidden */
  74986. export var ssaoPixelShader: {
  74987. name: string;
  74988. shader: string;
  74989. };
  74990. }
  74991. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74992. import { Camera } from "babylonjs/Cameras/camera";
  74993. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74994. import { Scene } from "babylonjs/scene";
  74995. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74996. import "babylonjs/Shaders/ssao.fragment";
  74997. import "babylonjs/Shaders/ssaoCombine.fragment";
  74998. /**
  74999. * Render pipeline to produce ssao effect
  75000. */
  75001. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75002. /**
  75003. * @ignore
  75004. * The PassPostProcess id in the pipeline that contains the original scene color
  75005. */
  75006. SSAOOriginalSceneColorEffect: string;
  75007. /**
  75008. * @ignore
  75009. * The SSAO PostProcess id in the pipeline
  75010. */
  75011. SSAORenderEffect: string;
  75012. /**
  75013. * @ignore
  75014. * The horizontal blur PostProcess id in the pipeline
  75015. */
  75016. SSAOBlurHRenderEffect: string;
  75017. /**
  75018. * @ignore
  75019. * The vertical blur PostProcess id in the pipeline
  75020. */
  75021. SSAOBlurVRenderEffect: string;
  75022. /**
  75023. * @ignore
  75024. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75025. */
  75026. SSAOCombineRenderEffect: string;
  75027. /**
  75028. * The output strength of the SSAO post-process. Default value is 1.0.
  75029. */
  75030. totalStrength: number;
  75031. /**
  75032. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75033. */
  75034. radius: number;
  75035. /**
  75036. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75037. * Must not be equal to fallOff and superior to fallOff.
  75038. * Default value is 0.0075
  75039. */
  75040. area: number;
  75041. /**
  75042. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75043. * Must not be equal to area and inferior to area.
  75044. * Default value is 0.000001
  75045. */
  75046. fallOff: number;
  75047. /**
  75048. * The base color of the SSAO post-process
  75049. * The final result is "base + ssao" between [0, 1]
  75050. */
  75051. base: number;
  75052. private _scene;
  75053. private _depthTexture;
  75054. private _randomTexture;
  75055. private _originalColorPostProcess;
  75056. private _ssaoPostProcess;
  75057. private _blurHPostProcess;
  75058. private _blurVPostProcess;
  75059. private _ssaoCombinePostProcess;
  75060. private _firstUpdate;
  75061. /**
  75062. * Gets active scene
  75063. */
  75064. get scene(): Scene;
  75065. /**
  75066. * @constructor
  75067. * @param name - The rendering pipeline name
  75068. * @param scene - The scene linked to this pipeline
  75069. * @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 }
  75070. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75071. */
  75072. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75073. /**
  75074. * Get the class name
  75075. * @returns "SSAORenderingPipeline"
  75076. */
  75077. getClassName(): string;
  75078. /**
  75079. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75080. */
  75081. dispose(disableDepthRender?: boolean): void;
  75082. private _createBlurPostProcess;
  75083. /** @hidden */
  75084. _rebuild(): void;
  75085. private _createSSAOPostProcess;
  75086. private _createSSAOCombinePostProcess;
  75087. private _createRandomTexture;
  75088. }
  75089. }
  75090. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75091. /** @hidden */
  75092. export var screenSpaceReflectionPixelShader: {
  75093. name: string;
  75094. shader: string;
  75095. };
  75096. }
  75097. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75098. import { Nullable } from "babylonjs/types";
  75099. import { Camera } from "babylonjs/Cameras/camera";
  75100. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75101. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75102. import { Engine } from "babylonjs/Engines/engine";
  75103. import { Scene } from "babylonjs/scene";
  75104. /**
  75105. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75106. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75107. */
  75108. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75109. /**
  75110. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75111. */
  75112. threshold: number;
  75113. /**
  75114. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75115. */
  75116. strength: number;
  75117. /**
  75118. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75119. */
  75120. reflectionSpecularFalloffExponent: number;
  75121. /**
  75122. * 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]
  75123. */
  75124. step: number;
  75125. /**
  75126. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75127. */
  75128. roughnessFactor: number;
  75129. private _geometryBufferRenderer;
  75130. private _enableSmoothReflections;
  75131. private _reflectionSamples;
  75132. private _smoothSteps;
  75133. /**
  75134. * Gets a string identifying the name of the class
  75135. * @returns "ScreenSpaceReflectionPostProcess" string
  75136. */
  75137. getClassName(): string;
  75138. /**
  75139. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75140. * @param name The name of the effect.
  75141. * @param scene The scene containing the objects to calculate reflections.
  75142. * @param options The required width/height ratio to downsize to before computing the render pass.
  75143. * @param camera The camera to apply the render pass to.
  75144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75145. * @param engine The engine which the post process will be applied. (default: current engine)
  75146. * @param reusable If the post process can be reused on the same frame. (default: false)
  75147. * @param textureType Type of textures used when performing the post process. (default: 0)
  75148. * @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)
  75149. */
  75150. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75151. /**
  75152. * Gets wether or not smoothing reflections is enabled.
  75153. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75154. */
  75155. get enableSmoothReflections(): boolean;
  75156. /**
  75157. * Sets wether or not smoothing reflections is enabled.
  75158. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75159. */
  75160. set enableSmoothReflections(enabled: boolean);
  75161. /**
  75162. * Gets the number of samples taken while computing reflections. More samples count is high,
  75163. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75164. */
  75165. get reflectionSamples(): number;
  75166. /**
  75167. * Sets the number of samples taken while computing reflections. More samples count is high,
  75168. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75169. */
  75170. set reflectionSamples(samples: number);
  75171. /**
  75172. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75173. * more the post-process will require GPU power and can generate a drop in FPS.
  75174. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75175. */
  75176. get smoothSteps(): number;
  75177. set smoothSteps(steps: number);
  75178. private _updateEffectDefines;
  75179. /** @hidden */
  75180. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75181. }
  75182. }
  75183. declare module "babylonjs/Shaders/standard.fragment" {
  75184. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75185. /** @hidden */
  75186. export var standardPixelShader: {
  75187. name: string;
  75188. shader: string;
  75189. };
  75190. }
  75191. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75192. import { Nullable } from "babylonjs/types";
  75193. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75194. import { Camera } from "babylonjs/Cameras/camera";
  75195. import { Texture } from "babylonjs/Materials/Textures/texture";
  75196. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75197. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75198. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75199. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75200. import { IDisposable } from "babylonjs/scene";
  75201. import { SpotLight } from "babylonjs/Lights/spotLight";
  75202. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75203. import { Scene } from "babylonjs/scene";
  75204. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75205. import { Animation } from "babylonjs/Animations/animation";
  75206. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75207. import "babylonjs/Shaders/standard.fragment";
  75208. /**
  75209. * Standard rendering pipeline
  75210. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75211. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75212. */
  75213. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75214. /**
  75215. * Public members
  75216. */
  75217. /**
  75218. * Post-process which contains the original scene color before the pipeline applies all the effects
  75219. */
  75220. originalPostProcess: Nullable<PostProcess>;
  75221. /**
  75222. * Post-process used to down scale an image x4
  75223. */
  75224. downSampleX4PostProcess: Nullable<PostProcess>;
  75225. /**
  75226. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75227. */
  75228. brightPassPostProcess: Nullable<PostProcess>;
  75229. /**
  75230. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75231. */
  75232. blurHPostProcesses: PostProcess[];
  75233. /**
  75234. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75235. */
  75236. blurVPostProcesses: PostProcess[];
  75237. /**
  75238. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75239. */
  75240. textureAdderPostProcess: Nullable<PostProcess>;
  75241. /**
  75242. * Post-process used to create volumetric lighting effect
  75243. */
  75244. volumetricLightPostProcess: Nullable<PostProcess>;
  75245. /**
  75246. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75247. */
  75248. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75249. /**
  75250. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75251. */
  75252. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75253. /**
  75254. * Post-process used to merge the volumetric light effect and the real scene color
  75255. */
  75256. volumetricLightMergePostProces: Nullable<PostProcess>;
  75257. /**
  75258. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75259. */
  75260. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75261. /**
  75262. * Base post-process used to calculate the average luminance of the final image for HDR
  75263. */
  75264. luminancePostProcess: Nullable<PostProcess>;
  75265. /**
  75266. * Post-processes used to create down sample post-processes in order to get
  75267. * the average luminance of the final image for HDR
  75268. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75269. */
  75270. luminanceDownSamplePostProcesses: PostProcess[];
  75271. /**
  75272. * Post-process used to create a HDR effect (light adaptation)
  75273. */
  75274. hdrPostProcess: Nullable<PostProcess>;
  75275. /**
  75276. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75277. */
  75278. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75279. /**
  75280. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75281. */
  75282. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75283. /**
  75284. * Post-process used to merge the final HDR post-process and the real scene color
  75285. */
  75286. hdrFinalPostProcess: Nullable<PostProcess>;
  75287. /**
  75288. * Post-process used to create a lens flare effect
  75289. */
  75290. lensFlarePostProcess: Nullable<PostProcess>;
  75291. /**
  75292. * Post-process that merges the result of the lens flare post-process and the real scene color
  75293. */
  75294. lensFlareComposePostProcess: Nullable<PostProcess>;
  75295. /**
  75296. * Post-process used to create a motion blur effect
  75297. */
  75298. motionBlurPostProcess: Nullable<PostProcess>;
  75299. /**
  75300. * Post-process used to create a depth of field effect
  75301. */
  75302. depthOfFieldPostProcess: Nullable<PostProcess>;
  75303. /**
  75304. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75305. */
  75306. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75307. /**
  75308. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75309. */
  75310. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75311. /**
  75312. * Represents the brightness threshold in order to configure the illuminated surfaces
  75313. */
  75314. brightThreshold: number;
  75315. /**
  75316. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75317. */
  75318. blurWidth: number;
  75319. /**
  75320. * Sets if the blur for highlighted surfaces must be only horizontal
  75321. */
  75322. horizontalBlur: boolean;
  75323. /**
  75324. * Gets the overall exposure used by the pipeline
  75325. */
  75326. get exposure(): number;
  75327. /**
  75328. * Sets the overall exposure used by the pipeline
  75329. */
  75330. set exposure(value: number);
  75331. /**
  75332. * Texture used typically to simulate "dirty" on camera lens
  75333. */
  75334. lensTexture: Nullable<Texture>;
  75335. /**
  75336. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75337. */
  75338. volumetricLightCoefficient: number;
  75339. /**
  75340. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75341. */
  75342. volumetricLightPower: number;
  75343. /**
  75344. * Used the set the blur intensity to smooth the volumetric lights
  75345. */
  75346. volumetricLightBlurScale: number;
  75347. /**
  75348. * Light (spot or directional) used to generate the volumetric lights rays
  75349. * The source light must have a shadow generate so the pipeline can get its
  75350. * depth map
  75351. */
  75352. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75353. /**
  75354. * For eye adaptation, represents the minimum luminance the eye can see
  75355. */
  75356. hdrMinimumLuminance: number;
  75357. /**
  75358. * For eye adaptation, represents the decrease luminance speed
  75359. */
  75360. hdrDecreaseRate: number;
  75361. /**
  75362. * For eye adaptation, represents the increase luminance speed
  75363. */
  75364. hdrIncreaseRate: number;
  75365. /**
  75366. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75367. */
  75368. get hdrAutoExposure(): boolean;
  75369. /**
  75370. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75371. */
  75372. set hdrAutoExposure(value: boolean);
  75373. /**
  75374. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75375. */
  75376. lensColorTexture: Nullable<Texture>;
  75377. /**
  75378. * The overall strengh for the lens flare effect
  75379. */
  75380. lensFlareStrength: number;
  75381. /**
  75382. * Dispersion coefficient for lens flare ghosts
  75383. */
  75384. lensFlareGhostDispersal: number;
  75385. /**
  75386. * Main lens flare halo width
  75387. */
  75388. lensFlareHaloWidth: number;
  75389. /**
  75390. * Based on the lens distortion effect, defines how much the lens flare result
  75391. * is distorted
  75392. */
  75393. lensFlareDistortionStrength: number;
  75394. /**
  75395. * Configures the blur intensity used for for lens flare (halo)
  75396. */
  75397. lensFlareBlurWidth: number;
  75398. /**
  75399. * Lens star texture must be used to simulate rays on the flares and is available
  75400. * in the documentation
  75401. */
  75402. lensStarTexture: Nullable<Texture>;
  75403. /**
  75404. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75405. * flare effect by taking account of the dirt texture
  75406. */
  75407. lensFlareDirtTexture: Nullable<Texture>;
  75408. /**
  75409. * Represents the focal length for the depth of field effect
  75410. */
  75411. depthOfFieldDistance: number;
  75412. /**
  75413. * Represents the blur intensity for the blurred part of the depth of field effect
  75414. */
  75415. depthOfFieldBlurWidth: number;
  75416. /**
  75417. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75418. */
  75419. get motionStrength(): number;
  75420. /**
  75421. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75422. */
  75423. set motionStrength(strength: number);
  75424. /**
  75425. * Gets wether or not the motion blur post-process is object based or screen based.
  75426. */
  75427. get objectBasedMotionBlur(): boolean;
  75428. /**
  75429. * Sets wether or not the motion blur post-process should be object based or screen based
  75430. */
  75431. set objectBasedMotionBlur(value: boolean);
  75432. /**
  75433. * List of animations for the pipeline (IAnimatable implementation)
  75434. */
  75435. animations: Animation[];
  75436. /**
  75437. * Private members
  75438. */
  75439. private _scene;
  75440. private _currentDepthOfFieldSource;
  75441. private _basePostProcess;
  75442. private _fixedExposure;
  75443. private _currentExposure;
  75444. private _hdrAutoExposure;
  75445. private _hdrCurrentLuminance;
  75446. private _motionStrength;
  75447. private _isObjectBasedMotionBlur;
  75448. private _floatTextureType;
  75449. private _camerasToBeAttached;
  75450. private _ratio;
  75451. private _bloomEnabled;
  75452. private _depthOfFieldEnabled;
  75453. private _vlsEnabled;
  75454. private _lensFlareEnabled;
  75455. private _hdrEnabled;
  75456. private _motionBlurEnabled;
  75457. private _fxaaEnabled;
  75458. private _screenSpaceReflectionsEnabled;
  75459. private _motionBlurSamples;
  75460. private _volumetricLightStepsCount;
  75461. private _samples;
  75462. /**
  75463. * @ignore
  75464. * Specifies if the bloom pipeline is enabled
  75465. */
  75466. get BloomEnabled(): boolean;
  75467. set BloomEnabled(enabled: boolean);
  75468. /**
  75469. * @ignore
  75470. * Specifies if the depth of field pipeline is enabed
  75471. */
  75472. get DepthOfFieldEnabled(): boolean;
  75473. set DepthOfFieldEnabled(enabled: boolean);
  75474. /**
  75475. * @ignore
  75476. * Specifies if the lens flare pipeline is enabed
  75477. */
  75478. get LensFlareEnabled(): boolean;
  75479. set LensFlareEnabled(enabled: boolean);
  75480. /**
  75481. * @ignore
  75482. * Specifies if the HDR pipeline is enabled
  75483. */
  75484. get HDREnabled(): boolean;
  75485. set HDREnabled(enabled: boolean);
  75486. /**
  75487. * @ignore
  75488. * Specifies if the volumetric lights scattering effect is enabled
  75489. */
  75490. get VLSEnabled(): boolean;
  75491. set VLSEnabled(enabled: boolean);
  75492. /**
  75493. * @ignore
  75494. * Specifies if the motion blur effect is enabled
  75495. */
  75496. get MotionBlurEnabled(): boolean;
  75497. set MotionBlurEnabled(enabled: boolean);
  75498. /**
  75499. * Specifies if anti-aliasing is enabled
  75500. */
  75501. get fxaaEnabled(): boolean;
  75502. set fxaaEnabled(enabled: boolean);
  75503. /**
  75504. * Specifies if screen space reflections are enabled.
  75505. */
  75506. get screenSpaceReflectionsEnabled(): boolean;
  75507. set screenSpaceReflectionsEnabled(enabled: boolean);
  75508. /**
  75509. * Specifies the number of steps used to calculate the volumetric lights
  75510. * Typically in interval [50, 200]
  75511. */
  75512. get volumetricLightStepsCount(): number;
  75513. set volumetricLightStepsCount(count: number);
  75514. /**
  75515. * Specifies the number of samples used for the motion blur effect
  75516. * Typically in interval [16, 64]
  75517. */
  75518. get motionBlurSamples(): number;
  75519. set motionBlurSamples(samples: number);
  75520. /**
  75521. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75522. */
  75523. get samples(): number;
  75524. set samples(sampleCount: number);
  75525. /**
  75526. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75527. * @constructor
  75528. * @param name The rendering pipeline name
  75529. * @param scene The scene linked to this pipeline
  75530. * @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)
  75531. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75532. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75533. */
  75534. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75535. private _buildPipeline;
  75536. private _createDownSampleX4PostProcess;
  75537. private _createBrightPassPostProcess;
  75538. private _createBlurPostProcesses;
  75539. private _createTextureAdderPostProcess;
  75540. private _createVolumetricLightPostProcess;
  75541. private _createLuminancePostProcesses;
  75542. private _createHdrPostProcess;
  75543. private _createLensFlarePostProcess;
  75544. private _createDepthOfFieldPostProcess;
  75545. private _createMotionBlurPostProcess;
  75546. private _getDepthTexture;
  75547. private _disposePostProcesses;
  75548. /**
  75549. * Dispose of the pipeline and stop all post processes
  75550. */
  75551. dispose(): void;
  75552. /**
  75553. * Serialize the rendering pipeline (Used when exporting)
  75554. * @returns the serialized object
  75555. */
  75556. serialize(): any;
  75557. /**
  75558. * Parse the serialized pipeline
  75559. * @param source Source pipeline.
  75560. * @param scene The scene to load the pipeline to.
  75561. * @param rootUrl The URL of the serialized pipeline.
  75562. * @returns An instantiated pipeline from the serialized object.
  75563. */
  75564. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75565. /**
  75566. * Luminance steps
  75567. */
  75568. static LuminanceSteps: number;
  75569. }
  75570. }
  75571. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75572. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75573. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75574. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75575. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75576. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75577. }
  75578. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75579. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75580. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75581. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75582. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75583. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75584. }
  75585. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75586. /** @hidden */
  75587. export var stereoscopicInterlacePixelShader: {
  75588. name: string;
  75589. shader: string;
  75590. };
  75591. }
  75592. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75593. import { Camera } from "babylonjs/Cameras/camera";
  75594. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75595. import { Engine } from "babylonjs/Engines/engine";
  75596. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75597. /**
  75598. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75599. */
  75600. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75601. private _stepSize;
  75602. private _passedProcess;
  75603. /**
  75604. * Gets a string identifying the name of the class
  75605. * @returns "StereoscopicInterlacePostProcessI" string
  75606. */
  75607. getClassName(): string;
  75608. /**
  75609. * Initializes a StereoscopicInterlacePostProcessI
  75610. * @param name The name of the effect.
  75611. * @param rigCameras The rig cameras to be appled to the post process
  75612. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75613. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75615. * @param engine The engine which the post process will be applied. (default: current engine)
  75616. * @param reusable If the post process can be reused on the same frame. (default: false)
  75617. */
  75618. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75619. }
  75620. /**
  75621. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75622. */
  75623. export class StereoscopicInterlacePostProcess extends PostProcess {
  75624. private _stepSize;
  75625. private _passedProcess;
  75626. /**
  75627. * Gets a string identifying the name of the class
  75628. * @returns "StereoscopicInterlacePostProcess" string
  75629. */
  75630. getClassName(): string;
  75631. /**
  75632. * Initializes a StereoscopicInterlacePostProcess
  75633. * @param name The name of the effect.
  75634. * @param rigCameras The rig cameras to be appled to the post process
  75635. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75637. * @param engine The engine which the post process will be applied. (default: current engine)
  75638. * @param reusable If the post process can be reused on the same frame. (default: false)
  75639. */
  75640. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75641. }
  75642. }
  75643. declare module "babylonjs/Shaders/tonemap.fragment" {
  75644. /** @hidden */
  75645. export var tonemapPixelShader: {
  75646. name: string;
  75647. shader: string;
  75648. };
  75649. }
  75650. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75651. import { Camera } from "babylonjs/Cameras/camera";
  75652. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75653. import "babylonjs/Shaders/tonemap.fragment";
  75654. import { Engine } from "babylonjs/Engines/engine";
  75655. /** Defines operator used for tonemapping */
  75656. export enum TonemappingOperator {
  75657. /** Hable */
  75658. Hable = 0,
  75659. /** Reinhard */
  75660. Reinhard = 1,
  75661. /** HejiDawson */
  75662. HejiDawson = 2,
  75663. /** Photographic */
  75664. Photographic = 3
  75665. }
  75666. /**
  75667. * Defines a post process to apply tone mapping
  75668. */
  75669. export class TonemapPostProcess extends PostProcess {
  75670. private _operator;
  75671. /** Defines the required exposure adjustement */
  75672. exposureAdjustment: number;
  75673. /**
  75674. * Gets a string identifying the name of the class
  75675. * @returns "TonemapPostProcess" string
  75676. */
  75677. getClassName(): string;
  75678. /**
  75679. * Creates a new TonemapPostProcess
  75680. * @param name defines the name of the postprocess
  75681. * @param _operator defines the operator to use
  75682. * @param exposureAdjustment defines the required exposure adjustement
  75683. * @param camera defines the camera to use (can be null)
  75684. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75685. * @param engine defines the hosting engine (can be ignore if camera is set)
  75686. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75687. */
  75688. constructor(name: string, _operator: TonemappingOperator,
  75689. /** Defines the required exposure adjustement */
  75690. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75691. }
  75692. }
  75693. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75694. /** @hidden */
  75695. export var volumetricLightScatteringPixelShader: {
  75696. name: string;
  75697. shader: string;
  75698. };
  75699. }
  75700. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75701. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75702. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75703. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75704. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75705. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75706. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75707. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75708. /** @hidden */
  75709. export var volumetricLightScatteringPassVertexShader: {
  75710. name: string;
  75711. shader: string;
  75712. };
  75713. }
  75714. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75715. /** @hidden */
  75716. export var volumetricLightScatteringPassPixelShader: {
  75717. name: string;
  75718. shader: string;
  75719. };
  75720. }
  75721. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75722. import { Vector3 } from "babylonjs/Maths/math.vector";
  75723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75724. import { Mesh } from "babylonjs/Meshes/mesh";
  75725. import { Camera } from "babylonjs/Cameras/camera";
  75726. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75727. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75728. import { Scene } from "babylonjs/scene";
  75729. import "babylonjs/Meshes/Builders/planeBuilder";
  75730. import "babylonjs/Shaders/depth.vertex";
  75731. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75732. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75733. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75734. import { Engine } from "babylonjs/Engines/engine";
  75735. /**
  75736. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75737. */
  75738. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75739. private _volumetricLightScatteringPass;
  75740. private _volumetricLightScatteringRTT;
  75741. private _viewPort;
  75742. private _screenCoordinates;
  75743. private _cachedDefines;
  75744. /**
  75745. * If not undefined, the mesh position is computed from the attached node position
  75746. */
  75747. attachedNode: {
  75748. position: Vector3;
  75749. };
  75750. /**
  75751. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75752. */
  75753. customMeshPosition: Vector3;
  75754. /**
  75755. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75756. */
  75757. useCustomMeshPosition: boolean;
  75758. /**
  75759. * If the post-process should inverse the light scattering direction
  75760. */
  75761. invert: boolean;
  75762. /**
  75763. * The internal mesh used by the post-process
  75764. */
  75765. mesh: Mesh;
  75766. /**
  75767. * @hidden
  75768. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75769. */
  75770. get useDiffuseColor(): boolean;
  75771. set useDiffuseColor(useDiffuseColor: boolean);
  75772. /**
  75773. * Array containing the excluded meshes not rendered in the internal pass
  75774. */
  75775. excludedMeshes: AbstractMesh[];
  75776. /**
  75777. * Controls the overall intensity of the post-process
  75778. */
  75779. exposure: number;
  75780. /**
  75781. * Dissipates each sample's contribution in range [0, 1]
  75782. */
  75783. decay: number;
  75784. /**
  75785. * Controls the overall intensity of each sample
  75786. */
  75787. weight: number;
  75788. /**
  75789. * Controls the density of each sample
  75790. */
  75791. density: number;
  75792. /**
  75793. * @constructor
  75794. * @param name The post-process name
  75795. * @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)
  75796. * @param camera The camera that the post-process will be attached to
  75797. * @param mesh The mesh used to create the light scattering
  75798. * @param samples The post-process quality, default 100
  75799. * @param samplingModeThe post-process filtering mode
  75800. * @param engine The babylon engine
  75801. * @param reusable If the post-process is reusable
  75802. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75803. */
  75804. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75805. /**
  75806. * Returns the string "VolumetricLightScatteringPostProcess"
  75807. * @returns "VolumetricLightScatteringPostProcess"
  75808. */
  75809. getClassName(): string;
  75810. private _isReady;
  75811. /**
  75812. * Sets the new light position for light scattering effect
  75813. * @param position The new custom light position
  75814. */
  75815. setCustomMeshPosition(position: Vector3): void;
  75816. /**
  75817. * Returns the light position for light scattering effect
  75818. * @return Vector3 The custom light position
  75819. */
  75820. getCustomMeshPosition(): Vector3;
  75821. /**
  75822. * Disposes the internal assets and detaches the post-process from the camera
  75823. */
  75824. dispose(camera: Camera): void;
  75825. /**
  75826. * Returns the render target texture used by the post-process
  75827. * @return the render target texture used by the post-process
  75828. */
  75829. getPass(): RenderTargetTexture;
  75830. private _meshExcluded;
  75831. private _createPass;
  75832. private _updateMeshScreenCoordinates;
  75833. /**
  75834. * Creates a default mesh for the Volumeric Light Scattering post-process
  75835. * @param name The mesh name
  75836. * @param scene The scene where to create the mesh
  75837. * @return the default mesh
  75838. */
  75839. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75840. }
  75841. }
  75842. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75843. /** @hidden */
  75844. export var screenSpaceCurvaturePixelShader: {
  75845. name: string;
  75846. shader: string;
  75847. };
  75848. }
  75849. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75850. import { Nullable } from "babylonjs/types";
  75851. import { Camera } from "babylonjs/Cameras/camera";
  75852. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75853. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75854. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75855. import { Engine } from "babylonjs/Engines/engine";
  75856. import { Scene } from "babylonjs/scene";
  75857. /**
  75858. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75859. */
  75860. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75861. /**
  75862. * Defines how much ridge the curvature effect displays.
  75863. */
  75864. ridge: number;
  75865. /**
  75866. * Defines how much valley the curvature effect displays.
  75867. */
  75868. valley: number;
  75869. private _geometryBufferRenderer;
  75870. /**
  75871. * Gets a string identifying the name of the class
  75872. * @returns "ScreenSpaceCurvaturePostProcess" string
  75873. */
  75874. getClassName(): string;
  75875. /**
  75876. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75877. * @param name The name of the effect.
  75878. * @param scene The scene containing the objects to blur according to their velocity.
  75879. * @param options The required width/height ratio to downsize to before computing the render pass.
  75880. * @param camera The camera to apply the render pass to.
  75881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75882. * @param engine The engine which the post process will be applied. (default: current engine)
  75883. * @param reusable If the post process can be reused on the same frame. (default: false)
  75884. * @param textureType Type of textures used when performing the post process. (default: 0)
  75885. * @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)
  75886. */
  75887. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75888. /**
  75889. * Support test.
  75890. */
  75891. static get IsSupported(): boolean;
  75892. /** @hidden */
  75893. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75894. }
  75895. }
  75896. declare module "babylonjs/PostProcesses/index" {
  75897. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75898. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75899. export * from "babylonjs/PostProcesses/bloomEffect";
  75900. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75901. export * from "babylonjs/PostProcesses/blurPostProcess";
  75902. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75903. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75904. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75905. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75906. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75907. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75908. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75909. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75910. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75911. export * from "babylonjs/PostProcesses/filterPostProcess";
  75912. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75913. export * from "babylonjs/PostProcesses/grainPostProcess";
  75914. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75915. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75916. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75917. export * from "babylonjs/PostProcesses/passPostProcess";
  75918. export * from "babylonjs/PostProcesses/postProcess";
  75919. export * from "babylonjs/PostProcesses/postProcessManager";
  75920. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75921. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75922. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75923. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75924. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75925. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75926. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75927. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75928. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75929. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75930. }
  75931. declare module "babylonjs/Probes/index" {
  75932. export * from "babylonjs/Probes/reflectionProbe";
  75933. }
  75934. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75935. import { Scene } from "babylonjs/scene";
  75936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75937. import { SmartArray } from "babylonjs/Misc/smartArray";
  75938. import { ISceneComponent } from "babylonjs/sceneComponent";
  75939. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75940. import "babylonjs/Meshes/Builders/boxBuilder";
  75941. import "babylonjs/Shaders/color.fragment";
  75942. import "babylonjs/Shaders/color.vertex";
  75943. import { Color3 } from "babylonjs/Maths/math.color";
  75944. import { Observable } from "babylonjs/Misc/observable";
  75945. module "babylonjs/scene" {
  75946. interface Scene {
  75947. /** @hidden (Backing field) */
  75948. _boundingBoxRenderer: BoundingBoxRenderer;
  75949. /** @hidden (Backing field) */
  75950. _forceShowBoundingBoxes: boolean;
  75951. /**
  75952. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75953. */
  75954. forceShowBoundingBoxes: boolean;
  75955. /**
  75956. * Gets the bounding box renderer associated with the scene
  75957. * @returns a BoundingBoxRenderer
  75958. */
  75959. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75960. }
  75961. }
  75962. module "babylonjs/Meshes/abstractMesh" {
  75963. interface AbstractMesh {
  75964. /** @hidden (Backing field) */
  75965. _showBoundingBox: boolean;
  75966. /**
  75967. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75968. */
  75969. showBoundingBox: boolean;
  75970. }
  75971. }
  75972. /**
  75973. * Component responsible of rendering the bounding box of the meshes in a scene.
  75974. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75975. */
  75976. export class BoundingBoxRenderer implements ISceneComponent {
  75977. /**
  75978. * The component name helpfull to identify the component in the list of scene components.
  75979. */
  75980. readonly name: string;
  75981. /**
  75982. * The scene the component belongs to.
  75983. */
  75984. scene: Scene;
  75985. /**
  75986. * Color of the bounding box lines placed in front of an object
  75987. */
  75988. frontColor: Color3;
  75989. /**
  75990. * Color of the bounding box lines placed behind an object
  75991. */
  75992. backColor: Color3;
  75993. /**
  75994. * Defines if the renderer should show the back lines or not
  75995. */
  75996. showBackLines: boolean;
  75997. /**
  75998. * Observable raised before rendering a bounding box
  75999. */
  76000. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76001. /**
  76002. * Observable raised after rendering a bounding box
  76003. */
  76004. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76005. /**
  76006. * @hidden
  76007. */
  76008. renderList: SmartArray<BoundingBox>;
  76009. private _colorShader;
  76010. private _vertexBuffers;
  76011. private _indexBuffer;
  76012. private _fillIndexBuffer;
  76013. private _fillIndexData;
  76014. /**
  76015. * Instantiates a new bounding box renderer in a scene.
  76016. * @param scene the scene the renderer renders in
  76017. */
  76018. constructor(scene: Scene);
  76019. /**
  76020. * Registers the component in a given scene
  76021. */
  76022. register(): void;
  76023. private _evaluateSubMesh;
  76024. private _activeMesh;
  76025. private _prepareRessources;
  76026. private _createIndexBuffer;
  76027. /**
  76028. * Rebuilds the elements related to this component in case of
  76029. * context lost for instance.
  76030. */
  76031. rebuild(): void;
  76032. /**
  76033. * @hidden
  76034. */
  76035. reset(): void;
  76036. /**
  76037. * Render the bounding boxes of a specific rendering group
  76038. * @param renderingGroupId defines the rendering group to render
  76039. */
  76040. render(renderingGroupId: number): void;
  76041. /**
  76042. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76043. * @param mesh Define the mesh to render the occlusion bounding box for
  76044. */
  76045. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76046. /**
  76047. * Dispose and release the resources attached to this renderer.
  76048. */
  76049. dispose(): void;
  76050. }
  76051. }
  76052. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76053. import { Nullable } from "babylonjs/types";
  76054. import { Scene } from "babylonjs/scene";
  76055. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76056. import { Camera } from "babylonjs/Cameras/camera";
  76057. import { ISceneComponent } from "babylonjs/sceneComponent";
  76058. module "babylonjs/scene" {
  76059. interface Scene {
  76060. /** @hidden (Backing field) */
  76061. _depthRenderer: {
  76062. [id: string]: DepthRenderer;
  76063. };
  76064. /**
  76065. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76066. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76067. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76068. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76069. * @returns the created depth renderer
  76070. */
  76071. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76072. /**
  76073. * Disables a depth renderer for a given camera
  76074. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76075. */
  76076. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76077. }
  76078. }
  76079. /**
  76080. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76081. * in several rendering techniques.
  76082. */
  76083. export class DepthRendererSceneComponent implements ISceneComponent {
  76084. /**
  76085. * The component name helpfull to identify the component in the list of scene components.
  76086. */
  76087. readonly name: string;
  76088. /**
  76089. * The scene the component belongs to.
  76090. */
  76091. scene: Scene;
  76092. /**
  76093. * Creates a new instance of the component for the given scene
  76094. * @param scene Defines the scene to register the component in
  76095. */
  76096. constructor(scene: Scene);
  76097. /**
  76098. * Registers the component in a given scene
  76099. */
  76100. register(): void;
  76101. /**
  76102. * Rebuilds the elements related to this component in case of
  76103. * context lost for instance.
  76104. */
  76105. rebuild(): void;
  76106. /**
  76107. * Disposes the component and the associated ressources
  76108. */
  76109. dispose(): void;
  76110. private _gatherRenderTargets;
  76111. private _gatherActiveCameraRenderTargets;
  76112. }
  76113. }
  76114. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76115. import { Nullable } from "babylonjs/types";
  76116. import { Scene } from "babylonjs/scene";
  76117. import { ISceneComponent } from "babylonjs/sceneComponent";
  76118. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76119. module "babylonjs/abstractScene" {
  76120. interface AbstractScene {
  76121. /** @hidden (Backing field) */
  76122. _prePassRenderer: Nullable<PrePassRenderer>;
  76123. /**
  76124. * Gets or Sets the current prepass renderer associated to the scene.
  76125. */
  76126. prePassRenderer: Nullable<PrePassRenderer>;
  76127. /**
  76128. * Enables the prepass and associates it with the scene
  76129. * @returns the PrePassRenderer
  76130. */
  76131. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76132. /**
  76133. * Disables the prepass associated with the scene
  76134. */
  76135. disablePrePassRenderer(): void;
  76136. }
  76137. }
  76138. /**
  76139. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76140. * in several rendering techniques.
  76141. */
  76142. export class PrePassRendererSceneComponent implements ISceneComponent {
  76143. /**
  76144. * The component name helpful to identify the component in the list of scene components.
  76145. */
  76146. readonly name: string;
  76147. /**
  76148. * The scene the component belongs to.
  76149. */
  76150. scene: Scene;
  76151. /**
  76152. * Creates a new instance of the component for the given scene
  76153. * @param scene Defines the scene to register the component in
  76154. */
  76155. constructor(scene: Scene);
  76156. /**
  76157. * Registers the component in a given scene
  76158. */
  76159. register(): void;
  76160. private _beforeCameraDraw;
  76161. private _afterCameraDraw;
  76162. private _beforeClearStage;
  76163. /**
  76164. * Rebuilds the elements related to this component in case of
  76165. * context lost for instance.
  76166. */
  76167. rebuild(): void;
  76168. /**
  76169. * Disposes the component and the associated ressources
  76170. */
  76171. dispose(): void;
  76172. }
  76173. }
  76174. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76175. /** @hidden */
  76176. export var fibonacci: {
  76177. name: string;
  76178. shader: string;
  76179. };
  76180. }
  76181. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76182. /** @hidden */
  76183. export var diffusionProfile: {
  76184. name: string;
  76185. shader: string;
  76186. };
  76187. }
  76188. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76189. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76191. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76192. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76193. /** @hidden */
  76194. export var subSurfaceScatteringPixelShader: {
  76195. name: string;
  76196. shader: string;
  76197. };
  76198. }
  76199. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76200. import { Nullable } from "babylonjs/types";
  76201. import { Camera } from "babylonjs/Cameras/camera";
  76202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76203. import { Engine } from "babylonjs/Engines/engine";
  76204. import { Scene } from "babylonjs/scene";
  76205. import "babylonjs/Shaders/imageProcessing.fragment";
  76206. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76207. import "babylonjs/Shaders/postprocess.vertex";
  76208. /**
  76209. * Sub surface scattering post process
  76210. */
  76211. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76212. /**
  76213. * Gets a string identifying the name of the class
  76214. * @returns "SubSurfaceScatteringPostProcess" string
  76215. */
  76216. getClassName(): string;
  76217. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76218. }
  76219. }
  76220. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76221. import { Scene } from "babylonjs/scene";
  76222. import { Color3 } from "babylonjs/Maths/math.color";
  76223. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76224. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76225. /**
  76226. * Contains all parameters needed for the prepass to perform
  76227. * screen space subsurface scattering
  76228. */
  76229. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76230. /** @hidden */
  76231. static _SceneComponentInitialization: (scene: Scene) => void;
  76232. private _ssDiffusionS;
  76233. private _ssFilterRadii;
  76234. private _ssDiffusionD;
  76235. /**
  76236. * Post process to attach for screen space subsurface scattering
  76237. */
  76238. postProcess: SubSurfaceScatteringPostProcess;
  76239. /**
  76240. * Diffusion profile color for subsurface scattering
  76241. */
  76242. get ssDiffusionS(): number[];
  76243. /**
  76244. * Diffusion profile max color channel value for subsurface scattering
  76245. */
  76246. get ssDiffusionD(): number[];
  76247. /**
  76248. * Diffusion profile filter radius for subsurface scattering
  76249. */
  76250. get ssFilterRadii(): number[];
  76251. /**
  76252. * Is subsurface enabled
  76253. */
  76254. enabled: boolean;
  76255. /**
  76256. * Name of the configuration
  76257. */
  76258. name: string;
  76259. /**
  76260. * Diffusion profile colors for subsurface scattering
  76261. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76262. * See ...
  76263. * Note that you can only store up to 5 of them
  76264. */
  76265. ssDiffusionProfileColors: Color3[];
  76266. /**
  76267. * Defines the ratio real world => scene units.
  76268. * Used for subsurface scattering
  76269. */
  76270. metersPerUnit: number;
  76271. /**
  76272. * Textures that should be present in the MRT for this effect to work
  76273. */
  76274. readonly texturesRequired: number[];
  76275. private _scene;
  76276. /**
  76277. * Builds a subsurface configuration object
  76278. * @param scene The scene
  76279. */
  76280. constructor(scene: Scene);
  76281. /**
  76282. * Adds a new diffusion profile.
  76283. * Useful for more realistic subsurface scattering on diverse materials.
  76284. * @param color The color of the diffusion profile. Should be the average color of the material.
  76285. * @return The index of the diffusion profile for the material subsurface configuration
  76286. */
  76287. addDiffusionProfile(color: Color3): number;
  76288. /**
  76289. * Creates the sss post process
  76290. * @return The created post process
  76291. */
  76292. createPostProcess(): SubSurfaceScatteringPostProcess;
  76293. /**
  76294. * Deletes all diffusion profiles.
  76295. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76296. */
  76297. clearAllDiffusionProfiles(): void;
  76298. /**
  76299. * Disposes this object
  76300. */
  76301. dispose(): void;
  76302. /**
  76303. * @hidden
  76304. * https://zero-radiance.github.io/post/sampling-diffusion/
  76305. *
  76306. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76307. * ------------------------------------------------------------------------------------
  76308. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76309. * PDF[r, phi, s] = r * R[r, phi, s]
  76310. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76311. * ------------------------------------------------------------------------------------
  76312. * We importance sample the color channel with the widest scattering distance.
  76313. */
  76314. getDiffusionProfileParameters(color: Color3): number;
  76315. /**
  76316. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76317. * 'u' is the random number (the value of the CDF): [0, 1).
  76318. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76319. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76320. */
  76321. private _sampleBurleyDiffusionProfile;
  76322. }
  76323. }
  76324. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76325. import { Nullable } from "babylonjs/types";
  76326. import { Scene } from "babylonjs/scene";
  76327. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76328. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76329. import { AbstractScene } from "babylonjs/abstractScene";
  76330. module "babylonjs/abstractScene" {
  76331. interface AbstractScene {
  76332. /** @hidden (Backing field) */
  76333. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76334. /**
  76335. * Gets or Sets the current prepass renderer associated to the scene.
  76336. */
  76337. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76338. /**
  76339. * Enables the subsurface effect for prepass
  76340. * @returns the SubSurfaceConfiguration
  76341. */
  76342. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76343. /**
  76344. * Disables the subsurface effect for prepass
  76345. */
  76346. disableSubSurfaceForPrePass(): void;
  76347. }
  76348. }
  76349. /**
  76350. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76351. * in several rendering techniques.
  76352. */
  76353. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76354. /**
  76355. * The component name helpful to identify the component in the list of scene components.
  76356. */
  76357. readonly name: string;
  76358. /**
  76359. * The scene the component belongs to.
  76360. */
  76361. scene: Scene;
  76362. /**
  76363. * Creates a new instance of the component for the given scene
  76364. * @param scene Defines the scene to register the component in
  76365. */
  76366. constructor(scene: Scene);
  76367. /**
  76368. * Registers the component in a given scene
  76369. */
  76370. register(): void;
  76371. /**
  76372. * Serializes the component data to the specified json object
  76373. * @param serializationObject The object to serialize to
  76374. */
  76375. serialize(serializationObject: any): void;
  76376. /**
  76377. * Adds all the elements from the container to the scene
  76378. * @param container the container holding the elements
  76379. */
  76380. addFromContainer(container: AbstractScene): void;
  76381. /**
  76382. * Removes all the elements in the container from the scene
  76383. * @param container contains the elements to remove
  76384. * @param dispose if the removed element should be disposed (default: false)
  76385. */
  76386. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76387. /**
  76388. * Rebuilds the elements related to this component in case of
  76389. * context lost for instance.
  76390. */
  76391. rebuild(): void;
  76392. /**
  76393. * Disposes the component and the associated ressources
  76394. */
  76395. dispose(): void;
  76396. }
  76397. }
  76398. declare module "babylonjs/Shaders/outline.fragment" {
  76399. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76400. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76401. /** @hidden */
  76402. export var outlinePixelShader: {
  76403. name: string;
  76404. shader: string;
  76405. };
  76406. }
  76407. declare module "babylonjs/Shaders/outline.vertex" {
  76408. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76411. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76412. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76413. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76414. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76415. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76416. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76417. /** @hidden */
  76418. export var outlineVertexShader: {
  76419. name: string;
  76420. shader: string;
  76421. };
  76422. }
  76423. declare module "babylonjs/Rendering/outlineRenderer" {
  76424. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76425. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76426. import { Scene } from "babylonjs/scene";
  76427. import { ISceneComponent } from "babylonjs/sceneComponent";
  76428. import "babylonjs/Shaders/outline.fragment";
  76429. import "babylonjs/Shaders/outline.vertex";
  76430. module "babylonjs/scene" {
  76431. interface Scene {
  76432. /** @hidden */
  76433. _outlineRenderer: OutlineRenderer;
  76434. /**
  76435. * Gets the outline renderer associated with the scene
  76436. * @returns a OutlineRenderer
  76437. */
  76438. getOutlineRenderer(): OutlineRenderer;
  76439. }
  76440. }
  76441. module "babylonjs/Meshes/abstractMesh" {
  76442. interface AbstractMesh {
  76443. /** @hidden (Backing field) */
  76444. _renderOutline: boolean;
  76445. /**
  76446. * Gets or sets a boolean indicating if the outline must be rendered as well
  76447. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76448. */
  76449. renderOutline: boolean;
  76450. /** @hidden (Backing field) */
  76451. _renderOverlay: boolean;
  76452. /**
  76453. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76454. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76455. */
  76456. renderOverlay: boolean;
  76457. }
  76458. }
  76459. /**
  76460. * This class is responsible to draw bothe outline/overlay of meshes.
  76461. * It should not be used directly but through the available method on mesh.
  76462. */
  76463. export class OutlineRenderer implements ISceneComponent {
  76464. /**
  76465. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76466. */
  76467. private static _StencilReference;
  76468. /**
  76469. * The name of the component. Each component must have a unique name.
  76470. */
  76471. name: string;
  76472. /**
  76473. * The scene the component belongs to.
  76474. */
  76475. scene: Scene;
  76476. /**
  76477. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76478. */
  76479. zOffset: number;
  76480. private _engine;
  76481. private _effect;
  76482. private _cachedDefines;
  76483. private _savedDepthWrite;
  76484. /**
  76485. * Instantiates a new outline renderer. (There could be only one per scene).
  76486. * @param scene Defines the scene it belongs to
  76487. */
  76488. constructor(scene: Scene);
  76489. /**
  76490. * Register the component to one instance of a scene.
  76491. */
  76492. register(): void;
  76493. /**
  76494. * Rebuilds the elements related to this component in case of
  76495. * context lost for instance.
  76496. */
  76497. rebuild(): void;
  76498. /**
  76499. * Disposes the component and the associated ressources.
  76500. */
  76501. dispose(): void;
  76502. /**
  76503. * Renders the outline in the canvas.
  76504. * @param subMesh Defines the sumesh to render
  76505. * @param batch Defines the batch of meshes in case of instances
  76506. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76507. */
  76508. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76509. /**
  76510. * Returns whether or not the outline renderer is ready for a given submesh.
  76511. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76512. * @param subMesh Defines the submesh to check readyness for
  76513. * @param useInstances Defines wheter wee are trying to render instances or not
  76514. * @returns true if ready otherwise false
  76515. */
  76516. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76517. private _beforeRenderingMesh;
  76518. private _afterRenderingMesh;
  76519. }
  76520. }
  76521. declare module "babylonjs/Rendering/index" {
  76522. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76523. export * from "babylonjs/Rendering/depthRenderer";
  76524. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76525. export * from "babylonjs/Rendering/edgesRenderer";
  76526. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76527. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76528. export * from "babylonjs/Rendering/prePassRenderer";
  76529. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76530. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76531. export * from "babylonjs/Rendering/outlineRenderer";
  76532. export * from "babylonjs/Rendering/renderingGroup";
  76533. export * from "babylonjs/Rendering/renderingManager";
  76534. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76535. }
  76536. declare module "babylonjs/Sprites/ISprites" {
  76537. /**
  76538. * Defines the basic options interface of a Sprite Frame Source Size.
  76539. */
  76540. export interface ISpriteJSONSpriteSourceSize {
  76541. /**
  76542. * number of the original width of the Frame
  76543. */
  76544. w: number;
  76545. /**
  76546. * number of the original height of the Frame
  76547. */
  76548. h: number;
  76549. }
  76550. /**
  76551. * Defines the basic options interface of a Sprite Frame Data.
  76552. */
  76553. export interface ISpriteJSONSpriteFrameData {
  76554. /**
  76555. * number of the x offset of the Frame
  76556. */
  76557. x: number;
  76558. /**
  76559. * number of the y offset of the Frame
  76560. */
  76561. y: number;
  76562. /**
  76563. * number of the width of the Frame
  76564. */
  76565. w: number;
  76566. /**
  76567. * number of the height of the Frame
  76568. */
  76569. h: number;
  76570. }
  76571. /**
  76572. * Defines the basic options interface of a JSON Sprite.
  76573. */
  76574. export interface ISpriteJSONSprite {
  76575. /**
  76576. * string name of the Frame
  76577. */
  76578. filename: string;
  76579. /**
  76580. * ISpriteJSONSpriteFrame basic object of the frame data
  76581. */
  76582. frame: ISpriteJSONSpriteFrameData;
  76583. /**
  76584. * boolean to flag is the frame was rotated.
  76585. */
  76586. rotated: boolean;
  76587. /**
  76588. * boolean to flag is the frame was trimmed.
  76589. */
  76590. trimmed: boolean;
  76591. /**
  76592. * ISpriteJSONSpriteFrame basic object of the source data
  76593. */
  76594. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76595. /**
  76596. * ISpriteJSONSpriteFrame basic object of the source data
  76597. */
  76598. sourceSize: ISpriteJSONSpriteSourceSize;
  76599. }
  76600. /**
  76601. * Defines the basic options interface of a JSON atlas.
  76602. */
  76603. export interface ISpriteJSONAtlas {
  76604. /**
  76605. * Array of objects that contain the frame data.
  76606. */
  76607. frames: Array<ISpriteJSONSprite>;
  76608. /**
  76609. * object basic object containing the sprite meta data.
  76610. */
  76611. meta?: object;
  76612. }
  76613. }
  76614. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76615. /** @hidden */
  76616. export var spriteMapPixelShader: {
  76617. name: string;
  76618. shader: string;
  76619. };
  76620. }
  76621. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76622. /** @hidden */
  76623. export var spriteMapVertexShader: {
  76624. name: string;
  76625. shader: string;
  76626. };
  76627. }
  76628. declare module "babylonjs/Sprites/spriteMap" {
  76629. import { IDisposable, Scene } from "babylonjs/scene";
  76630. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76631. import { Texture } from "babylonjs/Materials/Textures/texture";
  76632. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76633. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76634. import "babylonjs/Meshes/Builders/planeBuilder";
  76635. import "babylonjs/Shaders/spriteMap.fragment";
  76636. import "babylonjs/Shaders/spriteMap.vertex";
  76637. /**
  76638. * Defines the basic options interface of a SpriteMap
  76639. */
  76640. export interface ISpriteMapOptions {
  76641. /**
  76642. * Vector2 of the number of cells in the grid.
  76643. */
  76644. stageSize?: Vector2;
  76645. /**
  76646. * Vector2 of the size of the output plane in World Units.
  76647. */
  76648. outputSize?: Vector2;
  76649. /**
  76650. * Vector3 of the position of the output plane in World Units.
  76651. */
  76652. outputPosition?: Vector3;
  76653. /**
  76654. * Vector3 of the rotation of the output plane.
  76655. */
  76656. outputRotation?: Vector3;
  76657. /**
  76658. * number of layers that the system will reserve in resources.
  76659. */
  76660. layerCount?: number;
  76661. /**
  76662. * number of max animation frames a single cell will reserve in resources.
  76663. */
  76664. maxAnimationFrames?: number;
  76665. /**
  76666. * number cell index of the base tile when the system compiles.
  76667. */
  76668. baseTile?: number;
  76669. /**
  76670. * boolean flip the sprite after its been repositioned by the framing data.
  76671. */
  76672. flipU?: boolean;
  76673. /**
  76674. * Vector3 scalar of the global RGB values of the SpriteMap.
  76675. */
  76676. colorMultiply?: Vector3;
  76677. }
  76678. /**
  76679. * Defines the IDisposable interface in order to be cleanable from resources.
  76680. */
  76681. export interface ISpriteMap extends IDisposable {
  76682. /**
  76683. * String name of the SpriteMap.
  76684. */
  76685. name: string;
  76686. /**
  76687. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76688. */
  76689. atlasJSON: ISpriteJSONAtlas;
  76690. /**
  76691. * Texture of the SpriteMap.
  76692. */
  76693. spriteSheet: Texture;
  76694. /**
  76695. * The parameters to initialize the SpriteMap with.
  76696. */
  76697. options: ISpriteMapOptions;
  76698. }
  76699. /**
  76700. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76701. */
  76702. export class SpriteMap implements ISpriteMap {
  76703. /** The Name of the spriteMap */
  76704. name: string;
  76705. /** The JSON file with the frame and meta data */
  76706. atlasJSON: ISpriteJSONAtlas;
  76707. /** The systems Sprite Sheet Texture */
  76708. spriteSheet: Texture;
  76709. /** Arguments passed with the Constructor */
  76710. options: ISpriteMapOptions;
  76711. /** Public Sprite Storage array, parsed from atlasJSON */
  76712. sprites: Array<ISpriteJSONSprite>;
  76713. /** Returns the Number of Sprites in the System */
  76714. get spriteCount(): number;
  76715. /** Returns the Position of Output Plane*/
  76716. get position(): Vector3;
  76717. /** Returns the Position of Output Plane*/
  76718. set position(v: Vector3);
  76719. /** Returns the Rotation of Output Plane*/
  76720. get rotation(): Vector3;
  76721. /** Returns the Rotation of Output Plane*/
  76722. set rotation(v: Vector3);
  76723. /** Sets the AnimationMap*/
  76724. get animationMap(): RawTexture;
  76725. /** Sets the AnimationMap*/
  76726. set animationMap(v: RawTexture);
  76727. /** Scene that the SpriteMap was created in */
  76728. private _scene;
  76729. /** Texture Buffer of Float32 that holds tile frame data*/
  76730. private _frameMap;
  76731. /** Texture Buffers of Float32 that holds tileMap data*/
  76732. private _tileMaps;
  76733. /** Texture Buffer of Float32 that holds Animation Data*/
  76734. private _animationMap;
  76735. /** Custom ShaderMaterial Central to the System*/
  76736. private _material;
  76737. /** Custom ShaderMaterial Central to the System*/
  76738. private _output;
  76739. /** Systems Time Ticker*/
  76740. private _time;
  76741. /**
  76742. * Creates a new SpriteMap
  76743. * @param name defines the SpriteMaps Name
  76744. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76745. * @param spriteSheet is the Texture that the Sprites are on.
  76746. * @param options a basic deployment configuration
  76747. * @param scene The Scene that the map is deployed on
  76748. */
  76749. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76750. /**
  76751. * Returns tileID location
  76752. * @returns Vector2 the cell position ID
  76753. */
  76754. getTileID(): Vector2;
  76755. /**
  76756. * Gets the UV location of the mouse over the SpriteMap.
  76757. * @returns Vector2 the UV position of the mouse interaction
  76758. */
  76759. getMousePosition(): Vector2;
  76760. /**
  76761. * Creates the "frame" texture Buffer
  76762. * -------------------------------------
  76763. * Structure of frames
  76764. * "filename": "Falling-Water-2.png",
  76765. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76766. * "rotated": true,
  76767. * "trimmed": true,
  76768. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76769. * "sourceSize": {"w":32,"h":32}
  76770. * @returns RawTexture of the frameMap
  76771. */
  76772. private _createFrameBuffer;
  76773. /**
  76774. * Creates the tileMap texture Buffer
  76775. * @param buffer normally and array of numbers, or a false to generate from scratch
  76776. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76777. * @returns RawTexture of the tileMap
  76778. */
  76779. private _createTileBuffer;
  76780. /**
  76781. * Modifies the data of the tileMaps
  76782. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76783. * @param pos is the iVector2 Coordinates of the Tile
  76784. * @param tile The SpriteIndex of the new Tile
  76785. */
  76786. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76787. /**
  76788. * Creates the animationMap texture Buffer
  76789. * @param buffer normally and array of numbers, or a false to generate from scratch
  76790. * @returns RawTexture of the animationMap
  76791. */
  76792. private _createTileAnimationBuffer;
  76793. /**
  76794. * Modifies the data of the animationMap
  76795. * @param cellID is the Index of the Sprite
  76796. * @param _frame is the target Animation frame
  76797. * @param toCell is the Target Index of the next frame of the animation
  76798. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76799. * @param speed is a global scalar of the time variable on the map.
  76800. */
  76801. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76802. /**
  76803. * Exports the .tilemaps file
  76804. */
  76805. saveTileMaps(): void;
  76806. /**
  76807. * Imports the .tilemaps file
  76808. * @param url of the .tilemaps file
  76809. */
  76810. loadTileMaps(url: string): void;
  76811. /**
  76812. * Release associated resources
  76813. */
  76814. dispose(): void;
  76815. }
  76816. }
  76817. declare module "babylonjs/Sprites/spritePackedManager" {
  76818. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76819. import { Scene } from "babylonjs/scene";
  76820. /**
  76821. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76822. * @see https://doc.babylonjs.com/babylon101/sprites
  76823. */
  76824. export class SpritePackedManager extends SpriteManager {
  76825. /** defines the packed manager's name */
  76826. name: string;
  76827. /**
  76828. * Creates a new sprite manager from a packed sprite sheet
  76829. * @param name defines the manager's name
  76830. * @param imgUrl defines the sprite sheet url
  76831. * @param capacity defines the maximum allowed number of sprites
  76832. * @param scene defines the hosting scene
  76833. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76834. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76835. * @param samplingMode defines the smapling mode to use with spritesheet
  76836. * @param fromPacked set to true; do not alter
  76837. */
  76838. constructor(
  76839. /** defines the packed manager's name */
  76840. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76841. }
  76842. }
  76843. declare module "babylonjs/Sprites/index" {
  76844. export * from "babylonjs/Sprites/sprite";
  76845. export * from "babylonjs/Sprites/ISprites";
  76846. export * from "babylonjs/Sprites/spriteManager";
  76847. export * from "babylonjs/Sprites/spriteMap";
  76848. export * from "babylonjs/Sprites/spritePackedManager";
  76849. export * from "babylonjs/Sprites/spriteSceneComponent";
  76850. }
  76851. declare module "babylonjs/States/index" {
  76852. export * from "babylonjs/States/alphaCullingState";
  76853. export * from "babylonjs/States/depthCullingState";
  76854. export * from "babylonjs/States/stencilState";
  76855. }
  76856. declare module "babylonjs/Misc/assetsManager" {
  76857. import { Scene } from "babylonjs/scene";
  76858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76859. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76860. import { Skeleton } from "babylonjs/Bones/skeleton";
  76861. import { Observable } from "babylonjs/Misc/observable";
  76862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76863. import { Texture } from "babylonjs/Materials/Textures/texture";
  76864. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76865. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76866. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76867. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76868. import { AssetContainer } from "babylonjs/assetContainer";
  76869. /**
  76870. * Defines the list of states available for a task inside a AssetsManager
  76871. */
  76872. export enum AssetTaskState {
  76873. /**
  76874. * Initialization
  76875. */
  76876. INIT = 0,
  76877. /**
  76878. * Running
  76879. */
  76880. RUNNING = 1,
  76881. /**
  76882. * Done
  76883. */
  76884. DONE = 2,
  76885. /**
  76886. * Error
  76887. */
  76888. ERROR = 3
  76889. }
  76890. /**
  76891. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76892. */
  76893. export abstract class AbstractAssetTask {
  76894. /**
  76895. * Task name
  76896. */ name: string;
  76897. /**
  76898. * Callback called when the task is successful
  76899. */
  76900. onSuccess: (task: any) => void;
  76901. /**
  76902. * Callback called when the task is not successful
  76903. */
  76904. onError: (task: any, message?: string, exception?: any) => void;
  76905. /**
  76906. * Creates a new AssetsManager
  76907. * @param name defines the name of the task
  76908. */
  76909. constructor(
  76910. /**
  76911. * Task name
  76912. */ name: string);
  76913. private _isCompleted;
  76914. private _taskState;
  76915. private _errorObject;
  76916. /**
  76917. * Get if the task is completed
  76918. */
  76919. get isCompleted(): boolean;
  76920. /**
  76921. * Gets the current state of the task
  76922. */
  76923. get taskState(): AssetTaskState;
  76924. /**
  76925. * Gets the current error object (if task is in error)
  76926. */
  76927. get errorObject(): {
  76928. message?: string;
  76929. exception?: any;
  76930. };
  76931. /**
  76932. * Internal only
  76933. * @hidden
  76934. */
  76935. _setErrorObject(message?: string, exception?: any): void;
  76936. /**
  76937. * Execute the current task
  76938. * @param scene defines the scene where you want your assets to be loaded
  76939. * @param onSuccess is a callback called when the task is successfully executed
  76940. * @param onError is a callback called if an error occurs
  76941. */
  76942. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76943. /**
  76944. * Execute the current task
  76945. * @param scene defines the scene where you want your assets to be loaded
  76946. * @param onSuccess is a callback called when the task is successfully executed
  76947. * @param onError is a callback called if an error occurs
  76948. */
  76949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76950. /**
  76951. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76952. * This can be used with failed tasks that have the reason for failure fixed.
  76953. */
  76954. reset(): void;
  76955. private onErrorCallback;
  76956. private onDoneCallback;
  76957. }
  76958. /**
  76959. * Define the interface used by progress events raised during assets loading
  76960. */
  76961. export interface IAssetsProgressEvent {
  76962. /**
  76963. * Defines the number of remaining tasks to process
  76964. */
  76965. remainingCount: number;
  76966. /**
  76967. * Defines the total number of tasks
  76968. */
  76969. totalCount: number;
  76970. /**
  76971. * Defines the task that was just processed
  76972. */
  76973. task: AbstractAssetTask;
  76974. }
  76975. /**
  76976. * Class used to share progress information about assets loading
  76977. */
  76978. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76979. /**
  76980. * Defines the number of remaining tasks to process
  76981. */
  76982. remainingCount: number;
  76983. /**
  76984. * Defines the total number of tasks
  76985. */
  76986. totalCount: number;
  76987. /**
  76988. * Defines the task that was just processed
  76989. */
  76990. task: AbstractAssetTask;
  76991. /**
  76992. * Creates a AssetsProgressEvent
  76993. * @param remainingCount defines the number of remaining tasks to process
  76994. * @param totalCount defines the total number of tasks
  76995. * @param task defines the task that was just processed
  76996. */
  76997. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76998. }
  76999. /**
  77000. * Define a task used by AssetsManager to load assets into a container
  77001. */
  77002. export class ContainerAssetTask extends AbstractAssetTask {
  77003. /**
  77004. * Defines the name of the task
  77005. */
  77006. name: string;
  77007. /**
  77008. * Defines the list of mesh's names you want to load
  77009. */
  77010. meshesNames: any;
  77011. /**
  77012. * Defines the root url to use as a base to load your meshes and associated resources
  77013. */
  77014. rootUrl: string;
  77015. /**
  77016. * Defines the filename or File of the scene to load from
  77017. */
  77018. sceneFilename: string | File;
  77019. /**
  77020. * Get the loaded asset container
  77021. */
  77022. loadedContainer: AssetContainer;
  77023. /**
  77024. * Gets the list of loaded meshes
  77025. */
  77026. loadedMeshes: Array<AbstractMesh>;
  77027. /**
  77028. * Gets the list of loaded particle systems
  77029. */
  77030. loadedParticleSystems: Array<IParticleSystem>;
  77031. /**
  77032. * Gets the list of loaded skeletons
  77033. */
  77034. loadedSkeletons: Array<Skeleton>;
  77035. /**
  77036. * Gets the list of loaded animation groups
  77037. */
  77038. loadedAnimationGroups: Array<AnimationGroup>;
  77039. /**
  77040. * Callback called when the task is successful
  77041. */
  77042. onSuccess: (task: ContainerAssetTask) => void;
  77043. /**
  77044. * Callback called when the task is successful
  77045. */
  77046. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77047. /**
  77048. * Creates a new ContainerAssetTask
  77049. * @param name defines the name of the task
  77050. * @param meshesNames defines the list of mesh's names you want to load
  77051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77052. * @param sceneFilename defines the filename or File of the scene to load from
  77053. */
  77054. constructor(
  77055. /**
  77056. * Defines the name of the task
  77057. */
  77058. name: string,
  77059. /**
  77060. * Defines the list of mesh's names you want to load
  77061. */
  77062. meshesNames: any,
  77063. /**
  77064. * Defines the root url to use as a base to load your meshes and associated resources
  77065. */
  77066. rootUrl: string,
  77067. /**
  77068. * Defines the filename or File of the scene to load from
  77069. */
  77070. sceneFilename: string | File);
  77071. /**
  77072. * Execute the current task
  77073. * @param scene defines the scene where you want your assets to be loaded
  77074. * @param onSuccess is a callback called when the task is successfully executed
  77075. * @param onError is a callback called if an error occurs
  77076. */
  77077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77078. }
  77079. /**
  77080. * Define a task used by AssetsManager to load meshes
  77081. */
  77082. export class MeshAssetTask extends AbstractAssetTask {
  77083. /**
  77084. * Defines the name of the task
  77085. */
  77086. name: string;
  77087. /**
  77088. * Defines the list of mesh's names you want to load
  77089. */
  77090. meshesNames: any;
  77091. /**
  77092. * Defines the root url to use as a base to load your meshes and associated resources
  77093. */
  77094. rootUrl: string;
  77095. /**
  77096. * Defines the filename or File of the scene to load from
  77097. */
  77098. sceneFilename: string | File;
  77099. /**
  77100. * Gets the list of loaded meshes
  77101. */
  77102. loadedMeshes: Array<AbstractMesh>;
  77103. /**
  77104. * Gets the list of loaded particle systems
  77105. */
  77106. loadedParticleSystems: Array<IParticleSystem>;
  77107. /**
  77108. * Gets the list of loaded skeletons
  77109. */
  77110. loadedSkeletons: Array<Skeleton>;
  77111. /**
  77112. * Gets the list of loaded animation groups
  77113. */
  77114. loadedAnimationGroups: Array<AnimationGroup>;
  77115. /**
  77116. * Callback called when the task is successful
  77117. */
  77118. onSuccess: (task: MeshAssetTask) => void;
  77119. /**
  77120. * Callback called when the task is successful
  77121. */
  77122. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77123. /**
  77124. * Creates a new MeshAssetTask
  77125. * @param name defines the name of the task
  77126. * @param meshesNames defines the list of mesh's names you want to load
  77127. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77128. * @param sceneFilename defines the filename or File of the scene to load from
  77129. */
  77130. constructor(
  77131. /**
  77132. * Defines the name of the task
  77133. */
  77134. name: string,
  77135. /**
  77136. * Defines the list of mesh's names you want to load
  77137. */
  77138. meshesNames: any,
  77139. /**
  77140. * Defines the root url to use as a base to load your meshes and associated resources
  77141. */
  77142. rootUrl: string,
  77143. /**
  77144. * Defines the filename or File of the scene to load from
  77145. */
  77146. sceneFilename: string | File);
  77147. /**
  77148. * Execute the current task
  77149. * @param scene defines the scene where you want your assets to be loaded
  77150. * @param onSuccess is a callback called when the task is successfully executed
  77151. * @param onError is a callback called if an error occurs
  77152. */
  77153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77154. }
  77155. /**
  77156. * Define a task used by AssetsManager to load text content
  77157. */
  77158. export class TextFileAssetTask extends AbstractAssetTask {
  77159. /**
  77160. * Defines the name of the task
  77161. */
  77162. name: string;
  77163. /**
  77164. * Defines the location of the file to load
  77165. */
  77166. url: string;
  77167. /**
  77168. * Gets the loaded text string
  77169. */
  77170. text: string;
  77171. /**
  77172. * Callback called when the task is successful
  77173. */
  77174. onSuccess: (task: TextFileAssetTask) => void;
  77175. /**
  77176. * Callback called when the task is successful
  77177. */
  77178. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77179. /**
  77180. * Creates a new TextFileAssetTask object
  77181. * @param name defines the name of the task
  77182. * @param url defines the location of the file to load
  77183. */
  77184. constructor(
  77185. /**
  77186. * Defines the name of the task
  77187. */
  77188. name: string,
  77189. /**
  77190. * Defines the location of the file to load
  77191. */
  77192. url: string);
  77193. /**
  77194. * Execute the current task
  77195. * @param scene defines the scene where you want your assets to be loaded
  77196. * @param onSuccess is a callback called when the task is successfully executed
  77197. * @param onError is a callback called if an error occurs
  77198. */
  77199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77200. }
  77201. /**
  77202. * Define a task used by AssetsManager to load binary data
  77203. */
  77204. export class BinaryFileAssetTask extends AbstractAssetTask {
  77205. /**
  77206. * Defines the name of the task
  77207. */
  77208. name: string;
  77209. /**
  77210. * Defines the location of the file to load
  77211. */
  77212. url: string;
  77213. /**
  77214. * Gets the lodaded data (as an array buffer)
  77215. */
  77216. data: ArrayBuffer;
  77217. /**
  77218. * Callback called when the task is successful
  77219. */
  77220. onSuccess: (task: BinaryFileAssetTask) => void;
  77221. /**
  77222. * Callback called when the task is successful
  77223. */
  77224. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77225. /**
  77226. * Creates a new BinaryFileAssetTask object
  77227. * @param name defines the name of the new task
  77228. * @param url defines the location of the file to load
  77229. */
  77230. constructor(
  77231. /**
  77232. * Defines the name of the task
  77233. */
  77234. name: string,
  77235. /**
  77236. * Defines the location of the file to load
  77237. */
  77238. url: string);
  77239. /**
  77240. * Execute the current task
  77241. * @param scene defines the scene where you want your assets to be loaded
  77242. * @param onSuccess is a callback called when the task is successfully executed
  77243. * @param onError is a callback called if an error occurs
  77244. */
  77245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77246. }
  77247. /**
  77248. * Define a task used by AssetsManager to load images
  77249. */
  77250. export class ImageAssetTask extends AbstractAssetTask {
  77251. /**
  77252. * Defines the name of the task
  77253. */
  77254. name: string;
  77255. /**
  77256. * Defines the location of the image to load
  77257. */
  77258. url: string;
  77259. /**
  77260. * Gets the loaded images
  77261. */
  77262. image: HTMLImageElement;
  77263. /**
  77264. * Callback called when the task is successful
  77265. */
  77266. onSuccess: (task: ImageAssetTask) => void;
  77267. /**
  77268. * Callback called when the task is successful
  77269. */
  77270. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77271. /**
  77272. * Creates a new ImageAssetTask
  77273. * @param name defines the name of the task
  77274. * @param url defines the location of the image to load
  77275. */
  77276. constructor(
  77277. /**
  77278. * Defines the name of the task
  77279. */
  77280. name: string,
  77281. /**
  77282. * Defines the location of the image to load
  77283. */
  77284. url: string);
  77285. /**
  77286. * Execute the current task
  77287. * @param scene defines the scene where you want your assets to be loaded
  77288. * @param onSuccess is a callback called when the task is successfully executed
  77289. * @param onError is a callback called if an error occurs
  77290. */
  77291. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77292. }
  77293. /**
  77294. * Defines the interface used by texture loading tasks
  77295. */
  77296. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77297. /**
  77298. * Gets the loaded texture
  77299. */
  77300. texture: TEX;
  77301. }
  77302. /**
  77303. * Define a task used by AssetsManager to load 2D textures
  77304. */
  77305. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77306. /**
  77307. * Defines the name of the task
  77308. */
  77309. name: string;
  77310. /**
  77311. * Defines the location of the file to load
  77312. */
  77313. url: string;
  77314. /**
  77315. * Defines if mipmap should not be generated (default is false)
  77316. */
  77317. noMipmap?: boolean | undefined;
  77318. /**
  77319. * Defines if texture must be inverted on Y axis (default is true)
  77320. */
  77321. invertY: boolean;
  77322. /**
  77323. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77324. */
  77325. samplingMode: number;
  77326. /**
  77327. * Gets the loaded texture
  77328. */
  77329. texture: Texture;
  77330. /**
  77331. * Callback called when the task is successful
  77332. */
  77333. onSuccess: (task: TextureAssetTask) => void;
  77334. /**
  77335. * Callback called when the task is successful
  77336. */
  77337. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77338. /**
  77339. * Creates a new TextureAssetTask object
  77340. * @param name defines the name of the task
  77341. * @param url defines the location of the file to load
  77342. * @param noMipmap defines if mipmap should not be generated (default is false)
  77343. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77344. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77345. */
  77346. constructor(
  77347. /**
  77348. * Defines the name of the task
  77349. */
  77350. name: string,
  77351. /**
  77352. * Defines the location of the file to load
  77353. */
  77354. url: string,
  77355. /**
  77356. * Defines if mipmap should not be generated (default is false)
  77357. */
  77358. noMipmap?: boolean | undefined,
  77359. /**
  77360. * Defines if texture must be inverted on Y axis (default is true)
  77361. */
  77362. invertY?: boolean,
  77363. /**
  77364. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77365. */
  77366. samplingMode?: number);
  77367. /**
  77368. * Execute the current task
  77369. * @param scene defines the scene where you want your assets to be loaded
  77370. * @param onSuccess is a callback called when the task is successfully executed
  77371. * @param onError is a callback called if an error occurs
  77372. */
  77373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77374. }
  77375. /**
  77376. * Define a task used by AssetsManager to load cube textures
  77377. */
  77378. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77379. /**
  77380. * Defines the name of the task
  77381. */
  77382. name: string;
  77383. /**
  77384. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77385. */
  77386. url: string;
  77387. /**
  77388. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77389. */
  77390. extensions?: string[] | undefined;
  77391. /**
  77392. * Defines if mipmaps should not be generated (default is false)
  77393. */
  77394. noMipmap?: boolean | undefined;
  77395. /**
  77396. * Defines the explicit list of files (undefined by default)
  77397. */
  77398. files?: string[] | undefined;
  77399. /**
  77400. * Gets the loaded texture
  77401. */
  77402. texture: CubeTexture;
  77403. /**
  77404. * Callback called when the task is successful
  77405. */
  77406. onSuccess: (task: CubeTextureAssetTask) => void;
  77407. /**
  77408. * Callback called when the task is successful
  77409. */
  77410. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77411. /**
  77412. * Creates a new CubeTextureAssetTask
  77413. * @param name defines the name of the task
  77414. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77415. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77416. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77417. * @param files defines the explicit list of files (undefined by default)
  77418. */
  77419. constructor(
  77420. /**
  77421. * Defines the name of the task
  77422. */
  77423. name: string,
  77424. /**
  77425. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77426. */
  77427. url: string,
  77428. /**
  77429. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77430. */
  77431. extensions?: string[] | undefined,
  77432. /**
  77433. * Defines if mipmaps should not be generated (default is false)
  77434. */
  77435. noMipmap?: boolean | undefined,
  77436. /**
  77437. * Defines the explicit list of files (undefined by default)
  77438. */
  77439. files?: string[] | undefined);
  77440. /**
  77441. * Execute the current task
  77442. * @param scene defines the scene where you want your assets to be loaded
  77443. * @param onSuccess is a callback called when the task is successfully executed
  77444. * @param onError is a callback called if an error occurs
  77445. */
  77446. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77447. }
  77448. /**
  77449. * Define a task used by AssetsManager to load HDR cube textures
  77450. */
  77451. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77452. /**
  77453. * Defines the name of the task
  77454. */
  77455. name: string;
  77456. /**
  77457. * Defines the location of the file to load
  77458. */
  77459. url: string;
  77460. /**
  77461. * Defines the desired size (the more it increases the longer the generation will be)
  77462. */
  77463. size: number;
  77464. /**
  77465. * Defines if mipmaps should not be generated (default is false)
  77466. */
  77467. noMipmap: boolean;
  77468. /**
  77469. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77470. */
  77471. generateHarmonics: boolean;
  77472. /**
  77473. * 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)
  77474. */
  77475. gammaSpace: boolean;
  77476. /**
  77477. * Internal Use Only
  77478. */
  77479. reserved: boolean;
  77480. /**
  77481. * Gets the loaded texture
  77482. */
  77483. texture: HDRCubeTexture;
  77484. /**
  77485. * Callback called when the task is successful
  77486. */
  77487. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77488. /**
  77489. * Callback called when the task is successful
  77490. */
  77491. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77492. /**
  77493. * Creates a new HDRCubeTextureAssetTask object
  77494. * @param name defines the name of the task
  77495. * @param url defines the location of the file to load
  77496. * @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.
  77497. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77498. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77499. * @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)
  77500. * @param reserved Internal use only
  77501. */
  77502. constructor(
  77503. /**
  77504. * Defines the name of the task
  77505. */
  77506. name: string,
  77507. /**
  77508. * Defines the location of the file to load
  77509. */
  77510. url: string,
  77511. /**
  77512. * Defines the desired size (the more it increases the longer the generation will be)
  77513. */
  77514. size: number,
  77515. /**
  77516. * Defines if mipmaps should not be generated (default is false)
  77517. */
  77518. noMipmap?: boolean,
  77519. /**
  77520. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77521. */
  77522. generateHarmonics?: boolean,
  77523. /**
  77524. * 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)
  77525. */
  77526. gammaSpace?: boolean,
  77527. /**
  77528. * Internal Use Only
  77529. */
  77530. reserved?: boolean);
  77531. /**
  77532. * Execute the current task
  77533. * @param scene defines the scene where you want your assets to be loaded
  77534. * @param onSuccess is a callback called when the task is successfully executed
  77535. * @param onError is a callback called if an error occurs
  77536. */
  77537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77538. }
  77539. /**
  77540. * Define a task used by AssetsManager to load Equirectangular cube textures
  77541. */
  77542. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77543. /**
  77544. * Defines the name of the task
  77545. */
  77546. name: string;
  77547. /**
  77548. * Defines the location of the file to load
  77549. */
  77550. url: string;
  77551. /**
  77552. * Defines the desired size (the more it increases the longer the generation will be)
  77553. */
  77554. size: number;
  77555. /**
  77556. * Defines if mipmaps should not be generated (default is false)
  77557. */
  77558. noMipmap: boolean;
  77559. /**
  77560. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77561. * but the standard material would require them in Gamma space) (default is true)
  77562. */
  77563. gammaSpace: boolean;
  77564. /**
  77565. * Gets the loaded texture
  77566. */
  77567. texture: EquiRectangularCubeTexture;
  77568. /**
  77569. * Callback called when the task is successful
  77570. */
  77571. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77572. /**
  77573. * Callback called when the task is successful
  77574. */
  77575. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77576. /**
  77577. * Creates a new EquiRectangularCubeTextureAssetTask object
  77578. * @param name defines the name of the task
  77579. * @param url defines the location of the file to load
  77580. * @param size defines the desired size (the more it increases the longer the generation will be)
  77581. * If the size is omitted this implies you are using a preprocessed cubemap.
  77582. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77583. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77584. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77585. * (default is true)
  77586. */
  77587. constructor(
  77588. /**
  77589. * Defines the name of the task
  77590. */
  77591. name: string,
  77592. /**
  77593. * Defines the location of the file to load
  77594. */
  77595. url: string,
  77596. /**
  77597. * Defines the desired size (the more it increases the longer the generation will be)
  77598. */
  77599. size: number,
  77600. /**
  77601. * Defines if mipmaps should not be generated (default is false)
  77602. */
  77603. noMipmap?: boolean,
  77604. /**
  77605. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77606. * but the standard material would require them in Gamma space) (default is true)
  77607. */
  77608. gammaSpace?: boolean);
  77609. /**
  77610. * Execute the current task
  77611. * @param scene defines the scene where you want your assets to be loaded
  77612. * @param onSuccess is a callback called when the task is successfully executed
  77613. * @param onError is a callback called if an error occurs
  77614. */
  77615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77616. }
  77617. /**
  77618. * This class can be used to easily import assets into a scene
  77619. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77620. */
  77621. export class AssetsManager {
  77622. private _scene;
  77623. private _isLoading;
  77624. protected _tasks: AbstractAssetTask[];
  77625. protected _waitingTasksCount: number;
  77626. protected _totalTasksCount: number;
  77627. /**
  77628. * Callback called when all tasks are processed
  77629. */
  77630. onFinish: (tasks: AbstractAssetTask[]) => void;
  77631. /**
  77632. * Callback called when a task is successful
  77633. */
  77634. onTaskSuccess: (task: AbstractAssetTask) => void;
  77635. /**
  77636. * Callback called when a task had an error
  77637. */
  77638. onTaskError: (task: AbstractAssetTask) => void;
  77639. /**
  77640. * Callback called when a task is done (whatever the result is)
  77641. */
  77642. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77643. /**
  77644. * Observable called when all tasks are processed
  77645. */
  77646. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77647. /**
  77648. * Observable called when a task had an error
  77649. */
  77650. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77651. /**
  77652. * Observable called when all tasks were executed
  77653. */
  77654. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77655. /**
  77656. * Observable called when a task is done (whatever the result is)
  77657. */
  77658. onProgressObservable: Observable<IAssetsProgressEvent>;
  77659. /**
  77660. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77661. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77662. */
  77663. useDefaultLoadingScreen: boolean;
  77664. /**
  77665. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77666. * when all assets have been downloaded.
  77667. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77668. */
  77669. autoHideLoadingUI: boolean;
  77670. /**
  77671. * Creates a new AssetsManager
  77672. * @param scene defines the scene to work on
  77673. */
  77674. constructor(scene: Scene);
  77675. /**
  77676. * Add a ContainerAssetTask to the list of active tasks
  77677. * @param taskName defines the name of the new task
  77678. * @param meshesNames defines the name of meshes to load
  77679. * @param rootUrl defines the root url to use to locate files
  77680. * @param sceneFilename defines the filename of the scene file
  77681. * @returns a new ContainerAssetTask object
  77682. */
  77683. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77684. /**
  77685. * Add a MeshAssetTask to the list of active tasks
  77686. * @param taskName defines the name of the new task
  77687. * @param meshesNames defines the name of meshes to load
  77688. * @param rootUrl defines the root url to use to locate files
  77689. * @param sceneFilename defines the filename of the scene file
  77690. * @returns a new MeshAssetTask object
  77691. */
  77692. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77693. /**
  77694. * Add a TextFileAssetTask to the list of active tasks
  77695. * @param taskName defines the name of the new task
  77696. * @param url defines the url of the file to load
  77697. * @returns a new TextFileAssetTask object
  77698. */
  77699. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77700. /**
  77701. * Add a BinaryFileAssetTask to the list of active tasks
  77702. * @param taskName defines the name of the new task
  77703. * @param url defines the url of the file to load
  77704. * @returns a new BinaryFileAssetTask object
  77705. */
  77706. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77707. /**
  77708. * Add a ImageAssetTask to the list of active tasks
  77709. * @param taskName defines the name of the new task
  77710. * @param url defines the url of the file to load
  77711. * @returns a new ImageAssetTask object
  77712. */
  77713. addImageTask(taskName: string, url: string): ImageAssetTask;
  77714. /**
  77715. * Add a TextureAssetTask to the list of active tasks
  77716. * @param taskName defines the name of the new task
  77717. * @param url defines the url of the file to load
  77718. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77719. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77720. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77721. * @returns a new TextureAssetTask object
  77722. */
  77723. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77724. /**
  77725. * Add a CubeTextureAssetTask to the list of active tasks
  77726. * @param taskName defines the name of the new task
  77727. * @param url defines the url of the file to load
  77728. * @param extensions defines the extension to use to load the cube map (can be null)
  77729. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77730. * @param files defines the list of files to load (can be null)
  77731. * @returns a new CubeTextureAssetTask object
  77732. */
  77733. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77734. /**
  77735. *
  77736. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77737. * @param taskName defines the name of the new task
  77738. * @param url defines the url of the file to load
  77739. * @param size defines the size you want for the cubemap (can be null)
  77740. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77741. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77742. * @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)
  77743. * @param reserved Internal use only
  77744. * @returns a new HDRCubeTextureAssetTask object
  77745. */
  77746. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77747. /**
  77748. *
  77749. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77750. * @param taskName defines the name of the new task
  77751. * @param url defines the url of the file to load
  77752. * @param size defines the size you want for the cubemap (can be null)
  77753. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77754. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77755. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77756. * @returns a new EquiRectangularCubeTextureAssetTask object
  77757. */
  77758. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77759. /**
  77760. * Remove a task from the assets manager.
  77761. * @param task the task to remove
  77762. */
  77763. removeTask(task: AbstractAssetTask): void;
  77764. private _decreaseWaitingTasksCount;
  77765. private _runTask;
  77766. /**
  77767. * Reset the AssetsManager and remove all tasks
  77768. * @return the current instance of the AssetsManager
  77769. */
  77770. reset(): AssetsManager;
  77771. /**
  77772. * Start the loading process
  77773. * @return the current instance of the AssetsManager
  77774. */
  77775. load(): AssetsManager;
  77776. /**
  77777. * Start the loading process as an async operation
  77778. * @return a promise returning the list of failed tasks
  77779. */
  77780. loadAsync(): Promise<void>;
  77781. }
  77782. }
  77783. declare module "babylonjs/Misc/deferred" {
  77784. /**
  77785. * Wrapper class for promise with external resolve and reject.
  77786. */
  77787. export class Deferred<T> {
  77788. /**
  77789. * The promise associated with this deferred object.
  77790. */
  77791. readonly promise: Promise<T>;
  77792. private _resolve;
  77793. private _reject;
  77794. /**
  77795. * The resolve method of the promise associated with this deferred object.
  77796. */
  77797. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77798. /**
  77799. * The reject method of the promise associated with this deferred object.
  77800. */
  77801. get reject(): (reason?: any) => void;
  77802. /**
  77803. * Constructor for this deferred object.
  77804. */
  77805. constructor();
  77806. }
  77807. }
  77808. declare module "babylonjs/Misc/meshExploder" {
  77809. import { Mesh } from "babylonjs/Meshes/mesh";
  77810. /**
  77811. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77812. */
  77813. export class MeshExploder {
  77814. private _centerMesh;
  77815. private _meshes;
  77816. private _meshesOrigins;
  77817. private _toCenterVectors;
  77818. private _scaledDirection;
  77819. private _newPosition;
  77820. private _centerPosition;
  77821. /**
  77822. * Explodes meshes from a center mesh.
  77823. * @param meshes The meshes to explode.
  77824. * @param centerMesh The mesh to be center of explosion.
  77825. */
  77826. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77827. private _setCenterMesh;
  77828. /**
  77829. * Get class name
  77830. * @returns "MeshExploder"
  77831. */
  77832. getClassName(): string;
  77833. /**
  77834. * "Exploded meshes"
  77835. * @returns Array of meshes with the centerMesh at index 0.
  77836. */
  77837. getMeshes(): Array<Mesh>;
  77838. /**
  77839. * Explodes meshes giving a specific direction
  77840. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77841. */
  77842. explode(direction?: number): void;
  77843. }
  77844. }
  77845. declare module "babylonjs/Misc/filesInput" {
  77846. import { Engine } from "babylonjs/Engines/engine";
  77847. import { Scene } from "babylonjs/scene";
  77848. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77849. import { Nullable } from "babylonjs/types";
  77850. /**
  77851. * Class used to help managing file picking and drag'n'drop
  77852. */
  77853. export class FilesInput {
  77854. /**
  77855. * List of files ready to be loaded
  77856. */
  77857. static get FilesToLoad(): {
  77858. [key: string]: File;
  77859. };
  77860. /**
  77861. * Callback called when a file is processed
  77862. */
  77863. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77864. private _engine;
  77865. private _currentScene;
  77866. private _sceneLoadedCallback;
  77867. private _progressCallback;
  77868. private _additionalRenderLoopLogicCallback;
  77869. private _textureLoadingCallback;
  77870. private _startingProcessingFilesCallback;
  77871. private _onReloadCallback;
  77872. private _errorCallback;
  77873. private _elementToMonitor;
  77874. private _sceneFileToLoad;
  77875. private _filesToLoad;
  77876. /**
  77877. * Creates a new FilesInput
  77878. * @param engine defines the rendering engine
  77879. * @param scene defines the hosting scene
  77880. * @param sceneLoadedCallback callback called when scene is loaded
  77881. * @param progressCallback callback called to track progress
  77882. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77883. * @param textureLoadingCallback callback called when a texture is loading
  77884. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77885. * @param onReloadCallback callback called when a reload is requested
  77886. * @param errorCallback callback call if an error occurs
  77887. */
  77888. 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>);
  77889. private _dragEnterHandler;
  77890. private _dragOverHandler;
  77891. private _dropHandler;
  77892. /**
  77893. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77894. * @param elementToMonitor defines the DOM element to track
  77895. */
  77896. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77897. /** Gets the current list of files to load */
  77898. get filesToLoad(): File[];
  77899. /**
  77900. * Release all associated resources
  77901. */
  77902. dispose(): void;
  77903. private renderFunction;
  77904. private drag;
  77905. private drop;
  77906. private _traverseFolder;
  77907. private _processFiles;
  77908. /**
  77909. * Load files from a drop event
  77910. * @param event defines the drop event to use as source
  77911. */
  77912. loadFiles(event: any): void;
  77913. private _processReload;
  77914. /**
  77915. * Reload the current scene from the loaded files
  77916. */
  77917. reload(): void;
  77918. }
  77919. }
  77920. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77921. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77922. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77923. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77924. }
  77925. declare module "babylonjs/Misc/sceneOptimizer" {
  77926. import { Scene, IDisposable } from "babylonjs/scene";
  77927. import { Observable } from "babylonjs/Misc/observable";
  77928. /**
  77929. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77930. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77931. */
  77932. export class SceneOptimization {
  77933. /**
  77934. * Defines the priority of this optimization (0 by default which means first in the list)
  77935. */
  77936. priority: number;
  77937. /**
  77938. * Gets a string describing the action executed by the current optimization
  77939. * @returns description string
  77940. */
  77941. getDescription(): string;
  77942. /**
  77943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77944. * @param scene defines the current scene where to apply this optimization
  77945. * @param optimizer defines the current optimizer
  77946. * @returns true if everything that can be done was applied
  77947. */
  77948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77949. /**
  77950. * Creates the SceneOptimization object
  77951. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77952. * @param desc defines the description associated with the optimization
  77953. */
  77954. constructor(
  77955. /**
  77956. * Defines the priority of this optimization (0 by default which means first in the list)
  77957. */
  77958. priority?: number);
  77959. }
  77960. /**
  77961. * Defines an optimization used to reduce the size of render target textures
  77962. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77963. */
  77964. export class TextureOptimization extends SceneOptimization {
  77965. /**
  77966. * Defines the priority of this optimization (0 by default which means first in the list)
  77967. */
  77968. priority: number;
  77969. /**
  77970. * 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
  77971. */
  77972. maximumSize: number;
  77973. /**
  77974. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77975. */
  77976. step: number;
  77977. /**
  77978. * Gets a string describing the action executed by the current optimization
  77979. * @returns description string
  77980. */
  77981. getDescription(): string;
  77982. /**
  77983. * Creates the TextureOptimization object
  77984. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77985. * @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
  77986. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77987. */
  77988. constructor(
  77989. /**
  77990. * Defines the priority of this optimization (0 by default which means first in the list)
  77991. */
  77992. priority?: number,
  77993. /**
  77994. * 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
  77995. */
  77996. maximumSize?: number,
  77997. /**
  77998. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77999. */
  78000. step?: number);
  78001. /**
  78002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78003. * @param scene defines the current scene where to apply this optimization
  78004. * @param optimizer defines the current optimizer
  78005. * @returns true if everything that can be done was applied
  78006. */
  78007. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78008. }
  78009. /**
  78010. * Defines an optimization used to increase or decrease the rendering resolution
  78011. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78012. */
  78013. export class HardwareScalingOptimization extends SceneOptimization {
  78014. /**
  78015. * Defines the priority of this optimization (0 by default which means first in the list)
  78016. */
  78017. priority: number;
  78018. /**
  78019. * Defines the maximum scale to use (2 by default)
  78020. */
  78021. maximumScale: number;
  78022. /**
  78023. * Defines the step to use between two passes (0.5 by default)
  78024. */
  78025. step: number;
  78026. private _currentScale;
  78027. private _directionOffset;
  78028. /**
  78029. * Gets a string describing the action executed by the current optimization
  78030. * @return description string
  78031. */
  78032. getDescription(): string;
  78033. /**
  78034. * Creates the HardwareScalingOptimization object
  78035. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78036. * @param maximumScale defines the maximum scale to use (2 by default)
  78037. * @param step defines the step to use between two passes (0.5 by default)
  78038. */
  78039. constructor(
  78040. /**
  78041. * Defines the priority of this optimization (0 by default which means first in the list)
  78042. */
  78043. priority?: number,
  78044. /**
  78045. * Defines the maximum scale to use (2 by default)
  78046. */
  78047. maximumScale?: number,
  78048. /**
  78049. * Defines the step to use between two passes (0.5 by default)
  78050. */
  78051. step?: number);
  78052. /**
  78053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78054. * @param scene defines the current scene where to apply this optimization
  78055. * @param optimizer defines the current optimizer
  78056. * @returns true if everything that can be done was applied
  78057. */
  78058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78059. }
  78060. /**
  78061. * Defines an optimization used to remove shadows
  78062. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78063. */
  78064. export class ShadowsOptimization extends SceneOptimization {
  78065. /**
  78066. * Gets a string describing the action executed by the current optimization
  78067. * @return description string
  78068. */
  78069. getDescription(): string;
  78070. /**
  78071. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78072. * @param scene defines the current scene where to apply this optimization
  78073. * @param optimizer defines the current optimizer
  78074. * @returns true if everything that can be done was applied
  78075. */
  78076. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78077. }
  78078. /**
  78079. * Defines an optimization used to turn post-processes off
  78080. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78081. */
  78082. export class PostProcessesOptimization extends SceneOptimization {
  78083. /**
  78084. * Gets a string describing the action executed by the current optimization
  78085. * @return description string
  78086. */
  78087. getDescription(): string;
  78088. /**
  78089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78090. * @param scene defines the current scene where to apply this optimization
  78091. * @param optimizer defines the current optimizer
  78092. * @returns true if everything that can be done was applied
  78093. */
  78094. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78095. }
  78096. /**
  78097. * Defines an optimization used to turn lens flares off
  78098. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78099. */
  78100. export class LensFlaresOptimization extends SceneOptimization {
  78101. /**
  78102. * Gets a string describing the action executed by the current optimization
  78103. * @return description string
  78104. */
  78105. getDescription(): string;
  78106. /**
  78107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78108. * @param scene defines the current scene where to apply this optimization
  78109. * @param optimizer defines the current optimizer
  78110. * @returns true if everything that can be done was applied
  78111. */
  78112. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78113. }
  78114. /**
  78115. * Defines an optimization based on user defined callback.
  78116. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78117. */
  78118. export class CustomOptimization extends SceneOptimization {
  78119. /**
  78120. * Callback called to apply the custom optimization.
  78121. */
  78122. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78123. /**
  78124. * Callback called to get custom description
  78125. */
  78126. onGetDescription: () => string;
  78127. /**
  78128. * Gets a string describing the action executed by the current optimization
  78129. * @returns description string
  78130. */
  78131. getDescription(): string;
  78132. /**
  78133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78134. * @param scene defines the current scene where to apply this optimization
  78135. * @param optimizer defines the current optimizer
  78136. * @returns true if everything that can be done was applied
  78137. */
  78138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78139. }
  78140. /**
  78141. * Defines an optimization used to turn particles off
  78142. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78143. */
  78144. export class ParticlesOptimization extends SceneOptimization {
  78145. /**
  78146. * Gets a string describing the action executed by the current optimization
  78147. * @return description string
  78148. */
  78149. getDescription(): string;
  78150. /**
  78151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78152. * @param scene defines the current scene where to apply this optimization
  78153. * @param optimizer defines the current optimizer
  78154. * @returns true if everything that can be done was applied
  78155. */
  78156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78157. }
  78158. /**
  78159. * Defines an optimization used to turn render targets off
  78160. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78161. */
  78162. export class RenderTargetsOptimization extends SceneOptimization {
  78163. /**
  78164. * Gets a string describing the action executed by the current optimization
  78165. * @return description string
  78166. */
  78167. getDescription(): string;
  78168. /**
  78169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78170. * @param scene defines the current scene where to apply this optimization
  78171. * @param optimizer defines the current optimizer
  78172. * @returns true if everything that can be done was applied
  78173. */
  78174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78175. }
  78176. /**
  78177. * Defines an optimization used to merge meshes with compatible materials
  78178. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78179. */
  78180. export class MergeMeshesOptimization extends SceneOptimization {
  78181. private static _UpdateSelectionTree;
  78182. /**
  78183. * Gets or sets a boolean which defines if optimization octree has to be updated
  78184. */
  78185. static get UpdateSelectionTree(): boolean;
  78186. /**
  78187. * Gets or sets a boolean which defines if optimization octree has to be updated
  78188. */
  78189. static set UpdateSelectionTree(value: boolean);
  78190. /**
  78191. * Gets a string describing the action executed by the current optimization
  78192. * @return description string
  78193. */
  78194. getDescription(): string;
  78195. private _canBeMerged;
  78196. /**
  78197. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78198. * @param scene defines the current scene where to apply this optimization
  78199. * @param optimizer defines the current optimizer
  78200. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78201. * @returns true if everything that can be done was applied
  78202. */
  78203. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78204. }
  78205. /**
  78206. * Defines a list of options used by SceneOptimizer
  78207. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78208. */
  78209. export class SceneOptimizerOptions {
  78210. /**
  78211. * Defines the target frame rate to reach (60 by default)
  78212. */
  78213. targetFrameRate: number;
  78214. /**
  78215. * Defines the interval between two checkes (2000ms by default)
  78216. */
  78217. trackerDuration: number;
  78218. /**
  78219. * Gets the list of optimizations to apply
  78220. */
  78221. optimizations: SceneOptimization[];
  78222. /**
  78223. * Creates a new list of options used by SceneOptimizer
  78224. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78225. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78226. */
  78227. constructor(
  78228. /**
  78229. * Defines the target frame rate to reach (60 by default)
  78230. */
  78231. targetFrameRate?: number,
  78232. /**
  78233. * Defines the interval between two checkes (2000ms by default)
  78234. */
  78235. trackerDuration?: number);
  78236. /**
  78237. * Add a new optimization
  78238. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78239. * @returns the current SceneOptimizerOptions
  78240. */
  78241. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78242. /**
  78243. * Add a new custom optimization
  78244. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78245. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78246. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78247. * @returns the current SceneOptimizerOptions
  78248. */
  78249. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78250. /**
  78251. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78252. * @param targetFrameRate defines the target frame rate (60 by default)
  78253. * @returns a SceneOptimizerOptions object
  78254. */
  78255. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78256. /**
  78257. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78258. * @param targetFrameRate defines the target frame rate (60 by default)
  78259. * @returns a SceneOptimizerOptions object
  78260. */
  78261. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78262. /**
  78263. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78264. * @param targetFrameRate defines the target frame rate (60 by default)
  78265. * @returns a SceneOptimizerOptions object
  78266. */
  78267. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78268. }
  78269. /**
  78270. * Class used to run optimizations in order to reach a target frame rate
  78271. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78272. */
  78273. export class SceneOptimizer implements IDisposable {
  78274. private _isRunning;
  78275. private _options;
  78276. private _scene;
  78277. private _currentPriorityLevel;
  78278. private _targetFrameRate;
  78279. private _trackerDuration;
  78280. private _currentFrameRate;
  78281. private _sceneDisposeObserver;
  78282. private _improvementMode;
  78283. /**
  78284. * Defines an observable called when the optimizer reaches the target frame rate
  78285. */
  78286. onSuccessObservable: Observable<SceneOptimizer>;
  78287. /**
  78288. * Defines an observable called when the optimizer enables an optimization
  78289. */
  78290. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78291. /**
  78292. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78293. */
  78294. onFailureObservable: Observable<SceneOptimizer>;
  78295. /**
  78296. * Gets a boolean indicating if the optimizer is in improvement mode
  78297. */
  78298. get isInImprovementMode(): boolean;
  78299. /**
  78300. * Gets the current priority level (0 at start)
  78301. */
  78302. get currentPriorityLevel(): number;
  78303. /**
  78304. * Gets the current frame rate checked by the SceneOptimizer
  78305. */
  78306. get currentFrameRate(): number;
  78307. /**
  78308. * Gets or sets the current target frame rate (60 by default)
  78309. */
  78310. get targetFrameRate(): number;
  78311. /**
  78312. * Gets or sets the current target frame rate (60 by default)
  78313. */
  78314. set targetFrameRate(value: number);
  78315. /**
  78316. * Gets or sets the current interval between two checks (every 2000ms by default)
  78317. */
  78318. get trackerDuration(): number;
  78319. /**
  78320. * Gets or sets the current interval between two checks (every 2000ms by default)
  78321. */
  78322. set trackerDuration(value: number);
  78323. /**
  78324. * Gets the list of active optimizations
  78325. */
  78326. get optimizations(): SceneOptimization[];
  78327. /**
  78328. * Creates a new SceneOptimizer
  78329. * @param scene defines the scene to work on
  78330. * @param options defines the options to use with the SceneOptimizer
  78331. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78332. * @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)
  78333. */
  78334. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78335. /**
  78336. * Stops the current optimizer
  78337. */
  78338. stop(): void;
  78339. /**
  78340. * Reset the optimizer to initial step (current priority level = 0)
  78341. */
  78342. reset(): void;
  78343. /**
  78344. * Start the optimizer. By default it will try to reach a specific framerate
  78345. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78346. */
  78347. start(): void;
  78348. private _checkCurrentState;
  78349. /**
  78350. * Release all resources
  78351. */
  78352. dispose(): void;
  78353. /**
  78354. * Helper function to create a SceneOptimizer with one single line of code
  78355. * @param scene defines the scene to work on
  78356. * @param options defines the options to use with the SceneOptimizer
  78357. * @param onSuccess defines a callback to call on success
  78358. * @param onFailure defines a callback to call on failure
  78359. * @returns the new SceneOptimizer object
  78360. */
  78361. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78362. }
  78363. }
  78364. declare module "babylonjs/Misc/sceneSerializer" {
  78365. import { Scene } from "babylonjs/scene";
  78366. /**
  78367. * Class used to serialize a scene into a string
  78368. */
  78369. export class SceneSerializer {
  78370. /**
  78371. * Clear cache used by a previous serialization
  78372. */
  78373. static ClearCache(): void;
  78374. /**
  78375. * Serialize a scene into a JSON compatible object
  78376. * @param scene defines the scene to serialize
  78377. * @returns a JSON compatible object
  78378. */
  78379. static Serialize(scene: Scene): any;
  78380. /**
  78381. * Serialize a mesh into a JSON compatible object
  78382. * @param toSerialize defines the mesh to serialize
  78383. * @param withParents defines if parents must be serialized as well
  78384. * @param withChildren defines if children must be serialized as well
  78385. * @returns a JSON compatible object
  78386. */
  78387. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78388. }
  78389. }
  78390. declare module "babylonjs/Misc/textureTools" {
  78391. import { Texture } from "babylonjs/Materials/Textures/texture";
  78392. /**
  78393. * Class used to host texture specific utilities
  78394. */
  78395. export class TextureTools {
  78396. /**
  78397. * Uses the GPU to create a copy texture rescaled at a given size
  78398. * @param texture Texture to copy from
  78399. * @param width defines the desired width
  78400. * @param height defines the desired height
  78401. * @param useBilinearMode defines if bilinear mode has to be used
  78402. * @return the generated texture
  78403. */
  78404. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78405. }
  78406. }
  78407. declare module "babylonjs/Misc/videoRecorder" {
  78408. import { Nullable } from "babylonjs/types";
  78409. import { Engine } from "babylonjs/Engines/engine";
  78410. /**
  78411. * This represents the different options available for the video capture.
  78412. */
  78413. export interface VideoRecorderOptions {
  78414. /** Defines the mime type of the video. */
  78415. mimeType: string;
  78416. /** Defines the FPS the video should be recorded at. */
  78417. fps: number;
  78418. /** Defines the chunk size for the recording data. */
  78419. recordChunckSize: number;
  78420. /** The audio tracks to attach to the recording. */
  78421. audioTracks?: MediaStreamTrack[];
  78422. }
  78423. /**
  78424. * This can help with recording videos from BabylonJS.
  78425. * This is based on the available WebRTC functionalities of the browser.
  78426. *
  78427. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78428. */
  78429. export class VideoRecorder {
  78430. private static readonly _defaultOptions;
  78431. /**
  78432. * Returns whether or not the VideoRecorder is available in your browser.
  78433. * @param engine Defines the Babylon Engine.
  78434. * @returns true if supported otherwise false.
  78435. */
  78436. static IsSupported(engine: Engine): boolean;
  78437. private readonly _options;
  78438. private _canvas;
  78439. private _mediaRecorder;
  78440. private _recordedChunks;
  78441. private _fileName;
  78442. private _resolve;
  78443. private _reject;
  78444. /**
  78445. * True when a recording is already in progress.
  78446. */
  78447. get isRecording(): boolean;
  78448. /**
  78449. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78450. * @param engine Defines the BabylonJS Engine you wish to record.
  78451. * @param options Defines options that can be used to customize the capture.
  78452. */
  78453. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78454. /**
  78455. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78456. */
  78457. stopRecording(): void;
  78458. /**
  78459. * Starts recording the canvas for a max duration specified in parameters.
  78460. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78461. * If null no automatic download will start and you can rely on the promise to get the data back.
  78462. * @param maxDuration Defines the maximum recording time in seconds.
  78463. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78464. * @return A promise callback at the end of the recording with the video data in Blob.
  78465. */
  78466. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78467. /**
  78468. * Releases internal resources used during the recording.
  78469. */
  78470. dispose(): void;
  78471. private _handleDataAvailable;
  78472. private _handleError;
  78473. private _handleStop;
  78474. }
  78475. }
  78476. declare module "babylonjs/Misc/screenshotTools" {
  78477. import { Camera } from "babylonjs/Cameras/camera";
  78478. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78479. import { Engine } from "babylonjs/Engines/engine";
  78480. /**
  78481. * Class containing a set of static utilities functions for screenshots
  78482. */
  78483. export class ScreenshotTools {
  78484. /**
  78485. * Captures a screenshot of the current rendering
  78486. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78487. * @param engine defines the rendering engine
  78488. * @param camera defines the source camera
  78489. * @param size This parameter can be set to a single number or to an object with the
  78490. * following (optional) properties: precision, width, height. If a single number is passed,
  78491. * it will be used for both width and height. If an object is passed, the screenshot size
  78492. * will be derived from the parameters. The precision property is a multiplier allowing
  78493. * rendering at a higher or lower resolution
  78494. * @param successCallback defines the callback receives a single parameter which contains the
  78495. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78496. * src parameter of an <img> to display it
  78497. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78498. * Check your browser for supported MIME types
  78499. */
  78500. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78501. /**
  78502. * Captures a screenshot of the current rendering
  78503. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78504. * @param engine defines the rendering engine
  78505. * @param camera defines the source camera
  78506. * @param size This parameter can be set to a single number or to an object with the
  78507. * following (optional) properties: precision, width, height. If a single number is passed,
  78508. * it will be used for both width and height. If an object is passed, the screenshot size
  78509. * will be derived from the parameters. The precision property is a multiplier allowing
  78510. * rendering at a higher or lower resolution
  78511. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78512. * Check your browser for supported MIME types
  78513. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78514. * to the src parameter of an <img> to display it
  78515. */
  78516. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78517. /**
  78518. * Generates an image screenshot from the specified camera.
  78519. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78520. * @param engine The engine to use for rendering
  78521. * @param camera The camera to use for rendering
  78522. * @param size This parameter can be set to a single number or to an object with the
  78523. * following (optional) properties: precision, width, height. If a single number is passed,
  78524. * it will be used for both width and height. If an object is passed, the screenshot size
  78525. * will be derived from the parameters. The precision property is a multiplier allowing
  78526. * rendering at a higher or lower resolution
  78527. * @param successCallback The callback receives a single parameter which contains the
  78528. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78529. * src parameter of an <img> to display it
  78530. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78531. * Check your browser for supported MIME types
  78532. * @param samples Texture samples (default: 1)
  78533. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78534. * @param fileName A name for for the downloaded file.
  78535. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78536. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78537. */
  78538. 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;
  78539. /**
  78540. * Generates an image screenshot from the specified camera.
  78541. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78542. * @param engine The engine to use for rendering
  78543. * @param camera The camera to use for rendering
  78544. * @param size This parameter can be set to a single number or to an object with the
  78545. * following (optional) properties: precision, width, height. If a single number is passed,
  78546. * it will be used for both width and height. If an object is passed, the screenshot size
  78547. * will be derived from the parameters. The precision property is a multiplier allowing
  78548. * rendering at a higher or lower resolution
  78549. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78550. * Check your browser for supported MIME types
  78551. * @param samples Texture samples (default: 1)
  78552. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78553. * @param fileName A name for for the downloaded file.
  78554. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78555. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78556. * to the src parameter of an <img> to display it
  78557. */
  78558. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78559. /**
  78560. * Gets height and width for screenshot size
  78561. * @private
  78562. */
  78563. private static _getScreenshotSize;
  78564. }
  78565. }
  78566. declare module "babylonjs/Misc/dataReader" {
  78567. /**
  78568. * Interface for a data buffer
  78569. */
  78570. export interface IDataBuffer {
  78571. /**
  78572. * Reads bytes from the data buffer.
  78573. * @param byteOffset The byte offset to read
  78574. * @param byteLength The byte length to read
  78575. * @returns A promise that resolves when the bytes are read
  78576. */
  78577. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78578. /**
  78579. * The byte length of the buffer.
  78580. */
  78581. readonly byteLength: number;
  78582. }
  78583. /**
  78584. * Utility class for reading from a data buffer
  78585. */
  78586. export class DataReader {
  78587. /**
  78588. * The data buffer associated with this data reader.
  78589. */
  78590. readonly buffer: IDataBuffer;
  78591. /**
  78592. * The current byte offset from the beginning of the data buffer.
  78593. */
  78594. byteOffset: number;
  78595. private _dataView;
  78596. private _dataByteOffset;
  78597. /**
  78598. * Constructor
  78599. * @param buffer The buffer to read
  78600. */
  78601. constructor(buffer: IDataBuffer);
  78602. /**
  78603. * Loads the given byte length.
  78604. * @param byteLength The byte length to load
  78605. * @returns A promise that resolves when the load is complete
  78606. */
  78607. loadAsync(byteLength: number): Promise<void>;
  78608. /**
  78609. * Read a unsigned 32-bit integer from the currently loaded data range.
  78610. * @returns The 32-bit integer read
  78611. */
  78612. readUint32(): number;
  78613. /**
  78614. * Read a byte array from the currently loaded data range.
  78615. * @param byteLength The byte length to read
  78616. * @returns The byte array read
  78617. */
  78618. readUint8Array(byteLength: number): Uint8Array;
  78619. /**
  78620. * Read a string from the currently loaded data range.
  78621. * @param byteLength The byte length to read
  78622. * @returns The string read
  78623. */
  78624. readString(byteLength: number): string;
  78625. /**
  78626. * Skips the given byte length the currently loaded data range.
  78627. * @param byteLength The byte length to skip
  78628. */
  78629. skipBytes(byteLength: number): void;
  78630. }
  78631. }
  78632. declare module "babylonjs/Misc/dataStorage" {
  78633. /**
  78634. * Class for storing data to local storage if available or in-memory storage otherwise
  78635. */
  78636. export class DataStorage {
  78637. private static _Storage;
  78638. private static _GetStorage;
  78639. /**
  78640. * Reads a string from the data storage
  78641. * @param key The key to read
  78642. * @param defaultValue The value if the key doesn't exist
  78643. * @returns The string value
  78644. */
  78645. static ReadString(key: string, defaultValue: string): string;
  78646. /**
  78647. * Writes a string to the data storage
  78648. * @param key The key to write
  78649. * @param value The value to write
  78650. */
  78651. static WriteString(key: string, value: string): void;
  78652. /**
  78653. * Reads a boolean from the data storage
  78654. * @param key The key to read
  78655. * @param defaultValue The value if the key doesn't exist
  78656. * @returns The boolean value
  78657. */
  78658. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78659. /**
  78660. * Writes a boolean to the data storage
  78661. * @param key The key to write
  78662. * @param value The value to write
  78663. */
  78664. static WriteBoolean(key: string, value: boolean): void;
  78665. /**
  78666. * Reads a number from the data storage
  78667. * @param key The key to read
  78668. * @param defaultValue The value if the key doesn't exist
  78669. * @returns The number value
  78670. */
  78671. static ReadNumber(key: string, defaultValue: number): number;
  78672. /**
  78673. * Writes a number to the data storage
  78674. * @param key The key to write
  78675. * @param value The value to write
  78676. */
  78677. static WriteNumber(key: string, value: number): void;
  78678. }
  78679. }
  78680. declare module "babylonjs/Misc/sceneRecorder" {
  78681. import { Scene } from "babylonjs/scene";
  78682. /**
  78683. * Class used to record delta files between 2 scene states
  78684. */
  78685. export class SceneRecorder {
  78686. private _trackedScene;
  78687. private _savedJSON;
  78688. /**
  78689. * Track a given scene. This means the current scene state will be considered the original state
  78690. * @param scene defines the scene to track
  78691. */
  78692. track(scene: Scene): void;
  78693. /**
  78694. * Get the delta between current state and original state
  78695. * @returns a string containing the delta
  78696. */
  78697. getDelta(): any;
  78698. private _compareArray;
  78699. private _compareObjects;
  78700. private _compareCollections;
  78701. private static GetShadowGeneratorById;
  78702. /**
  78703. * Apply a given delta to a given scene
  78704. * @param deltaJSON defines the JSON containing the delta
  78705. * @param scene defines the scene to apply the delta to
  78706. */
  78707. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78708. private static _ApplyPropertiesToEntity;
  78709. private static _ApplyDeltaForEntity;
  78710. }
  78711. }
  78712. declare module "babylonjs/Misc/trajectoryClassifier" {
  78713. import { DeepImmutable, Nullable } from "babylonjs/types";
  78714. import { Vector3 } from "babylonjs/Maths/math.vector";
  78715. /**
  78716. * A 3D trajectory consisting of an order list of vectors describing a
  78717. * path of motion through 3D space.
  78718. */
  78719. export class Trajectory {
  78720. private _points;
  78721. private readonly _segmentLength;
  78722. /**
  78723. * Serialize to JSON.
  78724. * @returns serialized JSON string
  78725. */
  78726. serialize(): string;
  78727. /**
  78728. * Deserialize from JSON.
  78729. * @param json serialized JSON string
  78730. * @returns deserialized Trajectory
  78731. */
  78732. static Deserialize(json: string): Trajectory;
  78733. /**
  78734. * Create a new empty Trajectory.
  78735. * @param segmentLength radius of discretization for Trajectory points
  78736. */
  78737. constructor(segmentLength?: number);
  78738. /**
  78739. * Get the length of the Trajectory.
  78740. * @returns length of the Trajectory
  78741. */
  78742. getLength(): number;
  78743. /**
  78744. * Append a new point to the Trajectory.
  78745. * NOTE: This implementation has many allocations.
  78746. * @param point point to append to the Trajectory
  78747. */
  78748. add(point: DeepImmutable<Vector3>): void;
  78749. /**
  78750. * Create a new Trajectory with a segment length chosen to make it
  78751. * probable that the new Trajectory will have a specified number of
  78752. * segments. This operation is imprecise.
  78753. * @param targetResolution number of segments desired
  78754. * @returns new Trajectory with approximately the requested number of segments
  78755. */
  78756. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78757. /**
  78758. * Convert Trajectory segments into tokenized representation. This
  78759. * representation is an array of numbers where each nth number is the
  78760. * index of the token which is most similar to the nth segment of the
  78761. * Trajectory.
  78762. * @param tokens list of vectors which serve as discrete tokens
  78763. * @returns list of indices of most similar token per segment
  78764. */
  78765. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78766. private static _forwardDir;
  78767. private static _inverseFromVec;
  78768. private static _upDir;
  78769. private static _fromToVec;
  78770. private static _lookMatrix;
  78771. /**
  78772. * Transform the rotation (i.e., direction) of a segment to isolate
  78773. * the relative transformation represented by the segment. This operation
  78774. * may or may not succeed due to singularities in the equations that define
  78775. * motion relativity in this context.
  78776. * @param priorVec the origin of the prior segment
  78777. * @param fromVec the origin of the current segment
  78778. * @param toVec the destination of the current segment
  78779. * @param result reference to output variable
  78780. * @returns whether or not transformation was successful
  78781. */
  78782. private static _transformSegmentDirToRef;
  78783. private static _bestMatch;
  78784. private static _score;
  78785. private static _bestScore;
  78786. /**
  78787. * Determine which token vector is most similar to the
  78788. * segment vector.
  78789. * @param segment segment vector
  78790. * @param tokens token vector list
  78791. * @returns index of the most similar token to the segment
  78792. */
  78793. private static _tokenizeSegment;
  78794. }
  78795. /**
  78796. * Class representing a set of known, named trajectories to which Trajectories can be
  78797. * added and using which Trajectories can be recognized.
  78798. */
  78799. export class TrajectoryClassifier {
  78800. private _maximumAllowableMatchCost;
  78801. private _vector3Alphabet;
  78802. private _levenshteinAlphabet;
  78803. private _nameToDescribedTrajectory;
  78804. /**
  78805. * Serialize to JSON.
  78806. * @returns JSON serialization
  78807. */
  78808. serialize(): string;
  78809. /**
  78810. * Deserialize from JSON.
  78811. * @param json JSON serialization
  78812. * @returns deserialized TrajectorySet
  78813. */
  78814. static Deserialize(json: string): TrajectoryClassifier;
  78815. /**
  78816. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78817. * VERY naive, need to be generating these things from known
  78818. * sets. Better version later, probably eliminating this one.
  78819. * @returns auto-generated TrajectorySet
  78820. */
  78821. static Generate(): TrajectoryClassifier;
  78822. private constructor();
  78823. /**
  78824. * Add a new Trajectory to the set with a given name.
  78825. * @param trajectory new Trajectory to be added
  78826. * @param classification name to which to add the Trajectory
  78827. */
  78828. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78829. /**
  78830. * Remove a known named trajectory and all Trajectories associated with it.
  78831. * @param classification name to remove
  78832. * @returns whether anything was removed
  78833. */
  78834. deleteClassification(classification: string): boolean;
  78835. /**
  78836. * Attempt to recognize a Trajectory from among all the classifications
  78837. * already known to the classifier.
  78838. * @param trajectory Trajectory to be recognized
  78839. * @returns classification of Trajectory if recognized, null otherwise
  78840. */
  78841. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78842. }
  78843. }
  78844. declare module "babylonjs/Misc/index" {
  78845. export * from "babylonjs/Misc/andOrNotEvaluator";
  78846. export * from "babylonjs/Misc/assetsManager";
  78847. export * from "babylonjs/Misc/basis";
  78848. export * from "babylonjs/Misc/dds";
  78849. export * from "babylonjs/Misc/decorators";
  78850. export * from "babylonjs/Misc/deferred";
  78851. export * from "babylonjs/Misc/environmentTextureTools";
  78852. export * from "babylonjs/Misc/meshExploder";
  78853. export * from "babylonjs/Misc/filesInput";
  78854. export * from "babylonjs/Misc/HighDynamicRange/index";
  78855. export * from "babylonjs/Misc/khronosTextureContainer";
  78856. export * from "babylonjs/Misc/observable";
  78857. export * from "babylonjs/Misc/performanceMonitor";
  78858. export * from "babylonjs/Misc/promise";
  78859. export * from "babylonjs/Misc/sceneOptimizer";
  78860. export * from "babylonjs/Misc/sceneSerializer";
  78861. export * from "babylonjs/Misc/smartArray";
  78862. export * from "babylonjs/Misc/stringDictionary";
  78863. export * from "babylonjs/Misc/tags";
  78864. export * from "babylonjs/Misc/textureTools";
  78865. export * from "babylonjs/Misc/tga";
  78866. export * from "babylonjs/Misc/tools";
  78867. export * from "babylonjs/Misc/videoRecorder";
  78868. export * from "babylonjs/Misc/virtualJoystick";
  78869. export * from "babylonjs/Misc/workerPool";
  78870. export * from "babylonjs/Misc/logger";
  78871. export * from "babylonjs/Misc/typeStore";
  78872. export * from "babylonjs/Misc/filesInputStore";
  78873. export * from "babylonjs/Misc/deepCopier";
  78874. export * from "babylonjs/Misc/pivotTools";
  78875. export * from "babylonjs/Misc/precisionDate";
  78876. export * from "babylonjs/Misc/screenshotTools";
  78877. export * from "babylonjs/Misc/typeStore";
  78878. export * from "babylonjs/Misc/webRequest";
  78879. export * from "babylonjs/Misc/iInspectable";
  78880. export * from "babylonjs/Misc/brdfTextureTools";
  78881. export * from "babylonjs/Misc/rgbdTextureTools";
  78882. export * from "babylonjs/Misc/gradients";
  78883. export * from "babylonjs/Misc/perfCounter";
  78884. export * from "babylonjs/Misc/fileRequest";
  78885. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78886. export * from "babylonjs/Misc/retryStrategy";
  78887. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78888. export * from "babylonjs/Misc/canvasGenerator";
  78889. export * from "babylonjs/Misc/fileTools";
  78890. export * from "babylonjs/Misc/stringTools";
  78891. export * from "babylonjs/Misc/dataReader";
  78892. export * from "babylonjs/Misc/minMaxReducer";
  78893. export * from "babylonjs/Misc/depthReducer";
  78894. export * from "babylonjs/Misc/dataStorage";
  78895. export * from "babylonjs/Misc/sceneRecorder";
  78896. export * from "babylonjs/Misc/khronosTextureContainer2";
  78897. export * from "babylonjs/Misc/trajectoryClassifier";
  78898. }
  78899. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78900. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78901. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78902. import { Observable } from "babylonjs/Misc/observable";
  78903. import { Matrix } from "babylonjs/Maths/math.vector";
  78904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78905. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78906. /**
  78907. * An interface for all Hit test features
  78908. */
  78909. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78910. /**
  78911. * Triggered when new babylon (transformed) hit test results are available
  78912. */
  78913. onHitTestResultObservable: Observable<T[]>;
  78914. }
  78915. /**
  78916. * Options used for hit testing
  78917. */
  78918. export interface IWebXRLegacyHitTestOptions {
  78919. /**
  78920. * Only test when user interacted with the scene. Default - hit test every frame
  78921. */
  78922. testOnPointerDownOnly?: boolean;
  78923. /**
  78924. * The node to use to transform the local results to world coordinates
  78925. */
  78926. worldParentNode?: TransformNode;
  78927. }
  78928. /**
  78929. * Interface defining the babylon result of raycasting/hit-test
  78930. */
  78931. export interface IWebXRLegacyHitResult {
  78932. /**
  78933. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78934. */
  78935. transformationMatrix: Matrix;
  78936. /**
  78937. * The native hit test result
  78938. */
  78939. xrHitResult: XRHitResult | XRHitTestResult;
  78940. }
  78941. /**
  78942. * The currently-working hit-test module.
  78943. * Hit test (or Ray-casting) is used to interact with the real world.
  78944. * For further information read here - https://github.com/immersive-web/hit-test
  78945. */
  78946. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78947. /**
  78948. * options to use when constructing this feature
  78949. */
  78950. readonly options: IWebXRLegacyHitTestOptions;
  78951. private _direction;
  78952. private _mat;
  78953. private _onSelectEnabled;
  78954. private _origin;
  78955. /**
  78956. * The module's name
  78957. */
  78958. static readonly Name: string;
  78959. /**
  78960. * The (Babylon) version of this module.
  78961. * This is an integer representing the implementation version.
  78962. * This number does not correspond to the WebXR specs version
  78963. */
  78964. static readonly Version: number;
  78965. /**
  78966. * Populated with the last native XR Hit Results
  78967. */
  78968. lastNativeXRHitResults: XRHitResult[];
  78969. /**
  78970. * Triggered when new babylon (transformed) hit test results are available
  78971. */
  78972. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78973. /**
  78974. * Creates a new instance of the (legacy version) hit test feature
  78975. * @param _xrSessionManager an instance of WebXRSessionManager
  78976. * @param options options to use when constructing this feature
  78977. */
  78978. constructor(_xrSessionManager: WebXRSessionManager,
  78979. /**
  78980. * options to use when constructing this feature
  78981. */
  78982. options?: IWebXRLegacyHitTestOptions);
  78983. /**
  78984. * execute a hit test with an XR Ray
  78985. *
  78986. * @param xrSession a native xrSession that will execute this hit test
  78987. * @param xrRay the ray (position and direction) to use for ray-casting
  78988. * @param referenceSpace native XR reference space to use for the hit-test
  78989. * @param filter filter function that will filter the results
  78990. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78991. */
  78992. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78993. /**
  78994. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78995. * @param event the (select) event to use to select with
  78996. * @param referenceSpace the reference space to use for this hit test
  78997. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78998. */
  78999. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79000. /**
  79001. * attach this feature
  79002. * Will usually be called by the features manager
  79003. *
  79004. * @returns true if successful.
  79005. */
  79006. attach(): boolean;
  79007. /**
  79008. * detach this feature.
  79009. * Will usually be called by the features manager
  79010. *
  79011. * @returns true if successful.
  79012. */
  79013. detach(): boolean;
  79014. /**
  79015. * Dispose this feature and all of the resources attached
  79016. */
  79017. dispose(): void;
  79018. protected _onXRFrame(frame: XRFrame): void;
  79019. private _onHitTestResults;
  79020. private _onSelect;
  79021. }
  79022. }
  79023. declare module "babylonjs/XR/features/WebXRHitTest" {
  79024. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79025. import { Observable } from "babylonjs/Misc/observable";
  79026. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79027. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79028. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79029. /**
  79030. * Options used for hit testing (version 2)
  79031. */
  79032. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79033. /**
  79034. * Do not create a permanent hit test. Will usually be used when only
  79035. * transient inputs are needed.
  79036. */
  79037. disablePermanentHitTest?: boolean;
  79038. /**
  79039. * Enable transient (for example touch-based) hit test inspections
  79040. */
  79041. enableTransientHitTest?: boolean;
  79042. /**
  79043. * Offset ray for the permanent hit test
  79044. */
  79045. offsetRay?: Vector3;
  79046. /**
  79047. * Offset ray for the transient hit test
  79048. */
  79049. transientOffsetRay?: Vector3;
  79050. /**
  79051. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79052. */
  79053. useReferenceSpace?: boolean;
  79054. /**
  79055. * Override the default entity type(s) of the hit-test result
  79056. */
  79057. entityTypes?: XRHitTestTrackableType[];
  79058. }
  79059. /**
  79060. * Interface defining the babylon result of hit-test
  79061. */
  79062. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79063. /**
  79064. * The input source that generated this hit test (if transient)
  79065. */
  79066. inputSource?: XRInputSource;
  79067. /**
  79068. * Is this a transient hit test
  79069. */
  79070. isTransient?: boolean;
  79071. /**
  79072. * Position of the hit test result
  79073. */
  79074. position: Vector3;
  79075. /**
  79076. * Rotation of the hit test result
  79077. */
  79078. rotationQuaternion: Quaternion;
  79079. /**
  79080. * The native hit test result
  79081. */
  79082. xrHitResult: XRHitTestResult;
  79083. }
  79084. /**
  79085. * The currently-working hit-test module.
  79086. * Hit test (or Ray-casting) is used to interact with the real world.
  79087. * For further information read here - https://github.com/immersive-web/hit-test
  79088. *
  79089. * Tested on chrome (mobile) 80.
  79090. */
  79091. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79092. /**
  79093. * options to use when constructing this feature
  79094. */
  79095. readonly options: IWebXRHitTestOptions;
  79096. private _tmpMat;
  79097. private _tmpPos;
  79098. private _tmpQuat;
  79099. private _transientXrHitTestSource;
  79100. private _xrHitTestSource;
  79101. private initHitTestSource;
  79102. /**
  79103. * The module's name
  79104. */
  79105. static readonly Name: string;
  79106. /**
  79107. * The (Babylon) version of this module.
  79108. * This is an integer representing the implementation version.
  79109. * This number does not correspond to the WebXR specs version
  79110. */
  79111. static readonly Version: number;
  79112. /**
  79113. * When set to true, each hit test will have its own position/rotation objects
  79114. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79115. * the developers will clone them or copy them as they see fit.
  79116. */
  79117. autoCloneTransformation: boolean;
  79118. /**
  79119. * Triggered when new babylon (transformed) hit test results are available
  79120. * Note - this will be called when results come back from the device. It can be an empty array!!
  79121. */
  79122. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79123. /**
  79124. * Use this to temporarily pause hit test checks.
  79125. */
  79126. paused: boolean;
  79127. /**
  79128. * Creates a new instance of the hit test feature
  79129. * @param _xrSessionManager an instance of WebXRSessionManager
  79130. * @param options options to use when constructing this feature
  79131. */
  79132. constructor(_xrSessionManager: WebXRSessionManager,
  79133. /**
  79134. * options to use when constructing this feature
  79135. */
  79136. options?: IWebXRHitTestOptions);
  79137. /**
  79138. * attach this feature
  79139. * Will usually be called by the features manager
  79140. *
  79141. * @returns true if successful.
  79142. */
  79143. attach(): boolean;
  79144. /**
  79145. * detach this feature.
  79146. * Will usually be called by the features manager
  79147. *
  79148. * @returns true if successful.
  79149. */
  79150. detach(): boolean;
  79151. /**
  79152. * Dispose this feature and all of the resources attached
  79153. */
  79154. dispose(): void;
  79155. protected _onXRFrame(frame: XRFrame): void;
  79156. private _processWebXRHitTestResult;
  79157. }
  79158. }
  79159. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79160. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79161. import { Observable } from "babylonjs/Misc/observable";
  79162. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79163. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79164. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79165. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79166. /**
  79167. * Configuration options of the anchor system
  79168. */
  79169. export interface IWebXRAnchorSystemOptions {
  79170. /**
  79171. * a node that will be used to convert local to world coordinates
  79172. */
  79173. worldParentNode?: TransformNode;
  79174. /**
  79175. * If set to true a reference of the created anchors will be kept until the next session starts
  79176. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79177. */
  79178. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79179. }
  79180. /**
  79181. * A babylon container for an XR Anchor
  79182. */
  79183. export interface IWebXRAnchor {
  79184. /**
  79185. * A babylon-assigned ID for this anchor
  79186. */
  79187. id: number;
  79188. /**
  79189. * Transformation matrix to apply to an object attached to this anchor
  79190. */
  79191. transformationMatrix: Matrix;
  79192. /**
  79193. * The native anchor object
  79194. */
  79195. xrAnchor: XRAnchor;
  79196. /**
  79197. * if defined, this object will be constantly updated by the anchor's position and rotation
  79198. */
  79199. attachedNode?: TransformNode;
  79200. }
  79201. /**
  79202. * An implementation of the anchor system for WebXR.
  79203. * For further information see https://github.com/immersive-web/anchors/
  79204. */
  79205. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79206. private _options;
  79207. private _lastFrameDetected;
  79208. private _trackedAnchors;
  79209. private _referenceSpaceForFrameAnchors;
  79210. private _futureAnchors;
  79211. /**
  79212. * The module's name
  79213. */
  79214. static readonly Name: string;
  79215. /**
  79216. * The (Babylon) version of this module.
  79217. * This is an integer representing the implementation version.
  79218. * This number does not correspond to the WebXR specs version
  79219. */
  79220. static readonly Version: number;
  79221. /**
  79222. * Observers registered here will be executed when a new anchor was added to the session
  79223. */
  79224. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79225. /**
  79226. * Observers registered here will be executed when an anchor was removed from the session
  79227. */
  79228. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79229. /**
  79230. * Observers registered here will be executed when an existing anchor updates
  79231. * This can execute N times every frame
  79232. */
  79233. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79234. /**
  79235. * Set the reference space to use for anchor creation, when not using a hit test.
  79236. * Will default to the session's reference space if not defined
  79237. */
  79238. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79239. /**
  79240. * constructs a new anchor system
  79241. * @param _xrSessionManager an instance of WebXRSessionManager
  79242. * @param _options configuration object for this feature
  79243. */
  79244. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79245. private _tmpVector;
  79246. private _tmpQuaternion;
  79247. private _populateTmpTransformation;
  79248. /**
  79249. * Create a new anchor point using a hit test result at a specific point in the scene
  79250. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79251. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79252. *
  79253. * @param hitTestResult The hit test result to use for this anchor creation
  79254. * @param position an optional position offset for this anchor
  79255. * @param rotationQuaternion an optional rotation offset for this anchor
  79256. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79257. */
  79258. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79259. /**
  79260. * Add a new anchor at a specific position and rotation
  79261. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79262. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79263. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79264. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79265. *
  79266. * @param position the position in which to add an anchor
  79267. * @param rotationQuaternion an optional rotation for the anchor transformation
  79268. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79269. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79270. */
  79271. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79272. /**
  79273. * detach this feature.
  79274. * Will usually be called by the features manager
  79275. *
  79276. * @returns true if successful.
  79277. */
  79278. detach(): boolean;
  79279. /**
  79280. * Dispose this feature and all of the resources attached
  79281. */
  79282. dispose(): void;
  79283. protected _onXRFrame(frame: XRFrame): void;
  79284. /**
  79285. * avoiding using Array.find for global support.
  79286. * @param xrAnchor the plane to find in the array
  79287. */
  79288. private _findIndexInAnchorArray;
  79289. private _updateAnchorWithXRFrame;
  79290. private _createAnchorAtTransformation;
  79291. }
  79292. }
  79293. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79294. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79295. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79296. import { Observable } from "babylonjs/Misc/observable";
  79297. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79298. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79299. /**
  79300. * Options used in the plane detector module
  79301. */
  79302. export interface IWebXRPlaneDetectorOptions {
  79303. /**
  79304. * The node to use to transform the local results to world coordinates
  79305. */
  79306. worldParentNode?: TransformNode;
  79307. /**
  79308. * If set to true a reference of the created planes will be kept until the next session starts
  79309. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79310. */
  79311. doNotRemovePlanesOnSessionEnded?: boolean;
  79312. }
  79313. /**
  79314. * A babylon interface for a WebXR plane.
  79315. * A Plane is actually a polygon, built from N points in space
  79316. *
  79317. * Supported in chrome 79, not supported in canary 81 ATM
  79318. */
  79319. export interface IWebXRPlane {
  79320. /**
  79321. * a babylon-assigned ID for this polygon
  79322. */
  79323. id: number;
  79324. /**
  79325. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79326. */
  79327. polygonDefinition: Array<Vector3>;
  79328. /**
  79329. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79330. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79331. */
  79332. transformationMatrix: Matrix;
  79333. /**
  79334. * the native xr-plane object
  79335. */
  79336. xrPlane: XRPlane;
  79337. }
  79338. /**
  79339. * The plane detector is used to detect planes in the real world when in AR
  79340. * For more information see https://github.com/immersive-web/real-world-geometry/
  79341. */
  79342. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79343. private _options;
  79344. private _detectedPlanes;
  79345. private _enabled;
  79346. private _lastFrameDetected;
  79347. /**
  79348. * The module's name
  79349. */
  79350. static readonly Name: string;
  79351. /**
  79352. * The (Babylon) version of this module.
  79353. * This is an integer representing the implementation version.
  79354. * This number does not correspond to the WebXR specs version
  79355. */
  79356. static readonly Version: number;
  79357. /**
  79358. * Observers registered here will be executed when a new plane was added to the session
  79359. */
  79360. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79361. /**
  79362. * Observers registered here will be executed when a plane is no longer detected in the session
  79363. */
  79364. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79365. /**
  79366. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79367. * This can execute N times every frame
  79368. */
  79369. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79370. /**
  79371. * construct a new Plane Detector
  79372. * @param _xrSessionManager an instance of xr Session manager
  79373. * @param _options configuration to use when constructing this feature
  79374. */
  79375. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79376. /**
  79377. * detach this feature.
  79378. * Will usually be called by the features manager
  79379. *
  79380. * @returns true if successful.
  79381. */
  79382. detach(): boolean;
  79383. /**
  79384. * Dispose this feature and all of the resources attached
  79385. */
  79386. dispose(): void;
  79387. protected _onXRFrame(frame: XRFrame): void;
  79388. private _init;
  79389. private _updatePlaneWithXRPlane;
  79390. /**
  79391. * avoiding using Array.find for global support.
  79392. * @param xrPlane the plane to find in the array
  79393. */
  79394. private findIndexInPlaneArray;
  79395. }
  79396. }
  79397. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79398. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79400. import { Observable } from "babylonjs/Misc/observable";
  79401. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79402. /**
  79403. * Options interface for the background remover plugin
  79404. */
  79405. export interface IWebXRBackgroundRemoverOptions {
  79406. /**
  79407. * Further background meshes to disable when entering AR
  79408. */
  79409. backgroundMeshes?: AbstractMesh[];
  79410. /**
  79411. * flags to configure the removal of the environment helper.
  79412. * If not set, the entire background will be removed. If set, flags should be set as well.
  79413. */
  79414. environmentHelperRemovalFlags?: {
  79415. /**
  79416. * Should the skybox be removed (default false)
  79417. */
  79418. skyBox?: boolean;
  79419. /**
  79420. * Should the ground be removed (default false)
  79421. */
  79422. ground?: boolean;
  79423. };
  79424. /**
  79425. * don't disable the environment helper
  79426. */
  79427. ignoreEnvironmentHelper?: boolean;
  79428. }
  79429. /**
  79430. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79431. */
  79432. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79433. /**
  79434. * read-only options to be used in this module
  79435. */
  79436. readonly options: IWebXRBackgroundRemoverOptions;
  79437. /**
  79438. * The module's name
  79439. */
  79440. static readonly Name: string;
  79441. /**
  79442. * The (Babylon) version of this module.
  79443. * This is an integer representing the implementation version.
  79444. * This number does not correspond to the WebXR specs version
  79445. */
  79446. static readonly Version: number;
  79447. /**
  79448. * registered observers will be triggered when the background state changes
  79449. */
  79450. onBackgroundStateChangedObservable: Observable<boolean>;
  79451. /**
  79452. * constructs a new background remover module
  79453. * @param _xrSessionManager the session manager for this module
  79454. * @param options read-only options to be used in this module
  79455. */
  79456. constructor(_xrSessionManager: WebXRSessionManager,
  79457. /**
  79458. * read-only options to be used in this module
  79459. */
  79460. options?: IWebXRBackgroundRemoverOptions);
  79461. /**
  79462. * attach this feature
  79463. * Will usually be called by the features manager
  79464. *
  79465. * @returns true if successful.
  79466. */
  79467. attach(): boolean;
  79468. /**
  79469. * detach this feature.
  79470. * Will usually be called by the features manager
  79471. *
  79472. * @returns true if successful.
  79473. */
  79474. detach(): boolean;
  79475. /**
  79476. * Dispose this feature and all of the resources attached
  79477. */
  79478. dispose(): void;
  79479. protected _onXRFrame(_xrFrame: XRFrame): void;
  79480. private _setBackgroundState;
  79481. }
  79482. }
  79483. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79484. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79485. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79486. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79487. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79488. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79489. import { Nullable } from "babylonjs/types";
  79490. /**
  79491. * Options for the controller physics feature
  79492. */
  79493. export class IWebXRControllerPhysicsOptions {
  79494. /**
  79495. * Should the headset get its own impostor
  79496. */
  79497. enableHeadsetImpostor?: boolean;
  79498. /**
  79499. * Optional parameters for the headset impostor
  79500. */
  79501. headsetImpostorParams?: {
  79502. /**
  79503. * The type of impostor to create. Default is sphere
  79504. */
  79505. impostorType: number;
  79506. /**
  79507. * the size of the impostor. Defaults to 10cm
  79508. */
  79509. impostorSize?: number | {
  79510. width: number;
  79511. height: number;
  79512. depth: number;
  79513. };
  79514. /**
  79515. * Friction definitions
  79516. */
  79517. friction?: number;
  79518. /**
  79519. * Restitution
  79520. */
  79521. restitution?: number;
  79522. };
  79523. /**
  79524. * The physics properties of the future impostors
  79525. */
  79526. physicsProperties?: {
  79527. /**
  79528. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79529. * Note that this requires a physics engine that supports mesh impostors!
  79530. */
  79531. useControllerMesh?: boolean;
  79532. /**
  79533. * The type of impostor to create. Default is sphere
  79534. */
  79535. impostorType?: number;
  79536. /**
  79537. * the size of the impostor. Defaults to 10cm
  79538. */
  79539. impostorSize?: number | {
  79540. width: number;
  79541. height: number;
  79542. depth: number;
  79543. };
  79544. /**
  79545. * Friction definitions
  79546. */
  79547. friction?: number;
  79548. /**
  79549. * Restitution
  79550. */
  79551. restitution?: number;
  79552. };
  79553. /**
  79554. * the xr input to use with this pointer selection
  79555. */
  79556. xrInput: WebXRInput;
  79557. }
  79558. /**
  79559. * Add physics impostor to your webxr controllers,
  79560. * including naive calculation of their linear and angular velocity
  79561. */
  79562. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79563. private readonly _options;
  79564. private _attachController;
  79565. private _controllers;
  79566. private _debugMode;
  79567. private _delta;
  79568. private _headsetImpostor?;
  79569. private _headsetMesh?;
  79570. private _lastTimestamp;
  79571. private _tmpQuaternion;
  79572. private _tmpVector;
  79573. /**
  79574. * The module's name
  79575. */
  79576. static readonly Name: string;
  79577. /**
  79578. * The (Babylon) version of this module.
  79579. * This is an integer representing the implementation version.
  79580. * This number does not correspond to the webxr specs version
  79581. */
  79582. static readonly Version: number;
  79583. /**
  79584. * Construct a new Controller Physics Feature
  79585. * @param _xrSessionManager the corresponding xr session manager
  79586. * @param _options options to create this feature with
  79587. */
  79588. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79589. /**
  79590. * @hidden
  79591. * enable debugging - will show console outputs and the impostor mesh
  79592. */
  79593. _enablePhysicsDebug(): void;
  79594. /**
  79595. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79596. * @param xrController the controller to add
  79597. */
  79598. addController(xrController: WebXRInputSource): void;
  79599. /**
  79600. * attach this feature
  79601. * Will usually be called by the features manager
  79602. *
  79603. * @returns true if successful.
  79604. */
  79605. attach(): boolean;
  79606. /**
  79607. * detach this feature.
  79608. * Will usually be called by the features manager
  79609. *
  79610. * @returns true if successful.
  79611. */
  79612. detach(): boolean;
  79613. /**
  79614. * Get the headset impostor, if enabled
  79615. * @returns the impostor
  79616. */
  79617. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79618. /**
  79619. * Get the physics impostor of a specific controller.
  79620. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79621. * @param controller the controller or the controller id of which to get the impostor
  79622. * @returns the impostor or null
  79623. */
  79624. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79625. /**
  79626. * Update the physics properties provided in the constructor
  79627. * @param newProperties the new properties object
  79628. */
  79629. setPhysicsProperties(newProperties: {
  79630. impostorType?: number;
  79631. impostorSize?: number | {
  79632. width: number;
  79633. height: number;
  79634. depth: number;
  79635. };
  79636. friction?: number;
  79637. restitution?: number;
  79638. }): void;
  79639. protected _onXRFrame(_xrFrame: any): void;
  79640. private _detachController;
  79641. }
  79642. }
  79643. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79644. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79645. import { Observable } from "babylonjs/Misc/observable";
  79646. import { Vector3 } from "babylonjs/Maths/math.vector";
  79647. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79648. /**
  79649. * A babylon interface for a "WebXR" feature point.
  79650. * Represents the position and confidence value of a given feature point.
  79651. */
  79652. export interface IWebXRFeaturePoint {
  79653. /**
  79654. * Represents the position of the feature point in world space.
  79655. */
  79656. position: Vector3;
  79657. /**
  79658. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79659. */
  79660. confidenceValue: number;
  79661. }
  79662. /**
  79663. * The feature point system is used to detect feature points from real world geometry.
  79664. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79665. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79666. */
  79667. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79668. private _enabled;
  79669. private _featurePointCloud;
  79670. /**
  79671. * The module's name
  79672. */
  79673. static readonly Name: string;
  79674. /**
  79675. * The (Babylon) version of this module.
  79676. * This is an integer representing the implementation version.
  79677. * This number does not correspond to the WebXR specs version
  79678. */
  79679. static readonly Version: number;
  79680. /**
  79681. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79682. * Will notify the observers about which feature points have been added.
  79683. */
  79684. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79685. /**
  79686. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79687. * Will notify the observers about which feature points have been updated.
  79688. */
  79689. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79690. /**
  79691. * The current feature point cloud maintained across frames.
  79692. */
  79693. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79694. /**
  79695. * construct the feature point system
  79696. * @param _xrSessionManager an instance of xr Session manager
  79697. */
  79698. constructor(_xrSessionManager: WebXRSessionManager);
  79699. /**
  79700. * Detach this feature.
  79701. * Will usually be called by the features manager
  79702. *
  79703. * @returns true if successful.
  79704. */
  79705. detach(): boolean;
  79706. /**
  79707. * Dispose this feature and all of the resources attached
  79708. */
  79709. dispose(): void;
  79710. /**
  79711. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79712. */
  79713. protected _onXRFrame(frame: XRFrame): void;
  79714. /**
  79715. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79716. */
  79717. private _init;
  79718. }
  79719. }
  79720. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79721. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79722. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79724. import { Mesh } from "babylonjs/Meshes/mesh";
  79725. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79726. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79727. import { Nullable } from "babylonjs/types";
  79728. import { IDisposable } from "babylonjs/scene";
  79729. import { Observable } from "babylonjs/Misc/observable";
  79730. /**
  79731. * Configuration interface for the hand tracking feature
  79732. */
  79733. export interface IWebXRHandTrackingOptions {
  79734. /**
  79735. * The xrInput that will be used as source for new hands
  79736. */
  79737. xrInput: WebXRInput;
  79738. /**
  79739. * Configuration object for the joint meshes
  79740. */
  79741. jointMeshes?: {
  79742. /**
  79743. * Should the meshes created be invisible (defaults to false)
  79744. */
  79745. invisible?: boolean;
  79746. /**
  79747. * A source mesh to be used to create instances. Defaults to a sphere.
  79748. * This mesh will be the source for all other (25) meshes.
  79749. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79750. */
  79751. sourceMesh?: Mesh;
  79752. /**
  79753. * Should the source mesh stay visible. Defaults to false
  79754. */
  79755. keepOriginalVisible?: boolean;
  79756. /**
  79757. * Scale factor for all instances (defaults to 2)
  79758. */
  79759. scaleFactor?: number;
  79760. /**
  79761. * Should each instance have its own physics impostor
  79762. */
  79763. enablePhysics?: boolean;
  79764. /**
  79765. * If enabled, override default physics properties
  79766. */
  79767. physicsProps?: {
  79768. friction?: number;
  79769. restitution?: number;
  79770. impostorType?: number;
  79771. };
  79772. /**
  79773. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79774. */
  79775. handMesh?: AbstractMesh;
  79776. };
  79777. }
  79778. /**
  79779. * Parts of the hands divided to writs and finger names
  79780. */
  79781. export const enum HandPart {
  79782. /**
  79783. * HandPart - Wrist
  79784. */
  79785. WRIST = "wrist",
  79786. /**
  79787. * HandPart - The THumb
  79788. */
  79789. THUMB = "thumb",
  79790. /**
  79791. * HandPart - Index finger
  79792. */
  79793. INDEX = "index",
  79794. /**
  79795. * HandPart - Middle finger
  79796. */
  79797. MIDDLE = "middle",
  79798. /**
  79799. * HandPart - Ring finger
  79800. */
  79801. RING = "ring",
  79802. /**
  79803. * HandPart - Little finger
  79804. */
  79805. LITTLE = "little"
  79806. }
  79807. /**
  79808. * Representing a single hand (with its corresponding native XRHand object)
  79809. */
  79810. export class WebXRHand implements IDisposable {
  79811. /** the controller to which the hand correlates */
  79812. readonly xrController: WebXRInputSource;
  79813. /** the meshes to be used to track the hand joints */
  79814. readonly trackedMeshes: AbstractMesh[];
  79815. /**
  79816. * Hand-parts definition (key is HandPart)
  79817. */
  79818. handPartsDefinition: {
  79819. [key: string]: number[];
  79820. };
  79821. /**
  79822. * Populate the HandPartsDefinition object.
  79823. * This is called as a side effect since certain browsers don't have XRHand defined.
  79824. */
  79825. private generateHandPartsDefinition;
  79826. /**
  79827. * Construct a new hand object
  79828. * @param xrController the controller to which the hand correlates
  79829. * @param trackedMeshes the meshes to be used to track the hand joints
  79830. */
  79831. constructor(
  79832. /** the controller to which the hand correlates */
  79833. xrController: WebXRInputSource,
  79834. /** the meshes to be used to track the hand joints */
  79835. trackedMeshes: AbstractMesh[]);
  79836. /**
  79837. * Update this hand from the latest xr frame
  79838. * @param xrFrame xrFrame to update from
  79839. * @param referenceSpace The current viewer reference space
  79840. * @param scaleFactor optional scale factor for the meshes
  79841. */
  79842. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79843. /**
  79844. * Get meshes of part of the hand
  79845. * @param part the part of hand to get
  79846. * @returns An array of meshes that correlate to the hand part requested
  79847. */
  79848. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79849. /**
  79850. * Dispose this Hand object
  79851. */
  79852. dispose(): void;
  79853. }
  79854. /**
  79855. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79856. */
  79857. export class WebXRHandTracking extends WebXRAbstractFeature {
  79858. /**
  79859. * options to use when constructing this feature
  79860. */
  79861. readonly options: IWebXRHandTrackingOptions;
  79862. private static _idCounter;
  79863. /**
  79864. * The module's name
  79865. */
  79866. static readonly Name: string;
  79867. /**
  79868. * The (Babylon) version of this module.
  79869. * This is an integer representing the implementation version.
  79870. * This number does not correspond to the WebXR specs version
  79871. */
  79872. static readonly Version: number;
  79873. /**
  79874. * This observable will notify registered observers when a new hand object was added and initialized
  79875. */
  79876. onHandAddedObservable: Observable<WebXRHand>;
  79877. /**
  79878. * This observable will notify its observers right before the hand object is disposed
  79879. */
  79880. onHandRemovedObservable: Observable<WebXRHand>;
  79881. private _hands;
  79882. /**
  79883. * Creates a new instance of the hit test feature
  79884. * @param _xrSessionManager an instance of WebXRSessionManager
  79885. * @param options options to use when constructing this feature
  79886. */
  79887. constructor(_xrSessionManager: WebXRSessionManager,
  79888. /**
  79889. * options to use when constructing this feature
  79890. */
  79891. options: IWebXRHandTrackingOptions);
  79892. /**
  79893. * Check if the needed objects are defined.
  79894. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79895. */
  79896. isCompatible(): boolean;
  79897. /**
  79898. * attach this feature
  79899. * Will usually be called by the features manager
  79900. *
  79901. * @returns true if successful.
  79902. */
  79903. attach(): boolean;
  79904. /**
  79905. * detach this feature.
  79906. * Will usually be called by the features manager
  79907. *
  79908. * @returns true if successful.
  79909. */
  79910. detach(): boolean;
  79911. /**
  79912. * Dispose this feature and all of the resources attached
  79913. */
  79914. dispose(): void;
  79915. /**
  79916. * Get the hand object according to the controller id
  79917. * @param controllerId the controller id to which we want to get the hand
  79918. * @returns null if not found or the WebXRHand object if found
  79919. */
  79920. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79921. /**
  79922. * Get a hand object according to the requested handedness
  79923. * @param handedness the handedness to request
  79924. * @returns null if not found or the WebXRHand object if found
  79925. */
  79926. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79927. protected _onXRFrame(_xrFrame: XRFrame): void;
  79928. private _attachHand;
  79929. private _detachHand;
  79930. }
  79931. }
  79932. declare module "babylonjs/XR/features/index" {
  79933. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79934. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79935. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79936. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79937. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79938. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79939. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79940. export * from "babylonjs/XR/features/WebXRHitTest";
  79941. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79942. export * from "babylonjs/XR/features/WebXRHandTracking";
  79943. }
  79944. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79945. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79947. import { Scene } from "babylonjs/scene";
  79948. /**
  79949. * The motion controller class for all microsoft mixed reality controllers
  79950. */
  79951. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79952. protected readonly _mapping: {
  79953. defaultButton: {
  79954. valueNodeName: string;
  79955. unpressedNodeName: string;
  79956. pressedNodeName: string;
  79957. };
  79958. defaultAxis: {
  79959. valueNodeName: string;
  79960. minNodeName: string;
  79961. maxNodeName: string;
  79962. };
  79963. buttons: {
  79964. "xr-standard-trigger": {
  79965. rootNodeName: string;
  79966. componentProperty: string;
  79967. states: string[];
  79968. };
  79969. "xr-standard-squeeze": {
  79970. rootNodeName: string;
  79971. componentProperty: string;
  79972. states: string[];
  79973. };
  79974. "xr-standard-touchpad": {
  79975. rootNodeName: string;
  79976. labelAnchorNodeName: string;
  79977. touchPointNodeName: string;
  79978. };
  79979. "xr-standard-thumbstick": {
  79980. rootNodeName: string;
  79981. componentProperty: string;
  79982. states: string[];
  79983. };
  79984. };
  79985. axes: {
  79986. "xr-standard-touchpad": {
  79987. "x-axis": {
  79988. rootNodeName: string;
  79989. };
  79990. "y-axis": {
  79991. rootNodeName: string;
  79992. };
  79993. };
  79994. "xr-standard-thumbstick": {
  79995. "x-axis": {
  79996. rootNodeName: string;
  79997. };
  79998. "y-axis": {
  79999. rootNodeName: string;
  80000. };
  80001. };
  80002. };
  80003. };
  80004. /**
  80005. * The base url used to load the left and right controller models
  80006. */
  80007. static MODEL_BASE_URL: string;
  80008. /**
  80009. * The name of the left controller model file
  80010. */
  80011. static MODEL_LEFT_FILENAME: string;
  80012. /**
  80013. * The name of the right controller model file
  80014. */
  80015. static MODEL_RIGHT_FILENAME: string;
  80016. profileId: string;
  80017. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80018. protected _getFilenameAndPath(): {
  80019. filename: string;
  80020. path: string;
  80021. };
  80022. protected _getModelLoadingConstraints(): boolean;
  80023. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80024. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80025. protected _updateModel(): void;
  80026. }
  80027. }
  80028. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80029. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80031. import { Scene } from "babylonjs/scene";
  80032. /**
  80033. * The motion controller class for oculus touch (quest, rift).
  80034. * This class supports legacy mapping as well the standard xr mapping
  80035. */
  80036. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80037. private _forceLegacyControllers;
  80038. private _modelRootNode;
  80039. /**
  80040. * The base url used to load the left and right controller models
  80041. */
  80042. static MODEL_BASE_URL: string;
  80043. /**
  80044. * The name of the left controller model file
  80045. */
  80046. static MODEL_LEFT_FILENAME: string;
  80047. /**
  80048. * The name of the right controller model file
  80049. */
  80050. static MODEL_RIGHT_FILENAME: string;
  80051. /**
  80052. * Base Url for the Quest controller model.
  80053. */
  80054. static QUEST_MODEL_BASE_URL: string;
  80055. profileId: string;
  80056. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80057. protected _getFilenameAndPath(): {
  80058. filename: string;
  80059. path: string;
  80060. };
  80061. protected _getModelLoadingConstraints(): boolean;
  80062. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80063. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80064. protected _updateModel(): void;
  80065. /**
  80066. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80067. * between the touch and touch 2.
  80068. */
  80069. private _isQuest;
  80070. }
  80071. }
  80072. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80073. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80074. import { Scene } from "babylonjs/scene";
  80075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80076. /**
  80077. * The motion controller class for the standard HTC-Vive controllers
  80078. */
  80079. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80080. private _modelRootNode;
  80081. /**
  80082. * The base url used to load the left and right controller models
  80083. */
  80084. static MODEL_BASE_URL: string;
  80085. /**
  80086. * File name for the controller model.
  80087. */
  80088. static MODEL_FILENAME: string;
  80089. profileId: string;
  80090. /**
  80091. * Create a new Vive motion controller object
  80092. * @param scene the scene to use to create this controller
  80093. * @param gamepadObject the corresponding gamepad object
  80094. * @param handedness the handedness of the controller
  80095. */
  80096. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80097. protected _getFilenameAndPath(): {
  80098. filename: string;
  80099. path: string;
  80100. };
  80101. protected _getModelLoadingConstraints(): boolean;
  80102. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80103. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80104. protected _updateModel(): void;
  80105. }
  80106. }
  80107. declare module "babylonjs/XR/motionController/index" {
  80108. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80109. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80110. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80111. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80112. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80113. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80114. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80115. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80116. }
  80117. declare module "babylonjs/XR/index" {
  80118. export * from "babylonjs/XR/webXRCamera";
  80119. export * from "babylonjs/XR/webXREnterExitUI";
  80120. export * from "babylonjs/XR/webXRExperienceHelper";
  80121. export * from "babylonjs/XR/webXRInput";
  80122. export * from "babylonjs/XR/webXRInputSource";
  80123. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80124. export * from "babylonjs/XR/webXRTypes";
  80125. export * from "babylonjs/XR/webXRSessionManager";
  80126. export * from "babylonjs/XR/webXRDefaultExperience";
  80127. export * from "babylonjs/XR/webXRFeaturesManager";
  80128. export * from "babylonjs/XR/features/index";
  80129. export * from "babylonjs/XR/motionController/index";
  80130. }
  80131. declare module "babylonjs/index" {
  80132. export * from "babylonjs/abstractScene";
  80133. export * from "babylonjs/Actions/index";
  80134. export * from "babylonjs/Animations/index";
  80135. export * from "babylonjs/assetContainer";
  80136. export * from "babylonjs/Audio/index";
  80137. export * from "babylonjs/Behaviors/index";
  80138. export * from "babylonjs/Bones/index";
  80139. export * from "babylonjs/Cameras/index";
  80140. export * from "babylonjs/Collisions/index";
  80141. export * from "babylonjs/Culling/index";
  80142. export * from "babylonjs/Debug/index";
  80143. export * from "babylonjs/DeviceInput/index";
  80144. export * from "babylonjs/Engines/index";
  80145. export * from "babylonjs/Events/index";
  80146. export * from "babylonjs/Gamepads/index";
  80147. export * from "babylonjs/Gizmos/index";
  80148. export * from "babylonjs/Helpers/index";
  80149. export * from "babylonjs/Instrumentation/index";
  80150. export * from "babylonjs/Layers/index";
  80151. export * from "babylonjs/LensFlares/index";
  80152. export * from "babylonjs/Lights/index";
  80153. export * from "babylonjs/Loading/index";
  80154. export * from "babylonjs/Materials/index";
  80155. export * from "babylonjs/Maths/index";
  80156. export * from "babylonjs/Meshes/index";
  80157. export * from "babylonjs/Morph/index";
  80158. export * from "babylonjs/Navigation/index";
  80159. export * from "babylonjs/node";
  80160. export * from "babylonjs/Offline/index";
  80161. export * from "babylonjs/Particles/index";
  80162. export * from "babylonjs/Physics/index";
  80163. export * from "babylonjs/PostProcesses/index";
  80164. export * from "babylonjs/Probes/index";
  80165. export * from "babylonjs/Rendering/index";
  80166. export * from "babylonjs/scene";
  80167. export * from "babylonjs/sceneComponent";
  80168. export * from "babylonjs/Sprites/index";
  80169. export * from "babylonjs/States/index";
  80170. export * from "babylonjs/Misc/index";
  80171. export * from "babylonjs/XR/index";
  80172. export * from "babylonjs/types";
  80173. }
  80174. declare module "babylonjs/Animations/pathCursor" {
  80175. import { Vector3 } from "babylonjs/Maths/math.vector";
  80176. import { Path2 } from "babylonjs/Maths/math.path";
  80177. /**
  80178. * A cursor which tracks a point on a path
  80179. */
  80180. export class PathCursor {
  80181. private path;
  80182. /**
  80183. * Stores path cursor callbacks for when an onchange event is triggered
  80184. */
  80185. private _onchange;
  80186. /**
  80187. * The value of the path cursor
  80188. */
  80189. value: number;
  80190. /**
  80191. * The animation array of the path cursor
  80192. */
  80193. animations: Animation[];
  80194. /**
  80195. * Initializes the path cursor
  80196. * @param path The path to track
  80197. */
  80198. constructor(path: Path2);
  80199. /**
  80200. * Gets the cursor point on the path
  80201. * @returns A point on the path cursor at the cursor location
  80202. */
  80203. getPoint(): Vector3;
  80204. /**
  80205. * Moves the cursor ahead by the step amount
  80206. * @param step The amount to move the cursor forward
  80207. * @returns This path cursor
  80208. */
  80209. moveAhead(step?: number): PathCursor;
  80210. /**
  80211. * Moves the cursor behind by the step amount
  80212. * @param step The amount to move the cursor back
  80213. * @returns This path cursor
  80214. */
  80215. moveBack(step?: number): PathCursor;
  80216. /**
  80217. * Moves the cursor by the step amount
  80218. * If the step amount is greater than one, an exception is thrown
  80219. * @param step The amount to move the cursor
  80220. * @returns This path cursor
  80221. */
  80222. move(step: number): PathCursor;
  80223. /**
  80224. * Ensures that the value is limited between zero and one
  80225. * @returns This path cursor
  80226. */
  80227. private ensureLimits;
  80228. /**
  80229. * Runs onchange callbacks on change (used by the animation engine)
  80230. * @returns This path cursor
  80231. */
  80232. private raiseOnChange;
  80233. /**
  80234. * Executes a function on change
  80235. * @param f A path cursor onchange callback
  80236. * @returns This path cursor
  80237. */
  80238. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80239. }
  80240. }
  80241. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80242. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80243. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80244. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80245. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80246. }
  80247. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80248. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80249. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80250. }
  80251. declare module "babylonjs/Engines/Processors/index" {
  80252. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80253. export * from "babylonjs/Engines/Processors/Expressions/index";
  80254. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80255. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80256. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80257. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80258. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80259. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80260. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80261. }
  80262. declare module "babylonjs/Legacy/legacy" {
  80263. import * as Babylon from "babylonjs/index";
  80264. export * from "babylonjs/index";
  80265. }
  80266. declare module "babylonjs/Shaders/blur.fragment" {
  80267. /** @hidden */
  80268. export var blurPixelShader: {
  80269. name: string;
  80270. shader: string;
  80271. };
  80272. }
  80273. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80274. /** @hidden */
  80275. export var pointCloudVertexDeclaration: {
  80276. name: string;
  80277. shader: string;
  80278. };
  80279. }
  80280. declare module "babylonjs" {
  80281. export * from "babylonjs/Legacy/legacy";
  80282. }
  80283. declare module BABYLON {
  80284. /** Alias type for value that can be null */
  80285. export type Nullable<T> = T | null;
  80286. /**
  80287. * Alias type for number that are floats
  80288. * @ignorenaming
  80289. */
  80290. export type float = number;
  80291. /**
  80292. * Alias type for number that are doubles.
  80293. * @ignorenaming
  80294. */
  80295. export type double = number;
  80296. /**
  80297. * Alias type for number that are integer
  80298. * @ignorenaming
  80299. */
  80300. export type int = number;
  80301. /** Alias type for number array or Float32Array */
  80302. export type FloatArray = number[] | Float32Array;
  80303. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80304. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80305. /**
  80306. * Alias for types that can be used by a Buffer or VertexBuffer.
  80307. */
  80308. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80309. /**
  80310. * Alias type for primitive types
  80311. * @ignorenaming
  80312. */
  80313. type Primitive = undefined | null | boolean | string | number | Function;
  80314. /**
  80315. * Type modifier to make all the properties of an object Readonly
  80316. */
  80317. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80318. /**
  80319. * Type modifier to make all the properties of an object Readonly recursively
  80320. */
  80321. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80322. /**
  80323. * Type modifier to make object properties readonly.
  80324. */
  80325. export type DeepImmutableObject<T> = {
  80326. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80327. };
  80328. /** @hidden */
  80329. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80330. }
  80331. }
  80332. declare module BABYLON {
  80333. /**
  80334. * A class serves as a medium between the observable and its observers
  80335. */
  80336. export class EventState {
  80337. /**
  80338. * Create a new EventState
  80339. * @param mask defines the mask associated with this state
  80340. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80341. * @param target defines the original target of the state
  80342. * @param currentTarget defines the current target of the state
  80343. */
  80344. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80345. /**
  80346. * Initialize the current event state
  80347. * @param mask defines the mask associated with this state
  80348. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80349. * @param target defines the original target of the state
  80350. * @param currentTarget defines the current target of the state
  80351. * @returns the current event state
  80352. */
  80353. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80354. /**
  80355. * An Observer can set this property to true to prevent subsequent observers of being notified
  80356. */
  80357. skipNextObservers: boolean;
  80358. /**
  80359. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80360. */
  80361. mask: number;
  80362. /**
  80363. * The object that originally notified the event
  80364. */
  80365. target?: any;
  80366. /**
  80367. * The current object in the bubbling phase
  80368. */
  80369. currentTarget?: any;
  80370. /**
  80371. * This will be populated with the return value of the last function that was executed.
  80372. * If it is the first function in the callback chain it will be the event data.
  80373. */
  80374. lastReturnValue?: any;
  80375. }
  80376. /**
  80377. * Represent an Observer registered to a given Observable object.
  80378. */
  80379. export class Observer<T> {
  80380. /**
  80381. * Defines the callback to call when the observer is notified
  80382. */
  80383. callback: (eventData: T, eventState: EventState) => void;
  80384. /**
  80385. * Defines the mask of the observer (used to filter notifications)
  80386. */
  80387. mask: number;
  80388. /**
  80389. * Defines the current scope used to restore the JS context
  80390. */
  80391. scope: any;
  80392. /** @hidden */
  80393. _willBeUnregistered: boolean;
  80394. /**
  80395. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80396. */
  80397. unregisterOnNextCall: boolean;
  80398. /**
  80399. * Creates a new observer
  80400. * @param callback defines the callback to call when the observer is notified
  80401. * @param mask defines the mask of the observer (used to filter notifications)
  80402. * @param scope defines the current scope used to restore the JS context
  80403. */
  80404. constructor(
  80405. /**
  80406. * Defines the callback to call when the observer is notified
  80407. */
  80408. callback: (eventData: T, eventState: EventState) => void,
  80409. /**
  80410. * Defines the mask of the observer (used to filter notifications)
  80411. */
  80412. mask: number,
  80413. /**
  80414. * Defines the current scope used to restore the JS context
  80415. */
  80416. scope?: any);
  80417. }
  80418. /**
  80419. * Represent a list of observers registered to multiple Observables object.
  80420. */
  80421. export class MultiObserver<T> {
  80422. private _observers;
  80423. private _observables;
  80424. /**
  80425. * Release associated resources
  80426. */
  80427. dispose(): void;
  80428. /**
  80429. * Raise a callback when one of the observable will notify
  80430. * @param observables defines a list of observables to watch
  80431. * @param callback defines the callback to call on notification
  80432. * @param mask defines the mask used to filter notifications
  80433. * @param scope defines the current scope used to restore the JS context
  80434. * @returns the new MultiObserver
  80435. */
  80436. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80437. }
  80438. /**
  80439. * The Observable class is a simple implementation of the Observable pattern.
  80440. *
  80441. * 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.
  80442. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80443. * 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).
  80444. * 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.
  80445. */
  80446. export class Observable<T> {
  80447. private _observers;
  80448. private _eventState;
  80449. private _onObserverAdded;
  80450. /**
  80451. * Gets the list of observers
  80452. */
  80453. get observers(): Array<Observer<T>>;
  80454. /**
  80455. * Creates a new observable
  80456. * @param onObserverAdded defines a callback to call when a new observer is added
  80457. */
  80458. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80459. /**
  80460. * Create a new Observer with the specified callback
  80461. * @param callback the callback that will be executed for that Observer
  80462. * @param mask the mask used to filter observers
  80463. * @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.
  80464. * @param scope optional scope for the callback to be called from
  80465. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80466. * @returns the new observer created for the callback
  80467. */
  80468. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80469. /**
  80470. * Create a new Observer with the specified callback and unregisters after the next notification
  80471. * @param callback the callback that will be executed for that Observer
  80472. * @returns the new observer created for the callback
  80473. */
  80474. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80475. /**
  80476. * Remove an Observer from the Observable object
  80477. * @param observer the instance of the Observer to remove
  80478. * @returns false if it doesn't belong to this Observable
  80479. */
  80480. remove(observer: Nullable<Observer<T>>): boolean;
  80481. /**
  80482. * Remove a callback from the Observable object
  80483. * @param callback the callback to remove
  80484. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80485. * @returns false if it doesn't belong to this Observable
  80486. */
  80487. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80488. private _deferUnregister;
  80489. private _remove;
  80490. /**
  80491. * Moves the observable to the top of the observer list making it get called first when notified
  80492. * @param observer the observer to move
  80493. */
  80494. makeObserverTopPriority(observer: Observer<T>): void;
  80495. /**
  80496. * Moves the observable to the bottom of the observer list making it get called last when notified
  80497. * @param observer the observer to move
  80498. */
  80499. makeObserverBottomPriority(observer: Observer<T>): void;
  80500. /**
  80501. * Notify all Observers by calling their respective callback with the given data
  80502. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80503. * @param eventData defines the data to send to all observers
  80504. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80505. * @param target defines the original target of the state
  80506. * @param currentTarget defines the current target of the state
  80507. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80508. */
  80509. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80510. /**
  80511. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80512. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80513. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80514. * and it is crucial that all callbacks will be executed.
  80515. * The order of the callbacks is kept, callbacks are not executed parallel.
  80516. *
  80517. * @param eventData The data to be sent to each callback
  80518. * @param mask is used to filter observers defaults to -1
  80519. * @param target defines the callback target (see EventState)
  80520. * @param currentTarget defines he current object in the bubbling phase
  80521. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80522. */
  80523. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80524. /**
  80525. * Notify a specific observer
  80526. * @param observer defines the observer to notify
  80527. * @param eventData defines the data to be sent to each callback
  80528. * @param mask is used to filter observers defaults to -1
  80529. */
  80530. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80531. /**
  80532. * Gets a boolean indicating if the observable has at least one observer
  80533. * @returns true is the Observable has at least one Observer registered
  80534. */
  80535. hasObservers(): boolean;
  80536. /**
  80537. * Clear the list of observers
  80538. */
  80539. clear(): void;
  80540. /**
  80541. * Clone the current observable
  80542. * @returns a new observable
  80543. */
  80544. clone(): Observable<T>;
  80545. /**
  80546. * Does this observable handles observer registered with a given mask
  80547. * @param mask defines the mask to be tested
  80548. * @return whether or not one observer registered with the given mask is handeled
  80549. **/
  80550. hasSpecificMask(mask?: number): boolean;
  80551. }
  80552. }
  80553. declare module BABYLON {
  80554. /**
  80555. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80556. * Babylon.js
  80557. */
  80558. export class DomManagement {
  80559. /**
  80560. * Checks if the window object exists
  80561. * @returns true if the window object exists
  80562. */
  80563. static IsWindowObjectExist(): boolean;
  80564. /**
  80565. * Checks if the navigator object exists
  80566. * @returns true if the navigator object exists
  80567. */
  80568. static IsNavigatorAvailable(): boolean;
  80569. /**
  80570. * Check if the document object exists
  80571. * @returns true if the document object exists
  80572. */
  80573. static IsDocumentAvailable(): boolean;
  80574. /**
  80575. * Extracts text content from a DOM element hierarchy
  80576. * @param element defines the root element
  80577. * @returns a string
  80578. */
  80579. static GetDOMTextContent(element: HTMLElement): string;
  80580. }
  80581. }
  80582. declare module BABYLON {
  80583. /**
  80584. * Logger used througouht the application to allow configuration of
  80585. * the log level required for the messages.
  80586. */
  80587. export class Logger {
  80588. /**
  80589. * No log
  80590. */
  80591. static readonly NoneLogLevel: number;
  80592. /**
  80593. * Only message logs
  80594. */
  80595. static readonly MessageLogLevel: number;
  80596. /**
  80597. * Only warning logs
  80598. */
  80599. static readonly WarningLogLevel: number;
  80600. /**
  80601. * Only error logs
  80602. */
  80603. static readonly ErrorLogLevel: number;
  80604. /**
  80605. * All logs
  80606. */
  80607. static readonly AllLogLevel: number;
  80608. private static _LogCache;
  80609. /**
  80610. * Gets a value indicating the number of loading errors
  80611. * @ignorenaming
  80612. */
  80613. static errorsCount: number;
  80614. /**
  80615. * Callback called when a new log is added
  80616. */
  80617. static OnNewCacheEntry: (entry: string) => void;
  80618. private static _AddLogEntry;
  80619. private static _FormatMessage;
  80620. private static _LogDisabled;
  80621. private static _LogEnabled;
  80622. private static _WarnDisabled;
  80623. private static _WarnEnabled;
  80624. private static _ErrorDisabled;
  80625. private static _ErrorEnabled;
  80626. /**
  80627. * Log a message to the console
  80628. */
  80629. static Log: (message: string) => void;
  80630. /**
  80631. * Write a warning message to the console
  80632. */
  80633. static Warn: (message: string) => void;
  80634. /**
  80635. * Write an error message to the console
  80636. */
  80637. static Error: (message: string) => void;
  80638. /**
  80639. * Gets current log cache (list of logs)
  80640. */
  80641. static get LogCache(): string;
  80642. /**
  80643. * Clears the log cache
  80644. */
  80645. static ClearLogCache(): void;
  80646. /**
  80647. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80648. */
  80649. static set LogLevels(level: number);
  80650. }
  80651. }
  80652. declare module BABYLON {
  80653. /** @hidden */
  80654. export class _TypeStore {
  80655. /** @hidden */
  80656. static RegisteredTypes: {
  80657. [key: string]: Object;
  80658. };
  80659. /** @hidden */
  80660. static GetClass(fqdn: string): any;
  80661. }
  80662. }
  80663. declare module BABYLON {
  80664. /**
  80665. * Helper to manipulate strings
  80666. */
  80667. export class StringTools {
  80668. /**
  80669. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80670. * @param str Source string
  80671. * @param suffix Suffix to search for in the source string
  80672. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80673. */
  80674. static EndsWith(str: string, suffix: string): boolean;
  80675. /**
  80676. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80677. * @param str Source string
  80678. * @param suffix Suffix to search for in the source string
  80679. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80680. */
  80681. static StartsWith(str: string, suffix: string): boolean;
  80682. /**
  80683. * Decodes a buffer into a string
  80684. * @param buffer The buffer to decode
  80685. * @returns The decoded string
  80686. */
  80687. static Decode(buffer: Uint8Array | Uint16Array): string;
  80688. /**
  80689. * Encode a buffer to a base64 string
  80690. * @param buffer defines the buffer to encode
  80691. * @returns the encoded string
  80692. */
  80693. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80694. /**
  80695. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80696. * @param num the number to convert and pad
  80697. * @param length the expected length of the string
  80698. * @returns the padded string
  80699. */
  80700. static PadNumber(num: number, length: number): string;
  80701. }
  80702. }
  80703. declare module BABYLON {
  80704. /**
  80705. * Class containing a set of static utilities functions for deep copy.
  80706. */
  80707. export class DeepCopier {
  80708. /**
  80709. * Tries to copy an object by duplicating every property
  80710. * @param source defines the source object
  80711. * @param destination defines the target object
  80712. * @param doNotCopyList defines a list of properties to avoid
  80713. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80714. */
  80715. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80716. }
  80717. }
  80718. declare module BABYLON {
  80719. /**
  80720. * Class containing a set of static utilities functions for precision date
  80721. */
  80722. export class PrecisionDate {
  80723. /**
  80724. * Gets either window.performance.now() if supported or Date.now() else
  80725. */
  80726. static get Now(): number;
  80727. }
  80728. }
  80729. declare module BABYLON {
  80730. /** @hidden */
  80731. export class _DevTools {
  80732. static WarnImport(name: string): string;
  80733. }
  80734. }
  80735. declare module BABYLON {
  80736. /**
  80737. * Interface used to define the mechanism to get data from the network
  80738. */
  80739. export interface IWebRequest {
  80740. /**
  80741. * Returns client's response url
  80742. */
  80743. responseURL: string;
  80744. /**
  80745. * Returns client's status
  80746. */
  80747. status: number;
  80748. /**
  80749. * Returns client's status as a text
  80750. */
  80751. statusText: string;
  80752. }
  80753. }
  80754. declare module BABYLON {
  80755. /**
  80756. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80757. */
  80758. export class WebRequest implements IWebRequest {
  80759. private _xhr;
  80760. /**
  80761. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80762. * i.e. when loading files, where the server/service expects an Authorization header
  80763. */
  80764. static CustomRequestHeaders: {
  80765. [key: string]: string;
  80766. };
  80767. /**
  80768. * Add callback functions in this array to update all the requests before they get sent to the network
  80769. */
  80770. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80771. private _injectCustomRequestHeaders;
  80772. /**
  80773. * Gets or sets a function to be called when loading progress changes
  80774. */
  80775. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80776. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80777. /**
  80778. * Returns client's state
  80779. */
  80780. get readyState(): number;
  80781. /**
  80782. * Returns client's status
  80783. */
  80784. get status(): number;
  80785. /**
  80786. * Returns client's status as a text
  80787. */
  80788. get statusText(): string;
  80789. /**
  80790. * Returns client's response
  80791. */
  80792. get response(): any;
  80793. /**
  80794. * Returns client's response url
  80795. */
  80796. get responseURL(): string;
  80797. /**
  80798. * Returns client's response as text
  80799. */
  80800. get responseText(): string;
  80801. /**
  80802. * Gets or sets the expected response type
  80803. */
  80804. get responseType(): XMLHttpRequestResponseType;
  80805. set responseType(value: XMLHttpRequestResponseType);
  80806. /** @hidden */
  80807. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80808. /** @hidden */
  80809. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80810. /**
  80811. * Cancels any network activity
  80812. */
  80813. abort(): void;
  80814. /**
  80815. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80816. * @param body defines an optional request body
  80817. */
  80818. send(body?: Document | BodyInit | null): void;
  80819. /**
  80820. * Sets the request method, request URL
  80821. * @param method defines the method to use (GET, POST, etc..)
  80822. * @param url defines the url to connect with
  80823. */
  80824. open(method: string, url: string): void;
  80825. /**
  80826. * Sets the value of a request header.
  80827. * @param name The name of the header whose value is to be set
  80828. * @param value The value to set as the body of the header
  80829. */
  80830. setRequestHeader(name: string, value: string): void;
  80831. /**
  80832. * Get the string containing the text of a particular header's value.
  80833. * @param name The name of the header
  80834. * @returns The string containing the text of the given header name
  80835. */
  80836. getResponseHeader(name: string): Nullable<string>;
  80837. }
  80838. }
  80839. declare module BABYLON {
  80840. /**
  80841. * File request interface
  80842. */
  80843. export interface IFileRequest {
  80844. /**
  80845. * Raised when the request is complete (success or error).
  80846. */
  80847. onCompleteObservable: Observable<IFileRequest>;
  80848. /**
  80849. * Aborts the request for a file.
  80850. */
  80851. abort: () => void;
  80852. }
  80853. }
  80854. declare module BABYLON {
  80855. /**
  80856. * Define options used to create a render target texture
  80857. */
  80858. export class RenderTargetCreationOptions {
  80859. /**
  80860. * Specifies is mipmaps must be generated
  80861. */
  80862. generateMipMaps?: boolean;
  80863. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80864. generateDepthBuffer?: boolean;
  80865. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80866. generateStencilBuffer?: boolean;
  80867. /** Defines texture type (int by default) */
  80868. type?: number;
  80869. /** Defines sampling mode (trilinear by default) */
  80870. samplingMode?: number;
  80871. /** Defines format (RGBA by default) */
  80872. format?: number;
  80873. }
  80874. }
  80875. declare module BABYLON {
  80876. /** Defines the cross module used constants to avoid circular dependncies */
  80877. export class Constants {
  80878. /** Defines that alpha blending is disabled */
  80879. static readonly ALPHA_DISABLE: number;
  80880. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80881. static readonly ALPHA_ADD: number;
  80882. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80883. static readonly ALPHA_COMBINE: number;
  80884. /** Defines that alpha blending is DEST - SRC * DEST */
  80885. static readonly ALPHA_SUBTRACT: number;
  80886. /** Defines that alpha blending is SRC * DEST */
  80887. static readonly ALPHA_MULTIPLY: number;
  80888. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80889. static readonly ALPHA_MAXIMIZED: number;
  80890. /** Defines that alpha blending is SRC + DEST */
  80891. static readonly ALPHA_ONEONE: number;
  80892. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80893. static readonly ALPHA_PREMULTIPLIED: number;
  80894. /**
  80895. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80896. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80897. */
  80898. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80899. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80900. static readonly ALPHA_INTERPOLATE: number;
  80901. /**
  80902. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80903. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80904. */
  80905. static readonly ALPHA_SCREENMODE: number;
  80906. /**
  80907. * Defines that alpha blending is SRC + DST
  80908. * Alpha will be set to SRC ALPHA + DST ALPHA
  80909. */
  80910. static readonly ALPHA_ONEONE_ONEONE: number;
  80911. /**
  80912. * Defines that alpha blending is SRC * DST ALPHA + DST
  80913. * Alpha will be set to 0
  80914. */
  80915. static readonly ALPHA_ALPHATOCOLOR: number;
  80916. /**
  80917. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80918. */
  80919. static readonly ALPHA_REVERSEONEMINUS: number;
  80920. /**
  80921. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80922. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80923. */
  80924. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80925. /**
  80926. * Defines that alpha blending is SRC + DST
  80927. * Alpha will be set to SRC ALPHA
  80928. */
  80929. static readonly ALPHA_ONEONE_ONEZERO: number;
  80930. /**
  80931. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80932. * Alpha will be set to DST ALPHA
  80933. */
  80934. static readonly ALPHA_EXCLUSION: number;
  80935. /** Defines that alpha blending equation a SUM */
  80936. static readonly ALPHA_EQUATION_ADD: number;
  80937. /** Defines that alpha blending equation a SUBSTRACTION */
  80938. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80939. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80940. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80941. /** Defines that alpha blending equation a MAX operation */
  80942. static readonly ALPHA_EQUATION_MAX: number;
  80943. /** Defines that alpha blending equation a MIN operation */
  80944. static readonly ALPHA_EQUATION_MIN: number;
  80945. /**
  80946. * Defines that alpha blending equation a DARKEN operation:
  80947. * It takes the min of the src and sums the alpha channels.
  80948. */
  80949. static readonly ALPHA_EQUATION_DARKEN: number;
  80950. /** Defines that the ressource is not delayed*/
  80951. static readonly DELAYLOADSTATE_NONE: number;
  80952. /** Defines that the ressource was successfully delay loaded */
  80953. static readonly DELAYLOADSTATE_LOADED: number;
  80954. /** Defines that the ressource is currently delay loading */
  80955. static readonly DELAYLOADSTATE_LOADING: number;
  80956. /** Defines that the ressource is delayed and has not started loading */
  80957. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80958. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80959. static readonly NEVER: number;
  80960. /** 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 */
  80961. static readonly ALWAYS: number;
  80962. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80963. static readonly LESS: number;
  80964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80965. static readonly EQUAL: number;
  80966. /** 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 */
  80967. static readonly LEQUAL: number;
  80968. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80969. static readonly GREATER: number;
  80970. /** 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 */
  80971. static readonly GEQUAL: number;
  80972. /** 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 */
  80973. static readonly NOTEQUAL: number;
  80974. /** Passed to stencilOperation to specify that stencil value must be kept */
  80975. static readonly KEEP: number;
  80976. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80977. static readonly REPLACE: number;
  80978. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80979. static readonly INCR: number;
  80980. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80981. static readonly DECR: number;
  80982. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80983. static readonly INVERT: number;
  80984. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80985. static readonly INCR_WRAP: number;
  80986. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80987. static readonly DECR_WRAP: number;
  80988. /** Texture is not repeating outside of 0..1 UVs */
  80989. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80990. /** Texture is repeating outside of 0..1 UVs */
  80991. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80992. /** Texture is repeating and mirrored */
  80993. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80994. /** ALPHA */
  80995. static readonly TEXTUREFORMAT_ALPHA: number;
  80996. /** LUMINANCE */
  80997. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80998. /** LUMINANCE_ALPHA */
  80999. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81000. /** RGB */
  81001. static readonly TEXTUREFORMAT_RGB: number;
  81002. /** RGBA */
  81003. static readonly TEXTUREFORMAT_RGBA: number;
  81004. /** RED */
  81005. static readonly TEXTUREFORMAT_RED: number;
  81006. /** RED (2nd reference) */
  81007. static readonly TEXTUREFORMAT_R: number;
  81008. /** RG */
  81009. static readonly TEXTUREFORMAT_RG: number;
  81010. /** RED_INTEGER */
  81011. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81012. /** RED_INTEGER (2nd reference) */
  81013. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81014. /** RG_INTEGER */
  81015. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81016. /** RGB_INTEGER */
  81017. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81018. /** RGBA_INTEGER */
  81019. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81020. /** UNSIGNED_BYTE */
  81021. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81022. /** UNSIGNED_BYTE (2nd reference) */
  81023. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81024. /** FLOAT */
  81025. static readonly TEXTURETYPE_FLOAT: number;
  81026. /** HALF_FLOAT */
  81027. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81028. /** BYTE */
  81029. static readonly TEXTURETYPE_BYTE: number;
  81030. /** SHORT */
  81031. static readonly TEXTURETYPE_SHORT: number;
  81032. /** UNSIGNED_SHORT */
  81033. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81034. /** INT */
  81035. static readonly TEXTURETYPE_INT: number;
  81036. /** UNSIGNED_INT */
  81037. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81038. /** UNSIGNED_SHORT_4_4_4_4 */
  81039. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81040. /** UNSIGNED_SHORT_5_5_5_1 */
  81041. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81042. /** UNSIGNED_SHORT_5_6_5 */
  81043. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81044. /** UNSIGNED_INT_2_10_10_10_REV */
  81045. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81046. /** UNSIGNED_INT_24_8 */
  81047. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81048. /** UNSIGNED_INT_10F_11F_11F_REV */
  81049. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81050. /** UNSIGNED_INT_5_9_9_9_REV */
  81051. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81052. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81053. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81054. /** nearest is mag = nearest and min = nearest and no mip */
  81055. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81056. /** mag = nearest and min = nearest and mip = none */
  81057. static readonly TEXTURE_NEAREST_NEAREST: number;
  81058. /** Bilinear is mag = linear and min = linear and no mip */
  81059. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81060. /** mag = linear and min = linear and mip = none */
  81061. static readonly TEXTURE_LINEAR_LINEAR: number;
  81062. /** Trilinear is mag = linear and min = linear and mip = linear */
  81063. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81064. /** Trilinear is mag = linear and min = linear and mip = linear */
  81065. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81066. /** mag = nearest and min = nearest and mip = nearest */
  81067. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81068. /** mag = nearest and min = linear and mip = nearest */
  81069. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81070. /** mag = nearest and min = linear and mip = linear */
  81071. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81072. /** mag = nearest and min = linear and mip = none */
  81073. static readonly TEXTURE_NEAREST_LINEAR: number;
  81074. /** nearest is mag = nearest and min = nearest and mip = linear */
  81075. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81076. /** mag = linear and min = nearest and mip = nearest */
  81077. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81078. /** mag = linear and min = nearest and mip = linear */
  81079. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81080. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81081. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81082. /** mag = linear and min = nearest and mip = none */
  81083. static readonly TEXTURE_LINEAR_NEAREST: number;
  81084. /** Explicit coordinates mode */
  81085. static readonly TEXTURE_EXPLICIT_MODE: number;
  81086. /** Spherical coordinates mode */
  81087. static readonly TEXTURE_SPHERICAL_MODE: number;
  81088. /** Planar coordinates mode */
  81089. static readonly TEXTURE_PLANAR_MODE: number;
  81090. /** Cubic coordinates mode */
  81091. static readonly TEXTURE_CUBIC_MODE: number;
  81092. /** Projection coordinates mode */
  81093. static readonly TEXTURE_PROJECTION_MODE: number;
  81094. /** Skybox coordinates mode */
  81095. static readonly TEXTURE_SKYBOX_MODE: number;
  81096. /** Inverse Cubic coordinates mode */
  81097. static readonly TEXTURE_INVCUBIC_MODE: number;
  81098. /** Equirectangular coordinates mode */
  81099. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81100. /** Equirectangular Fixed coordinates mode */
  81101. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81102. /** Equirectangular Fixed Mirrored coordinates mode */
  81103. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81104. /** Offline (baking) quality for texture filtering */
  81105. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81106. /** High quality for texture filtering */
  81107. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81108. /** Medium quality for texture filtering */
  81109. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81110. /** Low quality for texture filtering */
  81111. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81112. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81113. static readonly SCALEMODE_FLOOR: number;
  81114. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81115. static readonly SCALEMODE_NEAREST: number;
  81116. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81117. static readonly SCALEMODE_CEILING: number;
  81118. /**
  81119. * The dirty texture flag value
  81120. */
  81121. static readonly MATERIAL_TextureDirtyFlag: number;
  81122. /**
  81123. * The dirty light flag value
  81124. */
  81125. static readonly MATERIAL_LightDirtyFlag: number;
  81126. /**
  81127. * The dirty fresnel flag value
  81128. */
  81129. static readonly MATERIAL_FresnelDirtyFlag: number;
  81130. /**
  81131. * The dirty attribute flag value
  81132. */
  81133. static readonly MATERIAL_AttributesDirtyFlag: number;
  81134. /**
  81135. * The dirty misc flag value
  81136. */
  81137. static readonly MATERIAL_MiscDirtyFlag: number;
  81138. /**
  81139. * The all dirty flag value
  81140. */
  81141. static readonly MATERIAL_AllDirtyFlag: number;
  81142. /**
  81143. * Returns the triangle fill mode
  81144. */
  81145. static readonly MATERIAL_TriangleFillMode: number;
  81146. /**
  81147. * Returns the wireframe mode
  81148. */
  81149. static readonly MATERIAL_WireFrameFillMode: number;
  81150. /**
  81151. * Returns the point fill mode
  81152. */
  81153. static readonly MATERIAL_PointFillMode: number;
  81154. /**
  81155. * Returns the point list draw mode
  81156. */
  81157. static readonly MATERIAL_PointListDrawMode: number;
  81158. /**
  81159. * Returns the line list draw mode
  81160. */
  81161. static readonly MATERIAL_LineListDrawMode: number;
  81162. /**
  81163. * Returns the line loop draw mode
  81164. */
  81165. static readonly MATERIAL_LineLoopDrawMode: number;
  81166. /**
  81167. * Returns the line strip draw mode
  81168. */
  81169. static readonly MATERIAL_LineStripDrawMode: number;
  81170. /**
  81171. * Returns the triangle strip draw mode
  81172. */
  81173. static readonly MATERIAL_TriangleStripDrawMode: number;
  81174. /**
  81175. * Returns the triangle fan draw mode
  81176. */
  81177. static readonly MATERIAL_TriangleFanDrawMode: number;
  81178. /**
  81179. * Stores the clock-wise side orientation
  81180. */
  81181. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81182. /**
  81183. * Stores the counter clock-wise side orientation
  81184. */
  81185. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81186. /**
  81187. * Nothing
  81188. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81189. */
  81190. static readonly ACTION_NothingTrigger: number;
  81191. /**
  81192. * On pick
  81193. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81194. */
  81195. static readonly ACTION_OnPickTrigger: number;
  81196. /**
  81197. * On left pick
  81198. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81199. */
  81200. static readonly ACTION_OnLeftPickTrigger: number;
  81201. /**
  81202. * On right pick
  81203. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81204. */
  81205. static readonly ACTION_OnRightPickTrigger: number;
  81206. /**
  81207. * On center pick
  81208. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81209. */
  81210. static readonly ACTION_OnCenterPickTrigger: number;
  81211. /**
  81212. * On pick down
  81213. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81214. */
  81215. static readonly ACTION_OnPickDownTrigger: number;
  81216. /**
  81217. * On double pick
  81218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81219. */
  81220. static readonly ACTION_OnDoublePickTrigger: number;
  81221. /**
  81222. * On pick up
  81223. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81224. */
  81225. static readonly ACTION_OnPickUpTrigger: number;
  81226. /**
  81227. * On pick out.
  81228. * This trigger will only be raised if you also declared a OnPickDown
  81229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81230. */
  81231. static readonly ACTION_OnPickOutTrigger: number;
  81232. /**
  81233. * On long press
  81234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81235. */
  81236. static readonly ACTION_OnLongPressTrigger: number;
  81237. /**
  81238. * On pointer over
  81239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81240. */
  81241. static readonly ACTION_OnPointerOverTrigger: number;
  81242. /**
  81243. * On pointer out
  81244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81245. */
  81246. static readonly ACTION_OnPointerOutTrigger: number;
  81247. /**
  81248. * On every frame
  81249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81250. */
  81251. static readonly ACTION_OnEveryFrameTrigger: number;
  81252. /**
  81253. * On intersection enter
  81254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81255. */
  81256. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81257. /**
  81258. * On intersection exit
  81259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81260. */
  81261. static readonly ACTION_OnIntersectionExitTrigger: number;
  81262. /**
  81263. * On key down
  81264. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81265. */
  81266. static readonly ACTION_OnKeyDownTrigger: number;
  81267. /**
  81268. * On key up
  81269. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81270. */
  81271. static readonly ACTION_OnKeyUpTrigger: number;
  81272. /**
  81273. * Billboard mode will only apply to Y axis
  81274. */
  81275. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81276. /**
  81277. * Billboard mode will apply to all axes
  81278. */
  81279. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81280. /**
  81281. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81282. */
  81283. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81284. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81285. * Test order :
  81286. * Is the bounding sphere outside the frustum ?
  81287. * If not, are the bounding box vertices outside the frustum ?
  81288. * It not, then the cullable object is in the frustum.
  81289. */
  81290. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81291. /** Culling strategy : Bounding Sphere Only.
  81292. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81293. * It's also less accurate than the standard because some not visible objects can still be selected.
  81294. * Test : is the bounding sphere outside the frustum ?
  81295. * If not, then the cullable object is in the frustum.
  81296. */
  81297. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81298. /** Culling strategy : Optimistic Inclusion.
  81299. * This in an inclusion test first, then the standard exclusion test.
  81300. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81301. * 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.
  81302. * Anyway, it's as accurate as the standard strategy.
  81303. * Test :
  81304. * Is the cullable object bounding sphere center in the frustum ?
  81305. * If not, apply the default culling strategy.
  81306. */
  81307. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81308. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81309. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81310. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81311. * 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.
  81312. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81313. * Test :
  81314. * Is the cullable object bounding sphere center in the frustum ?
  81315. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81316. */
  81317. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81318. /**
  81319. * No logging while loading
  81320. */
  81321. static readonly SCENELOADER_NO_LOGGING: number;
  81322. /**
  81323. * Minimal logging while loading
  81324. */
  81325. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81326. /**
  81327. * Summary logging while loading
  81328. */
  81329. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81330. /**
  81331. * Detailled logging while loading
  81332. */
  81333. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81334. /**
  81335. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81336. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81337. */
  81338. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81339. /**
  81340. * Constant used to retrieve the position texture index in the textures array in the prepass
  81341. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81342. */
  81343. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81344. /**
  81345. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81346. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81347. */
  81348. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81349. /**
  81350. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81351. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81352. */
  81353. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81354. /**
  81355. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81356. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81357. */
  81358. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81359. /**
  81360. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81361. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81362. */
  81363. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81364. /**
  81365. * Constant used to retrieve albedo index in the textures array in the prepass
  81366. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81367. */
  81368. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81369. }
  81370. }
  81371. declare module BABYLON {
  81372. /**
  81373. * This represents the required contract to create a new type of texture loader.
  81374. */
  81375. export interface IInternalTextureLoader {
  81376. /**
  81377. * Defines wether the loader supports cascade loading the different faces.
  81378. */
  81379. supportCascades: boolean;
  81380. /**
  81381. * This returns if the loader support the current file information.
  81382. * @param extension defines the file extension of the file being loaded
  81383. * @param mimeType defines the optional mime type of the file being loaded
  81384. * @returns true if the loader can load the specified file
  81385. */
  81386. canLoad(extension: string, mimeType?: string): boolean;
  81387. /**
  81388. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81389. * @param data contains the texture data
  81390. * @param texture defines the BabylonJS internal texture
  81391. * @param createPolynomials will be true if polynomials have been requested
  81392. * @param onLoad defines the callback to trigger once the texture is ready
  81393. * @param onError defines the callback to trigger in case of error
  81394. */
  81395. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81396. /**
  81397. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81398. * @param data contains the texture data
  81399. * @param texture defines the BabylonJS internal texture
  81400. * @param callback defines the method to call once ready to upload
  81401. */
  81402. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81403. }
  81404. }
  81405. declare module BABYLON {
  81406. /**
  81407. * Class used to store and describe the pipeline context associated with an effect
  81408. */
  81409. export interface IPipelineContext {
  81410. /**
  81411. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81412. */
  81413. isAsync: boolean;
  81414. /**
  81415. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81416. */
  81417. isReady: boolean;
  81418. /** @hidden */
  81419. _getVertexShaderCode(): string | null;
  81420. /** @hidden */
  81421. _getFragmentShaderCode(): string | null;
  81422. /** @hidden */
  81423. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81424. }
  81425. }
  81426. declare module BABYLON {
  81427. /**
  81428. * Class used to store gfx data (like WebGLBuffer)
  81429. */
  81430. export class DataBuffer {
  81431. /**
  81432. * Gets or sets the number of objects referencing this buffer
  81433. */
  81434. references: number;
  81435. /** Gets or sets the size of the underlying buffer */
  81436. capacity: number;
  81437. /**
  81438. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81439. */
  81440. is32Bits: boolean;
  81441. /**
  81442. * Gets the underlying buffer
  81443. */
  81444. get underlyingResource(): any;
  81445. }
  81446. }
  81447. declare module BABYLON {
  81448. /** @hidden */
  81449. export interface IShaderProcessor {
  81450. attributeProcessor?: (attribute: string) => string;
  81451. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81452. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81453. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81454. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81455. lineProcessor?: (line: string, isFragment: boolean) => string;
  81456. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81457. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81458. }
  81459. }
  81460. declare module BABYLON {
  81461. /** @hidden */
  81462. export interface ProcessingOptions {
  81463. defines: string[];
  81464. indexParameters: any;
  81465. isFragment: boolean;
  81466. shouldUseHighPrecisionShader: boolean;
  81467. supportsUniformBuffers: boolean;
  81468. shadersRepository: string;
  81469. includesShadersStore: {
  81470. [key: string]: string;
  81471. };
  81472. processor?: IShaderProcessor;
  81473. version: string;
  81474. platformName: string;
  81475. lookForClosingBracketForUniformBuffer?: boolean;
  81476. }
  81477. }
  81478. declare module BABYLON {
  81479. /** @hidden */
  81480. export class ShaderCodeNode {
  81481. line: string;
  81482. children: ShaderCodeNode[];
  81483. additionalDefineKey?: string;
  81484. additionalDefineValue?: string;
  81485. isValid(preprocessors: {
  81486. [key: string]: string;
  81487. }): boolean;
  81488. process(preprocessors: {
  81489. [key: string]: string;
  81490. }, options: ProcessingOptions): string;
  81491. }
  81492. }
  81493. declare module BABYLON {
  81494. /** @hidden */
  81495. export class ShaderCodeCursor {
  81496. private _lines;
  81497. lineIndex: number;
  81498. get currentLine(): string;
  81499. get canRead(): boolean;
  81500. set lines(value: string[]);
  81501. }
  81502. }
  81503. declare module BABYLON {
  81504. /** @hidden */
  81505. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81506. process(preprocessors: {
  81507. [key: string]: string;
  81508. }, options: ProcessingOptions): string;
  81509. }
  81510. }
  81511. declare module BABYLON {
  81512. /** @hidden */
  81513. export class ShaderDefineExpression {
  81514. isTrue(preprocessors: {
  81515. [key: string]: string;
  81516. }): boolean;
  81517. private static _OperatorPriority;
  81518. private static _Stack;
  81519. static postfixToInfix(postfix: string[]): string;
  81520. static infixToPostfix(infix: string): string[];
  81521. }
  81522. }
  81523. declare module BABYLON {
  81524. /** @hidden */
  81525. export class ShaderCodeTestNode extends ShaderCodeNode {
  81526. testExpression: ShaderDefineExpression;
  81527. isValid(preprocessors: {
  81528. [key: string]: string;
  81529. }): boolean;
  81530. }
  81531. }
  81532. declare module BABYLON {
  81533. /** @hidden */
  81534. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81535. define: string;
  81536. not: boolean;
  81537. constructor(define: string, not?: boolean);
  81538. isTrue(preprocessors: {
  81539. [key: string]: string;
  81540. }): boolean;
  81541. }
  81542. }
  81543. declare module BABYLON {
  81544. /** @hidden */
  81545. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81546. leftOperand: ShaderDefineExpression;
  81547. rightOperand: ShaderDefineExpression;
  81548. isTrue(preprocessors: {
  81549. [key: string]: string;
  81550. }): boolean;
  81551. }
  81552. }
  81553. declare module BABYLON {
  81554. /** @hidden */
  81555. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81556. leftOperand: ShaderDefineExpression;
  81557. rightOperand: ShaderDefineExpression;
  81558. isTrue(preprocessors: {
  81559. [key: string]: string;
  81560. }): boolean;
  81561. }
  81562. }
  81563. declare module BABYLON {
  81564. /** @hidden */
  81565. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81566. define: string;
  81567. operand: string;
  81568. testValue: string;
  81569. constructor(define: string, operand: string, testValue: string);
  81570. isTrue(preprocessors: {
  81571. [key: string]: string;
  81572. }): boolean;
  81573. }
  81574. }
  81575. declare module BABYLON {
  81576. /**
  81577. * Class used to enable access to offline support
  81578. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81579. */
  81580. export interface IOfflineProvider {
  81581. /**
  81582. * Gets a boolean indicating if scene must be saved in the database
  81583. */
  81584. enableSceneOffline: boolean;
  81585. /**
  81586. * Gets a boolean indicating if textures must be saved in the database
  81587. */
  81588. enableTexturesOffline: boolean;
  81589. /**
  81590. * Open the offline support and make it available
  81591. * @param successCallback defines the callback to call on success
  81592. * @param errorCallback defines the callback to call on error
  81593. */
  81594. open(successCallback: () => void, errorCallback: () => void): void;
  81595. /**
  81596. * Loads an image from the offline support
  81597. * @param url defines the url to load from
  81598. * @param image defines the target DOM image
  81599. */
  81600. loadImage(url: string, image: HTMLImageElement): void;
  81601. /**
  81602. * Loads a file from offline support
  81603. * @param url defines the URL to load from
  81604. * @param sceneLoaded defines a callback to call on success
  81605. * @param progressCallBack defines a callback to call when progress changed
  81606. * @param errorCallback defines a callback to call on error
  81607. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81608. */
  81609. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81610. }
  81611. }
  81612. declare module BABYLON {
  81613. /**
  81614. * Class used to help managing file picking and drag'n'drop
  81615. * File Storage
  81616. */
  81617. export class FilesInputStore {
  81618. /**
  81619. * List of files ready to be loaded
  81620. */
  81621. static FilesToLoad: {
  81622. [key: string]: File;
  81623. };
  81624. }
  81625. }
  81626. declare module BABYLON {
  81627. /**
  81628. * Class used to define a retry strategy when error happens while loading assets
  81629. */
  81630. export class RetryStrategy {
  81631. /**
  81632. * Function used to defines an exponential back off strategy
  81633. * @param maxRetries defines the maximum number of retries (3 by default)
  81634. * @param baseInterval defines the interval between retries
  81635. * @returns the strategy function to use
  81636. */
  81637. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81638. }
  81639. }
  81640. declare module BABYLON {
  81641. /**
  81642. * @ignore
  81643. * Application error to support additional information when loading a file
  81644. */
  81645. export abstract class BaseError extends Error {
  81646. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81647. }
  81648. }
  81649. declare module BABYLON {
  81650. /** @ignore */
  81651. export class LoadFileError extends BaseError {
  81652. request?: WebRequest;
  81653. file?: File;
  81654. /**
  81655. * Creates a new LoadFileError
  81656. * @param message defines the message of the error
  81657. * @param request defines the optional web request
  81658. * @param file defines the optional file
  81659. */
  81660. constructor(message: string, object?: WebRequest | File);
  81661. }
  81662. /** @ignore */
  81663. export class RequestFileError extends BaseError {
  81664. request: WebRequest;
  81665. /**
  81666. * Creates a new LoadFileError
  81667. * @param message defines the message of the error
  81668. * @param request defines the optional web request
  81669. */
  81670. constructor(message: string, request: WebRequest);
  81671. }
  81672. /** @ignore */
  81673. export class ReadFileError extends BaseError {
  81674. file: File;
  81675. /**
  81676. * Creates a new ReadFileError
  81677. * @param message defines the message of the error
  81678. * @param file defines the optional file
  81679. */
  81680. constructor(message: string, file: File);
  81681. }
  81682. /**
  81683. * @hidden
  81684. */
  81685. export class FileTools {
  81686. /**
  81687. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81688. */
  81689. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81690. /**
  81691. * Gets or sets the base URL to use to load assets
  81692. */
  81693. static BaseUrl: string;
  81694. /**
  81695. * Default behaviour for cors in the application.
  81696. * It can be a string if the expected behavior is identical in the entire app.
  81697. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81698. */
  81699. static CorsBehavior: string | ((url: string | string[]) => string);
  81700. /**
  81701. * Gets or sets a function used to pre-process url before using them to load assets
  81702. */
  81703. static PreprocessUrl: (url: string) => string;
  81704. /**
  81705. * Removes unwanted characters from an url
  81706. * @param url defines the url to clean
  81707. * @returns the cleaned url
  81708. */
  81709. private static _CleanUrl;
  81710. /**
  81711. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81712. * @param url define the url we are trying
  81713. * @param element define the dom element where to configure the cors policy
  81714. */
  81715. static SetCorsBehavior(url: string | string[], element: {
  81716. crossOrigin: string | null;
  81717. }): void;
  81718. /**
  81719. * Loads an image as an HTMLImageElement.
  81720. * @param input url string, ArrayBuffer, or Blob to load
  81721. * @param onLoad callback called when the image successfully loads
  81722. * @param onError callback called when the image fails to load
  81723. * @param offlineProvider offline provider for caching
  81724. * @param mimeType optional mime type
  81725. * @returns the HTMLImageElement of the loaded image
  81726. */
  81727. 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>;
  81728. /**
  81729. * Reads a file from a File object
  81730. * @param file defines the file to load
  81731. * @param onSuccess defines the callback to call when data is loaded
  81732. * @param onProgress defines the callback to call during loading process
  81733. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81734. * @param onError defines the callback to call when an error occurs
  81735. * @returns a file request object
  81736. */
  81737. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81738. /**
  81739. * Loads a file from a url
  81740. * @param url url to load
  81741. * @param onSuccess callback called when the file successfully loads
  81742. * @param onProgress callback called while file is loading (if the server supports this mode)
  81743. * @param offlineProvider defines the offline provider for caching
  81744. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81745. * @param onError callback called when the file fails to load
  81746. * @returns a file request object
  81747. */
  81748. 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;
  81749. /**
  81750. * Loads a file
  81751. * @param url url to load
  81752. * @param onSuccess callback called when the file successfully loads
  81753. * @param onProgress callback called while file is loading (if the server supports this mode)
  81754. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81755. * @param onError callback called when the file fails to load
  81756. * @param onOpened callback called when the web request is opened
  81757. * @returns a file request object
  81758. */
  81759. 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;
  81760. /**
  81761. * Checks if the loaded document was accessed via `file:`-Protocol.
  81762. * @returns boolean
  81763. */
  81764. static IsFileURL(): boolean;
  81765. }
  81766. }
  81767. declare module BABYLON {
  81768. /** @hidden */
  81769. export class ShaderProcessor {
  81770. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81771. private static _ProcessPrecision;
  81772. private static _ExtractOperation;
  81773. private static _BuildSubExpression;
  81774. private static _BuildExpression;
  81775. private static _MoveCursorWithinIf;
  81776. private static _MoveCursor;
  81777. private static _EvaluatePreProcessors;
  81778. private static _PreparePreProcessors;
  81779. private static _ProcessShaderConversion;
  81780. private static _ProcessIncludes;
  81781. /**
  81782. * Loads a file from a url
  81783. * @param url url to load
  81784. * @param onSuccess callback called when the file successfully loads
  81785. * @param onProgress callback called while file is loading (if the server supports this mode)
  81786. * @param offlineProvider defines the offline provider for caching
  81787. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81788. * @param onError callback called when the file fails to load
  81789. * @returns a file request object
  81790. * @hidden
  81791. */
  81792. 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;
  81793. }
  81794. }
  81795. declare module BABYLON {
  81796. /**
  81797. * @hidden
  81798. */
  81799. export interface IColor4Like {
  81800. r: float;
  81801. g: float;
  81802. b: float;
  81803. a: float;
  81804. }
  81805. /**
  81806. * @hidden
  81807. */
  81808. export interface IColor3Like {
  81809. r: float;
  81810. g: float;
  81811. b: float;
  81812. }
  81813. /**
  81814. * @hidden
  81815. */
  81816. export interface IVector4Like {
  81817. x: float;
  81818. y: float;
  81819. z: float;
  81820. w: float;
  81821. }
  81822. /**
  81823. * @hidden
  81824. */
  81825. export interface IVector3Like {
  81826. x: float;
  81827. y: float;
  81828. z: float;
  81829. }
  81830. /**
  81831. * @hidden
  81832. */
  81833. export interface IVector2Like {
  81834. x: float;
  81835. y: float;
  81836. }
  81837. /**
  81838. * @hidden
  81839. */
  81840. export interface IMatrixLike {
  81841. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81842. updateFlag: int;
  81843. }
  81844. /**
  81845. * @hidden
  81846. */
  81847. export interface IViewportLike {
  81848. x: float;
  81849. y: float;
  81850. width: float;
  81851. height: float;
  81852. }
  81853. /**
  81854. * @hidden
  81855. */
  81856. export interface IPlaneLike {
  81857. normal: IVector3Like;
  81858. d: float;
  81859. normalize(): void;
  81860. }
  81861. }
  81862. declare module BABYLON {
  81863. /**
  81864. * Interface used to define common properties for effect fallbacks
  81865. */
  81866. export interface IEffectFallbacks {
  81867. /**
  81868. * Removes the defines that should be removed when falling back.
  81869. * @param currentDefines defines the current define statements for the shader.
  81870. * @param effect defines the current effect we try to compile
  81871. * @returns The resulting defines with defines of the current rank removed.
  81872. */
  81873. reduce(currentDefines: string, effect: Effect): string;
  81874. /**
  81875. * Removes the fallback from the bound mesh.
  81876. */
  81877. unBindMesh(): void;
  81878. /**
  81879. * Checks to see if more fallbacks are still availible.
  81880. */
  81881. hasMoreFallbacks: boolean;
  81882. }
  81883. }
  81884. declare module BABYLON {
  81885. /**
  81886. * Class used to evalaute queries containing `and` and `or` operators
  81887. */
  81888. export class AndOrNotEvaluator {
  81889. /**
  81890. * Evaluate a query
  81891. * @param query defines the query to evaluate
  81892. * @param evaluateCallback defines the callback used to filter result
  81893. * @returns true if the query matches
  81894. */
  81895. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81896. private static _HandleParenthesisContent;
  81897. private static _SimplifyNegation;
  81898. }
  81899. }
  81900. declare module BABYLON {
  81901. /**
  81902. * Class used to store custom tags
  81903. */
  81904. export class Tags {
  81905. /**
  81906. * Adds support for tags on the given object
  81907. * @param obj defines the object to use
  81908. */
  81909. static EnableFor(obj: any): void;
  81910. /**
  81911. * Removes tags support
  81912. * @param obj defines the object to use
  81913. */
  81914. static DisableFor(obj: any): void;
  81915. /**
  81916. * Gets a boolean indicating if the given object has tags
  81917. * @param obj defines the object to use
  81918. * @returns a boolean
  81919. */
  81920. static HasTags(obj: any): boolean;
  81921. /**
  81922. * Gets the tags available on a given object
  81923. * @param obj defines the object to use
  81924. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81925. * @returns the tags
  81926. */
  81927. static GetTags(obj: any, asString?: boolean): any;
  81928. /**
  81929. * Adds tags to an object
  81930. * @param obj defines the object to use
  81931. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81932. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81933. */
  81934. static AddTagsTo(obj: any, tagsString: string): void;
  81935. /**
  81936. * @hidden
  81937. */
  81938. static _AddTagTo(obj: any, tag: string): void;
  81939. /**
  81940. * Removes specific tags from a specific object
  81941. * @param obj defines the object to use
  81942. * @param tagsString defines the tags to remove
  81943. */
  81944. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81945. /**
  81946. * @hidden
  81947. */
  81948. static _RemoveTagFrom(obj: any, tag: string): void;
  81949. /**
  81950. * Defines if tags hosted on an object match a given query
  81951. * @param obj defines the object to use
  81952. * @param tagsQuery defines the tag query
  81953. * @returns a boolean
  81954. */
  81955. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81956. }
  81957. }
  81958. declare module BABYLON {
  81959. /**
  81960. * Scalar computation library
  81961. */
  81962. export class Scalar {
  81963. /**
  81964. * Two pi constants convenient for computation.
  81965. */
  81966. static TwoPi: number;
  81967. /**
  81968. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81969. * @param a number
  81970. * @param b number
  81971. * @param epsilon (default = 1.401298E-45)
  81972. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81973. */
  81974. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81975. /**
  81976. * Returns a string : the upper case translation of the number i to hexadecimal.
  81977. * @param i number
  81978. * @returns the upper case translation of the number i to hexadecimal.
  81979. */
  81980. static ToHex(i: number): string;
  81981. /**
  81982. * Returns -1 if value is negative and +1 is value is positive.
  81983. * @param value the value
  81984. * @returns the value itself if it's equal to zero.
  81985. */
  81986. static Sign(value: number): number;
  81987. /**
  81988. * Returns the value itself if it's between min and max.
  81989. * Returns min if the value is lower than min.
  81990. * Returns max if the value is greater than max.
  81991. * @param value the value to clmap
  81992. * @param min the min value to clamp to (default: 0)
  81993. * @param max the max value to clamp to (default: 1)
  81994. * @returns the clamped value
  81995. */
  81996. static Clamp(value: number, min?: number, max?: number): number;
  81997. /**
  81998. * the log2 of value.
  81999. * @param value the value to compute log2 of
  82000. * @returns the log2 of value.
  82001. */
  82002. static Log2(value: number): number;
  82003. /**
  82004. * Loops the value, so that it is never larger than length and never smaller than 0.
  82005. *
  82006. * This is similar to the modulo operator but it works with floating point numbers.
  82007. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82008. * With t = 5 and length = 2.5, the result would be 0.0.
  82009. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82010. * @param value the value
  82011. * @param length the length
  82012. * @returns the looped value
  82013. */
  82014. static Repeat(value: number, length: number): number;
  82015. /**
  82016. * Normalize the value between 0.0 and 1.0 using min and max values
  82017. * @param value value to normalize
  82018. * @param min max to normalize between
  82019. * @param max min to normalize between
  82020. * @returns the normalized value
  82021. */
  82022. static Normalize(value: number, min: number, max: number): number;
  82023. /**
  82024. * Denormalize the value from 0.0 and 1.0 using min and max values
  82025. * @param normalized value to denormalize
  82026. * @param min max to denormalize between
  82027. * @param max min to denormalize between
  82028. * @returns the denormalized value
  82029. */
  82030. static Denormalize(normalized: number, min: number, max: number): number;
  82031. /**
  82032. * Calculates the shortest difference between two given angles given in degrees.
  82033. * @param current current angle in degrees
  82034. * @param target target angle in degrees
  82035. * @returns the delta
  82036. */
  82037. static DeltaAngle(current: number, target: number): number;
  82038. /**
  82039. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82040. * @param tx value
  82041. * @param length length
  82042. * @returns The returned value will move back and forth between 0 and length
  82043. */
  82044. static PingPong(tx: number, length: number): number;
  82045. /**
  82046. * Interpolates between min and max with smoothing at the limits.
  82047. *
  82048. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82049. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82050. * @param from from
  82051. * @param to to
  82052. * @param tx value
  82053. * @returns the smooth stepped value
  82054. */
  82055. static SmoothStep(from: number, to: number, tx: number): number;
  82056. /**
  82057. * Moves a value current towards target.
  82058. *
  82059. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82060. * Negative values of maxDelta pushes the value away from target.
  82061. * @param current current value
  82062. * @param target target value
  82063. * @param maxDelta max distance to move
  82064. * @returns resulting value
  82065. */
  82066. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82067. /**
  82068. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82069. *
  82070. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82071. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82072. * @param current current value
  82073. * @param target target value
  82074. * @param maxDelta max distance to move
  82075. * @returns resulting angle
  82076. */
  82077. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82078. /**
  82079. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82080. * @param start start value
  82081. * @param end target value
  82082. * @param amount amount to lerp between
  82083. * @returns the lerped value
  82084. */
  82085. static Lerp(start: number, end: number, amount: number): number;
  82086. /**
  82087. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82088. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82089. * @param start start value
  82090. * @param end target value
  82091. * @param amount amount to lerp between
  82092. * @returns the lerped value
  82093. */
  82094. static LerpAngle(start: number, end: number, amount: number): number;
  82095. /**
  82096. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82097. * @param a start value
  82098. * @param b target value
  82099. * @param value value between a and b
  82100. * @returns the inverseLerp value
  82101. */
  82102. static InverseLerp(a: number, b: number, value: number): number;
  82103. /**
  82104. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82105. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82106. * @param value1 spline value
  82107. * @param tangent1 spline value
  82108. * @param value2 spline value
  82109. * @param tangent2 spline value
  82110. * @param amount input value
  82111. * @returns hermite result
  82112. */
  82113. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82114. /**
  82115. * Returns a random float number between and min and max values
  82116. * @param min min value of random
  82117. * @param max max value of random
  82118. * @returns random value
  82119. */
  82120. static RandomRange(min: number, max: number): number;
  82121. /**
  82122. * This function returns percentage of a number in a given range.
  82123. *
  82124. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82125. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82126. * @param number to convert to percentage
  82127. * @param min min range
  82128. * @param max max range
  82129. * @returns the percentage
  82130. */
  82131. static RangeToPercent(number: number, min: number, max: number): number;
  82132. /**
  82133. * This function returns number that corresponds to the percentage in a given range.
  82134. *
  82135. * PercentToRange(0.34,0,100) will return 34.
  82136. * @param percent to convert to number
  82137. * @param min min range
  82138. * @param max max range
  82139. * @returns the number
  82140. */
  82141. static PercentToRange(percent: number, min: number, max: number): number;
  82142. /**
  82143. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82144. * @param angle The angle to normalize in radian.
  82145. * @return The converted angle.
  82146. */
  82147. static NormalizeRadians(angle: number): number;
  82148. }
  82149. }
  82150. declare module BABYLON {
  82151. /**
  82152. * Constant used to convert a value to gamma space
  82153. * @ignorenaming
  82154. */
  82155. export const ToGammaSpace: number;
  82156. /**
  82157. * Constant used to convert a value to linear space
  82158. * @ignorenaming
  82159. */
  82160. export const ToLinearSpace = 2.2;
  82161. /**
  82162. * Constant used to define the minimal number value in Babylon.js
  82163. * @ignorenaming
  82164. */
  82165. let Epsilon: number;
  82166. }
  82167. declare module BABYLON {
  82168. /**
  82169. * Class used to represent a viewport on screen
  82170. */
  82171. export class Viewport {
  82172. /** viewport left coordinate */
  82173. x: number;
  82174. /** viewport top coordinate */
  82175. y: number;
  82176. /**viewport width */
  82177. width: number;
  82178. /** viewport height */
  82179. height: number;
  82180. /**
  82181. * Creates a Viewport object located at (x, y) and sized (width, height)
  82182. * @param x defines viewport left coordinate
  82183. * @param y defines viewport top coordinate
  82184. * @param width defines the viewport width
  82185. * @param height defines the viewport height
  82186. */
  82187. constructor(
  82188. /** viewport left coordinate */
  82189. x: number,
  82190. /** viewport top coordinate */
  82191. y: number,
  82192. /**viewport width */
  82193. width: number,
  82194. /** viewport height */
  82195. height: number);
  82196. /**
  82197. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82198. * @param renderWidth defines the rendering width
  82199. * @param renderHeight defines the rendering height
  82200. * @returns a new Viewport
  82201. */
  82202. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82203. /**
  82204. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82205. * @param renderWidth defines the rendering width
  82206. * @param renderHeight defines the rendering height
  82207. * @param ref defines the target viewport
  82208. * @returns the current viewport
  82209. */
  82210. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82211. /**
  82212. * Returns a new Viewport copied from the current one
  82213. * @returns a new Viewport
  82214. */
  82215. clone(): Viewport;
  82216. }
  82217. }
  82218. declare module BABYLON {
  82219. /**
  82220. * Class containing a set of static utilities functions for arrays.
  82221. */
  82222. export class ArrayTools {
  82223. /**
  82224. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82225. * @param size the number of element to construct and put in the array
  82226. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82227. * @returns a new array filled with new objects
  82228. */
  82229. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82230. }
  82231. }
  82232. declare module BABYLON {
  82233. /**
  82234. * Represents a plane by the equation ax + by + cz + d = 0
  82235. */
  82236. export class Plane {
  82237. private static _TmpMatrix;
  82238. /**
  82239. * Normal of the plane (a,b,c)
  82240. */
  82241. normal: Vector3;
  82242. /**
  82243. * d component of the plane
  82244. */
  82245. d: number;
  82246. /**
  82247. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82248. * @param a a component of the plane
  82249. * @param b b component of the plane
  82250. * @param c c component of the plane
  82251. * @param d d component of the plane
  82252. */
  82253. constructor(a: number, b: number, c: number, d: number);
  82254. /**
  82255. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82256. */
  82257. asArray(): number[];
  82258. /**
  82259. * @returns a new plane copied from the current Plane.
  82260. */
  82261. clone(): Plane;
  82262. /**
  82263. * @returns the string "Plane".
  82264. */
  82265. getClassName(): string;
  82266. /**
  82267. * @returns the Plane hash code.
  82268. */
  82269. getHashCode(): number;
  82270. /**
  82271. * Normalize the current Plane in place.
  82272. * @returns the updated Plane.
  82273. */
  82274. normalize(): Plane;
  82275. /**
  82276. * Applies a transformation the plane and returns the result
  82277. * @param transformation the transformation matrix to be applied to the plane
  82278. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82279. */
  82280. transform(transformation: DeepImmutable<Matrix>): Plane;
  82281. /**
  82282. * Compute the dot product between the point and the plane normal
  82283. * @param point point to calculate the dot product with
  82284. * @returns the dot product (float) of the point coordinates and the plane normal.
  82285. */
  82286. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82287. /**
  82288. * Updates the current Plane from the plane defined by the three given points.
  82289. * @param point1 one of the points used to contruct the plane
  82290. * @param point2 one of the points used to contruct the plane
  82291. * @param point3 one of the points used to contruct the plane
  82292. * @returns the updated Plane.
  82293. */
  82294. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82295. /**
  82296. * Checks if the plane is facing a given direction
  82297. * @param direction the direction to check if the plane is facing
  82298. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82299. * @returns True is the vector "direction" is the same side than the plane normal.
  82300. */
  82301. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82302. /**
  82303. * Calculates the distance to a point
  82304. * @param point point to calculate distance to
  82305. * @returns the signed distance (float) from the given point to the Plane.
  82306. */
  82307. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82308. /**
  82309. * Creates a plane from an array
  82310. * @param array the array to create a plane from
  82311. * @returns a new Plane from the given array.
  82312. */
  82313. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82314. /**
  82315. * Creates a plane from three points
  82316. * @param point1 point used to create the plane
  82317. * @param point2 point used to create the plane
  82318. * @param point3 point used to create the plane
  82319. * @returns a new Plane defined by the three given points.
  82320. */
  82321. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82322. /**
  82323. * Creates a plane from an origin point and a normal
  82324. * @param origin origin of the plane to be constructed
  82325. * @param normal normal of the plane to be constructed
  82326. * @returns a new Plane the normal vector to this plane at the given origin point.
  82327. * Note : the vector "normal" is updated because normalized.
  82328. */
  82329. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82330. /**
  82331. * Calculates the distance from a plane and a point
  82332. * @param origin origin of the plane to be constructed
  82333. * @param normal normal of the plane to be constructed
  82334. * @param point point to calculate distance to
  82335. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82336. */
  82337. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82338. }
  82339. }
  82340. declare module BABYLON {
  82341. /** @hidden */
  82342. export class PerformanceConfigurator {
  82343. /** @hidden */
  82344. static MatrixUse64Bits: boolean;
  82345. /** @hidden */
  82346. static MatrixTrackPrecisionChange: boolean;
  82347. /** @hidden */
  82348. static MatrixCurrentType: any;
  82349. /** @hidden */
  82350. static MatrixTrackedMatrices: Array<any> | null;
  82351. /** @hidden */
  82352. static SetMatrixPrecision(use64bits: boolean): void;
  82353. }
  82354. }
  82355. declare module BABYLON {
  82356. /**
  82357. * Class representing a vector containing 2 coordinates
  82358. */
  82359. export class Vector2 {
  82360. /** defines the first coordinate */
  82361. x: number;
  82362. /** defines the second coordinate */
  82363. y: number;
  82364. /**
  82365. * Creates a new Vector2 from the given x and y coordinates
  82366. * @param x defines the first coordinate
  82367. * @param y defines the second coordinate
  82368. */
  82369. constructor(
  82370. /** defines the first coordinate */
  82371. x?: number,
  82372. /** defines the second coordinate */
  82373. y?: number);
  82374. /**
  82375. * Gets a string with the Vector2 coordinates
  82376. * @returns a string with the Vector2 coordinates
  82377. */
  82378. toString(): string;
  82379. /**
  82380. * Gets class name
  82381. * @returns the string "Vector2"
  82382. */
  82383. getClassName(): string;
  82384. /**
  82385. * Gets current vector hash code
  82386. * @returns the Vector2 hash code as a number
  82387. */
  82388. getHashCode(): number;
  82389. /**
  82390. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82391. * @param array defines the source array
  82392. * @param index defines the offset in source array
  82393. * @returns the current Vector2
  82394. */
  82395. toArray(array: FloatArray, index?: number): Vector2;
  82396. /**
  82397. * Update the current vector from an array
  82398. * @param array defines the destination array
  82399. * @param index defines the offset in the destination array
  82400. * @returns the current Vector3
  82401. */
  82402. fromArray(array: FloatArray, index?: number): Vector2;
  82403. /**
  82404. * Copy the current vector to an array
  82405. * @returns a new array with 2 elements: the Vector2 coordinates.
  82406. */
  82407. asArray(): number[];
  82408. /**
  82409. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82410. * @param source defines the source Vector2
  82411. * @returns the current updated Vector2
  82412. */
  82413. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82414. /**
  82415. * Sets the Vector2 coordinates with the given floats
  82416. * @param x defines the first coordinate
  82417. * @param y defines the second coordinate
  82418. * @returns the current updated Vector2
  82419. */
  82420. copyFromFloats(x: number, y: number): Vector2;
  82421. /**
  82422. * Sets the Vector2 coordinates with the given floats
  82423. * @param x defines the first coordinate
  82424. * @param y defines the second coordinate
  82425. * @returns the current updated Vector2
  82426. */
  82427. set(x: number, y: number): Vector2;
  82428. /**
  82429. * Add another vector with the current one
  82430. * @param otherVector defines the other vector
  82431. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82432. */
  82433. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82434. /**
  82435. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82436. * @param otherVector defines the other vector
  82437. * @param result defines the target vector
  82438. * @returns the unmodified current Vector2
  82439. */
  82440. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82441. /**
  82442. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82443. * @param otherVector defines the other vector
  82444. * @returns the current updated Vector2
  82445. */
  82446. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82447. /**
  82448. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82449. * @param otherVector defines the other vector
  82450. * @returns a new Vector2
  82451. */
  82452. addVector3(otherVector: Vector3): Vector2;
  82453. /**
  82454. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82455. * @param otherVector defines the other vector
  82456. * @returns a new Vector2
  82457. */
  82458. subtract(otherVector: Vector2): Vector2;
  82459. /**
  82460. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82461. * @param otherVector defines the other vector
  82462. * @param result defines the target vector
  82463. * @returns the unmodified current Vector2
  82464. */
  82465. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82466. /**
  82467. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82468. * @param otherVector defines the other vector
  82469. * @returns the current updated Vector2
  82470. */
  82471. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82472. /**
  82473. * Multiplies in place the current Vector2 coordinates by the given ones
  82474. * @param otherVector defines the other vector
  82475. * @returns the current updated Vector2
  82476. */
  82477. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82478. /**
  82479. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82480. * @param otherVector defines the other vector
  82481. * @returns a new Vector2
  82482. */
  82483. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82484. /**
  82485. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82486. * @param otherVector defines the other vector
  82487. * @param result defines the target vector
  82488. * @returns the unmodified current Vector2
  82489. */
  82490. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82491. /**
  82492. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82493. * @param x defines the first coordinate
  82494. * @param y defines the second coordinate
  82495. * @returns a new Vector2
  82496. */
  82497. multiplyByFloats(x: number, y: number): Vector2;
  82498. /**
  82499. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82500. * @param otherVector defines the other vector
  82501. * @returns a new Vector2
  82502. */
  82503. divide(otherVector: Vector2): Vector2;
  82504. /**
  82505. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82506. * @param otherVector defines the other vector
  82507. * @param result defines the target vector
  82508. * @returns the unmodified current Vector2
  82509. */
  82510. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82511. /**
  82512. * Divides the current Vector2 coordinates by the given ones
  82513. * @param otherVector defines the other vector
  82514. * @returns the current updated Vector2
  82515. */
  82516. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82517. /**
  82518. * Gets a new Vector2 with current Vector2 negated coordinates
  82519. * @returns a new Vector2
  82520. */
  82521. negate(): Vector2;
  82522. /**
  82523. * Negate this vector in place
  82524. * @returns this
  82525. */
  82526. negateInPlace(): Vector2;
  82527. /**
  82528. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82529. * @param result defines the Vector3 object where to store the result
  82530. * @returns the current Vector2
  82531. */
  82532. negateToRef(result: Vector2): Vector2;
  82533. /**
  82534. * Multiply the Vector2 coordinates by scale
  82535. * @param scale defines the scaling factor
  82536. * @returns the current updated Vector2
  82537. */
  82538. scaleInPlace(scale: number): Vector2;
  82539. /**
  82540. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82541. * @param scale defines the scaling factor
  82542. * @returns a new Vector2
  82543. */
  82544. scale(scale: number): Vector2;
  82545. /**
  82546. * Scale the current Vector2 values by a factor to a given Vector2
  82547. * @param scale defines the scale factor
  82548. * @param result defines the Vector2 object where to store the result
  82549. * @returns the unmodified current Vector2
  82550. */
  82551. scaleToRef(scale: number, result: Vector2): Vector2;
  82552. /**
  82553. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82554. * @param scale defines the scale factor
  82555. * @param result defines the Vector2 object where to store the result
  82556. * @returns the unmodified current Vector2
  82557. */
  82558. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82559. /**
  82560. * Gets a boolean if two vectors are equals
  82561. * @param otherVector defines the other vector
  82562. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82563. */
  82564. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82565. /**
  82566. * Gets a boolean if two vectors are equals (using an epsilon value)
  82567. * @param otherVector defines the other vector
  82568. * @param epsilon defines the minimal distance to consider equality
  82569. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82570. */
  82571. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82572. /**
  82573. * Gets a new Vector2 from current Vector2 floored values
  82574. * @returns a new Vector2
  82575. */
  82576. floor(): Vector2;
  82577. /**
  82578. * Gets a new Vector2 from current Vector2 floored values
  82579. * @returns a new Vector2
  82580. */
  82581. fract(): Vector2;
  82582. /**
  82583. * Gets the length of the vector
  82584. * @returns the vector length (float)
  82585. */
  82586. length(): number;
  82587. /**
  82588. * Gets the vector squared length
  82589. * @returns the vector squared length (float)
  82590. */
  82591. lengthSquared(): number;
  82592. /**
  82593. * Normalize the vector
  82594. * @returns the current updated Vector2
  82595. */
  82596. normalize(): Vector2;
  82597. /**
  82598. * Gets a new Vector2 copied from the Vector2
  82599. * @returns a new Vector2
  82600. */
  82601. clone(): Vector2;
  82602. /**
  82603. * Gets a new Vector2(0, 0)
  82604. * @returns a new Vector2
  82605. */
  82606. static Zero(): Vector2;
  82607. /**
  82608. * Gets a new Vector2(1, 1)
  82609. * @returns a new Vector2
  82610. */
  82611. static One(): Vector2;
  82612. /**
  82613. * Gets a new Vector2 set from the given index element of the given array
  82614. * @param array defines the data source
  82615. * @param offset defines the offset in the data source
  82616. * @returns a new Vector2
  82617. */
  82618. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82619. /**
  82620. * Sets "result" from the given index element of the given array
  82621. * @param array defines the data source
  82622. * @param offset defines the offset in the data source
  82623. * @param result defines the target vector
  82624. */
  82625. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82626. /**
  82627. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82628. * @param value1 defines 1st point of control
  82629. * @param value2 defines 2nd point of control
  82630. * @param value3 defines 3rd point of control
  82631. * @param value4 defines 4th point of control
  82632. * @param amount defines the interpolation factor
  82633. * @returns a new Vector2
  82634. */
  82635. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82636. /**
  82637. * 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".
  82638. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82639. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82640. * @param value defines the value to clamp
  82641. * @param min defines the lower limit
  82642. * @param max defines the upper limit
  82643. * @returns a new Vector2
  82644. */
  82645. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82646. /**
  82647. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82648. * @param value1 defines the 1st control point
  82649. * @param tangent1 defines the outgoing tangent
  82650. * @param value2 defines the 2nd control point
  82651. * @param tangent2 defines the incoming tangent
  82652. * @param amount defines the interpolation factor
  82653. * @returns a new Vector2
  82654. */
  82655. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82656. /**
  82657. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82658. * @param start defines the start vector
  82659. * @param end defines the end vector
  82660. * @param amount defines the interpolation factor
  82661. * @returns a new Vector2
  82662. */
  82663. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82664. /**
  82665. * Gets the dot product of the vector "left" and the vector "right"
  82666. * @param left defines first vector
  82667. * @param right defines second vector
  82668. * @returns the dot product (float)
  82669. */
  82670. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82671. /**
  82672. * Returns a new Vector2 equal to the normalized given vector
  82673. * @param vector defines the vector to normalize
  82674. * @returns a new Vector2
  82675. */
  82676. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82677. /**
  82678. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82679. * @param left defines 1st vector
  82680. * @param right defines 2nd vector
  82681. * @returns a new Vector2
  82682. */
  82683. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82684. /**
  82685. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82686. * @param left defines 1st vector
  82687. * @param right defines 2nd vector
  82688. * @returns a new Vector2
  82689. */
  82690. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82691. /**
  82692. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82693. * @param vector defines the vector to transform
  82694. * @param transformation defines the matrix to apply
  82695. * @returns a new Vector2
  82696. */
  82697. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82698. /**
  82699. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82700. * @param vector defines the vector to transform
  82701. * @param transformation defines the matrix to apply
  82702. * @param result defines the target vector
  82703. */
  82704. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82705. /**
  82706. * Determines if a given vector is included in a triangle
  82707. * @param p defines the vector to test
  82708. * @param p0 defines 1st triangle point
  82709. * @param p1 defines 2nd triangle point
  82710. * @param p2 defines 3rd triangle point
  82711. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82712. */
  82713. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82714. /**
  82715. * Gets the distance between the vectors "value1" and "value2"
  82716. * @param value1 defines first vector
  82717. * @param value2 defines second vector
  82718. * @returns the distance between vectors
  82719. */
  82720. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82721. /**
  82722. * Returns the squared distance between the vectors "value1" and "value2"
  82723. * @param value1 defines first vector
  82724. * @param value2 defines second vector
  82725. * @returns the squared distance between vectors
  82726. */
  82727. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82728. /**
  82729. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82730. * @param value1 defines first vector
  82731. * @param value2 defines second vector
  82732. * @returns a new Vector2
  82733. */
  82734. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82735. /**
  82736. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82737. * @param p defines the middle point
  82738. * @param segA defines one point of the segment
  82739. * @param segB defines the other point of the segment
  82740. * @returns the shortest distance
  82741. */
  82742. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82743. }
  82744. /**
  82745. * Class used to store (x,y,z) vector representation
  82746. * A Vector3 is the main object used in 3D geometry
  82747. * It can represent etiher the coordinates of a point the space, either a direction
  82748. * Reminder: js uses a left handed forward facing system
  82749. */
  82750. export class Vector3 {
  82751. private static _UpReadOnly;
  82752. private static _ZeroReadOnly;
  82753. /** @hidden */
  82754. _x: number;
  82755. /** @hidden */
  82756. _y: number;
  82757. /** @hidden */
  82758. _z: number;
  82759. /** @hidden */
  82760. _isDirty: boolean;
  82761. /** Gets or sets the x coordinate */
  82762. get x(): number;
  82763. set x(value: number);
  82764. /** Gets or sets the y coordinate */
  82765. get y(): number;
  82766. set y(value: number);
  82767. /** Gets or sets the z coordinate */
  82768. get z(): number;
  82769. set z(value: number);
  82770. /**
  82771. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82772. * @param x defines the first coordinates (on X axis)
  82773. * @param y defines the second coordinates (on Y axis)
  82774. * @param z defines the third coordinates (on Z axis)
  82775. */
  82776. constructor(x?: number, y?: number, z?: number);
  82777. /**
  82778. * Creates a string representation of the Vector3
  82779. * @returns a string with the Vector3 coordinates.
  82780. */
  82781. toString(): string;
  82782. /**
  82783. * Gets the class name
  82784. * @returns the string "Vector3"
  82785. */
  82786. getClassName(): string;
  82787. /**
  82788. * Creates the Vector3 hash code
  82789. * @returns a number which tends to be unique between Vector3 instances
  82790. */
  82791. getHashCode(): number;
  82792. /**
  82793. * Creates an array containing three elements : the coordinates of the Vector3
  82794. * @returns a new array of numbers
  82795. */
  82796. asArray(): number[];
  82797. /**
  82798. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82799. * @param array defines the destination array
  82800. * @param index defines the offset in the destination array
  82801. * @returns the current Vector3
  82802. */
  82803. toArray(array: FloatArray, index?: number): Vector3;
  82804. /**
  82805. * Update the current vector from an array
  82806. * @param array defines the destination array
  82807. * @param index defines the offset in the destination array
  82808. * @returns the current Vector3
  82809. */
  82810. fromArray(array: FloatArray, index?: number): Vector3;
  82811. /**
  82812. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82813. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82814. */
  82815. toQuaternion(): Quaternion;
  82816. /**
  82817. * Adds the given vector to the current Vector3
  82818. * @param otherVector defines the second operand
  82819. * @returns the current updated Vector3
  82820. */
  82821. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82822. /**
  82823. * Adds the given coordinates to the current Vector3
  82824. * @param x defines the x coordinate of the operand
  82825. * @param y defines the y coordinate of the operand
  82826. * @param z defines the z coordinate of the operand
  82827. * @returns the current updated Vector3
  82828. */
  82829. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82830. /**
  82831. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82832. * @param otherVector defines the second operand
  82833. * @returns the resulting Vector3
  82834. */
  82835. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82836. /**
  82837. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82838. * @param otherVector defines the second operand
  82839. * @param result defines the Vector3 object where to store the result
  82840. * @returns the current Vector3
  82841. */
  82842. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82843. /**
  82844. * Subtract the given vector from the current Vector3
  82845. * @param otherVector defines the second operand
  82846. * @returns the current updated Vector3
  82847. */
  82848. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82849. /**
  82850. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82851. * @param otherVector defines the second operand
  82852. * @returns the resulting Vector3
  82853. */
  82854. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82855. /**
  82856. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82857. * @param otherVector defines the second operand
  82858. * @param result defines the Vector3 object where to store the result
  82859. * @returns the current Vector3
  82860. */
  82861. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82862. /**
  82863. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82864. * @param x defines the x coordinate of the operand
  82865. * @param y defines the y coordinate of the operand
  82866. * @param z defines the z coordinate of the operand
  82867. * @returns the resulting Vector3
  82868. */
  82869. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82870. /**
  82871. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82872. * @param x defines the x coordinate of the operand
  82873. * @param y defines the y coordinate of the operand
  82874. * @param z defines the z coordinate of the operand
  82875. * @param result defines the Vector3 object where to store the result
  82876. * @returns the current Vector3
  82877. */
  82878. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82879. /**
  82880. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82881. * @returns a new Vector3
  82882. */
  82883. negate(): Vector3;
  82884. /**
  82885. * Negate this vector in place
  82886. * @returns this
  82887. */
  82888. negateInPlace(): Vector3;
  82889. /**
  82890. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82891. * @param result defines the Vector3 object where to store the result
  82892. * @returns the current Vector3
  82893. */
  82894. negateToRef(result: Vector3): Vector3;
  82895. /**
  82896. * Multiplies the Vector3 coordinates by the float "scale"
  82897. * @param scale defines the multiplier factor
  82898. * @returns the current updated Vector3
  82899. */
  82900. scaleInPlace(scale: number): Vector3;
  82901. /**
  82902. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82903. * @param scale defines the multiplier factor
  82904. * @returns a new Vector3
  82905. */
  82906. scale(scale: number): Vector3;
  82907. /**
  82908. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82909. * @param scale defines the multiplier factor
  82910. * @param result defines the Vector3 object where to store the result
  82911. * @returns the current Vector3
  82912. */
  82913. scaleToRef(scale: number, result: Vector3): Vector3;
  82914. /**
  82915. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82916. * @param scale defines the scale factor
  82917. * @param result defines the Vector3 object where to store the result
  82918. * @returns the unmodified current Vector3
  82919. */
  82920. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82921. /**
  82922. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82923. * @param origin defines the origin of the projection ray
  82924. * @param plane defines the plane to project to
  82925. * @returns the projected vector3
  82926. */
  82927. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82928. /**
  82929. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82930. * @param origin defines the origin of the projection ray
  82931. * @param plane defines the plane to project to
  82932. * @param result defines the Vector3 where to store the result
  82933. */
  82934. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82935. /**
  82936. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82937. * @param otherVector defines the second operand
  82938. * @returns true if both vectors are equals
  82939. */
  82940. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82941. /**
  82942. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82943. * @param otherVector defines the second operand
  82944. * @param epsilon defines the minimal distance to define values as equals
  82945. * @returns true if both vectors are distant less than epsilon
  82946. */
  82947. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82948. /**
  82949. * Returns true if the current Vector3 coordinates equals the given floats
  82950. * @param x defines the x coordinate of the operand
  82951. * @param y defines the y coordinate of the operand
  82952. * @param z defines the z coordinate of the operand
  82953. * @returns true if both vectors are equals
  82954. */
  82955. equalsToFloats(x: number, y: number, z: number): boolean;
  82956. /**
  82957. * Multiplies the current Vector3 coordinates by the given ones
  82958. * @param otherVector defines the second operand
  82959. * @returns the current updated Vector3
  82960. */
  82961. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82962. /**
  82963. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82964. * @param otherVector defines the second operand
  82965. * @returns the new Vector3
  82966. */
  82967. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82968. /**
  82969. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82970. * @param otherVector defines the second operand
  82971. * @param result defines the Vector3 object where to store the result
  82972. * @returns the current Vector3
  82973. */
  82974. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82975. /**
  82976. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82977. * @param x defines the x coordinate of the operand
  82978. * @param y defines the y coordinate of the operand
  82979. * @param z defines the z coordinate of the operand
  82980. * @returns the new Vector3
  82981. */
  82982. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82983. /**
  82984. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82985. * @param otherVector defines the second operand
  82986. * @returns the new Vector3
  82987. */
  82988. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82989. /**
  82990. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82991. * @param otherVector defines the second operand
  82992. * @param result defines the Vector3 object where to store the result
  82993. * @returns the current Vector3
  82994. */
  82995. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82996. /**
  82997. * Divides the current Vector3 coordinates by the given ones.
  82998. * @param otherVector defines the second operand
  82999. * @returns the current updated Vector3
  83000. */
  83001. divideInPlace(otherVector: Vector3): Vector3;
  83002. /**
  83003. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83004. * @param other defines the second operand
  83005. * @returns the current updated Vector3
  83006. */
  83007. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83008. /**
  83009. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83010. * @param other defines the second operand
  83011. * @returns the current updated Vector3
  83012. */
  83013. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83014. /**
  83015. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83016. * @param x defines the x coordinate of the operand
  83017. * @param y defines the y coordinate of the operand
  83018. * @param z defines the z coordinate of the operand
  83019. * @returns the current updated Vector3
  83020. */
  83021. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83022. /**
  83023. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83024. * @param x defines the x coordinate of the operand
  83025. * @param y defines the y coordinate of the operand
  83026. * @param z defines the z coordinate of the operand
  83027. * @returns the current updated Vector3
  83028. */
  83029. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83030. /**
  83031. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83032. * Check if is non uniform within a certain amount of decimal places to account for this
  83033. * @param epsilon the amount the values can differ
  83034. * @returns if the the vector is non uniform to a certain number of decimal places
  83035. */
  83036. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83037. /**
  83038. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83039. */
  83040. get isNonUniform(): boolean;
  83041. /**
  83042. * Gets a new Vector3 from current Vector3 floored values
  83043. * @returns a new Vector3
  83044. */
  83045. floor(): Vector3;
  83046. /**
  83047. * Gets a new Vector3 from current Vector3 floored values
  83048. * @returns a new Vector3
  83049. */
  83050. fract(): Vector3;
  83051. /**
  83052. * Gets the length of the Vector3
  83053. * @returns the length of the Vector3
  83054. */
  83055. length(): number;
  83056. /**
  83057. * Gets the squared length of the Vector3
  83058. * @returns squared length of the Vector3
  83059. */
  83060. lengthSquared(): number;
  83061. /**
  83062. * Normalize the current Vector3.
  83063. * Please note that this is an in place operation.
  83064. * @returns the current updated Vector3
  83065. */
  83066. normalize(): Vector3;
  83067. /**
  83068. * Reorders the x y z properties of the vector in place
  83069. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83070. * @returns the current updated vector
  83071. */
  83072. reorderInPlace(order: string): this;
  83073. /**
  83074. * Rotates the vector around 0,0,0 by a quaternion
  83075. * @param quaternion the rotation quaternion
  83076. * @param result vector to store the result
  83077. * @returns the resulting vector
  83078. */
  83079. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83080. /**
  83081. * Rotates a vector around a given point
  83082. * @param quaternion the rotation quaternion
  83083. * @param point the point to rotate around
  83084. * @param result vector to store the result
  83085. * @returns the resulting vector
  83086. */
  83087. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83088. /**
  83089. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83090. * The cross product is then orthogonal to both current and "other"
  83091. * @param other defines the right operand
  83092. * @returns the cross product
  83093. */
  83094. cross(other: Vector3): Vector3;
  83095. /**
  83096. * Normalize the current Vector3 with the given input length.
  83097. * Please note that this is an in place operation.
  83098. * @param len the length of the vector
  83099. * @returns the current updated Vector3
  83100. */
  83101. normalizeFromLength(len: number): Vector3;
  83102. /**
  83103. * Normalize the current Vector3 to a new vector
  83104. * @returns the new Vector3
  83105. */
  83106. normalizeToNew(): Vector3;
  83107. /**
  83108. * Normalize the current Vector3 to the reference
  83109. * @param reference define the Vector3 to update
  83110. * @returns the updated Vector3
  83111. */
  83112. normalizeToRef(reference: Vector3): Vector3;
  83113. /**
  83114. * Creates a new Vector3 copied from the current Vector3
  83115. * @returns the new Vector3
  83116. */
  83117. clone(): Vector3;
  83118. /**
  83119. * Copies the given vector coordinates to the current Vector3 ones
  83120. * @param source defines the source Vector3
  83121. * @returns the current updated Vector3
  83122. */
  83123. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83124. /**
  83125. * Copies the given floats to the current Vector3 coordinates
  83126. * @param x defines the x coordinate of the operand
  83127. * @param y defines the y coordinate of the operand
  83128. * @param z defines the z coordinate of the operand
  83129. * @returns the current updated Vector3
  83130. */
  83131. copyFromFloats(x: number, y: number, z: number): Vector3;
  83132. /**
  83133. * Copies the given floats to the current Vector3 coordinates
  83134. * @param x defines the x coordinate of the operand
  83135. * @param y defines the y coordinate of the operand
  83136. * @param z defines the z coordinate of the operand
  83137. * @returns the current updated Vector3
  83138. */
  83139. set(x: number, y: number, z: number): Vector3;
  83140. /**
  83141. * Copies the given float to the current Vector3 coordinates
  83142. * @param v defines the x, y and z coordinates of the operand
  83143. * @returns the current updated Vector3
  83144. */
  83145. setAll(v: number): Vector3;
  83146. /**
  83147. * Get the clip factor between two vectors
  83148. * @param vector0 defines the first operand
  83149. * @param vector1 defines the second operand
  83150. * @param axis defines the axis to use
  83151. * @param size defines the size along the axis
  83152. * @returns the clip factor
  83153. */
  83154. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83155. /**
  83156. * Get angle between two vectors
  83157. * @param vector0 angle between vector0 and vector1
  83158. * @param vector1 angle between vector0 and vector1
  83159. * @param normal direction of the normal
  83160. * @return the angle between vector0 and vector1
  83161. */
  83162. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83163. /**
  83164. * Returns a new Vector3 set from the index "offset" of the given array
  83165. * @param array defines the source array
  83166. * @param offset defines the offset in the source array
  83167. * @returns the new Vector3
  83168. */
  83169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83170. /**
  83171. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83172. * @param array defines the source array
  83173. * @param offset defines the offset in the source array
  83174. * @returns the new Vector3
  83175. * @deprecated Please use FromArray instead.
  83176. */
  83177. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83178. /**
  83179. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83180. * @param array defines the source array
  83181. * @param offset defines the offset in the source array
  83182. * @param result defines the Vector3 where to store the result
  83183. */
  83184. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83185. /**
  83186. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83187. * @param array defines the source array
  83188. * @param offset defines the offset in the source array
  83189. * @param result defines the Vector3 where to store the result
  83190. * @deprecated Please use FromArrayToRef instead.
  83191. */
  83192. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83193. /**
  83194. * Sets the given vector "result" with the given floats.
  83195. * @param x defines the x coordinate of the source
  83196. * @param y defines the y coordinate of the source
  83197. * @param z defines the z coordinate of the source
  83198. * @param result defines the Vector3 where to store the result
  83199. */
  83200. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83201. /**
  83202. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83203. * @returns a new empty Vector3
  83204. */
  83205. static Zero(): Vector3;
  83206. /**
  83207. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83208. * @returns a new unit Vector3
  83209. */
  83210. static One(): Vector3;
  83211. /**
  83212. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83213. * @returns a new up Vector3
  83214. */
  83215. static Up(): Vector3;
  83216. /**
  83217. * Gets a up Vector3 that must not be updated
  83218. */
  83219. static get UpReadOnly(): DeepImmutable<Vector3>;
  83220. /**
  83221. * Gets a zero Vector3 that must not be updated
  83222. */
  83223. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83224. /**
  83225. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83226. * @returns a new down Vector3
  83227. */
  83228. static Down(): Vector3;
  83229. /**
  83230. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83231. * @param rightHandedSystem is the scene right-handed (negative z)
  83232. * @returns a new forward Vector3
  83233. */
  83234. static Forward(rightHandedSystem?: boolean): Vector3;
  83235. /**
  83236. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83237. * @param rightHandedSystem is the scene right-handed (negative-z)
  83238. * @returns a new forward Vector3
  83239. */
  83240. static Backward(rightHandedSystem?: boolean): Vector3;
  83241. /**
  83242. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83243. * @returns a new right Vector3
  83244. */
  83245. static Right(): Vector3;
  83246. /**
  83247. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83248. * @returns a new left Vector3
  83249. */
  83250. static Left(): Vector3;
  83251. /**
  83252. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83253. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83254. * @param vector defines the Vector3 to transform
  83255. * @param transformation defines the transformation matrix
  83256. * @returns the transformed Vector3
  83257. */
  83258. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83259. /**
  83260. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83261. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83262. * @param vector defines the Vector3 to transform
  83263. * @param transformation defines the transformation matrix
  83264. * @param result defines the Vector3 where to store the result
  83265. */
  83266. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83267. /**
  83268. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83269. * This method computes tranformed coordinates only, not transformed direction vectors
  83270. * @param x define the x coordinate of the source vector
  83271. * @param y define the y coordinate of the source vector
  83272. * @param z define the z coordinate of the source vector
  83273. * @param transformation defines the transformation matrix
  83274. * @param result defines the Vector3 where to store the result
  83275. */
  83276. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83277. /**
  83278. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83279. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83280. * @param vector defines the Vector3 to transform
  83281. * @param transformation defines the transformation matrix
  83282. * @returns the new Vector3
  83283. */
  83284. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83285. /**
  83286. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83287. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83288. * @param vector defines the Vector3 to transform
  83289. * @param transformation defines the transformation matrix
  83290. * @param result defines the Vector3 where to store the result
  83291. */
  83292. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83293. /**
  83294. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83295. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83296. * @param x define the x coordinate of the source vector
  83297. * @param y define the y coordinate of the source vector
  83298. * @param z define the z coordinate of the source vector
  83299. * @param transformation defines the transformation matrix
  83300. * @param result defines the Vector3 where to store the result
  83301. */
  83302. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83303. /**
  83304. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83305. * @param value1 defines the first control point
  83306. * @param value2 defines the second control point
  83307. * @param value3 defines the third control point
  83308. * @param value4 defines the fourth control point
  83309. * @param amount defines the amount on the spline to use
  83310. * @returns the new Vector3
  83311. */
  83312. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83313. /**
  83314. * 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"
  83315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83317. * @param value defines the current value
  83318. * @param min defines the lower range value
  83319. * @param max defines the upper range value
  83320. * @returns the new Vector3
  83321. */
  83322. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83323. /**
  83324. * 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"
  83325. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83326. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83327. * @param value defines the current value
  83328. * @param min defines the lower range value
  83329. * @param max defines the upper range value
  83330. * @param result defines the Vector3 where to store the result
  83331. */
  83332. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83333. /**
  83334. * Checks if a given vector is inside a specific range
  83335. * @param v defines the vector to test
  83336. * @param min defines the minimum range
  83337. * @param max defines the maximum range
  83338. */
  83339. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83340. /**
  83341. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83342. * @param value1 defines the first control point
  83343. * @param tangent1 defines the first tangent vector
  83344. * @param value2 defines the second control point
  83345. * @param tangent2 defines the second tangent vector
  83346. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83347. * @returns the new Vector3
  83348. */
  83349. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83350. /**
  83351. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83352. * @param start defines the start value
  83353. * @param end defines the end value
  83354. * @param amount max defines amount between both (between 0 and 1)
  83355. * @returns the new Vector3
  83356. */
  83357. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83358. /**
  83359. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83360. * @param start defines the start value
  83361. * @param end defines the end value
  83362. * @param amount max defines amount between both (between 0 and 1)
  83363. * @param result defines the Vector3 where to store the result
  83364. */
  83365. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83366. /**
  83367. * Returns the dot product (float) between the vectors "left" and "right"
  83368. * @param left defines the left operand
  83369. * @param right defines the right operand
  83370. * @returns the dot product
  83371. */
  83372. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83373. /**
  83374. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83375. * The cross product is then orthogonal to both "left" and "right"
  83376. * @param left defines the left operand
  83377. * @param right defines the right operand
  83378. * @returns the cross product
  83379. */
  83380. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83381. /**
  83382. * Sets the given vector "result" with the cross product of "left" and "right"
  83383. * The cross product is then orthogonal to both "left" and "right"
  83384. * @param left defines the left operand
  83385. * @param right defines the right operand
  83386. * @param result defines the Vector3 where to store the result
  83387. */
  83388. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83389. /**
  83390. * Returns a new Vector3 as the normalization of the given vector
  83391. * @param vector defines the Vector3 to normalize
  83392. * @returns the new Vector3
  83393. */
  83394. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83395. /**
  83396. * Sets the given vector "result" with the normalization of the given first vector
  83397. * @param vector defines the Vector3 to normalize
  83398. * @param result defines the Vector3 where to store the result
  83399. */
  83400. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83401. /**
  83402. * Project a Vector3 onto screen space
  83403. * @param vector defines the Vector3 to project
  83404. * @param world defines the world matrix to use
  83405. * @param transform defines the transform (view x projection) matrix to use
  83406. * @param viewport defines the screen viewport to use
  83407. * @returns the new Vector3
  83408. */
  83409. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83410. /** @hidden */
  83411. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83412. /**
  83413. * Unproject from screen space to object space
  83414. * @param source defines the screen space Vector3 to use
  83415. * @param viewportWidth defines the current width of the viewport
  83416. * @param viewportHeight defines the current height of the viewport
  83417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83418. * @param transform defines the transform (view x projection) matrix to use
  83419. * @returns the new Vector3
  83420. */
  83421. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83422. /**
  83423. * Unproject from screen space to object space
  83424. * @param source defines the screen space Vector3 to use
  83425. * @param viewportWidth defines the current width of the viewport
  83426. * @param viewportHeight defines the current height of the viewport
  83427. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83428. * @param view defines the view matrix to use
  83429. * @param projection defines the projection matrix to use
  83430. * @returns the new Vector3
  83431. */
  83432. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83433. /**
  83434. * Unproject from screen space to object space
  83435. * @param source defines the screen space Vector3 to use
  83436. * @param viewportWidth defines the current width of the viewport
  83437. * @param viewportHeight defines the current height of the viewport
  83438. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83439. * @param view defines the view matrix to use
  83440. * @param projection defines the projection matrix to use
  83441. * @param result defines the Vector3 where to store the result
  83442. */
  83443. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83444. /**
  83445. * Unproject from screen space to object space
  83446. * @param sourceX defines the screen space x coordinate to use
  83447. * @param sourceY defines the screen space y coordinate to use
  83448. * @param sourceZ defines the screen space z coordinate to use
  83449. * @param viewportWidth defines the current width of the viewport
  83450. * @param viewportHeight defines the current height of the viewport
  83451. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83452. * @param view defines the view matrix to use
  83453. * @param projection defines the projection matrix to use
  83454. * @param result defines the Vector3 where to store the result
  83455. */
  83456. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83457. /**
  83458. * Gets the minimal coordinate values between two Vector3
  83459. * @param left defines the first operand
  83460. * @param right defines the second operand
  83461. * @returns the new Vector3
  83462. */
  83463. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83464. /**
  83465. * Gets the maximal coordinate values between two Vector3
  83466. * @param left defines the first operand
  83467. * @param right defines the second operand
  83468. * @returns the new Vector3
  83469. */
  83470. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83471. /**
  83472. * Returns the distance between the vectors "value1" and "value2"
  83473. * @param value1 defines the first operand
  83474. * @param value2 defines the second operand
  83475. * @returns the distance
  83476. */
  83477. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83478. /**
  83479. * Returns the squared distance between the vectors "value1" and "value2"
  83480. * @param value1 defines the first operand
  83481. * @param value2 defines the second operand
  83482. * @returns the squared distance
  83483. */
  83484. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83485. /**
  83486. * Returns a new Vector3 located at the center between "value1" and "value2"
  83487. * @param value1 defines the first operand
  83488. * @param value2 defines the second operand
  83489. * @returns the new Vector3
  83490. */
  83491. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83492. /**
  83493. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83494. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83495. * to something in order to rotate it from its local system to the given target system
  83496. * Note: axis1, axis2 and axis3 are normalized during this operation
  83497. * @param axis1 defines the first axis
  83498. * @param axis2 defines the second axis
  83499. * @param axis3 defines the third axis
  83500. * @returns a new Vector3
  83501. */
  83502. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83503. /**
  83504. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83505. * @param axis1 defines the first axis
  83506. * @param axis2 defines the second axis
  83507. * @param axis3 defines the third axis
  83508. * @param ref defines the Vector3 where to store the result
  83509. */
  83510. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83511. }
  83512. /**
  83513. * Vector4 class created for EulerAngle class conversion to Quaternion
  83514. */
  83515. export class Vector4 {
  83516. /** x value of the vector */
  83517. x: number;
  83518. /** y value of the vector */
  83519. y: number;
  83520. /** z value of the vector */
  83521. z: number;
  83522. /** w value of the vector */
  83523. w: number;
  83524. /**
  83525. * Creates a Vector4 object from the given floats.
  83526. * @param x x value of the vector
  83527. * @param y y value of the vector
  83528. * @param z z value of the vector
  83529. * @param w w value of the vector
  83530. */
  83531. constructor(
  83532. /** x value of the vector */
  83533. x: number,
  83534. /** y value of the vector */
  83535. y: number,
  83536. /** z value of the vector */
  83537. z: number,
  83538. /** w value of the vector */
  83539. w: number);
  83540. /**
  83541. * Returns the string with the Vector4 coordinates.
  83542. * @returns a string containing all the vector values
  83543. */
  83544. toString(): string;
  83545. /**
  83546. * Returns the string "Vector4".
  83547. * @returns "Vector4"
  83548. */
  83549. getClassName(): string;
  83550. /**
  83551. * Returns the Vector4 hash code.
  83552. * @returns a unique hash code
  83553. */
  83554. getHashCode(): number;
  83555. /**
  83556. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83557. * @returns the resulting array
  83558. */
  83559. asArray(): number[];
  83560. /**
  83561. * Populates the given array from the given index with the Vector4 coordinates.
  83562. * @param array array to populate
  83563. * @param index index of the array to start at (default: 0)
  83564. * @returns the Vector4.
  83565. */
  83566. toArray(array: FloatArray, index?: number): Vector4;
  83567. /**
  83568. * Update the current vector from an array
  83569. * @param array defines the destination array
  83570. * @param index defines the offset in the destination array
  83571. * @returns the current Vector3
  83572. */
  83573. fromArray(array: FloatArray, index?: number): Vector4;
  83574. /**
  83575. * Adds the given vector to the current Vector4.
  83576. * @param otherVector the vector to add
  83577. * @returns the updated Vector4.
  83578. */
  83579. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83580. /**
  83581. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83582. * @param otherVector the vector to add
  83583. * @returns the resulting vector
  83584. */
  83585. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83586. /**
  83587. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83588. * @param otherVector the vector to add
  83589. * @param result the vector to store the result
  83590. * @returns the current Vector4.
  83591. */
  83592. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83593. /**
  83594. * Subtract in place the given vector from the current Vector4.
  83595. * @param otherVector the vector to subtract
  83596. * @returns the updated Vector4.
  83597. */
  83598. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83599. /**
  83600. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83601. * @param otherVector the vector to add
  83602. * @returns the new vector with the result
  83603. */
  83604. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83605. /**
  83606. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83607. * @param otherVector the vector to subtract
  83608. * @param result the vector to store the result
  83609. * @returns the current Vector4.
  83610. */
  83611. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83612. /**
  83613. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83614. */
  83615. /**
  83616. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83617. * @param x value to subtract
  83618. * @param y value to subtract
  83619. * @param z value to subtract
  83620. * @param w value to subtract
  83621. * @returns new vector containing the result
  83622. */
  83623. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83624. /**
  83625. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83626. * @param x value to subtract
  83627. * @param y value to subtract
  83628. * @param z value to subtract
  83629. * @param w value to subtract
  83630. * @param result the vector to store the result in
  83631. * @returns the current Vector4.
  83632. */
  83633. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83634. /**
  83635. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83636. * @returns a new vector with the negated values
  83637. */
  83638. negate(): Vector4;
  83639. /**
  83640. * Negate this vector in place
  83641. * @returns this
  83642. */
  83643. negateInPlace(): Vector4;
  83644. /**
  83645. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83646. * @param result defines the Vector3 object where to store the result
  83647. * @returns the current Vector4
  83648. */
  83649. negateToRef(result: Vector4): Vector4;
  83650. /**
  83651. * Multiplies the current Vector4 coordinates by scale (float).
  83652. * @param scale the number to scale with
  83653. * @returns the updated Vector4.
  83654. */
  83655. scaleInPlace(scale: number): Vector4;
  83656. /**
  83657. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83658. * @param scale the number to scale with
  83659. * @returns a new vector with the result
  83660. */
  83661. scale(scale: number): Vector4;
  83662. /**
  83663. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83664. * @param scale the number to scale with
  83665. * @param result a vector to store the result in
  83666. * @returns the current Vector4.
  83667. */
  83668. scaleToRef(scale: number, result: Vector4): Vector4;
  83669. /**
  83670. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83671. * @param scale defines the scale factor
  83672. * @param result defines the Vector4 object where to store the result
  83673. * @returns the unmodified current Vector4
  83674. */
  83675. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83676. /**
  83677. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83678. * @param otherVector the vector to compare against
  83679. * @returns true if they are equal
  83680. */
  83681. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83682. /**
  83683. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83684. * @param otherVector vector to compare against
  83685. * @param epsilon (Default: very small number)
  83686. * @returns true if they are equal
  83687. */
  83688. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83689. /**
  83690. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83691. * @param x x value to compare against
  83692. * @param y y value to compare against
  83693. * @param z z value to compare against
  83694. * @param w w value to compare against
  83695. * @returns true if equal
  83696. */
  83697. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83698. /**
  83699. * Multiplies in place the current Vector4 by the given one.
  83700. * @param otherVector vector to multiple with
  83701. * @returns the updated Vector4.
  83702. */
  83703. multiplyInPlace(otherVector: Vector4): Vector4;
  83704. /**
  83705. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83706. * @param otherVector vector to multiple with
  83707. * @returns resulting new vector
  83708. */
  83709. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83710. /**
  83711. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83712. * @param otherVector vector to multiple with
  83713. * @param result vector to store the result
  83714. * @returns the current Vector4.
  83715. */
  83716. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83717. /**
  83718. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83719. * @param x x value multiply with
  83720. * @param y y value multiply with
  83721. * @param z z value multiply with
  83722. * @param w w value multiply with
  83723. * @returns resulting new vector
  83724. */
  83725. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83726. /**
  83727. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83728. * @param otherVector vector to devide with
  83729. * @returns resulting new vector
  83730. */
  83731. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83732. /**
  83733. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83734. * @param otherVector vector to devide with
  83735. * @param result vector to store the result
  83736. * @returns the current Vector4.
  83737. */
  83738. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83739. /**
  83740. * Divides the current Vector3 coordinates by the given ones.
  83741. * @param otherVector vector to devide with
  83742. * @returns the updated Vector3.
  83743. */
  83744. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83745. /**
  83746. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83747. * @param other defines the second operand
  83748. * @returns the current updated Vector4
  83749. */
  83750. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83751. /**
  83752. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83753. * @param other defines the second operand
  83754. * @returns the current updated Vector4
  83755. */
  83756. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83757. /**
  83758. * Gets a new Vector4 from current Vector4 floored values
  83759. * @returns a new Vector4
  83760. */
  83761. floor(): Vector4;
  83762. /**
  83763. * Gets a new Vector4 from current Vector3 floored values
  83764. * @returns a new Vector4
  83765. */
  83766. fract(): Vector4;
  83767. /**
  83768. * Returns the Vector4 length (float).
  83769. * @returns the length
  83770. */
  83771. length(): number;
  83772. /**
  83773. * Returns the Vector4 squared length (float).
  83774. * @returns the length squared
  83775. */
  83776. lengthSquared(): number;
  83777. /**
  83778. * Normalizes in place the Vector4.
  83779. * @returns the updated Vector4.
  83780. */
  83781. normalize(): Vector4;
  83782. /**
  83783. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83784. * @returns this converted to a new vector3
  83785. */
  83786. toVector3(): Vector3;
  83787. /**
  83788. * Returns a new Vector4 copied from the current one.
  83789. * @returns the new cloned vector
  83790. */
  83791. clone(): Vector4;
  83792. /**
  83793. * Updates the current Vector4 with the given one coordinates.
  83794. * @param source the source vector to copy from
  83795. * @returns the updated Vector4.
  83796. */
  83797. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83798. /**
  83799. * Updates the current Vector4 coordinates with the given floats.
  83800. * @param x float to copy from
  83801. * @param y float to copy from
  83802. * @param z float to copy from
  83803. * @param w float to copy from
  83804. * @returns the updated Vector4.
  83805. */
  83806. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83807. /**
  83808. * Updates the current Vector4 coordinates with the given floats.
  83809. * @param x float to set from
  83810. * @param y float to set from
  83811. * @param z float to set from
  83812. * @param w float to set from
  83813. * @returns the updated Vector4.
  83814. */
  83815. set(x: number, y: number, z: number, w: number): Vector4;
  83816. /**
  83817. * Copies the given float to the current Vector3 coordinates
  83818. * @param v defines the x, y, z and w coordinates of the operand
  83819. * @returns the current updated Vector3
  83820. */
  83821. setAll(v: number): Vector4;
  83822. /**
  83823. * Returns a new Vector4 set from the starting index of the given array.
  83824. * @param array the array to pull values from
  83825. * @param offset the offset into the array to start at
  83826. * @returns the new vector
  83827. */
  83828. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83829. /**
  83830. * Updates the given vector "result" from the starting index of the given array.
  83831. * @param array the array to pull values from
  83832. * @param offset the offset into the array to start at
  83833. * @param result the vector to store the result in
  83834. */
  83835. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83836. /**
  83837. * Updates the given vector "result" from the starting index of the given Float32Array.
  83838. * @param array the array to pull values from
  83839. * @param offset the offset into the array to start at
  83840. * @param result the vector to store the result in
  83841. */
  83842. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83843. /**
  83844. * Updates the given vector "result" coordinates from the given floats.
  83845. * @param x float to set from
  83846. * @param y float to set from
  83847. * @param z float to set from
  83848. * @param w float to set from
  83849. * @param result the vector to the floats in
  83850. */
  83851. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83852. /**
  83853. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83854. * @returns the new vector
  83855. */
  83856. static Zero(): Vector4;
  83857. /**
  83858. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83859. * @returns the new vector
  83860. */
  83861. static One(): Vector4;
  83862. /**
  83863. * Returns a new normalized Vector4 from the given one.
  83864. * @param vector the vector to normalize
  83865. * @returns the vector
  83866. */
  83867. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83868. /**
  83869. * Updates the given vector "result" from the normalization of the given one.
  83870. * @param vector the vector to normalize
  83871. * @param result the vector to store the result in
  83872. */
  83873. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83874. /**
  83875. * Returns a vector with the minimum values from the left and right vectors
  83876. * @param left left vector to minimize
  83877. * @param right right vector to minimize
  83878. * @returns a new vector with the minimum of the left and right vector values
  83879. */
  83880. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83881. /**
  83882. * Returns a vector with the maximum values from the left and right vectors
  83883. * @param left left vector to maximize
  83884. * @param right right vector to maximize
  83885. * @returns a new vector with the maximum of the left and right vector values
  83886. */
  83887. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83888. /**
  83889. * Returns the distance (float) between the vectors "value1" and "value2".
  83890. * @param value1 value to calulate the distance between
  83891. * @param value2 value to calulate the distance between
  83892. * @return the distance between the two vectors
  83893. */
  83894. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83895. /**
  83896. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83897. * @param value1 value to calulate the distance between
  83898. * @param value2 value to calulate the distance between
  83899. * @return the distance between the two vectors squared
  83900. */
  83901. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83902. /**
  83903. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83904. * @param value1 value to calulate the center between
  83905. * @param value2 value to calulate the center between
  83906. * @return the center between the two vectors
  83907. */
  83908. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83909. /**
  83910. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83911. * This methods computes transformed normalized direction vectors only.
  83912. * @param vector the vector to transform
  83913. * @param transformation the transformation matrix to apply
  83914. * @returns the new vector
  83915. */
  83916. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83917. /**
  83918. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83919. * This methods computes transformed normalized direction vectors only.
  83920. * @param vector the vector to transform
  83921. * @param transformation the transformation matrix to apply
  83922. * @param result the vector to store the result in
  83923. */
  83924. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83925. /**
  83926. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83927. * This methods computes transformed normalized direction vectors only.
  83928. * @param x value to transform
  83929. * @param y value to transform
  83930. * @param z value to transform
  83931. * @param w value to transform
  83932. * @param transformation the transformation matrix to apply
  83933. * @param result the vector to store the results in
  83934. */
  83935. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83936. /**
  83937. * Creates a new Vector4 from a Vector3
  83938. * @param source defines the source data
  83939. * @param w defines the 4th component (default is 0)
  83940. * @returns a new Vector4
  83941. */
  83942. static FromVector3(source: Vector3, w?: number): Vector4;
  83943. }
  83944. /**
  83945. * Class used to store quaternion data
  83946. * @see https://en.wikipedia.org/wiki/Quaternion
  83947. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83948. */
  83949. export class Quaternion {
  83950. /** @hidden */
  83951. _x: number;
  83952. /** @hidden */
  83953. _y: number;
  83954. /** @hidden */
  83955. _z: number;
  83956. /** @hidden */
  83957. _w: number;
  83958. /** @hidden */
  83959. _isDirty: boolean;
  83960. /** Gets or sets the x coordinate */
  83961. get x(): number;
  83962. set x(value: number);
  83963. /** Gets or sets the y coordinate */
  83964. get y(): number;
  83965. set y(value: number);
  83966. /** Gets or sets the z coordinate */
  83967. get z(): number;
  83968. set z(value: number);
  83969. /** Gets or sets the w coordinate */
  83970. get w(): number;
  83971. set w(value: number);
  83972. /**
  83973. * Creates a new Quaternion from the given floats
  83974. * @param x defines the first component (0 by default)
  83975. * @param y defines the second component (0 by default)
  83976. * @param z defines the third component (0 by default)
  83977. * @param w defines the fourth component (1.0 by default)
  83978. */
  83979. constructor(x?: number, y?: number, z?: number, w?: number);
  83980. /**
  83981. * Gets a string representation for the current quaternion
  83982. * @returns a string with the Quaternion coordinates
  83983. */
  83984. toString(): string;
  83985. /**
  83986. * Gets the class name of the quaternion
  83987. * @returns the string "Quaternion"
  83988. */
  83989. getClassName(): string;
  83990. /**
  83991. * Gets a hash code for this quaternion
  83992. * @returns the quaternion hash code
  83993. */
  83994. getHashCode(): number;
  83995. /**
  83996. * Copy the quaternion to an array
  83997. * @returns a new array populated with 4 elements from the quaternion coordinates
  83998. */
  83999. asArray(): number[];
  84000. /**
  84001. * Check if two quaternions are equals
  84002. * @param otherQuaternion defines the second operand
  84003. * @return true if the current quaternion and the given one coordinates are strictly equals
  84004. */
  84005. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84006. /**
  84007. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84008. * @param otherQuaternion defines the other quaternion
  84009. * @param epsilon defines the minimal distance to consider equality
  84010. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84011. */
  84012. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84013. /**
  84014. * Clone the current quaternion
  84015. * @returns a new quaternion copied from the current one
  84016. */
  84017. clone(): Quaternion;
  84018. /**
  84019. * Copy a quaternion to the current one
  84020. * @param other defines the other quaternion
  84021. * @returns the updated current quaternion
  84022. */
  84023. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84024. /**
  84025. * Updates the current quaternion with the given float coordinates
  84026. * @param x defines the x coordinate
  84027. * @param y defines the y coordinate
  84028. * @param z defines the z coordinate
  84029. * @param w defines the w coordinate
  84030. * @returns the updated current quaternion
  84031. */
  84032. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84033. /**
  84034. * Updates the current quaternion from the given float coordinates
  84035. * @param x defines the x coordinate
  84036. * @param y defines the y coordinate
  84037. * @param z defines the z coordinate
  84038. * @param w defines the w coordinate
  84039. * @returns the updated current quaternion
  84040. */
  84041. set(x: number, y: number, z: number, w: number): Quaternion;
  84042. /**
  84043. * Adds two quaternions
  84044. * @param other defines the second operand
  84045. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84046. */
  84047. add(other: DeepImmutable<Quaternion>): Quaternion;
  84048. /**
  84049. * Add a quaternion to the current one
  84050. * @param other defines the quaternion to add
  84051. * @returns the current quaternion
  84052. */
  84053. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84054. /**
  84055. * Subtract two quaternions
  84056. * @param other defines the second operand
  84057. * @returns a new quaternion as the subtraction result of the given one from the current one
  84058. */
  84059. subtract(other: Quaternion): Quaternion;
  84060. /**
  84061. * Multiplies the current quaternion by a scale factor
  84062. * @param value defines the scale factor
  84063. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84064. */
  84065. scale(value: number): Quaternion;
  84066. /**
  84067. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84068. * @param scale defines the scale factor
  84069. * @param result defines the Quaternion object where to store the result
  84070. * @returns the unmodified current quaternion
  84071. */
  84072. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84073. /**
  84074. * Multiplies in place the current quaternion by a scale factor
  84075. * @param value defines the scale factor
  84076. * @returns the current modified quaternion
  84077. */
  84078. scaleInPlace(value: number): Quaternion;
  84079. /**
  84080. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84081. * @param scale defines the scale factor
  84082. * @param result defines the Quaternion object where to store the result
  84083. * @returns the unmodified current quaternion
  84084. */
  84085. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84086. /**
  84087. * Multiplies two quaternions
  84088. * @param q1 defines the second operand
  84089. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84090. */
  84091. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84092. /**
  84093. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84094. * @param q1 defines the second operand
  84095. * @param result defines the target quaternion
  84096. * @returns the current quaternion
  84097. */
  84098. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84099. /**
  84100. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84101. * @param q1 defines the second operand
  84102. * @returns the currentupdated quaternion
  84103. */
  84104. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84105. /**
  84106. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84107. * @param ref defines the target quaternion
  84108. * @returns the current quaternion
  84109. */
  84110. conjugateToRef(ref: Quaternion): Quaternion;
  84111. /**
  84112. * Conjugates in place (1-q) the current quaternion
  84113. * @returns the current updated quaternion
  84114. */
  84115. conjugateInPlace(): Quaternion;
  84116. /**
  84117. * Conjugates in place (1-q) the current quaternion
  84118. * @returns a new quaternion
  84119. */
  84120. conjugate(): Quaternion;
  84121. /**
  84122. * Gets length of current quaternion
  84123. * @returns the quaternion length (float)
  84124. */
  84125. length(): number;
  84126. /**
  84127. * Normalize in place the current quaternion
  84128. * @returns the current updated quaternion
  84129. */
  84130. normalize(): Quaternion;
  84131. /**
  84132. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84133. * @param order is a reserved parameter and is ignored for now
  84134. * @returns a new Vector3 containing the Euler angles
  84135. */
  84136. toEulerAngles(order?: string): Vector3;
  84137. /**
  84138. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84139. * @param result defines the vector which will be filled with the Euler angles
  84140. * @returns the current unchanged quaternion
  84141. */
  84142. toEulerAnglesToRef(result: Vector3): Quaternion;
  84143. /**
  84144. * Updates the given rotation matrix with the current quaternion values
  84145. * @param result defines the target matrix
  84146. * @returns the current unchanged quaternion
  84147. */
  84148. toRotationMatrix(result: Matrix): Quaternion;
  84149. /**
  84150. * Updates the current quaternion from the given rotation matrix values
  84151. * @param matrix defines the source matrix
  84152. * @returns the current updated quaternion
  84153. */
  84154. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84155. /**
  84156. * Creates a new quaternion from a rotation matrix
  84157. * @param matrix defines the source matrix
  84158. * @returns a new quaternion created from the given rotation matrix values
  84159. */
  84160. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84161. /**
  84162. * Updates the given quaternion with the given rotation matrix values
  84163. * @param matrix defines the source matrix
  84164. * @param result defines the target quaternion
  84165. */
  84166. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84167. /**
  84168. * Returns the dot product (float) between the quaternions "left" and "right"
  84169. * @param left defines the left operand
  84170. * @param right defines the right operand
  84171. * @returns the dot product
  84172. */
  84173. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84174. /**
  84175. * Checks if the two quaternions are close to each other
  84176. * @param quat0 defines the first quaternion to check
  84177. * @param quat1 defines the second quaternion to check
  84178. * @returns true if the two quaternions are close to each other
  84179. */
  84180. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84181. /**
  84182. * Creates an empty quaternion
  84183. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84184. */
  84185. static Zero(): Quaternion;
  84186. /**
  84187. * Inverse a given quaternion
  84188. * @param q defines the source quaternion
  84189. * @returns a new quaternion as the inverted current quaternion
  84190. */
  84191. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84192. /**
  84193. * Inverse a given quaternion
  84194. * @param q defines the source quaternion
  84195. * @param result the quaternion the result will be stored in
  84196. * @returns the result quaternion
  84197. */
  84198. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84199. /**
  84200. * Creates an identity quaternion
  84201. * @returns the identity quaternion
  84202. */
  84203. static Identity(): Quaternion;
  84204. /**
  84205. * Gets a boolean indicating if the given quaternion is identity
  84206. * @param quaternion defines the quaternion to check
  84207. * @returns true if the quaternion is identity
  84208. */
  84209. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84210. /**
  84211. * Creates a quaternion from a rotation around an axis
  84212. * @param axis defines the axis to use
  84213. * @param angle defines the angle to use
  84214. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84215. */
  84216. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84217. /**
  84218. * Creates a rotation around an axis and stores it into the given quaternion
  84219. * @param axis defines the axis to use
  84220. * @param angle defines the angle to use
  84221. * @param result defines the target quaternion
  84222. * @returns the target quaternion
  84223. */
  84224. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84225. /**
  84226. * Creates a new quaternion from data stored into an array
  84227. * @param array defines the data source
  84228. * @param offset defines the offset in the source array where the data starts
  84229. * @returns a new quaternion
  84230. */
  84231. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84232. /**
  84233. * Updates the given quaternion "result" from the starting index of the given array.
  84234. * @param array the array to pull values from
  84235. * @param offset the offset into the array to start at
  84236. * @param result the quaternion to store the result in
  84237. */
  84238. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84239. /**
  84240. * Create a quaternion from Euler rotation angles
  84241. * @param x Pitch
  84242. * @param y Yaw
  84243. * @param z Roll
  84244. * @returns the new Quaternion
  84245. */
  84246. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84247. /**
  84248. * Updates a quaternion from Euler rotation angles
  84249. * @param x Pitch
  84250. * @param y Yaw
  84251. * @param z Roll
  84252. * @param result the quaternion to store the result
  84253. * @returns the updated quaternion
  84254. */
  84255. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84256. /**
  84257. * Create a quaternion from Euler rotation vector
  84258. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84259. * @returns the new Quaternion
  84260. */
  84261. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84262. /**
  84263. * Updates a quaternion from Euler rotation vector
  84264. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84265. * @param result the quaternion to store the result
  84266. * @returns the updated quaternion
  84267. */
  84268. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84269. /**
  84270. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84271. * @param yaw defines the rotation around Y axis
  84272. * @param pitch defines the rotation around X axis
  84273. * @param roll defines the rotation around Z axis
  84274. * @returns the new quaternion
  84275. */
  84276. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84277. /**
  84278. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84279. * @param yaw defines the rotation around Y axis
  84280. * @param pitch defines the rotation around X axis
  84281. * @param roll defines the rotation around Z axis
  84282. * @param result defines the target quaternion
  84283. */
  84284. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84285. /**
  84286. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84287. * @param alpha defines the rotation around first axis
  84288. * @param beta defines the rotation around second axis
  84289. * @param gamma defines the rotation around third axis
  84290. * @returns the new quaternion
  84291. */
  84292. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84293. /**
  84294. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84295. * @param alpha defines the rotation around first axis
  84296. * @param beta defines the rotation around second axis
  84297. * @param gamma defines the rotation around third axis
  84298. * @param result defines the target quaternion
  84299. */
  84300. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84301. /**
  84302. * 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)
  84303. * @param axis1 defines the first axis
  84304. * @param axis2 defines the second axis
  84305. * @param axis3 defines the third axis
  84306. * @returns the new quaternion
  84307. */
  84308. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84309. /**
  84310. * 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
  84311. * @param axis1 defines the first axis
  84312. * @param axis2 defines the second axis
  84313. * @param axis3 defines the third axis
  84314. * @param ref defines the target quaternion
  84315. */
  84316. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84317. /**
  84318. * Interpolates between two quaternions
  84319. * @param left defines first quaternion
  84320. * @param right defines second quaternion
  84321. * @param amount defines the gradient to use
  84322. * @returns the new interpolated quaternion
  84323. */
  84324. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84325. /**
  84326. * Interpolates between two quaternions and stores it into a target quaternion
  84327. * @param left defines first quaternion
  84328. * @param right defines second quaternion
  84329. * @param amount defines the gradient to use
  84330. * @param result defines the target quaternion
  84331. */
  84332. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84333. /**
  84334. * Interpolate between two quaternions using Hermite interpolation
  84335. * @param value1 defines first quaternion
  84336. * @param tangent1 defines the incoming tangent
  84337. * @param value2 defines second quaternion
  84338. * @param tangent2 defines the outgoing tangent
  84339. * @param amount defines the target quaternion
  84340. * @returns the new interpolated quaternion
  84341. */
  84342. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84343. }
  84344. /**
  84345. * Class used to store matrix data (4x4)
  84346. */
  84347. export class Matrix {
  84348. /**
  84349. * Gets the precision of matrix computations
  84350. */
  84351. static get Use64Bits(): boolean;
  84352. private static _updateFlagSeed;
  84353. private static _identityReadOnly;
  84354. private _isIdentity;
  84355. private _isIdentityDirty;
  84356. private _isIdentity3x2;
  84357. private _isIdentity3x2Dirty;
  84358. /**
  84359. * Gets the update flag of the matrix which is an unique number for the matrix.
  84360. * It will be incremented every time the matrix data change.
  84361. * You can use it to speed the comparison between two versions of the same matrix.
  84362. */
  84363. updateFlag: number;
  84364. private readonly _m;
  84365. /**
  84366. * Gets the internal data of the matrix
  84367. */
  84368. get m(): DeepImmutable<Float32Array | Array<number>>;
  84369. /** @hidden */
  84370. _markAsUpdated(): void;
  84371. /** @hidden */
  84372. private _updateIdentityStatus;
  84373. /**
  84374. * Creates an empty matrix (filled with zeros)
  84375. */
  84376. constructor();
  84377. /**
  84378. * Check if the current matrix is identity
  84379. * @returns true is the matrix is the identity matrix
  84380. */
  84381. isIdentity(): boolean;
  84382. /**
  84383. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84384. * @returns true is the matrix is the identity matrix
  84385. */
  84386. isIdentityAs3x2(): boolean;
  84387. /**
  84388. * Gets the determinant of the matrix
  84389. * @returns the matrix determinant
  84390. */
  84391. determinant(): number;
  84392. /**
  84393. * Returns the matrix as a Float32Array or Array<number>
  84394. * @returns the matrix underlying array
  84395. */
  84396. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84397. /**
  84398. * Returns the matrix as a Float32Array or Array<number>
  84399. * @returns the matrix underlying array.
  84400. */
  84401. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84402. /**
  84403. * Inverts the current matrix in place
  84404. * @returns the current inverted matrix
  84405. */
  84406. invert(): Matrix;
  84407. /**
  84408. * Sets all the matrix elements to zero
  84409. * @returns the current matrix
  84410. */
  84411. reset(): Matrix;
  84412. /**
  84413. * Adds the current matrix with a second one
  84414. * @param other defines the matrix to add
  84415. * @returns a new matrix as the addition of the current matrix and the given one
  84416. */
  84417. add(other: DeepImmutable<Matrix>): Matrix;
  84418. /**
  84419. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84420. * @param other defines the matrix to add
  84421. * @param result defines the target matrix
  84422. * @returns the current matrix
  84423. */
  84424. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84425. /**
  84426. * Adds in place the given matrix to the current matrix
  84427. * @param other defines the second operand
  84428. * @returns the current updated matrix
  84429. */
  84430. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84431. /**
  84432. * Sets the given matrix to the current inverted Matrix
  84433. * @param other defines the target matrix
  84434. * @returns the unmodified current matrix
  84435. */
  84436. invertToRef(other: Matrix): Matrix;
  84437. /**
  84438. * add a value at the specified position in the current Matrix
  84439. * @param index the index of the value within the matrix. between 0 and 15.
  84440. * @param value the value to be added
  84441. * @returns the current updated matrix
  84442. */
  84443. addAtIndex(index: number, value: number): Matrix;
  84444. /**
  84445. * mutiply the specified position in the current Matrix by a value
  84446. * @param index the index of the value within the matrix. between 0 and 15.
  84447. * @param value the value to be added
  84448. * @returns the current updated matrix
  84449. */
  84450. multiplyAtIndex(index: number, value: number): Matrix;
  84451. /**
  84452. * Inserts the translation vector (using 3 floats) in the current matrix
  84453. * @param x defines the 1st component of the translation
  84454. * @param y defines the 2nd component of the translation
  84455. * @param z defines the 3rd component of the translation
  84456. * @returns the current updated matrix
  84457. */
  84458. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84459. /**
  84460. * Adds the translation vector (using 3 floats) in the current matrix
  84461. * @param x defines the 1st component of the translation
  84462. * @param y defines the 2nd component of the translation
  84463. * @param z defines the 3rd component of the translation
  84464. * @returns the current updated matrix
  84465. */
  84466. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84467. /**
  84468. * Inserts the translation vector in the current matrix
  84469. * @param vector3 defines the translation to insert
  84470. * @returns the current updated matrix
  84471. */
  84472. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84473. /**
  84474. * Gets the translation value of the current matrix
  84475. * @returns a new Vector3 as the extracted translation from the matrix
  84476. */
  84477. getTranslation(): Vector3;
  84478. /**
  84479. * Fill a Vector3 with the extracted translation from the matrix
  84480. * @param result defines the Vector3 where to store the translation
  84481. * @returns the current matrix
  84482. */
  84483. getTranslationToRef(result: Vector3): Matrix;
  84484. /**
  84485. * Remove rotation and scaling part from the matrix
  84486. * @returns the updated matrix
  84487. */
  84488. removeRotationAndScaling(): Matrix;
  84489. /**
  84490. * Multiply two matrices
  84491. * @param other defines the second operand
  84492. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84493. */
  84494. multiply(other: DeepImmutable<Matrix>): Matrix;
  84495. /**
  84496. * Copy the current matrix from the given one
  84497. * @param other defines the source matrix
  84498. * @returns the current updated matrix
  84499. */
  84500. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84501. /**
  84502. * Populates the given array from the starting index with the current matrix values
  84503. * @param array defines the target array
  84504. * @param offset defines the offset in the target array where to start storing values
  84505. * @returns the current matrix
  84506. */
  84507. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84508. /**
  84509. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84510. * @param other defines the second operand
  84511. * @param result defines the matrix where to store the multiplication
  84512. * @returns the current matrix
  84513. */
  84514. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84515. /**
  84516. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84517. * @param other defines the second operand
  84518. * @param result defines the array where to store the multiplication
  84519. * @param offset defines the offset in the target array where to start storing values
  84520. * @returns the current matrix
  84521. */
  84522. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84523. /**
  84524. * Check equality between this matrix and a second one
  84525. * @param value defines the second matrix to compare
  84526. * @returns true is the current matrix and the given one values are strictly equal
  84527. */
  84528. equals(value: DeepImmutable<Matrix>): boolean;
  84529. /**
  84530. * Clone the current matrix
  84531. * @returns a new matrix from the current matrix
  84532. */
  84533. clone(): Matrix;
  84534. /**
  84535. * Returns the name of the current matrix class
  84536. * @returns the string "Matrix"
  84537. */
  84538. getClassName(): string;
  84539. /**
  84540. * Gets the hash code of the current matrix
  84541. * @returns the hash code
  84542. */
  84543. getHashCode(): number;
  84544. /**
  84545. * Decomposes the current Matrix into a translation, rotation and scaling components
  84546. * @param scale defines the scale vector3 given as a reference to update
  84547. * @param rotation defines the rotation quaternion given as a reference to update
  84548. * @param translation defines the translation vector3 given as a reference to update
  84549. * @returns true if operation was successful
  84550. */
  84551. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84552. /**
  84553. * Gets specific row of the matrix
  84554. * @param index defines the number of the row to get
  84555. * @returns the index-th row of the current matrix as a new Vector4
  84556. */
  84557. getRow(index: number): Nullable<Vector4>;
  84558. /**
  84559. * Sets the index-th row of the current matrix to the vector4 values
  84560. * @param index defines the number of the row to set
  84561. * @param row defines the target vector4
  84562. * @returns the updated current matrix
  84563. */
  84564. setRow(index: number, row: Vector4): Matrix;
  84565. /**
  84566. * Compute the transpose of the matrix
  84567. * @returns the new transposed matrix
  84568. */
  84569. transpose(): Matrix;
  84570. /**
  84571. * Compute the transpose of the matrix and store it in a given matrix
  84572. * @param result defines the target matrix
  84573. * @returns the current matrix
  84574. */
  84575. transposeToRef(result: Matrix): Matrix;
  84576. /**
  84577. * Sets the index-th row of the current matrix with the given 4 x float values
  84578. * @param index defines the row index
  84579. * @param x defines the x component to set
  84580. * @param y defines the y component to set
  84581. * @param z defines the z component to set
  84582. * @param w defines the w component to set
  84583. * @returns the updated current matrix
  84584. */
  84585. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84586. /**
  84587. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84588. * @param scale defines the scale factor
  84589. * @returns a new matrix
  84590. */
  84591. scale(scale: number): Matrix;
  84592. /**
  84593. * Scale the current matrix values by a factor to a given result matrix
  84594. * @param scale defines the scale factor
  84595. * @param result defines the matrix to store the result
  84596. * @returns the current matrix
  84597. */
  84598. scaleToRef(scale: number, result: Matrix): Matrix;
  84599. /**
  84600. * Scale the current matrix values by a factor and add the result to a given matrix
  84601. * @param scale defines the scale factor
  84602. * @param result defines the Matrix to store the result
  84603. * @returns the current matrix
  84604. */
  84605. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84606. /**
  84607. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84608. * @param ref matrix to store the result
  84609. */
  84610. toNormalMatrix(ref: Matrix): void;
  84611. /**
  84612. * Gets only rotation part of the current matrix
  84613. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84614. */
  84615. getRotationMatrix(): Matrix;
  84616. /**
  84617. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84618. * @param result defines the target matrix to store data to
  84619. * @returns the current matrix
  84620. */
  84621. getRotationMatrixToRef(result: Matrix): Matrix;
  84622. /**
  84623. * Toggles model matrix from being right handed to left handed in place and vice versa
  84624. */
  84625. toggleModelMatrixHandInPlace(): void;
  84626. /**
  84627. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84628. */
  84629. toggleProjectionMatrixHandInPlace(): void;
  84630. /**
  84631. * Creates a matrix from an array
  84632. * @param array defines the source array
  84633. * @param offset defines an offset in the source array
  84634. * @returns a new Matrix set from the starting index of the given array
  84635. */
  84636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84637. /**
  84638. * Copy the content of an array into a given matrix
  84639. * @param array defines the source array
  84640. * @param offset defines an offset in the source array
  84641. * @param result defines the target matrix
  84642. */
  84643. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84644. /**
  84645. * Stores an array into a matrix after having multiplied each component by a given factor
  84646. * @param array defines the source array
  84647. * @param offset defines the offset in the source array
  84648. * @param scale defines the scaling factor
  84649. * @param result defines the target matrix
  84650. */
  84651. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84652. /**
  84653. * Gets an identity matrix that must not be updated
  84654. */
  84655. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84656. /**
  84657. * Stores a list of values (16) inside a given matrix
  84658. * @param initialM11 defines 1st value of 1st row
  84659. * @param initialM12 defines 2nd value of 1st row
  84660. * @param initialM13 defines 3rd value of 1st row
  84661. * @param initialM14 defines 4th value of 1st row
  84662. * @param initialM21 defines 1st value of 2nd row
  84663. * @param initialM22 defines 2nd value of 2nd row
  84664. * @param initialM23 defines 3rd value of 2nd row
  84665. * @param initialM24 defines 4th value of 2nd row
  84666. * @param initialM31 defines 1st value of 3rd row
  84667. * @param initialM32 defines 2nd value of 3rd row
  84668. * @param initialM33 defines 3rd value of 3rd row
  84669. * @param initialM34 defines 4th value of 3rd row
  84670. * @param initialM41 defines 1st value of 4th row
  84671. * @param initialM42 defines 2nd value of 4th row
  84672. * @param initialM43 defines 3rd value of 4th row
  84673. * @param initialM44 defines 4th value of 4th row
  84674. * @param result defines the target matrix
  84675. */
  84676. 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;
  84677. /**
  84678. * Creates new matrix from a list of values (16)
  84679. * @param initialM11 defines 1st value of 1st row
  84680. * @param initialM12 defines 2nd value of 1st row
  84681. * @param initialM13 defines 3rd value of 1st row
  84682. * @param initialM14 defines 4th value of 1st row
  84683. * @param initialM21 defines 1st value of 2nd row
  84684. * @param initialM22 defines 2nd value of 2nd row
  84685. * @param initialM23 defines 3rd value of 2nd row
  84686. * @param initialM24 defines 4th value of 2nd row
  84687. * @param initialM31 defines 1st value of 3rd row
  84688. * @param initialM32 defines 2nd value of 3rd row
  84689. * @param initialM33 defines 3rd value of 3rd row
  84690. * @param initialM34 defines 4th value of 3rd row
  84691. * @param initialM41 defines 1st value of 4th row
  84692. * @param initialM42 defines 2nd value of 4th row
  84693. * @param initialM43 defines 3rd value of 4th row
  84694. * @param initialM44 defines 4th value of 4th row
  84695. * @returns the new matrix
  84696. */
  84697. 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;
  84698. /**
  84699. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84700. * @param scale defines the scale vector3
  84701. * @param rotation defines the rotation quaternion
  84702. * @param translation defines the translation vector3
  84703. * @returns a new matrix
  84704. */
  84705. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84706. /**
  84707. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84708. * @param scale defines the scale vector3
  84709. * @param rotation defines the rotation quaternion
  84710. * @param translation defines the translation vector3
  84711. * @param result defines the target matrix
  84712. */
  84713. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84714. /**
  84715. * Creates a new identity matrix
  84716. * @returns a new identity matrix
  84717. */
  84718. static Identity(): Matrix;
  84719. /**
  84720. * Creates a new identity matrix and stores the result in a given matrix
  84721. * @param result defines the target matrix
  84722. */
  84723. static IdentityToRef(result: Matrix): void;
  84724. /**
  84725. * Creates a new zero matrix
  84726. * @returns a new zero matrix
  84727. */
  84728. static Zero(): Matrix;
  84729. /**
  84730. * Creates a new rotation matrix for "angle" radians around the X axis
  84731. * @param angle defines the angle (in radians) to use
  84732. * @return the new matrix
  84733. */
  84734. static RotationX(angle: number): Matrix;
  84735. /**
  84736. * Creates a new matrix as the invert of a given matrix
  84737. * @param source defines the source matrix
  84738. * @returns the new matrix
  84739. */
  84740. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84741. /**
  84742. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84743. * @param angle defines the angle (in radians) to use
  84744. * @param result defines the target matrix
  84745. */
  84746. static RotationXToRef(angle: number, result: Matrix): void;
  84747. /**
  84748. * Creates a new rotation matrix for "angle" radians around the Y axis
  84749. * @param angle defines the angle (in radians) to use
  84750. * @return the new matrix
  84751. */
  84752. static RotationY(angle: number): Matrix;
  84753. /**
  84754. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84755. * @param angle defines the angle (in radians) to use
  84756. * @param result defines the target matrix
  84757. */
  84758. static RotationYToRef(angle: number, result: Matrix): void;
  84759. /**
  84760. * Creates a new rotation matrix for "angle" radians around the Z axis
  84761. * @param angle defines the angle (in radians) to use
  84762. * @return the new matrix
  84763. */
  84764. static RotationZ(angle: number): Matrix;
  84765. /**
  84766. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84767. * @param angle defines the angle (in radians) to use
  84768. * @param result defines the target matrix
  84769. */
  84770. static RotationZToRef(angle: number, result: Matrix): void;
  84771. /**
  84772. * Creates a new rotation matrix for "angle" radians around the given axis
  84773. * @param axis defines the axis to use
  84774. * @param angle defines the angle (in radians) to use
  84775. * @return the new matrix
  84776. */
  84777. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84778. /**
  84779. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84780. * @param axis defines the axis to use
  84781. * @param angle defines the angle (in radians) to use
  84782. * @param result defines the target matrix
  84783. */
  84784. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84785. /**
  84786. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84787. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84788. * @param from defines the vector to align
  84789. * @param to defines the vector to align to
  84790. * @param result defines the target matrix
  84791. */
  84792. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84793. /**
  84794. * Creates a rotation matrix
  84795. * @param yaw defines the yaw angle in radians (Y axis)
  84796. * @param pitch defines the pitch angle in radians (X axis)
  84797. * @param roll defines the roll angle in radians (Z axis)
  84798. * @returns the new rotation matrix
  84799. */
  84800. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84801. /**
  84802. * Creates a rotation matrix and stores it in a given matrix
  84803. * @param yaw defines the yaw angle in radians (Y axis)
  84804. * @param pitch defines the pitch angle in radians (X axis)
  84805. * @param roll defines the roll angle in radians (Z axis)
  84806. * @param result defines the target matrix
  84807. */
  84808. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84809. /**
  84810. * Creates a scaling matrix
  84811. * @param x defines the scale factor on X axis
  84812. * @param y defines the scale factor on Y axis
  84813. * @param z defines the scale factor on Z axis
  84814. * @returns the new matrix
  84815. */
  84816. static Scaling(x: number, y: number, z: number): Matrix;
  84817. /**
  84818. * Creates a scaling matrix and stores it in a given matrix
  84819. * @param x defines the scale factor on X axis
  84820. * @param y defines the scale factor on Y axis
  84821. * @param z defines the scale factor on Z axis
  84822. * @param result defines the target matrix
  84823. */
  84824. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84825. /**
  84826. * Creates a translation matrix
  84827. * @param x defines the translation on X axis
  84828. * @param y defines the translation on Y axis
  84829. * @param z defines the translationon Z axis
  84830. * @returns the new matrix
  84831. */
  84832. static Translation(x: number, y: number, z: number): Matrix;
  84833. /**
  84834. * Creates a translation matrix and stores it in a given matrix
  84835. * @param x defines the translation on X axis
  84836. * @param y defines the translation on Y axis
  84837. * @param z defines the translationon Z axis
  84838. * @param result defines the target matrix
  84839. */
  84840. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84841. /**
  84842. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84843. * @param startValue defines the start value
  84844. * @param endValue defines the end value
  84845. * @param gradient defines the gradient factor
  84846. * @returns the new matrix
  84847. */
  84848. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84849. /**
  84850. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84851. * @param startValue defines the start value
  84852. * @param endValue defines the end value
  84853. * @param gradient defines the gradient factor
  84854. * @param result defines the Matrix object where to store data
  84855. */
  84856. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84857. /**
  84858. * Builds a new matrix whose values are computed by:
  84859. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84860. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84861. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84862. * @param startValue defines the first matrix
  84863. * @param endValue defines the second matrix
  84864. * @param gradient defines the gradient between the two matrices
  84865. * @returns the new matrix
  84866. */
  84867. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84868. /**
  84869. * Update a matrix to values which are computed by:
  84870. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84871. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84872. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84873. * @param startValue defines the first matrix
  84874. * @param endValue defines the second matrix
  84875. * @param gradient defines the gradient between the two matrices
  84876. * @param result defines the target matrix
  84877. */
  84878. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84879. /**
  84880. * 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"
  84881. * This function works in left handed mode
  84882. * @param eye defines the final position of the entity
  84883. * @param target defines where the entity should look at
  84884. * @param up defines the up vector for the entity
  84885. * @returns the new matrix
  84886. */
  84887. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84888. /**
  84889. * 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".
  84890. * This function works in left handed mode
  84891. * @param eye defines the final position of the entity
  84892. * @param target defines where the entity should look at
  84893. * @param up defines the up vector for the entity
  84894. * @param result defines the target matrix
  84895. */
  84896. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84897. /**
  84898. * 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"
  84899. * This function works in right handed mode
  84900. * @param eye defines the final position of the entity
  84901. * @param target defines where the entity should look at
  84902. * @param up defines the up vector for the entity
  84903. * @returns the new matrix
  84904. */
  84905. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84906. /**
  84907. * 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".
  84908. * This function works in right handed mode
  84909. * @param eye defines the final position of the entity
  84910. * @param target defines where the entity should look at
  84911. * @param up defines the up vector for the entity
  84912. * @param result defines the target matrix
  84913. */
  84914. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84915. /**
  84916. * Create a left-handed orthographic projection matrix
  84917. * @param width defines the viewport width
  84918. * @param height defines the viewport height
  84919. * @param znear defines the near clip plane
  84920. * @param zfar defines the far clip plane
  84921. * @returns a new matrix as a left-handed orthographic projection matrix
  84922. */
  84923. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84924. /**
  84925. * Store a left-handed orthographic projection to a given matrix
  84926. * @param width defines the viewport width
  84927. * @param height defines the viewport height
  84928. * @param znear defines the near clip plane
  84929. * @param zfar defines the far clip plane
  84930. * @param result defines the target matrix
  84931. */
  84932. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84933. /**
  84934. * Create a left-handed orthographic projection matrix
  84935. * @param left defines the viewport left coordinate
  84936. * @param right defines the viewport right coordinate
  84937. * @param bottom defines the viewport bottom coordinate
  84938. * @param top defines the viewport top coordinate
  84939. * @param znear defines the near clip plane
  84940. * @param zfar defines the far clip plane
  84941. * @returns a new matrix as a left-handed orthographic projection matrix
  84942. */
  84943. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84944. /**
  84945. * Stores a left-handed orthographic projection into a given matrix
  84946. * @param left defines the viewport left coordinate
  84947. * @param right defines the viewport right coordinate
  84948. * @param bottom defines the viewport bottom coordinate
  84949. * @param top defines the viewport top coordinate
  84950. * @param znear defines the near clip plane
  84951. * @param zfar defines the far clip plane
  84952. * @param result defines the target matrix
  84953. */
  84954. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84955. /**
  84956. * Creates a right-handed orthographic projection matrix
  84957. * @param left defines the viewport left coordinate
  84958. * @param right defines the viewport right coordinate
  84959. * @param bottom defines the viewport bottom coordinate
  84960. * @param top defines the viewport top coordinate
  84961. * @param znear defines the near clip plane
  84962. * @param zfar defines the far clip plane
  84963. * @returns a new matrix as a right-handed orthographic projection matrix
  84964. */
  84965. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84966. /**
  84967. * Stores a right-handed orthographic projection into a given matrix
  84968. * @param left defines the viewport left coordinate
  84969. * @param right defines the viewport right coordinate
  84970. * @param bottom defines the viewport bottom coordinate
  84971. * @param top defines the viewport top coordinate
  84972. * @param znear defines the near clip plane
  84973. * @param zfar defines the far clip plane
  84974. * @param result defines the target matrix
  84975. */
  84976. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84977. /**
  84978. * Creates a left-handed perspective projection matrix
  84979. * @param width defines the viewport width
  84980. * @param height defines the viewport height
  84981. * @param znear defines the near clip plane
  84982. * @param zfar defines the far clip plane
  84983. * @returns a new matrix as a left-handed perspective projection matrix
  84984. */
  84985. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84986. /**
  84987. * Creates a left-handed perspective projection matrix
  84988. * @param fov defines the horizontal field of view
  84989. * @param aspect defines the aspect ratio
  84990. * @param znear defines the near clip plane
  84991. * @param zfar defines the far clip plane
  84992. * @returns a new matrix as a left-handed perspective projection matrix
  84993. */
  84994. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84995. /**
  84996. * Stores a left-handed perspective projection into a given matrix
  84997. * @param fov defines the horizontal field of view
  84998. * @param aspect defines the aspect ratio
  84999. * @param znear defines the near clip plane
  85000. * @param zfar defines the far clip plane
  85001. * @param result defines the target matrix
  85002. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85003. */
  85004. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85005. /**
  85006. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85007. * @param fov defines the horizontal field of view
  85008. * @param aspect defines the aspect ratio
  85009. * @param znear defines the near clip plane
  85010. * @param zfar not used as infinity is used as far clip
  85011. * @param result defines the target matrix
  85012. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85013. */
  85014. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85015. /**
  85016. * Creates a right-handed perspective projection matrix
  85017. * @param fov defines the horizontal field of view
  85018. * @param aspect defines the aspect ratio
  85019. * @param znear defines the near clip plane
  85020. * @param zfar defines the far clip plane
  85021. * @returns a new matrix as a right-handed perspective projection matrix
  85022. */
  85023. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85024. /**
  85025. * Stores a right-handed perspective projection into a given matrix
  85026. * @param fov defines the horizontal field of view
  85027. * @param aspect defines the aspect ratio
  85028. * @param znear defines the near clip plane
  85029. * @param zfar defines the far clip plane
  85030. * @param result defines the target matrix
  85031. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85032. */
  85033. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85034. /**
  85035. * Stores a right-handed perspective projection into a given matrix
  85036. * @param fov defines the horizontal field of view
  85037. * @param aspect defines the aspect ratio
  85038. * @param znear defines the near clip plane
  85039. * @param zfar not used as infinity is used as far clip
  85040. * @param result defines the target matrix
  85041. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85042. */
  85043. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85044. /**
  85045. * Stores a perspective projection for WebVR info a given matrix
  85046. * @param fov defines the field of view
  85047. * @param znear defines the near clip plane
  85048. * @param zfar defines the far clip plane
  85049. * @param result defines the target matrix
  85050. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85051. */
  85052. static PerspectiveFovWebVRToRef(fov: {
  85053. upDegrees: number;
  85054. downDegrees: number;
  85055. leftDegrees: number;
  85056. rightDegrees: number;
  85057. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85058. /**
  85059. * Computes a complete transformation matrix
  85060. * @param viewport defines the viewport to use
  85061. * @param world defines the world matrix
  85062. * @param view defines the view matrix
  85063. * @param projection defines the projection matrix
  85064. * @param zmin defines the near clip plane
  85065. * @param zmax defines the far clip plane
  85066. * @returns the transformation matrix
  85067. */
  85068. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85069. /**
  85070. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85071. * @param matrix defines the matrix to use
  85072. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85073. */
  85074. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85075. /**
  85076. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85077. * @param matrix defines the matrix to use
  85078. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85079. */
  85080. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85081. /**
  85082. * Compute the transpose of a given matrix
  85083. * @param matrix defines the matrix to transpose
  85084. * @returns the new matrix
  85085. */
  85086. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85087. /**
  85088. * Compute the transpose of a matrix and store it in a target matrix
  85089. * @param matrix defines the matrix to transpose
  85090. * @param result defines the target matrix
  85091. */
  85092. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85093. /**
  85094. * Computes a reflection matrix from a plane
  85095. * @param plane defines the reflection plane
  85096. * @returns a new matrix
  85097. */
  85098. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85099. /**
  85100. * Computes a reflection matrix from a plane
  85101. * @param plane defines the reflection plane
  85102. * @param result defines the target matrix
  85103. */
  85104. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85105. /**
  85106. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85107. * @param xaxis defines the value of the 1st axis
  85108. * @param yaxis defines the value of the 2nd axis
  85109. * @param zaxis defines the value of the 3rd axis
  85110. * @param result defines the target matrix
  85111. */
  85112. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85113. /**
  85114. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85115. * @param quat defines the quaternion to use
  85116. * @param result defines the target matrix
  85117. */
  85118. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85119. }
  85120. /**
  85121. * @hidden
  85122. */
  85123. export class TmpVectors {
  85124. static Vector2: Vector2[];
  85125. static Vector3: Vector3[];
  85126. static Vector4: Vector4[];
  85127. static Quaternion: Quaternion[];
  85128. static Matrix: Matrix[];
  85129. }
  85130. }
  85131. declare module BABYLON {
  85132. /**
  85133. * Defines potential orientation for back face culling
  85134. */
  85135. export enum Orientation {
  85136. /**
  85137. * Clockwise
  85138. */
  85139. CW = 0,
  85140. /** Counter clockwise */
  85141. CCW = 1
  85142. }
  85143. /** Class used to represent a Bezier curve */
  85144. export class BezierCurve {
  85145. /**
  85146. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85147. * @param t defines the time
  85148. * @param x1 defines the left coordinate on X axis
  85149. * @param y1 defines the left coordinate on Y axis
  85150. * @param x2 defines the right coordinate on X axis
  85151. * @param y2 defines the right coordinate on Y axis
  85152. * @returns the interpolated value
  85153. */
  85154. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85155. }
  85156. /**
  85157. * Defines angle representation
  85158. */
  85159. export class Angle {
  85160. private _radians;
  85161. /**
  85162. * Creates an Angle object of "radians" radians (float).
  85163. * @param radians the angle in radians
  85164. */
  85165. constructor(radians: number);
  85166. /**
  85167. * Get value in degrees
  85168. * @returns the Angle value in degrees (float)
  85169. */
  85170. degrees(): number;
  85171. /**
  85172. * Get value in radians
  85173. * @returns the Angle value in radians (float)
  85174. */
  85175. radians(): number;
  85176. /**
  85177. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85178. * @param a defines first point as the origin
  85179. * @param b defines point
  85180. * @returns a new Angle
  85181. */
  85182. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85183. /**
  85184. * Gets a new Angle object from the given float in radians
  85185. * @param radians defines the angle value in radians
  85186. * @returns a new Angle
  85187. */
  85188. static FromRadians(radians: number): Angle;
  85189. /**
  85190. * Gets a new Angle object from the given float in degrees
  85191. * @param degrees defines the angle value in degrees
  85192. * @returns a new Angle
  85193. */
  85194. static FromDegrees(degrees: number): Angle;
  85195. }
  85196. /**
  85197. * This represents an arc in a 2d space.
  85198. */
  85199. export class Arc2 {
  85200. /** Defines the start point of the arc */
  85201. startPoint: Vector2;
  85202. /** Defines the mid point of the arc */
  85203. midPoint: Vector2;
  85204. /** Defines the end point of the arc */
  85205. endPoint: Vector2;
  85206. /**
  85207. * Defines the center point of the arc.
  85208. */
  85209. centerPoint: Vector2;
  85210. /**
  85211. * Defines the radius of the arc.
  85212. */
  85213. radius: number;
  85214. /**
  85215. * Defines the angle of the arc (from mid point to end point).
  85216. */
  85217. angle: Angle;
  85218. /**
  85219. * Defines the start angle of the arc (from start point to middle point).
  85220. */
  85221. startAngle: Angle;
  85222. /**
  85223. * Defines the orientation of the arc (clock wise/counter clock wise).
  85224. */
  85225. orientation: Orientation;
  85226. /**
  85227. * Creates an Arc object from the three given points : start, middle and end.
  85228. * @param startPoint Defines the start point of the arc
  85229. * @param midPoint Defines the midlle point of the arc
  85230. * @param endPoint Defines the end point of the arc
  85231. */
  85232. constructor(
  85233. /** Defines the start point of the arc */
  85234. startPoint: Vector2,
  85235. /** Defines the mid point of the arc */
  85236. midPoint: Vector2,
  85237. /** Defines the end point of the arc */
  85238. endPoint: Vector2);
  85239. }
  85240. /**
  85241. * Represents a 2D path made up of multiple 2D points
  85242. */
  85243. export class Path2 {
  85244. private _points;
  85245. private _length;
  85246. /**
  85247. * If the path start and end point are the same
  85248. */
  85249. closed: boolean;
  85250. /**
  85251. * Creates a Path2 object from the starting 2D coordinates x and y.
  85252. * @param x the starting points x value
  85253. * @param y the starting points y value
  85254. */
  85255. constructor(x: number, y: number);
  85256. /**
  85257. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85258. * @param x the added points x value
  85259. * @param y the added points y value
  85260. * @returns the updated Path2.
  85261. */
  85262. addLineTo(x: number, y: number): Path2;
  85263. /**
  85264. * 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.
  85265. * @param midX middle point x value
  85266. * @param midY middle point y value
  85267. * @param endX end point x value
  85268. * @param endY end point y value
  85269. * @param numberOfSegments (default: 36)
  85270. * @returns the updated Path2.
  85271. */
  85272. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85273. /**
  85274. * Closes the Path2.
  85275. * @returns the Path2.
  85276. */
  85277. close(): Path2;
  85278. /**
  85279. * Gets the sum of the distance between each sequential point in the path
  85280. * @returns the Path2 total length (float).
  85281. */
  85282. length(): number;
  85283. /**
  85284. * Gets the points which construct the path
  85285. * @returns the Path2 internal array of points.
  85286. */
  85287. getPoints(): Vector2[];
  85288. /**
  85289. * Retreives the point at the distance aways from the starting point
  85290. * @param normalizedLengthPosition the length along the path to retreive the point from
  85291. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85292. */
  85293. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85294. /**
  85295. * Creates a new path starting from an x and y position
  85296. * @param x starting x value
  85297. * @param y starting y value
  85298. * @returns a new Path2 starting at the coordinates (x, y).
  85299. */
  85300. static StartingAt(x: number, y: number): Path2;
  85301. }
  85302. /**
  85303. * Represents a 3D path made up of multiple 3D points
  85304. */
  85305. export class Path3D {
  85306. /**
  85307. * an array of Vector3, the curve axis of the Path3D
  85308. */
  85309. path: Vector3[];
  85310. private _curve;
  85311. private _distances;
  85312. private _tangents;
  85313. private _normals;
  85314. private _binormals;
  85315. private _raw;
  85316. private _alignTangentsWithPath;
  85317. private readonly _pointAtData;
  85318. /**
  85319. * new Path3D(path, normal, raw)
  85320. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85321. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85322. * @param path an array of Vector3, the curve axis of the Path3D
  85323. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85324. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85325. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85326. */
  85327. constructor(
  85328. /**
  85329. * an array of Vector3, the curve axis of the Path3D
  85330. */
  85331. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85332. /**
  85333. * Returns the Path3D array of successive Vector3 designing its curve.
  85334. * @returns the Path3D array of successive Vector3 designing its curve.
  85335. */
  85336. getCurve(): Vector3[];
  85337. /**
  85338. * Returns the Path3D array of successive Vector3 designing its curve.
  85339. * @returns the Path3D array of successive Vector3 designing its curve.
  85340. */
  85341. getPoints(): Vector3[];
  85342. /**
  85343. * @returns the computed length (float) of the path.
  85344. */
  85345. length(): number;
  85346. /**
  85347. * Returns an array populated with tangent vectors on each Path3D curve point.
  85348. * @returns an array populated with tangent vectors on each Path3D curve point.
  85349. */
  85350. getTangents(): Vector3[];
  85351. /**
  85352. * Returns an array populated with normal vectors on each Path3D curve point.
  85353. * @returns an array populated with normal vectors on each Path3D curve point.
  85354. */
  85355. getNormals(): Vector3[];
  85356. /**
  85357. * Returns an array populated with binormal vectors on each Path3D curve point.
  85358. * @returns an array populated with binormal vectors on each Path3D curve point.
  85359. */
  85360. getBinormals(): Vector3[];
  85361. /**
  85362. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85363. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85364. */
  85365. getDistances(): number[];
  85366. /**
  85367. * Returns an interpolated point along this path
  85368. * @param position the position of the point along this path, from 0.0 to 1.0
  85369. * @returns a new Vector3 as the point
  85370. */
  85371. getPointAt(position: number): Vector3;
  85372. /**
  85373. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85374. * @param position the position of the point along this path, from 0.0 to 1.0
  85375. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85376. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85377. */
  85378. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85379. /**
  85380. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85381. * @param position the position of the point along this path, from 0.0 to 1.0
  85382. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85383. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85384. */
  85385. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85386. /**
  85387. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85388. * @param position the position of the point along this path, from 0.0 to 1.0
  85389. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85390. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85391. */
  85392. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85393. /**
  85394. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85395. * @param position the position of the point along this path, from 0.0 to 1.0
  85396. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85397. */
  85398. getDistanceAt(position: number): number;
  85399. /**
  85400. * Returns the array index of the previous point of an interpolated point along this path
  85401. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85402. * @returns the array index
  85403. */
  85404. getPreviousPointIndexAt(position: number): number;
  85405. /**
  85406. * 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)
  85407. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85408. * @returns the sub position
  85409. */
  85410. getSubPositionAt(position: number): number;
  85411. /**
  85412. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85413. * @param target the vector of which to get the closest position to
  85414. * @returns the position of the closest virtual point on this path to the target vector
  85415. */
  85416. getClosestPositionTo(target: Vector3): number;
  85417. /**
  85418. * Returns a sub path (slice) of this path
  85419. * @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
  85420. * @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
  85421. * @returns a sub path (slice) of this path
  85422. */
  85423. slice(start?: number, end?: number): Path3D;
  85424. /**
  85425. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85426. * @param path path which all values are copied into the curves points
  85427. * @param firstNormal which should be projected onto the curve
  85428. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85429. * @returns the same object updated.
  85430. */
  85431. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85432. private _compute;
  85433. private _getFirstNonNullVector;
  85434. private _getLastNonNullVector;
  85435. private _normalVector;
  85436. /**
  85437. * Updates the point at data for an interpolated point along this curve
  85438. * @param position the position of the point along this curve, from 0.0 to 1.0
  85439. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85440. * @returns the (updated) point at data
  85441. */
  85442. private _updatePointAtData;
  85443. /**
  85444. * Updates the point at data from the specified parameters
  85445. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85446. * @param point the interpolated point
  85447. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85448. */
  85449. private _setPointAtData;
  85450. /**
  85451. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85452. */
  85453. private _updateInterpolationMatrix;
  85454. }
  85455. /**
  85456. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85457. * A Curve3 is designed from a series of successive Vector3.
  85458. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85459. */
  85460. export class Curve3 {
  85461. private _points;
  85462. private _length;
  85463. /**
  85464. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85465. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85466. * @param v1 (Vector3) the control point
  85467. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85468. * @param nbPoints (integer) the wanted number of points in the curve
  85469. * @returns the created Curve3
  85470. */
  85471. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85472. /**
  85473. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85474. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85475. * @param v1 (Vector3) the first control point
  85476. * @param v2 (Vector3) the second control point
  85477. * @param v3 (Vector3) the end point of the Cubic Bezier
  85478. * @param nbPoints (integer) the wanted number of points in the curve
  85479. * @returns the created Curve3
  85480. */
  85481. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85482. /**
  85483. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85484. * @param p1 (Vector3) the origin point of the Hermite Spline
  85485. * @param t1 (Vector3) the tangent vector at the origin point
  85486. * @param p2 (Vector3) the end point of the Hermite Spline
  85487. * @param t2 (Vector3) the tangent vector at the end point
  85488. * @param nbPoints (integer) the wanted number of points in the curve
  85489. * @returns the created Curve3
  85490. */
  85491. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85492. /**
  85493. * Returns a Curve3 object along a CatmullRom Spline curve :
  85494. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85495. * @param nbPoints (integer) the wanted number of points between each curve control points
  85496. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85497. * @returns the created Curve3
  85498. */
  85499. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85500. /**
  85501. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85502. * A Curve3 is designed from a series of successive Vector3.
  85503. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85504. * @param points points which make up the curve
  85505. */
  85506. constructor(points: Vector3[]);
  85507. /**
  85508. * @returns the Curve3 stored array of successive Vector3
  85509. */
  85510. getPoints(): Vector3[];
  85511. /**
  85512. * @returns the computed length (float) of the curve.
  85513. */
  85514. length(): number;
  85515. /**
  85516. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85517. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85518. * curveA and curveB keep unchanged.
  85519. * @param curve the curve to continue from this curve
  85520. * @returns the newly constructed curve
  85521. */
  85522. continue(curve: DeepImmutable<Curve3>): Curve3;
  85523. private _computeLength;
  85524. }
  85525. }
  85526. declare module BABYLON {
  85527. /**
  85528. * This represents the main contract an easing function should follow.
  85529. * Easing functions are used throughout the animation system.
  85530. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85531. */
  85532. export interface IEasingFunction {
  85533. /**
  85534. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85535. * of the easing function.
  85536. * The link below provides some of the most common examples of easing functions.
  85537. * @see https://easings.net/
  85538. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85539. * @returns the corresponding value on the curve defined by the easing function
  85540. */
  85541. ease(gradient: number): number;
  85542. }
  85543. /**
  85544. * Base class used for every default easing function.
  85545. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85546. */
  85547. export class EasingFunction implements IEasingFunction {
  85548. /**
  85549. * Interpolation follows the mathematical formula associated with the easing function.
  85550. */
  85551. static readonly EASINGMODE_EASEIN: number;
  85552. /**
  85553. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85554. */
  85555. static readonly EASINGMODE_EASEOUT: number;
  85556. /**
  85557. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85558. */
  85559. static readonly EASINGMODE_EASEINOUT: number;
  85560. private _easingMode;
  85561. /**
  85562. * Sets the easing mode of the current function.
  85563. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85564. */
  85565. setEasingMode(easingMode: number): void;
  85566. /**
  85567. * Gets the current easing mode.
  85568. * @returns the easing mode
  85569. */
  85570. getEasingMode(): number;
  85571. /**
  85572. * @hidden
  85573. */
  85574. easeInCore(gradient: number): number;
  85575. /**
  85576. * Given an input gradient between 0 and 1, this returns the corresponding value
  85577. * of the easing function.
  85578. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85579. * @returns the corresponding value on the curve defined by the easing function
  85580. */
  85581. ease(gradient: number): number;
  85582. }
  85583. /**
  85584. * Easing function with a circle shape (see link below).
  85585. * @see https://easings.net/#easeInCirc
  85586. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85587. */
  85588. export class CircleEase extends EasingFunction implements IEasingFunction {
  85589. /** @hidden */
  85590. easeInCore(gradient: number): number;
  85591. }
  85592. /**
  85593. * Easing function with a ease back shape (see link below).
  85594. * @see https://easings.net/#easeInBack
  85595. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85596. */
  85597. export class BackEase extends EasingFunction implements IEasingFunction {
  85598. /** Defines the amplitude of the function */
  85599. amplitude: number;
  85600. /**
  85601. * Instantiates a back ease easing
  85602. * @see https://easings.net/#easeInBack
  85603. * @param amplitude Defines the amplitude of the function
  85604. */
  85605. constructor(
  85606. /** Defines the amplitude of the function */
  85607. amplitude?: number);
  85608. /** @hidden */
  85609. easeInCore(gradient: number): number;
  85610. }
  85611. /**
  85612. * Easing function with a bouncing shape (see link below).
  85613. * @see https://easings.net/#easeInBounce
  85614. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85615. */
  85616. export class BounceEase extends EasingFunction implements IEasingFunction {
  85617. /** Defines the number of bounces */
  85618. bounces: number;
  85619. /** Defines the amplitude of the bounce */
  85620. bounciness: number;
  85621. /**
  85622. * Instantiates a bounce easing
  85623. * @see https://easings.net/#easeInBounce
  85624. * @param bounces Defines the number of bounces
  85625. * @param bounciness Defines the amplitude of the bounce
  85626. */
  85627. constructor(
  85628. /** Defines the number of bounces */
  85629. bounces?: number,
  85630. /** Defines the amplitude of the bounce */
  85631. bounciness?: number);
  85632. /** @hidden */
  85633. easeInCore(gradient: number): number;
  85634. }
  85635. /**
  85636. * Easing function with a power of 3 shape (see link below).
  85637. * @see https://easings.net/#easeInCubic
  85638. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85639. */
  85640. export class CubicEase extends EasingFunction implements IEasingFunction {
  85641. /** @hidden */
  85642. easeInCore(gradient: number): number;
  85643. }
  85644. /**
  85645. * Easing function with an elastic shape (see link below).
  85646. * @see https://easings.net/#easeInElastic
  85647. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85648. */
  85649. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85650. /** Defines the number of oscillations*/
  85651. oscillations: number;
  85652. /** Defines the amplitude of the oscillations*/
  85653. springiness: number;
  85654. /**
  85655. * Instantiates an elastic easing function
  85656. * @see https://easings.net/#easeInElastic
  85657. * @param oscillations Defines the number of oscillations
  85658. * @param springiness Defines the amplitude of the oscillations
  85659. */
  85660. constructor(
  85661. /** Defines the number of oscillations*/
  85662. oscillations?: number,
  85663. /** Defines the amplitude of the oscillations*/
  85664. springiness?: number);
  85665. /** @hidden */
  85666. easeInCore(gradient: number): number;
  85667. }
  85668. /**
  85669. * Easing function with an exponential shape (see link below).
  85670. * @see https://easings.net/#easeInExpo
  85671. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85672. */
  85673. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85674. /** Defines the exponent of the function */
  85675. exponent: number;
  85676. /**
  85677. * Instantiates an exponential easing function
  85678. * @see https://easings.net/#easeInExpo
  85679. * @param exponent Defines the exponent of the function
  85680. */
  85681. constructor(
  85682. /** Defines the exponent of the function */
  85683. exponent?: number);
  85684. /** @hidden */
  85685. easeInCore(gradient: number): number;
  85686. }
  85687. /**
  85688. * Easing function with a power shape (see link below).
  85689. * @see https://easings.net/#easeInQuad
  85690. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85691. */
  85692. export class PowerEase extends EasingFunction implements IEasingFunction {
  85693. /** Defines the power of the function */
  85694. power: number;
  85695. /**
  85696. * Instantiates an power base easing function
  85697. * @see https://easings.net/#easeInQuad
  85698. * @param power Defines the power of the function
  85699. */
  85700. constructor(
  85701. /** Defines the power of the function */
  85702. power?: number);
  85703. /** @hidden */
  85704. easeInCore(gradient: number): number;
  85705. }
  85706. /**
  85707. * Easing function with a power of 2 shape (see link below).
  85708. * @see https://easings.net/#easeInQuad
  85709. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85710. */
  85711. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85712. /** @hidden */
  85713. easeInCore(gradient: number): number;
  85714. }
  85715. /**
  85716. * Easing function with a power of 4 shape (see link below).
  85717. * @see https://easings.net/#easeInQuart
  85718. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85719. */
  85720. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85721. /** @hidden */
  85722. easeInCore(gradient: number): number;
  85723. }
  85724. /**
  85725. * Easing function with a power of 5 shape (see link below).
  85726. * @see https://easings.net/#easeInQuint
  85727. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85728. */
  85729. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85730. /** @hidden */
  85731. easeInCore(gradient: number): number;
  85732. }
  85733. /**
  85734. * Easing function with a sin shape (see link below).
  85735. * @see https://easings.net/#easeInSine
  85736. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85737. */
  85738. export class SineEase extends EasingFunction implements IEasingFunction {
  85739. /** @hidden */
  85740. easeInCore(gradient: number): number;
  85741. }
  85742. /**
  85743. * Easing function with a bezier shape (see link below).
  85744. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85745. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85746. */
  85747. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85748. /** Defines the x component of the start tangent in the bezier curve */
  85749. x1: number;
  85750. /** Defines the y component of the start tangent in the bezier curve */
  85751. y1: number;
  85752. /** Defines the x component of the end tangent in the bezier curve */
  85753. x2: number;
  85754. /** Defines the y component of the end tangent in the bezier curve */
  85755. y2: number;
  85756. /**
  85757. * Instantiates a bezier function
  85758. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85759. * @param x1 Defines the x component of the start tangent in the bezier curve
  85760. * @param y1 Defines the y component of the start tangent in the bezier curve
  85761. * @param x2 Defines the x component of the end tangent in the bezier curve
  85762. * @param y2 Defines the y component of the end tangent in the bezier curve
  85763. */
  85764. constructor(
  85765. /** Defines the x component of the start tangent in the bezier curve */
  85766. x1?: number,
  85767. /** Defines the y component of the start tangent in the bezier curve */
  85768. y1?: number,
  85769. /** Defines the x component of the end tangent in the bezier curve */
  85770. x2?: number,
  85771. /** Defines the y component of the end tangent in the bezier curve */
  85772. y2?: number);
  85773. /** @hidden */
  85774. easeInCore(gradient: number): number;
  85775. }
  85776. }
  85777. declare module BABYLON {
  85778. /**
  85779. * Class used to hold a RBG color
  85780. */
  85781. export class Color3 {
  85782. /**
  85783. * Defines the red component (between 0 and 1, default is 0)
  85784. */
  85785. r: number;
  85786. /**
  85787. * Defines the green component (between 0 and 1, default is 0)
  85788. */
  85789. g: number;
  85790. /**
  85791. * Defines the blue component (between 0 and 1, default is 0)
  85792. */
  85793. b: number;
  85794. /**
  85795. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85796. * @param r defines the red component (between 0 and 1, default is 0)
  85797. * @param g defines the green component (between 0 and 1, default is 0)
  85798. * @param b defines the blue component (between 0 and 1, default is 0)
  85799. */
  85800. constructor(
  85801. /**
  85802. * Defines the red component (between 0 and 1, default is 0)
  85803. */
  85804. r?: number,
  85805. /**
  85806. * Defines the green component (between 0 and 1, default is 0)
  85807. */
  85808. g?: number,
  85809. /**
  85810. * Defines the blue component (between 0 and 1, default is 0)
  85811. */
  85812. b?: number);
  85813. /**
  85814. * Creates a string with the Color3 current values
  85815. * @returns the string representation of the Color3 object
  85816. */
  85817. toString(): string;
  85818. /**
  85819. * Returns the string "Color3"
  85820. * @returns "Color3"
  85821. */
  85822. getClassName(): string;
  85823. /**
  85824. * Compute the Color3 hash code
  85825. * @returns an unique number that can be used to hash Color3 objects
  85826. */
  85827. getHashCode(): number;
  85828. /**
  85829. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85830. * @param array defines the array where to store the r,g,b components
  85831. * @param index defines an optional index in the target array to define where to start storing values
  85832. * @returns the current Color3 object
  85833. */
  85834. toArray(array: FloatArray, index?: number): Color3;
  85835. /**
  85836. * Update the current color with values stored in an array from the starting index of the given array
  85837. * @param array defines the source array
  85838. * @param offset defines an offset in the source array
  85839. * @returns the current Color3 object
  85840. */
  85841. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85842. /**
  85843. * Returns a new Color4 object from the current Color3 and the given alpha
  85844. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85845. * @returns a new Color4 object
  85846. */
  85847. toColor4(alpha?: number): Color4;
  85848. /**
  85849. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85850. * @returns the new array
  85851. */
  85852. asArray(): number[];
  85853. /**
  85854. * Returns the luminance value
  85855. * @returns a float value
  85856. */
  85857. toLuminance(): number;
  85858. /**
  85859. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85860. * @param otherColor defines the second operand
  85861. * @returns the new Color3 object
  85862. */
  85863. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85864. /**
  85865. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85866. * @param otherColor defines the second operand
  85867. * @param result defines the Color3 object where to store the result
  85868. * @returns the current Color3
  85869. */
  85870. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85871. /**
  85872. * Determines equality between Color3 objects
  85873. * @param otherColor defines the second operand
  85874. * @returns true if the rgb values are equal to the given ones
  85875. */
  85876. equals(otherColor: DeepImmutable<Color3>): boolean;
  85877. /**
  85878. * Determines equality between the current Color3 object and a set of r,b,g values
  85879. * @param r defines the red component to check
  85880. * @param g defines the green component to check
  85881. * @param b defines the blue component to check
  85882. * @returns true if the rgb values are equal to the given ones
  85883. */
  85884. equalsFloats(r: number, g: number, b: number): boolean;
  85885. /**
  85886. * Multiplies in place each rgb value by scale
  85887. * @param scale defines the scaling factor
  85888. * @returns the updated Color3
  85889. */
  85890. scale(scale: number): Color3;
  85891. /**
  85892. * Multiplies the rgb values by scale and stores the result into "result"
  85893. * @param scale defines the scaling factor
  85894. * @param result defines the Color3 object where to store the result
  85895. * @returns the unmodified current Color3
  85896. */
  85897. scaleToRef(scale: number, result: Color3): Color3;
  85898. /**
  85899. * Scale the current Color3 values by a factor and add the result to a given Color3
  85900. * @param scale defines the scale factor
  85901. * @param result defines color to store the result into
  85902. * @returns the unmodified current Color3
  85903. */
  85904. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85905. /**
  85906. * Clamps the rgb values by the min and max values and stores the result into "result"
  85907. * @param min defines minimum clamping value (default is 0)
  85908. * @param max defines maximum clamping value (default is 1)
  85909. * @param result defines color to store the result into
  85910. * @returns the original Color3
  85911. */
  85912. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85913. /**
  85914. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85915. * @param otherColor defines the second operand
  85916. * @returns the new Color3
  85917. */
  85918. add(otherColor: DeepImmutable<Color3>): Color3;
  85919. /**
  85920. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85921. * @param otherColor defines the second operand
  85922. * @param result defines Color3 object to store the result into
  85923. * @returns the unmodified current Color3
  85924. */
  85925. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85926. /**
  85927. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85928. * @param otherColor defines the second operand
  85929. * @returns the new Color3
  85930. */
  85931. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85932. /**
  85933. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85934. * @param otherColor defines the second operand
  85935. * @param result defines Color3 object to store the result into
  85936. * @returns the unmodified current Color3
  85937. */
  85938. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85939. /**
  85940. * Copy the current object
  85941. * @returns a new Color3 copied the current one
  85942. */
  85943. clone(): Color3;
  85944. /**
  85945. * Copies the rgb values from the source in the current Color3
  85946. * @param source defines the source Color3 object
  85947. * @returns the updated Color3 object
  85948. */
  85949. copyFrom(source: DeepImmutable<Color3>): Color3;
  85950. /**
  85951. * Updates the Color3 rgb values from the given floats
  85952. * @param r defines the red component to read from
  85953. * @param g defines the green component to read from
  85954. * @param b defines the blue component to read from
  85955. * @returns the current Color3 object
  85956. */
  85957. copyFromFloats(r: number, g: number, b: number): Color3;
  85958. /**
  85959. * Updates the Color3 rgb values from the given floats
  85960. * @param r defines the red component to read from
  85961. * @param g defines the green component to read from
  85962. * @param b defines the blue component to read from
  85963. * @returns the current Color3 object
  85964. */
  85965. set(r: number, g: number, b: number): Color3;
  85966. /**
  85967. * Compute the Color3 hexadecimal code as a string
  85968. * @returns a string containing the hexadecimal representation of the Color3 object
  85969. */
  85970. toHexString(): string;
  85971. /**
  85972. * Computes a new Color3 converted from the current one to linear space
  85973. * @returns a new Color3 object
  85974. */
  85975. toLinearSpace(): Color3;
  85976. /**
  85977. * Converts current color in rgb space to HSV values
  85978. * @returns a new color3 representing the HSV values
  85979. */
  85980. toHSV(): Color3;
  85981. /**
  85982. * Converts current color in rgb space to HSV values
  85983. * @param result defines the Color3 where to store the HSV values
  85984. */
  85985. toHSVToRef(result: Color3): void;
  85986. /**
  85987. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85988. * @param convertedColor defines the Color3 object where to store the linear space version
  85989. * @returns the unmodified Color3
  85990. */
  85991. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85992. /**
  85993. * Computes a new Color3 converted from the current one to gamma space
  85994. * @returns a new Color3 object
  85995. */
  85996. toGammaSpace(): Color3;
  85997. /**
  85998. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85999. * @param convertedColor defines the Color3 object where to store the gamma space version
  86000. * @returns the unmodified Color3
  86001. */
  86002. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86003. private static _BlackReadOnly;
  86004. /**
  86005. * Convert Hue, saturation and value to a Color3 (RGB)
  86006. * @param hue defines the hue
  86007. * @param saturation defines the saturation
  86008. * @param value defines the value
  86009. * @param result defines the Color3 where to store the RGB values
  86010. */
  86011. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86012. /**
  86013. * Creates a new Color3 from the string containing valid hexadecimal values
  86014. * @param hex defines a string containing valid hexadecimal values
  86015. * @returns a new Color3 object
  86016. */
  86017. static FromHexString(hex: string): Color3;
  86018. /**
  86019. * Creates a new Color3 from the starting index of the given array
  86020. * @param array defines the source array
  86021. * @param offset defines an offset in the source array
  86022. * @returns a new Color3 object
  86023. */
  86024. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86025. /**
  86026. * Creates a new Color3 from the starting index element of the given array
  86027. * @param array defines the source array to read from
  86028. * @param offset defines the offset in the source array
  86029. * @param result defines the target Color3 object
  86030. */
  86031. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86032. /**
  86033. * Creates a new Color3 from integer values (< 256)
  86034. * @param r defines the red component to read from (value between 0 and 255)
  86035. * @param g defines the green component to read from (value between 0 and 255)
  86036. * @param b defines the blue component to read from (value between 0 and 255)
  86037. * @returns a new Color3 object
  86038. */
  86039. static FromInts(r: number, g: number, b: number): Color3;
  86040. /**
  86041. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86042. * @param start defines the start Color3 value
  86043. * @param end defines the end Color3 value
  86044. * @param amount defines the gradient value between start and end
  86045. * @returns a new Color3 object
  86046. */
  86047. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86048. /**
  86049. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86050. * @param left defines the start value
  86051. * @param right defines the end value
  86052. * @param amount defines the gradient factor
  86053. * @param result defines the Color3 object where to store the result
  86054. */
  86055. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86056. /**
  86057. * Returns a Color3 value containing a red color
  86058. * @returns a new Color3 object
  86059. */
  86060. static Red(): Color3;
  86061. /**
  86062. * Returns a Color3 value containing a green color
  86063. * @returns a new Color3 object
  86064. */
  86065. static Green(): Color3;
  86066. /**
  86067. * Returns a Color3 value containing a blue color
  86068. * @returns a new Color3 object
  86069. */
  86070. static Blue(): Color3;
  86071. /**
  86072. * Returns a Color3 value containing a black color
  86073. * @returns a new Color3 object
  86074. */
  86075. static Black(): Color3;
  86076. /**
  86077. * Gets a Color3 value containing a black color that must not be updated
  86078. */
  86079. static get BlackReadOnly(): DeepImmutable<Color3>;
  86080. /**
  86081. * Returns a Color3 value containing a white color
  86082. * @returns a new Color3 object
  86083. */
  86084. static White(): Color3;
  86085. /**
  86086. * Returns a Color3 value containing a purple color
  86087. * @returns a new Color3 object
  86088. */
  86089. static Purple(): Color3;
  86090. /**
  86091. * Returns a Color3 value containing a magenta color
  86092. * @returns a new Color3 object
  86093. */
  86094. static Magenta(): Color3;
  86095. /**
  86096. * Returns a Color3 value containing a yellow color
  86097. * @returns a new Color3 object
  86098. */
  86099. static Yellow(): Color3;
  86100. /**
  86101. * Returns a Color3 value containing a gray color
  86102. * @returns a new Color3 object
  86103. */
  86104. static Gray(): Color3;
  86105. /**
  86106. * Returns a Color3 value containing a teal color
  86107. * @returns a new Color3 object
  86108. */
  86109. static Teal(): Color3;
  86110. /**
  86111. * Returns a Color3 value containing a random color
  86112. * @returns a new Color3 object
  86113. */
  86114. static Random(): Color3;
  86115. }
  86116. /**
  86117. * Class used to hold a RBGA color
  86118. */
  86119. export class Color4 {
  86120. /**
  86121. * Defines the red component (between 0 and 1, default is 0)
  86122. */
  86123. r: number;
  86124. /**
  86125. * Defines the green component (between 0 and 1, default is 0)
  86126. */
  86127. g: number;
  86128. /**
  86129. * Defines the blue component (between 0 and 1, default is 0)
  86130. */
  86131. b: number;
  86132. /**
  86133. * Defines the alpha component (between 0 and 1, default is 1)
  86134. */
  86135. a: number;
  86136. /**
  86137. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86138. * @param r defines the red component (between 0 and 1, default is 0)
  86139. * @param g defines the green component (between 0 and 1, default is 0)
  86140. * @param b defines the blue component (between 0 and 1, default is 0)
  86141. * @param a defines the alpha component (between 0 and 1, default is 1)
  86142. */
  86143. constructor(
  86144. /**
  86145. * Defines the red component (between 0 and 1, default is 0)
  86146. */
  86147. r?: number,
  86148. /**
  86149. * Defines the green component (between 0 and 1, default is 0)
  86150. */
  86151. g?: number,
  86152. /**
  86153. * Defines the blue component (between 0 and 1, default is 0)
  86154. */
  86155. b?: number,
  86156. /**
  86157. * Defines the alpha component (between 0 and 1, default is 1)
  86158. */
  86159. a?: number);
  86160. /**
  86161. * Adds in place the given Color4 values to the current Color4 object
  86162. * @param right defines the second operand
  86163. * @returns the current updated Color4 object
  86164. */
  86165. addInPlace(right: DeepImmutable<Color4>): Color4;
  86166. /**
  86167. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86168. * @returns the new array
  86169. */
  86170. asArray(): number[];
  86171. /**
  86172. * Stores from the starting index in the given array the Color4 successive values
  86173. * @param array defines the array where to store the r,g,b components
  86174. * @param index defines an optional index in the target array to define where to start storing values
  86175. * @returns the current Color4 object
  86176. */
  86177. toArray(array: number[], index?: number): Color4;
  86178. /**
  86179. * Update the current color with values stored in an array from the starting index of the given array
  86180. * @param array defines the source array
  86181. * @param offset defines an offset in the source array
  86182. * @returns the current Color4 object
  86183. */
  86184. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86185. /**
  86186. * Determines equality between Color4 objects
  86187. * @param otherColor defines the second operand
  86188. * @returns true if the rgba values are equal to the given ones
  86189. */
  86190. equals(otherColor: DeepImmutable<Color4>): boolean;
  86191. /**
  86192. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86193. * @param right defines the second operand
  86194. * @returns a new Color4 object
  86195. */
  86196. add(right: DeepImmutable<Color4>): Color4;
  86197. /**
  86198. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86199. * @param right defines the second operand
  86200. * @returns a new Color4 object
  86201. */
  86202. subtract(right: DeepImmutable<Color4>): Color4;
  86203. /**
  86204. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86205. * @param right defines the second operand
  86206. * @param result defines the Color4 object where to store the result
  86207. * @returns the current Color4 object
  86208. */
  86209. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86210. /**
  86211. * Creates a new Color4 with the current Color4 values multiplied by scale
  86212. * @param scale defines the scaling factor to apply
  86213. * @returns a new Color4 object
  86214. */
  86215. scale(scale: number): Color4;
  86216. /**
  86217. * Multiplies the current Color4 values by scale and stores the result in "result"
  86218. * @param scale defines the scaling factor to apply
  86219. * @param result defines the Color4 object where to store the result
  86220. * @returns the current unmodified Color4
  86221. */
  86222. scaleToRef(scale: number, result: Color4): Color4;
  86223. /**
  86224. * Scale the current Color4 values by a factor and add the result to a given Color4
  86225. * @param scale defines the scale factor
  86226. * @param result defines the Color4 object where to store the result
  86227. * @returns the unmodified current Color4
  86228. */
  86229. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86230. /**
  86231. * Clamps the rgb values by the min and max values and stores the result into "result"
  86232. * @param min defines minimum clamping value (default is 0)
  86233. * @param max defines maximum clamping value (default is 1)
  86234. * @param result defines color to store the result into.
  86235. * @returns the cuurent Color4
  86236. */
  86237. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86238. /**
  86239. * Multipy an Color4 value by another and return a new Color4 object
  86240. * @param color defines the Color4 value to multiply by
  86241. * @returns a new Color4 object
  86242. */
  86243. multiply(color: Color4): Color4;
  86244. /**
  86245. * Multipy a Color4 value by another and push the result in a reference value
  86246. * @param color defines the Color4 value to multiply by
  86247. * @param result defines the Color4 to fill the result in
  86248. * @returns the result Color4
  86249. */
  86250. multiplyToRef(color: Color4, result: Color4): Color4;
  86251. /**
  86252. * Creates a string with the Color4 current values
  86253. * @returns the string representation of the Color4 object
  86254. */
  86255. toString(): string;
  86256. /**
  86257. * Returns the string "Color4"
  86258. * @returns "Color4"
  86259. */
  86260. getClassName(): string;
  86261. /**
  86262. * Compute the Color4 hash code
  86263. * @returns an unique number that can be used to hash Color4 objects
  86264. */
  86265. getHashCode(): number;
  86266. /**
  86267. * Creates a new Color4 copied from the current one
  86268. * @returns a new Color4 object
  86269. */
  86270. clone(): Color4;
  86271. /**
  86272. * Copies the given Color4 values into the current one
  86273. * @param source defines the source Color4 object
  86274. * @returns the current updated Color4 object
  86275. */
  86276. copyFrom(source: Color4): Color4;
  86277. /**
  86278. * Copies the given float values into the current one
  86279. * @param r defines the red component to read from
  86280. * @param g defines the green component to read from
  86281. * @param b defines the blue component to read from
  86282. * @param a defines the alpha component to read from
  86283. * @returns the current updated Color4 object
  86284. */
  86285. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86286. /**
  86287. * Copies the given float values into the current one
  86288. * @param r defines the red component to read from
  86289. * @param g defines the green component to read from
  86290. * @param b defines the blue component to read from
  86291. * @param a defines the alpha component to read from
  86292. * @returns the current updated Color4 object
  86293. */
  86294. set(r: number, g: number, b: number, a: number): Color4;
  86295. /**
  86296. * Compute the Color4 hexadecimal code as a string
  86297. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86298. * @returns a string containing the hexadecimal representation of the Color4 object
  86299. */
  86300. toHexString(returnAsColor3?: boolean): string;
  86301. /**
  86302. * Computes a new Color4 converted from the current one to linear space
  86303. * @returns a new Color4 object
  86304. */
  86305. toLinearSpace(): Color4;
  86306. /**
  86307. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86308. * @param convertedColor defines the Color4 object where to store the linear space version
  86309. * @returns the unmodified Color4
  86310. */
  86311. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86312. /**
  86313. * Computes a new Color4 converted from the current one to gamma space
  86314. * @returns a new Color4 object
  86315. */
  86316. toGammaSpace(): Color4;
  86317. /**
  86318. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86319. * @param convertedColor defines the Color4 object where to store the gamma space version
  86320. * @returns the unmodified Color4
  86321. */
  86322. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86323. /**
  86324. * Creates a new Color4 from the string containing valid hexadecimal values
  86325. * @param hex defines a string containing valid hexadecimal values
  86326. * @returns a new Color4 object
  86327. */
  86328. static FromHexString(hex: string): Color4;
  86329. /**
  86330. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86331. * @param left defines the start value
  86332. * @param right defines the end value
  86333. * @param amount defines the gradient factor
  86334. * @returns a new Color4 object
  86335. */
  86336. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86337. /**
  86338. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86339. * @param left defines the start value
  86340. * @param right defines the end value
  86341. * @param amount defines the gradient factor
  86342. * @param result defines the Color4 object where to store data
  86343. */
  86344. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86345. /**
  86346. * Creates a new Color4 from a Color3 and an alpha value
  86347. * @param color3 defines the source Color3 to read from
  86348. * @param alpha defines the alpha component (1.0 by default)
  86349. * @returns a new Color4 object
  86350. */
  86351. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86352. /**
  86353. * Creates a new Color4 from the starting index element of the given array
  86354. * @param array defines the source array to read from
  86355. * @param offset defines the offset in the source array
  86356. * @returns a new Color4 object
  86357. */
  86358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86359. /**
  86360. * Creates a new Color4 from the starting index element of the given array
  86361. * @param array defines the source array to read from
  86362. * @param offset defines the offset in the source array
  86363. * @param result defines the target Color4 object
  86364. */
  86365. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86366. /**
  86367. * Creates a new Color3 from integer values (< 256)
  86368. * @param r defines the red component to read from (value between 0 and 255)
  86369. * @param g defines the green component to read from (value between 0 and 255)
  86370. * @param b defines the blue component to read from (value between 0 and 255)
  86371. * @param a defines the alpha component to read from (value between 0 and 255)
  86372. * @returns a new Color3 object
  86373. */
  86374. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86375. /**
  86376. * Check the content of a given array and convert it to an array containing RGBA data
  86377. * If the original array was already containing count * 4 values then it is returned directly
  86378. * @param colors defines the array to check
  86379. * @param count defines the number of RGBA data to expect
  86380. * @returns an array containing count * 4 values (RGBA)
  86381. */
  86382. static CheckColors4(colors: number[], count: number): number[];
  86383. }
  86384. /**
  86385. * @hidden
  86386. */
  86387. export class TmpColors {
  86388. static Color3: Color3[];
  86389. static Color4: Color4[];
  86390. }
  86391. }
  86392. declare module BABYLON {
  86393. /**
  86394. * Defines an interface which represents an animation key frame
  86395. */
  86396. export interface IAnimationKey {
  86397. /**
  86398. * Frame of the key frame
  86399. */
  86400. frame: number;
  86401. /**
  86402. * Value at the specifies key frame
  86403. */
  86404. value: any;
  86405. /**
  86406. * The input tangent for the cubic hermite spline
  86407. */
  86408. inTangent?: any;
  86409. /**
  86410. * The output tangent for the cubic hermite spline
  86411. */
  86412. outTangent?: any;
  86413. /**
  86414. * The animation interpolation type
  86415. */
  86416. interpolation?: AnimationKeyInterpolation;
  86417. }
  86418. /**
  86419. * Enum for the animation key frame interpolation type
  86420. */
  86421. export enum AnimationKeyInterpolation {
  86422. /**
  86423. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86424. */
  86425. STEP = 1
  86426. }
  86427. }
  86428. declare module BABYLON {
  86429. /**
  86430. * Represents the range of an animation
  86431. */
  86432. export class AnimationRange {
  86433. /**The name of the animation range**/
  86434. name: string;
  86435. /**The starting frame of the animation */
  86436. from: number;
  86437. /**The ending frame of the animation*/
  86438. to: number;
  86439. /**
  86440. * Initializes the range of an animation
  86441. * @param name The name of the animation range
  86442. * @param from The starting frame of the animation
  86443. * @param to The ending frame of the animation
  86444. */
  86445. constructor(
  86446. /**The name of the animation range**/
  86447. name: string,
  86448. /**The starting frame of the animation */
  86449. from: number,
  86450. /**The ending frame of the animation*/
  86451. to: number);
  86452. /**
  86453. * Makes a copy of the animation range
  86454. * @returns A copy of the animation range
  86455. */
  86456. clone(): AnimationRange;
  86457. }
  86458. }
  86459. declare module BABYLON {
  86460. /**
  86461. * Composed of a frame, and an action function
  86462. */
  86463. export class AnimationEvent {
  86464. /** The frame for which the event is triggered **/
  86465. frame: number;
  86466. /** The event to perform when triggered **/
  86467. action: (currentFrame: number) => void;
  86468. /** Specifies if the event should be triggered only once**/
  86469. onlyOnce?: boolean | undefined;
  86470. /**
  86471. * Specifies if the animation event is done
  86472. */
  86473. isDone: boolean;
  86474. /**
  86475. * Initializes the animation event
  86476. * @param frame The frame for which the event is triggered
  86477. * @param action The event to perform when triggered
  86478. * @param onlyOnce Specifies if the event should be triggered only once
  86479. */
  86480. constructor(
  86481. /** The frame for which the event is triggered **/
  86482. frame: number,
  86483. /** The event to perform when triggered **/
  86484. action: (currentFrame: number) => void,
  86485. /** Specifies if the event should be triggered only once**/
  86486. onlyOnce?: boolean | undefined);
  86487. /** @hidden */
  86488. _clone(): AnimationEvent;
  86489. }
  86490. }
  86491. declare module BABYLON {
  86492. /**
  86493. * Interface used to define a behavior
  86494. */
  86495. export interface Behavior<T> {
  86496. /** gets or sets behavior's name */
  86497. name: string;
  86498. /**
  86499. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86500. */
  86501. init(): void;
  86502. /**
  86503. * Called when the behavior is attached to a target
  86504. * @param target defines the target where the behavior is attached to
  86505. */
  86506. attach(target: T): void;
  86507. /**
  86508. * Called when the behavior is detached from its target
  86509. */
  86510. detach(): void;
  86511. }
  86512. /**
  86513. * Interface implemented by classes supporting behaviors
  86514. */
  86515. export interface IBehaviorAware<T> {
  86516. /**
  86517. * Attach a behavior
  86518. * @param behavior defines the behavior to attach
  86519. * @returns the current host
  86520. */
  86521. addBehavior(behavior: Behavior<T>): T;
  86522. /**
  86523. * Remove a behavior from the current object
  86524. * @param behavior defines the behavior to detach
  86525. * @returns the current host
  86526. */
  86527. removeBehavior(behavior: Behavior<T>): T;
  86528. /**
  86529. * Gets a behavior using its name to search
  86530. * @param name defines the name to search
  86531. * @returns the behavior or null if not found
  86532. */
  86533. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86534. }
  86535. }
  86536. declare module BABYLON {
  86537. /**
  86538. * Defines an array and its length.
  86539. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86540. */
  86541. export interface ISmartArrayLike<T> {
  86542. /**
  86543. * The data of the array.
  86544. */
  86545. data: Array<T>;
  86546. /**
  86547. * The active length of the array.
  86548. */
  86549. length: number;
  86550. }
  86551. /**
  86552. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86553. */
  86554. export class SmartArray<T> implements ISmartArrayLike<T> {
  86555. /**
  86556. * The full set of data from the array.
  86557. */
  86558. data: Array<T>;
  86559. /**
  86560. * The active length of the array.
  86561. */
  86562. length: number;
  86563. protected _id: number;
  86564. /**
  86565. * Instantiates a Smart Array.
  86566. * @param capacity defines the default capacity of the array.
  86567. */
  86568. constructor(capacity: number);
  86569. /**
  86570. * Pushes a value at the end of the active data.
  86571. * @param value defines the object to push in the array.
  86572. */
  86573. push(value: T): void;
  86574. /**
  86575. * Iterates over the active data and apply the lambda to them.
  86576. * @param func defines the action to apply on each value.
  86577. */
  86578. forEach(func: (content: T) => void): void;
  86579. /**
  86580. * Sorts the full sets of data.
  86581. * @param compareFn defines the comparison function to apply.
  86582. */
  86583. sort(compareFn: (a: T, b: T) => number): void;
  86584. /**
  86585. * Resets the active data to an empty array.
  86586. */
  86587. reset(): void;
  86588. /**
  86589. * Releases all the data from the array as well as the array.
  86590. */
  86591. dispose(): void;
  86592. /**
  86593. * Concats the active data with a given array.
  86594. * @param array defines the data to concatenate with.
  86595. */
  86596. concat(array: any): void;
  86597. /**
  86598. * Returns the position of a value in the active data.
  86599. * @param value defines the value to find the index for
  86600. * @returns the index if found in the active data otherwise -1
  86601. */
  86602. indexOf(value: T): number;
  86603. /**
  86604. * Returns whether an element is part of the active data.
  86605. * @param value defines the value to look for
  86606. * @returns true if found in the active data otherwise false
  86607. */
  86608. contains(value: T): boolean;
  86609. private static _GlobalId;
  86610. }
  86611. /**
  86612. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86613. * The data in this array can only be present once
  86614. */
  86615. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86616. private _duplicateId;
  86617. /**
  86618. * Pushes a value at the end of the active data.
  86619. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86620. * @param value defines the object to push in the array.
  86621. */
  86622. push(value: T): void;
  86623. /**
  86624. * Pushes a value at the end of the active data.
  86625. * If the data is already present, it won t be added again
  86626. * @param value defines the object to push in the array.
  86627. * @returns true if added false if it was already present
  86628. */
  86629. pushNoDuplicate(value: T): boolean;
  86630. /**
  86631. * Resets the active data to an empty array.
  86632. */
  86633. reset(): void;
  86634. /**
  86635. * Concats the active data with a given array.
  86636. * This ensures no dupplicate will be present in the result.
  86637. * @param array defines the data to concatenate with.
  86638. */
  86639. concatWithNoDuplicate(array: any): void;
  86640. }
  86641. }
  86642. declare module BABYLON {
  86643. /**
  86644. * @ignore
  86645. * This is a list of all the different input types that are available in the application.
  86646. * Fo instance: ArcRotateCameraGamepadInput...
  86647. */
  86648. export var CameraInputTypes: {};
  86649. /**
  86650. * This is the contract to implement in order to create a new input class.
  86651. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86652. */
  86653. export interface ICameraInput<TCamera extends Camera> {
  86654. /**
  86655. * Defines the camera the input is attached to.
  86656. */
  86657. camera: Nullable<TCamera>;
  86658. /**
  86659. * Gets the class name of the current intput.
  86660. * @returns the class name
  86661. */
  86662. getClassName(): string;
  86663. /**
  86664. * Get the friendly name associated with the input class.
  86665. * @returns the input friendly name
  86666. */
  86667. getSimpleName(): string;
  86668. /**
  86669. * Attach the input controls to a specific dom element to get the input from.
  86670. * @param element Defines the element the controls should be listened from
  86671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86672. */
  86673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86674. /**
  86675. * Detach the current controls from the specified dom element.
  86676. * @param element Defines the element to stop listening the inputs from
  86677. */
  86678. detachControl(element: Nullable<HTMLElement>): void;
  86679. /**
  86680. * Update the current camera state depending on the inputs that have been used this frame.
  86681. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86682. */
  86683. checkInputs?: () => void;
  86684. }
  86685. /**
  86686. * Represents a map of input types to input instance or input index to input instance.
  86687. */
  86688. export interface CameraInputsMap<TCamera extends Camera> {
  86689. /**
  86690. * Accessor to the input by input type.
  86691. */
  86692. [name: string]: ICameraInput<TCamera>;
  86693. /**
  86694. * Accessor to the input by input index.
  86695. */
  86696. [idx: number]: ICameraInput<TCamera>;
  86697. }
  86698. /**
  86699. * This represents the input manager used within a camera.
  86700. * It helps dealing with all the different kind of input attached to a camera.
  86701. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86702. */
  86703. export class CameraInputsManager<TCamera extends Camera> {
  86704. /**
  86705. * Defines the list of inputs attahed to the camera.
  86706. */
  86707. attached: CameraInputsMap<TCamera>;
  86708. /**
  86709. * Defines the dom element the camera is collecting inputs from.
  86710. * This is null if the controls have not been attached.
  86711. */
  86712. attachedElement: Nullable<HTMLElement>;
  86713. /**
  86714. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86715. */
  86716. noPreventDefault: boolean;
  86717. /**
  86718. * Defined the camera the input manager belongs to.
  86719. */
  86720. camera: TCamera;
  86721. /**
  86722. * Update the current camera state depending on the inputs that have been used this frame.
  86723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86724. */
  86725. checkInputs: () => void;
  86726. /**
  86727. * Instantiate a new Camera Input Manager.
  86728. * @param camera Defines the camera the input manager blongs to
  86729. */
  86730. constructor(camera: TCamera);
  86731. /**
  86732. * Add an input method to a camera
  86733. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86734. * @param input camera input method
  86735. */
  86736. add(input: ICameraInput<TCamera>): void;
  86737. /**
  86738. * Remove a specific input method from a camera
  86739. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86740. * @param inputToRemove camera input method
  86741. */
  86742. remove(inputToRemove: ICameraInput<TCamera>): void;
  86743. /**
  86744. * Remove a specific input type from a camera
  86745. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86746. * @param inputType the type of the input to remove
  86747. */
  86748. removeByType(inputType: string): void;
  86749. private _addCheckInputs;
  86750. /**
  86751. * Attach the input controls to the currently attached dom element to listen the events from.
  86752. * @param input Defines the input to attach
  86753. */
  86754. attachInput(input: ICameraInput<TCamera>): void;
  86755. /**
  86756. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86757. * @param element Defines the dom element to collect the events from
  86758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86759. */
  86760. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86761. /**
  86762. * Detach the current manager inputs controls from a specific dom element.
  86763. * @param element Defines the dom element to collect the events from
  86764. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86765. */
  86766. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86767. /**
  86768. * Rebuild the dynamic inputCheck function from the current list of
  86769. * defined inputs in the manager.
  86770. */
  86771. rebuildInputCheck(): void;
  86772. /**
  86773. * Remove all attached input methods from a camera
  86774. */
  86775. clear(): void;
  86776. /**
  86777. * Serialize the current input manager attached to a camera.
  86778. * This ensures than once parsed,
  86779. * the input associated to the camera will be identical to the current ones
  86780. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86781. */
  86782. serialize(serializedCamera: any): void;
  86783. /**
  86784. * Parses an input manager serialized JSON to restore the previous list of inputs
  86785. * and states associated to a camera.
  86786. * @param parsedCamera Defines the JSON to parse
  86787. */
  86788. parse(parsedCamera: any): void;
  86789. }
  86790. }
  86791. declare module BABYLON {
  86792. /**
  86793. * Class used to store data that will be store in GPU memory
  86794. */
  86795. export class Buffer {
  86796. private _engine;
  86797. private _buffer;
  86798. /** @hidden */
  86799. _data: Nullable<DataArray>;
  86800. private _updatable;
  86801. private _instanced;
  86802. private _divisor;
  86803. /**
  86804. * Gets the byte stride.
  86805. */
  86806. readonly byteStride: number;
  86807. /**
  86808. * Constructor
  86809. * @param engine the engine
  86810. * @param data the data to use for this buffer
  86811. * @param updatable whether the data is updatable
  86812. * @param stride the stride (optional)
  86813. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86814. * @param instanced whether the buffer is instanced (optional)
  86815. * @param useBytes set to true if the stride in in bytes (optional)
  86816. * @param divisor sets an optional divisor for instances (1 by default)
  86817. */
  86818. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86819. /**
  86820. * Create a new VertexBuffer based on the current buffer
  86821. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86822. * @param offset defines offset in the buffer (0 by default)
  86823. * @param size defines the size in floats of attributes (position is 3 for instance)
  86824. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86825. * @param instanced defines if the vertex buffer contains indexed data
  86826. * @param useBytes defines if the offset and stride are in bytes *
  86827. * @param divisor sets an optional divisor for instances (1 by default)
  86828. * @returns the new vertex buffer
  86829. */
  86830. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86831. /**
  86832. * Gets a boolean indicating if the Buffer is updatable?
  86833. * @returns true if the buffer is updatable
  86834. */
  86835. isUpdatable(): boolean;
  86836. /**
  86837. * Gets current buffer's data
  86838. * @returns a DataArray or null
  86839. */
  86840. getData(): Nullable<DataArray>;
  86841. /**
  86842. * Gets underlying native buffer
  86843. * @returns underlying native buffer
  86844. */
  86845. getBuffer(): Nullable<DataBuffer>;
  86846. /**
  86847. * Gets the stride in float32 units (i.e. byte stride / 4).
  86848. * May not be an integer if the byte stride is not divisible by 4.
  86849. * @returns the stride in float32 units
  86850. * @deprecated Please use byteStride instead.
  86851. */
  86852. getStrideSize(): number;
  86853. /**
  86854. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86855. * @param data defines the data to store
  86856. */
  86857. create(data?: Nullable<DataArray>): void;
  86858. /** @hidden */
  86859. _rebuild(): void;
  86860. /**
  86861. * Update current buffer data
  86862. * @param data defines the data to store
  86863. */
  86864. update(data: DataArray): void;
  86865. /**
  86866. * Updates the data directly.
  86867. * @param data the new data
  86868. * @param offset the new offset
  86869. * @param vertexCount the vertex count (optional)
  86870. * @param useBytes set to true if the offset is in bytes
  86871. */
  86872. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86873. /**
  86874. * Release all resources
  86875. */
  86876. dispose(): void;
  86877. }
  86878. /**
  86879. * Specialized buffer used to store vertex data
  86880. */
  86881. export class VertexBuffer {
  86882. /** @hidden */
  86883. _buffer: Buffer;
  86884. private _kind;
  86885. private _size;
  86886. private _ownsBuffer;
  86887. private _instanced;
  86888. private _instanceDivisor;
  86889. /**
  86890. * The byte type.
  86891. */
  86892. static readonly BYTE: number;
  86893. /**
  86894. * The unsigned byte type.
  86895. */
  86896. static readonly UNSIGNED_BYTE: number;
  86897. /**
  86898. * The short type.
  86899. */
  86900. static readonly SHORT: number;
  86901. /**
  86902. * The unsigned short type.
  86903. */
  86904. static readonly UNSIGNED_SHORT: number;
  86905. /**
  86906. * The integer type.
  86907. */
  86908. static readonly INT: number;
  86909. /**
  86910. * The unsigned integer type.
  86911. */
  86912. static readonly UNSIGNED_INT: number;
  86913. /**
  86914. * The float type.
  86915. */
  86916. static readonly FLOAT: number;
  86917. /**
  86918. * Gets or sets the instance divisor when in instanced mode
  86919. */
  86920. get instanceDivisor(): number;
  86921. set instanceDivisor(value: number);
  86922. /**
  86923. * Gets the byte stride.
  86924. */
  86925. readonly byteStride: number;
  86926. /**
  86927. * Gets the byte offset.
  86928. */
  86929. readonly byteOffset: number;
  86930. /**
  86931. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86932. */
  86933. readonly normalized: boolean;
  86934. /**
  86935. * Gets the data type of each component in the array.
  86936. */
  86937. readonly type: number;
  86938. /**
  86939. * Constructor
  86940. * @param engine the engine
  86941. * @param data the data to use for this vertex buffer
  86942. * @param kind the vertex buffer kind
  86943. * @param updatable whether the data is updatable
  86944. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86945. * @param stride the stride (optional)
  86946. * @param instanced whether the buffer is instanced (optional)
  86947. * @param offset the offset of the data (optional)
  86948. * @param size the number of components (optional)
  86949. * @param type the type of the component (optional)
  86950. * @param normalized whether the data contains normalized data (optional)
  86951. * @param useBytes set to true if stride and offset are in bytes (optional)
  86952. * @param divisor defines the instance divisor to use (1 by default)
  86953. */
  86954. 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);
  86955. /** @hidden */
  86956. _rebuild(): void;
  86957. /**
  86958. * Returns the kind of the VertexBuffer (string)
  86959. * @returns a string
  86960. */
  86961. getKind(): string;
  86962. /**
  86963. * Gets a boolean indicating if the VertexBuffer is updatable?
  86964. * @returns true if the buffer is updatable
  86965. */
  86966. isUpdatable(): boolean;
  86967. /**
  86968. * Gets current buffer's data
  86969. * @returns a DataArray or null
  86970. */
  86971. getData(): Nullable<DataArray>;
  86972. /**
  86973. * Gets underlying native buffer
  86974. * @returns underlying native buffer
  86975. */
  86976. getBuffer(): Nullable<DataBuffer>;
  86977. /**
  86978. * Gets the stride in float32 units (i.e. byte stride / 4).
  86979. * May not be an integer if the byte stride is not divisible by 4.
  86980. * @returns the stride in float32 units
  86981. * @deprecated Please use byteStride instead.
  86982. */
  86983. getStrideSize(): number;
  86984. /**
  86985. * Returns the offset as a multiple of the type byte length.
  86986. * @returns the offset in bytes
  86987. * @deprecated Please use byteOffset instead.
  86988. */
  86989. getOffset(): number;
  86990. /**
  86991. * Returns the number of components per vertex attribute (integer)
  86992. * @returns the size in float
  86993. */
  86994. getSize(): number;
  86995. /**
  86996. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86997. * @returns true if this buffer is instanced
  86998. */
  86999. getIsInstanced(): boolean;
  87000. /**
  87001. * Returns the instancing divisor, zero for non-instanced (integer).
  87002. * @returns a number
  87003. */
  87004. getInstanceDivisor(): number;
  87005. /**
  87006. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87007. * @param data defines the data to store
  87008. */
  87009. create(data?: DataArray): void;
  87010. /**
  87011. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87012. * This function will create a new buffer if the current one is not updatable
  87013. * @param data defines the data to store
  87014. */
  87015. update(data: DataArray): void;
  87016. /**
  87017. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87018. * Returns the directly updated WebGLBuffer.
  87019. * @param data the new data
  87020. * @param offset the new offset
  87021. * @param useBytes set to true if the offset is in bytes
  87022. */
  87023. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87024. /**
  87025. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87026. */
  87027. dispose(): void;
  87028. /**
  87029. * Enumerates each value of this vertex buffer as numbers.
  87030. * @param count the number of values to enumerate
  87031. * @param callback the callback function called for each value
  87032. */
  87033. forEach(count: number, callback: (value: number, index: number) => void): void;
  87034. /**
  87035. * Positions
  87036. */
  87037. static readonly PositionKind: string;
  87038. /**
  87039. * Normals
  87040. */
  87041. static readonly NormalKind: string;
  87042. /**
  87043. * Tangents
  87044. */
  87045. static readonly TangentKind: string;
  87046. /**
  87047. * Texture coordinates
  87048. */
  87049. static readonly UVKind: string;
  87050. /**
  87051. * Texture coordinates 2
  87052. */
  87053. static readonly UV2Kind: string;
  87054. /**
  87055. * Texture coordinates 3
  87056. */
  87057. static readonly UV3Kind: string;
  87058. /**
  87059. * Texture coordinates 4
  87060. */
  87061. static readonly UV4Kind: string;
  87062. /**
  87063. * Texture coordinates 5
  87064. */
  87065. static readonly UV5Kind: string;
  87066. /**
  87067. * Texture coordinates 6
  87068. */
  87069. static readonly UV6Kind: string;
  87070. /**
  87071. * Colors
  87072. */
  87073. static readonly ColorKind: string;
  87074. /**
  87075. * Matrix indices (for bones)
  87076. */
  87077. static readonly MatricesIndicesKind: string;
  87078. /**
  87079. * Matrix weights (for bones)
  87080. */
  87081. static readonly MatricesWeightsKind: string;
  87082. /**
  87083. * Additional matrix indices (for bones)
  87084. */
  87085. static readonly MatricesIndicesExtraKind: string;
  87086. /**
  87087. * Additional matrix weights (for bones)
  87088. */
  87089. static readonly MatricesWeightsExtraKind: string;
  87090. /**
  87091. * Deduces the stride given a kind.
  87092. * @param kind The kind string to deduce
  87093. * @returns The deduced stride
  87094. */
  87095. static DeduceStride(kind: string): number;
  87096. /**
  87097. * Gets the byte length of the given type.
  87098. * @param type the type
  87099. * @returns the number of bytes
  87100. */
  87101. static GetTypeByteLength(type: number): number;
  87102. /**
  87103. * Enumerates each value of the given parameters as numbers.
  87104. * @param data the data to enumerate
  87105. * @param byteOffset the byte offset of the data
  87106. * @param byteStride the byte stride of the data
  87107. * @param componentCount the number of components per element
  87108. * @param componentType the type of the component
  87109. * @param count the number of values to enumerate
  87110. * @param normalized whether the data is normalized
  87111. * @param callback the callback function called for each value
  87112. */
  87113. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87114. private static _GetFloatValue;
  87115. }
  87116. }
  87117. declare module BABYLON {
  87118. /**
  87119. * The options Interface for creating a Capsule Mesh
  87120. */
  87121. export interface ICreateCapsuleOptions {
  87122. /** The Orientation of the capsule. Default : Vector3.Up() */
  87123. orientation?: Vector3;
  87124. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87125. subdivisions: number;
  87126. /** Number of cylindrical segments on the capsule. */
  87127. tessellation: number;
  87128. /** Height or Length of the capsule. */
  87129. height: number;
  87130. /** Radius of the capsule. */
  87131. radius: number;
  87132. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87133. capSubdivisions: number;
  87134. /** Overwrite for the top radius. */
  87135. radiusTop?: number;
  87136. /** Overwrite for the bottom radius. */
  87137. radiusBottom?: number;
  87138. /** Overwrite for the top capSubdivisions. */
  87139. topCapSubdivisions?: number;
  87140. /** Overwrite for the bottom capSubdivisions. */
  87141. bottomCapSubdivisions?: number;
  87142. }
  87143. /**
  87144. * Class containing static functions to help procedurally build meshes
  87145. */
  87146. export class CapsuleBuilder {
  87147. /**
  87148. * Creates a capsule or a pill mesh
  87149. * @param name defines the name of the mesh
  87150. * @param options The constructors options.
  87151. * @param scene The scene the mesh is scoped to.
  87152. * @returns Capsule Mesh
  87153. */
  87154. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87155. }
  87156. }
  87157. declare module BABYLON {
  87158. /**
  87159. * @hidden
  87160. */
  87161. export class IntersectionInfo {
  87162. bu: Nullable<number>;
  87163. bv: Nullable<number>;
  87164. distance: number;
  87165. faceId: number;
  87166. subMeshId: number;
  87167. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87168. }
  87169. }
  87170. declare module BABYLON {
  87171. /**
  87172. * Class used to store bounding sphere information
  87173. */
  87174. export class BoundingSphere {
  87175. /**
  87176. * Gets the center of the bounding sphere in local space
  87177. */
  87178. readonly center: Vector3;
  87179. /**
  87180. * Radius of the bounding sphere in local space
  87181. */
  87182. radius: number;
  87183. /**
  87184. * Gets the center of the bounding sphere in world space
  87185. */
  87186. readonly centerWorld: Vector3;
  87187. /**
  87188. * Radius of the bounding sphere in world space
  87189. */
  87190. radiusWorld: number;
  87191. /**
  87192. * Gets the minimum vector in local space
  87193. */
  87194. readonly minimum: Vector3;
  87195. /**
  87196. * Gets the maximum vector in local space
  87197. */
  87198. readonly maximum: Vector3;
  87199. private _worldMatrix;
  87200. private static readonly TmpVector3;
  87201. /**
  87202. * Creates a new bounding sphere
  87203. * @param min defines the minimum vector (in local space)
  87204. * @param max defines the maximum vector (in local space)
  87205. * @param worldMatrix defines the new world matrix
  87206. */
  87207. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87208. /**
  87209. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87210. * @param min defines the new minimum vector (in local space)
  87211. * @param max defines the new maximum vector (in local space)
  87212. * @param worldMatrix defines the new world matrix
  87213. */
  87214. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87215. /**
  87216. * Scale the current bounding sphere by applying a scale factor
  87217. * @param factor defines the scale factor to apply
  87218. * @returns the current bounding box
  87219. */
  87220. scale(factor: number): BoundingSphere;
  87221. /**
  87222. * Gets the world matrix of the bounding box
  87223. * @returns a matrix
  87224. */
  87225. getWorldMatrix(): DeepImmutable<Matrix>;
  87226. /** @hidden */
  87227. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87228. /**
  87229. * Tests if the bounding sphere is intersecting the frustum planes
  87230. * @param frustumPlanes defines the frustum planes to test
  87231. * @returns true if there is an intersection
  87232. */
  87233. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87234. /**
  87235. * Tests if the bounding sphere center is in between the frustum planes.
  87236. * Used for optimistic fast inclusion.
  87237. * @param frustumPlanes defines the frustum planes to test
  87238. * @returns true if the sphere center is in between the frustum planes
  87239. */
  87240. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87241. /**
  87242. * Tests if a point is inside the bounding sphere
  87243. * @param point defines the point to test
  87244. * @returns true if the point is inside the bounding sphere
  87245. */
  87246. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87247. /**
  87248. * Checks if two sphere intersct
  87249. * @param sphere0 sphere 0
  87250. * @param sphere1 sphere 1
  87251. * @returns true if the speres intersect
  87252. */
  87253. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87254. }
  87255. }
  87256. declare module BABYLON {
  87257. /**
  87258. * Class used to store bounding box information
  87259. */
  87260. export class BoundingBox implements ICullable {
  87261. /**
  87262. * Gets the 8 vectors representing the bounding box in local space
  87263. */
  87264. readonly vectors: Vector3[];
  87265. /**
  87266. * Gets the center of the bounding box in local space
  87267. */
  87268. readonly center: Vector3;
  87269. /**
  87270. * Gets the center of the bounding box in world space
  87271. */
  87272. readonly centerWorld: Vector3;
  87273. /**
  87274. * Gets the extend size in local space
  87275. */
  87276. readonly extendSize: Vector3;
  87277. /**
  87278. * Gets the extend size in world space
  87279. */
  87280. readonly extendSizeWorld: Vector3;
  87281. /**
  87282. * Gets the OBB (object bounding box) directions
  87283. */
  87284. readonly directions: Vector3[];
  87285. /**
  87286. * Gets the 8 vectors representing the bounding box in world space
  87287. */
  87288. readonly vectorsWorld: Vector3[];
  87289. /**
  87290. * Gets the minimum vector in world space
  87291. */
  87292. readonly minimumWorld: Vector3;
  87293. /**
  87294. * Gets the maximum vector in world space
  87295. */
  87296. readonly maximumWorld: Vector3;
  87297. /**
  87298. * Gets the minimum vector in local space
  87299. */
  87300. readonly minimum: Vector3;
  87301. /**
  87302. * Gets the maximum vector in local space
  87303. */
  87304. readonly maximum: Vector3;
  87305. private _worldMatrix;
  87306. private static readonly TmpVector3;
  87307. /**
  87308. * @hidden
  87309. */
  87310. _tag: number;
  87311. /**
  87312. * Creates a new bounding box
  87313. * @param min defines the minimum vector (in local space)
  87314. * @param max defines the maximum vector (in local space)
  87315. * @param worldMatrix defines the new world matrix
  87316. */
  87317. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87318. /**
  87319. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87320. * @param min defines the new minimum vector (in local space)
  87321. * @param max defines the new maximum vector (in local space)
  87322. * @param worldMatrix defines the new world matrix
  87323. */
  87324. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87325. /**
  87326. * Scale the current bounding box by applying a scale factor
  87327. * @param factor defines the scale factor to apply
  87328. * @returns the current bounding box
  87329. */
  87330. scale(factor: number): BoundingBox;
  87331. /**
  87332. * Gets the world matrix of the bounding box
  87333. * @returns a matrix
  87334. */
  87335. getWorldMatrix(): DeepImmutable<Matrix>;
  87336. /** @hidden */
  87337. _update(world: DeepImmutable<Matrix>): void;
  87338. /**
  87339. * Tests if the bounding box is intersecting the frustum planes
  87340. * @param frustumPlanes defines the frustum planes to test
  87341. * @returns true if there is an intersection
  87342. */
  87343. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87344. /**
  87345. * Tests if the bounding box is entirely inside the frustum planes
  87346. * @param frustumPlanes defines the frustum planes to test
  87347. * @returns true if there is an inclusion
  87348. */
  87349. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87350. /**
  87351. * Tests if a point is inside the bounding box
  87352. * @param point defines the point to test
  87353. * @returns true if the point is inside the bounding box
  87354. */
  87355. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87356. /**
  87357. * Tests if the bounding box intersects with a bounding sphere
  87358. * @param sphere defines the sphere to test
  87359. * @returns true if there is an intersection
  87360. */
  87361. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87362. /**
  87363. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87364. * @param min defines the min vector to use
  87365. * @param max defines the max vector to use
  87366. * @returns true if there is an intersection
  87367. */
  87368. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87369. /**
  87370. * Tests if two bounding boxes are intersections
  87371. * @param box0 defines the first box to test
  87372. * @param box1 defines the second box to test
  87373. * @returns true if there is an intersection
  87374. */
  87375. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87376. /**
  87377. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87378. * @param minPoint defines the minimum vector of the bounding box
  87379. * @param maxPoint defines the maximum vector of the bounding box
  87380. * @param sphereCenter defines the sphere center
  87381. * @param sphereRadius defines the sphere radius
  87382. * @returns true if there is an intersection
  87383. */
  87384. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87385. /**
  87386. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87387. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87388. * @param frustumPlanes defines the frustum planes to test
  87389. * @return true if there is an inclusion
  87390. */
  87391. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87392. /**
  87393. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87394. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87395. * @param frustumPlanes defines the frustum planes to test
  87396. * @return true if there is an intersection
  87397. */
  87398. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87399. }
  87400. }
  87401. declare module BABYLON {
  87402. /** @hidden */
  87403. export class Collider {
  87404. /** Define if a collision was found */
  87405. collisionFound: boolean;
  87406. /**
  87407. * Define last intersection point in local space
  87408. */
  87409. intersectionPoint: Vector3;
  87410. /**
  87411. * Define last collided mesh
  87412. */
  87413. collidedMesh: Nullable<AbstractMesh>;
  87414. private _collisionPoint;
  87415. private _planeIntersectionPoint;
  87416. private _tempVector;
  87417. private _tempVector2;
  87418. private _tempVector3;
  87419. private _tempVector4;
  87420. private _edge;
  87421. private _baseToVertex;
  87422. private _destinationPoint;
  87423. private _slidePlaneNormal;
  87424. private _displacementVector;
  87425. /** @hidden */
  87426. _radius: Vector3;
  87427. /** @hidden */
  87428. _retry: number;
  87429. private _velocity;
  87430. private _basePoint;
  87431. private _epsilon;
  87432. /** @hidden */
  87433. _velocityWorldLength: number;
  87434. /** @hidden */
  87435. _basePointWorld: Vector3;
  87436. private _velocityWorld;
  87437. private _normalizedVelocity;
  87438. /** @hidden */
  87439. _initialVelocity: Vector3;
  87440. /** @hidden */
  87441. _initialPosition: Vector3;
  87442. private _nearestDistance;
  87443. private _collisionMask;
  87444. get collisionMask(): number;
  87445. set collisionMask(mask: number);
  87446. /**
  87447. * Gets the plane normal used to compute the sliding response (in local space)
  87448. */
  87449. get slidePlaneNormal(): Vector3;
  87450. /** @hidden */
  87451. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87452. /** @hidden */
  87453. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87454. /** @hidden */
  87455. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87456. /** @hidden */
  87457. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87458. /** @hidden */
  87459. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87460. /** @hidden */
  87461. _getResponse(pos: Vector3, vel: Vector3): void;
  87462. }
  87463. }
  87464. declare module BABYLON {
  87465. /**
  87466. * Interface for cullable objects
  87467. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87468. */
  87469. export interface ICullable {
  87470. /**
  87471. * Checks if the object or part of the object is in the frustum
  87472. * @param frustumPlanes Camera near/planes
  87473. * @returns true if the object is in frustum otherwise false
  87474. */
  87475. isInFrustum(frustumPlanes: Plane[]): boolean;
  87476. /**
  87477. * Checks if a cullable object (mesh...) is in the camera frustum
  87478. * Unlike isInFrustum this cheks the full bounding box
  87479. * @param frustumPlanes Camera near/planes
  87480. * @returns true if the object is in frustum otherwise false
  87481. */
  87482. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87483. }
  87484. /**
  87485. * Info for a bounding data of a mesh
  87486. */
  87487. export class BoundingInfo implements ICullable {
  87488. /**
  87489. * Bounding box for the mesh
  87490. */
  87491. readonly boundingBox: BoundingBox;
  87492. /**
  87493. * Bounding sphere for the mesh
  87494. */
  87495. readonly boundingSphere: BoundingSphere;
  87496. private _isLocked;
  87497. private static readonly TmpVector3;
  87498. /**
  87499. * Constructs bounding info
  87500. * @param minimum min vector of the bounding box/sphere
  87501. * @param maximum max vector of the bounding box/sphere
  87502. * @param worldMatrix defines the new world matrix
  87503. */
  87504. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87505. /**
  87506. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87507. * @param min defines the new minimum vector (in local space)
  87508. * @param max defines the new maximum vector (in local space)
  87509. * @param worldMatrix defines the new world matrix
  87510. */
  87511. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87512. /**
  87513. * min vector of the bounding box/sphere
  87514. */
  87515. get minimum(): Vector3;
  87516. /**
  87517. * max vector of the bounding box/sphere
  87518. */
  87519. get maximum(): Vector3;
  87520. /**
  87521. * If the info is locked and won't be updated to avoid perf overhead
  87522. */
  87523. get isLocked(): boolean;
  87524. set isLocked(value: boolean);
  87525. /**
  87526. * Updates the bounding sphere and box
  87527. * @param world world matrix to be used to update
  87528. */
  87529. update(world: DeepImmutable<Matrix>): void;
  87530. /**
  87531. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87532. * @param center New center of the bounding info
  87533. * @param extend New extend of the bounding info
  87534. * @returns the current bounding info
  87535. */
  87536. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87537. /**
  87538. * Scale the current bounding info by applying a scale factor
  87539. * @param factor defines the scale factor to apply
  87540. * @returns the current bounding info
  87541. */
  87542. scale(factor: number): BoundingInfo;
  87543. /**
  87544. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87545. * @param frustumPlanes defines the frustum to test
  87546. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87547. * @returns true if the bounding info is in the frustum planes
  87548. */
  87549. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87550. /**
  87551. * Gets the world distance between the min and max points of the bounding box
  87552. */
  87553. get diagonalLength(): number;
  87554. /**
  87555. * Checks if a cullable object (mesh...) is in the camera frustum
  87556. * Unlike isInFrustum this cheks the full bounding box
  87557. * @param frustumPlanes Camera near/planes
  87558. * @returns true if the object is in frustum otherwise false
  87559. */
  87560. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87561. /** @hidden */
  87562. _checkCollision(collider: Collider): boolean;
  87563. /**
  87564. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87565. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87566. * @param point the point to check intersection with
  87567. * @returns if the point intersects
  87568. */
  87569. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87570. /**
  87571. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87572. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87573. * @param boundingInfo the bounding info to check intersection with
  87574. * @param precise if the intersection should be done using OBB
  87575. * @returns if the bounding info intersects
  87576. */
  87577. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87578. }
  87579. }
  87580. declare module BABYLON {
  87581. /**
  87582. * Extracts minimum and maximum values from a list of indexed positions
  87583. * @param positions defines the positions to use
  87584. * @param indices defines the indices to the positions
  87585. * @param indexStart defines the start index
  87586. * @param indexCount defines the end index
  87587. * @param bias defines bias value to add to the result
  87588. * @return minimum and maximum values
  87589. */
  87590. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87591. minimum: Vector3;
  87592. maximum: Vector3;
  87593. };
  87594. /**
  87595. * Extracts minimum and maximum values from a list of positions
  87596. * @param positions defines the positions to use
  87597. * @param start defines the start index in the positions array
  87598. * @param count defines the number of positions to handle
  87599. * @param bias defines bias value to add to the result
  87600. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87601. * @return minimum and maximum values
  87602. */
  87603. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87604. minimum: Vector3;
  87605. maximum: Vector3;
  87606. };
  87607. }
  87608. declare module BABYLON {
  87609. /** @hidden */
  87610. export class WebGLDataBuffer extends DataBuffer {
  87611. private _buffer;
  87612. constructor(resource: WebGLBuffer);
  87613. get underlyingResource(): any;
  87614. }
  87615. }
  87616. declare module BABYLON {
  87617. /** @hidden */
  87618. export class WebGLPipelineContext implements IPipelineContext {
  87619. engine: ThinEngine;
  87620. program: Nullable<WebGLProgram>;
  87621. context?: WebGLRenderingContext;
  87622. vertexShader?: WebGLShader;
  87623. fragmentShader?: WebGLShader;
  87624. isParallelCompiled: boolean;
  87625. onCompiled?: () => void;
  87626. transformFeedback?: WebGLTransformFeedback | null;
  87627. vertexCompilationError: Nullable<string>;
  87628. fragmentCompilationError: Nullable<string>;
  87629. programLinkError: Nullable<string>;
  87630. programValidationError: Nullable<string>;
  87631. get isAsync(): boolean;
  87632. get isReady(): boolean;
  87633. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87634. _getVertexShaderCode(): string | null;
  87635. _getFragmentShaderCode(): string | null;
  87636. }
  87637. }
  87638. declare module BABYLON {
  87639. interface ThinEngine {
  87640. /**
  87641. * Create an uniform buffer
  87642. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87643. * @param elements defines the content of the uniform buffer
  87644. * @returns the webGL uniform buffer
  87645. */
  87646. createUniformBuffer(elements: FloatArray): DataBuffer;
  87647. /**
  87648. * Create a dynamic uniform buffer
  87649. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87650. * @param elements defines the content of the uniform buffer
  87651. * @returns the webGL uniform buffer
  87652. */
  87653. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87654. /**
  87655. * Update an existing uniform buffer
  87656. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87657. * @param uniformBuffer defines the target uniform buffer
  87658. * @param elements defines the content to update
  87659. * @param offset defines the offset in the uniform buffer where update should start
  87660. * @param count defines the size of the data to update
  87661. */
  87662. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87663. /**
  87664. * Bind an uniform buffer to the current webGL context
  87665. * @param buffer defines the buffer to bind
  87666. */
  87667. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87668. /**
  87669. * Bind a buffer to the current webGL context at a given location
  87670. * @param buffer defines the buffer to bind
  87671. * @param location defines the index where to bind the buffer
  87672. */
  87673. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87674. /**
  87675. * Bind a specific block at a given index in a specific shader program
  87676. * @param pipelineContext defines the pipeline context to use
  87677. * @param blockName defines the block name
  87678. * @param index defines the index where to bind the block
  87679. */
  87680. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87681. }
  87682. }
  87683. declare module BABYLON {
  87684. /**
  87685. * Uniform buffer objects.
  87686. *
  87687. * Handles blocks of uniform on the GPU.
  87688. *
  87689. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87690. *
  87691. * For more information, please refer to :
  87692. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87693. */
  87694. export class UniformBuffer {
  87695. private _engine;
  87696. private _buffer;
  87697. private _data;
  87698. private _bufferData;
  87699. private _dynamic?;
  87700. private _uniformLocations;
  87701. private _uniformSizes;
  87702. private _uniformLocationPointer;
  87703. private _needSync;
  87704. private _noUBO;
  87705. private _currentEffect;
  87706. /** @hidden */
  87707. _alreadyBound: boolean;
  87708. private static _MAX_UNIFORM_SIZE;
  87709. private static _tempBuffer;
  87710. /**
  87711. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87712. * This is dynamic to allow compat with webgl 1 and 2.
  87713. * You will need to pass the name of the uniform as well as the value.
  87714. */
  87715. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87716. /**
  87717. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87718. * This is dynamic to allow compat with webgl 1 and 2.
  87719. * You will need to pass the name of the uniform as well as the value.
  87720. */
  87721. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87722. /**
  87723. * Lambda to Update a single float in a uniform buffer.
  87724. * This is dynamic to allow compat with webgl 1 and 2.
  87725. * You will need to pass the name of the uniform as well as the value.
  87726. */
  87727. updateFloat: (name: string, x: number) => void;
  87728. /**
  87729. * Lambda to Update a vec2 of float in a uniform buffer.
  87730. * This is dynamic to allow compat with webgl 1 and 2.
  87731. * You will need to pass the name of the uniform as well as the value.
  87732. */
  87733. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87734. /**
  87735. * Lambda to Update a vec3 of float in a uniform buffer.
  87736. * This is dynamic to allow compat with webgl 1 and 2.
  87737. * You will need to pass the name of the uniform as well as the value.
  87738. */
  87739. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87740. /**
  87741. * Lambda to Update a vec4 of float in a uniform buffer.
  87742. * This is dynamic to allow compat with webgl 1 and 2.
  87743. * You will need to pass the name of the uniform as well as the value.
  87744. */
  87745. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87746. /**
  87747. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87748. * This is dynamic to allow compat with webgl 1 and 2.
  87749. * You will need to pass the name of the uniform as well as the value.
  87750. */
  87751. updateMatrix: (name: string, mat: Matrix) => void;
  87752. /**
  87753. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87754. * This is dynamic to allow compat with webgl 1 and 2.
  87755. * You will need to pass the name of the uniform as well as the value.
  87756. */
  87757. updateVector3: (name: string, vector: Vector3) => void;
  87758. /**
  87759. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87760. * This is dynamic to allow compat with webgl 1 and 2.
  87761. * You will need to pass the name of the uniform as well as the value.
  87762. */
  87763. updateVector4: (name: string, vector: Vector4) => void;
  87764. /**
  87765. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87766. * This is dynamic to allow compat with webgl 1 and 2.
  87767. * You will need to pass the name of the uniform as well as the value.
  87768. */
  87769. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87770. /**
  87771. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87772. * This is dynamic to allow compat with webgl 1 and 2.
  87773. * You will need to pass the name of the uniform as well as the value.
  87774. */
  87775. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87776. /**
  87777. * Instantiates a new Uniform buffer objects.
  87778. *
  87779. * Handles blocks of uniform on the GPU.
  87780. *
  87781. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87782. *
  87783. * For more information, please refer to :
  87784. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87785. * @param engine Define the engine the buffer is associated with
  87786. * @param data Define the data contained in the buffer
  87787. * @param dynamic Define if the buffer is updatable
  87788. */
  87789. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87790. /**
  87791. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87792. * or just falling back on setUniformXXX calls.
  87793. */
  87794. get useUbo(): boolean;
  87795. /**
  87796. * Indicates if the WebGL underlying uniform buffer is in sync
  87797. * with the javascript cache data.
  87798. */
  87799. get isSync(): boolean;
  87800. /**
  87801. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87802. * Also, a dynamic UniformBuffer will disable cache verification and always
  87803. * update the underlying WebGL uniform buffer to the GPU.
  87804. * @returns if Dynamic, otherwise false
  87805. */
  87806. isDynamic(): boolean;
  87807. /**
  87808. * The data cache on JS side.
  87809. * @returns the underlying data as a float array
  87810. */
  87811. getData(): Float32Array;
  87812. /**
  87813. * The underlying WebGL Uniform buffer.
  87814. * @returns the webgl buffer
  87815. */
  87816. getBuffer(): Nullable<DataBuffer>;
  87817. /**
  87818. * std140 layout specifies how to align data within an UBO structure.
  87819. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87820. * for specs.
  87821. */
  87822. private _fillAlignment;
  87823. /**
  87824. * Adds an uniform in the buffer.
  87825. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87826. * for the layout to be correct !
  87827. * @param name Name of the uniform, as used in the uniform block in the shader.
  87828. * @param size Data size, or data directly.
  87829. */
  87830. addUniform(name: string, size: number | number[]): void;
  87831. /**
  87832. * Adds a Matrix 4x4 to the uniform buffer.
  87833. * @param name Name of the uniform, as used in the uniform block in the shader.
  87834. * @param mat A 4x4 matrix.
  87835. */
  87836. addMatrix(name: string, mat: Matrix): void;
  87837. /**
  87838. * Adds a vec2 to the uniform buffer.
  87839. * @param name Name of the uniform, as used in the uniform block in the shader.
  87840. * @param x Define the x component value of the vec2
  87841. * @param y Define the y component value of the vec2
  87842. */
  87843. addFloat2(name: string, x: number, y: number): void;
  87844. /**
  87845. * Adds a vec3 to the uniform buffer.
  87846. * @param name Name of the uniform, as used in the uniform block in the shader.
  87847. * @param x Define the x component value of the vec3
  87848. * @param y Define the y component value of the vec3
  87849. * @param z Define the z component value of the vec3
  87850. */
  87851. addFloat3(name: string, x: number, y: number, z: number): void;
  87852. /**
  87853. * Adds a vec3 to the uniform buffer.
  87854. * @param name Name of the uniform, as used in the uniform block in the shader.
  87855. * @param color Define the vec3 from a Color
  87856. */
  87857. addColor3(name: string, color: Color3): void;
  87858. /**
  87859. * Adds a vec4 to the uniform buffer.
  87860. * @param name Name of the uniform, as used in the uniform block in the shader.
  87861. * @param color Define the rgb components from a Color
  87862. * @param alpha Define the a component of the vec4
  87863. */
  87864. addColor4(name: string, color: Color3, alpha: number): void;
  87865. /**
  87866. * Adds a vec3 to the uniform buffer.
  87867. * @param name Name of the uniform, as used in the uniform block in the shader.
  87868. * @param vector Define the vec3 components from a Vector
  87869. */
  87870. addVector3(name: string, vector: Vector3): void;
  87871. /**
  87872. * Adds a Matrix 3x3 to the uniform buffer.
  87873. * @param name Name of the uniform, as used in the uniform block in the shader.
  87874. */
  87875. addMatrix3x3(name: string): void;
  87876. /**
  87877. * Adds a Matrix 2x2 to the uniform buffer.
  87878. * @param name Name of the uniform, as used in the uniform block in the shader.
  87879. */
  87880. addMatrix2x2(name: string): void;
  87881. /**
  87882. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87883. */
  87884. create(): void;
  87885. /** @hidden */
  87886. _rebuild(): void;
  87887. /**
  87888. * Updates the WebGL Uniform Buffer on the GPU.
  87889. * If the `dynamic` flag is set to true, no cache comparison is done.
  87890. * Otherwise, the buffer will be updated only if the cache differs.
  87891. */
  87892. update(): void;
  87893. /**
  87894. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87895. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87896. * @param data Define the flattened data
  87897. * @param size Define the size of the data.
  87898. */
  87899. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87900. private _valueCache;
  87901. private _cacheMatrix;
  87902. private _updateMatrix3x3ForUniform;
  87903. private _updateMatrix3x3ForEffect;
  87904. private _updateMatrix2x2ForEffect;
  87905. private _updateMatrix2x2ForUniform;
  87906. private _updateFloatForEffect;
  87907. private _updateFloatForUniform;
  87908. private _updateFloat2ForEffect;
  87909. private _updateFloat2ForUniform;
  87910. private _updateFloat3ForEffect;
  87911. private _updateFloat3ForUniform;
  87912. private _updateFloat4ForEffect;
  87913. private _updateFloat4ForUniform;
  87914. private _updateMatrixForEffect;
  87915. private _updateMatrixForUniform;
  87916. private _updateVector3ForEffect;
  87917. private _updateVector3ForUniform;
  87918. private _updateVector4ForEffect;
  87919. private _updateVector4ForUniform;
  87920. private _updateColor3ForEffect;
  87921. private _updateColor3ForUniform;
  87922. private _updateColor4ForEffect;
  87923. private _updateColor4ForUniform;
  87924. /**
  87925. * Sets a sampler uniform on the effect.
  87926. * @param name Define the name of the sampler.
  87927. * @param texture Define the texture to set in the sampler
  87928. */
  87929. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87930. /**
  87931. * Directly updates the value of the uniform in the cache AND on the GPU.
  87932. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87933. * @param data Define the flattened data
  87934. */
  87935. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87936. /**
  87937. * Binds this uniform buffer to an effect.
  87938. * @param effect Define the effect to bind the buffer to
  87939. * @param name Name of the uniform block in the shader.
  87940. */
  87941. bindToEffect(effect: Effect, name: string): void;
  87942. /**
  87943. * Disposes the uniform buffer.
  87944. */
  87945. dispose(): void;
  87946. }
  87947. }
  87948. declare module BABYLON {
  87949. /**
  87950. * Enum that determines the text-wrapping mode to use.
  87951. */
  87952. export enum InspectableType {
  87953. /**
  87954. * Checkbox for booleans
  87955. */
  87956. Checkbox = 0,
  87957. /**
  87958. * Sliders for numbers
  87959. */
  87960. Slider = 1,
  87961. /**
  87962. * Vector3
  87963. */
  87964. Vector3 = 2,
  87965. /**
  87966. * Quaternions
  87967. */
  87968. Quaternion = 3,
  87969. /**
  87970. * Color3
  87971. */
  87972. Color3 = 4,
  87973. /**
  87974. * String
  87975. */
  87976. String = 5
  87977. }
  87978. /**
  87979. * Interface used to define custom inspectable properties.
  87980. * This interface is used by the inspector to display custom property grids
  87981. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87982. */
  87983. export interface IInspectable {
  87984. /**
  87985. * Gets the label to display
  87986. */
  87987. label: string;
  87988. /**
  87989. * Gets the name of the property to edit
  87990. */
  87991. propertyName: string;
  87992. /**
  87993. * Gets the type of the editor to use
  87994. */
  87995. type: InspectableType;
  87996. /**
  87997. * Gets the minimum value of the property when using in "slider" mode
  87998. */
  87999. min?: number;
  88000. /**
  88001. * Gets the maximum value of the property when using in "slider" mode
  88002. */
  88003. max?: number;
  88004. /**
  88005. * Gets the setp to use when using in "slider" mode
  88006. */
  88007. step?: number;
  88008. }
  88009. }
  88010. declare module BABYLON {
  88011. /**
  88012. * Class used to provide helper for timing
  88013. */
  88014. export class TimingTools {
  88015. /**
  88016. * Polyfill for setImmediate
  88017. * @param action defines the action to execute after the current execution block
  88018. */
  88019. static SetImmediate(action: () => void): void;
  88020. }
  88021. }
  88022. declare module BABYLON {
  88023. /**
  88024. * Class used to enable instatition of objects by class name
  88025. */
  88026. export class InstantiationTools {
  88027. /**
  88028. * Use this object to register external classes like custom textures or material
  88029. * to allow the laoders to instantiate them
  88030. */
  88031. static RegisteredExternalClasses: {
  88032. [key: string]: Object;
  88033. };
  88034. /**
  88035. * Tries to instantiate a new object from a given class name
  88036. * @param className defines the class name to instantiate
  88037. * @returns the new object or null if the system was not able to do the instantiation
  88038. */
  88039. static Instantiate(className: string): any;
  88040. }
  88041. }
  88042. declare module BABYLON {
  88043. /**
  88044. * Define options used to create a depth texture
  88045. */
  88046. export class DepthTextureCreationOptions {
  88047. /** Specifies whether or not a stencil should be allocated in the texture */
  88048. generateStencil?: boolean;
  88049. /** Specifies whether or not bilinear filtering is enable on the texture */
  88050. bilinearFiltering?: boolean;
  88051. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88052. comparisonFunction?: number;
  88053. /** Specifies if the created texture is a cube texture */
  88054. isCube?: boolean;
  88055. }
  88056. }
  88057. declare module BABYLON {
  88058. interface ThinEngine {
  88059. /**
  88060. * Creates a depth stencil cube texture.
  88061. * This is only available in WebGL 2.
  88062. * @param size The size of face edge in the cube texture.
  88063. * @param options The options defining the cube texture.
  88064. * @returns The cube texture
  88065. */
  88066. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88067. /**
  88068. * Creates a cube texture
  88069. * @param rootUrl defines the url where the files to load is located
  88070. * @param scene defines the current scene
  88071. * @param files defines the list of files to load (1 per face)
  88072. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88073. * @param onLoad defines an optional callback raised when the texture is loaded
  88074. * @param onError defines an optional callback raised if there is an issue to load the texture
  88075. * @param format defines the format of the data
  88076. * @param forcedExtension defines the extension to use to pick the right loader
  88077. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88078. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88079. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88080. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88081. * @returns the cube texture as an InternalTexture
  88082. */
  88083. 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;
  88084. /**
  88085. * Creates a cube texture
  88086. * @param rootUrl defines the url where the files to load is located
  88087. * @param scene defines the current scene
  88088. * @param files defines the list of files to load (1 per face)
  88089. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88090. * @param onLoad defines an optional callback raised when the texture is loaded
  88091. * @param onError defines an optional callback raised if there is an issue to load the texture
  88092. * @param format defines the format of the data
  88093. * @param forcedExtension defines the extension to use to pick the right loader
  88094. * @returns the cube texture as an InternalTexture
  88095. */
  88096. 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;
  88097. /**
  88098. * Creates a cube texture
  88099. * @param rootUrl defines the url where the files to load is located
  88100. * @param scene defines the current scene
  88101. * @param files defines the list of files to load (1 per face)
  88102. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88103. * @param onLoad defines an optional callback raised when the texture is loaded
  88104. * @param onError defines an optional callback raised if there is an issue to load the texture
  88105. * @param format defines the format of the data
  88106. * @param forcedExtension defines the extension to use to pick the right loader
  88107. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88108. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88109. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88110. * @returns the cube texture as an InternalTexture
  88111. */
  88112. 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;
  88113. /** @hidden */
  88114. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88115. /** @hidden */
  88116. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88117. /** @hidden */
  88118. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88119. /** @hidden */
  88120. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88121. /**
  88122. * @hidden
  88123. */
  88124. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88125. }
  88126. }
  88127. declare module BABYLON {
  88128. /**
  88129. * Class for creating a cube texture
  88130. */
  88131. export class CubeTexture extends BaseTexture {
  88132. private _delayedOnLoad;
  88133. /**
  88134. * Observable triggered once the texture has been loaded.
  88135. */
  88136. onLoadObservable: Observable<CubeTexture>;
  88137. /**
  88138. * The url of the texture
  88139. */
  88140. url: string;
  88141. /**
  88142. * Gets or sets the center of the bounding box associated with the cube texture.
  88143. * It must define where the camera used to render the texture was set
  88144. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88145. */
  88146. boundingBoxPosition: Vector3;
  88147. private _boundingBoxSize;
  88148. /**
  88149. * Gets or sets the size of the bounding box associated with the cube texture
  88150. * When defined, the cubemap will switch to local mode
  88151. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88152. * @example https://www.babylonjs-playground.com/#RNASML
  88153. */
  88154. set boundingBoxSize(value: Vector3);
  88155. /**
  88156. * Returns the bounding box size
  88157. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88158. */
  88159. get boundingBoxSize(): Vector3;
  88160. protected _rotationY: number;
  88161. /**
  88162. * Sets texture matrix rotation angle around Y axis in radians.
  88163. */
  88164. set rotationY(value: number);
  88165. /**
  88166. * Gets texture matrix rotation angle around Y axis radians.
  88167. */
  88168. get rotationY(): number;
  88169. /**
  88170. * Are mip maps generated for this texture or not.
  88171. */
  88172. get noMipmap(): boolean;
  88173. private _noMipmap;
  88174. private _files;
  88175. protected _forcedExtension: Nullable<string>;
  88176. private _extensions;
  88177. private _textureMatrix;
  88178. private _format;
  88179. private _createPolynomials;
  88180. /**
  88181. * Creates a cube texture from an array of image urls
  88182. * @param files defines an array of image urls
  88183. * @param scene defines the hosting scene
  88184. * @param noMipmap specifies if mip maps are not used
  88185. * @returns a cube texture
  88186. */
  88187. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88188. /**
  88189. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88190. * @param url defines the url of the prefiltered texture
  88191. * @param scene defines the scene the texture is attached to
  88192. * @param forcedExtension defines the extension of the file if different from the url
  88193. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88194. * @return the prefiltered texture
  88195. */
  88196. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88197. /**
  88198. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88199. * as prefiltered data.
  88200. * @param rootUrl defines the url of the texture or the root name of the six images
  88201. * @param null defines the scene or engine the texture is attached to
  88202. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88203. * @param noMipmap defines if mipmaps should be created or not
  88204. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88205. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88206. * @param onError defines a callback triggered in case of error during load
  88207. * @param format defines the internal format to use for the texture once loaded
  88208. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88209. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88210. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88211. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88212. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88213. * @return the cube texture
  88214. */
  88215. 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);
  88216. /**
  88217. * Get the current class name of the texture useful for serialization or dynamic coding.
  88218. * @returns "CubeTexture"
  88219. */
  88220. getClassName(): string;
  88221. /**
  88222. * Update the url (and optional buffer) of this texture if url was null during construction.
  88223. * @param url the url of the texture
  88224. * @param forcedExtension defines the extension to use
  88225. * @param onLoad callback called when the texture is loaded (defaults to null)
  88226. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88227. */
  88228. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88229. /**
  88230. * Delays loading of the cube texture
  88231. * @param forcedExtension defines the extension to use
  88232. */
  88233. delayLoad(forcedExtension?: string): void;
  88234. /**
  88235. * Returns the reflection texture matrix
  88236. * @returns the reflection texture matrix
  88237. */
  88238. getReflectionTextureMatrix(): Matrix;
  88239. /**
  88240. * Sets the reflection texture matrix
  88241. * @param value Reflection texture matrix
  88242. */
  88243. setReflectionTextureMatrix(value: Matrix): void;
  88244. /**
  88245. * Parses text to create a cube texture
  88246. * @param parsedTexture define the serialized text to read from
  88247. * @param scene defines the hosting scene
  88248. * @param rootUrl defines the root url of the cube texture
  88249. * @returns a cube texture
  88250. */
  88251. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88252. /**
  88253. * Makes a clone, or deep copy, of the cube texture
  88254. * @returns a new cube texture
  88255. */
  88256. clone(): CubeTexture;
  88257. }
  88258. }
  88259. declare module BABYLON {
  88260. /**
  88261. * Manages the defines for the Material
  88262. */
  88263. export class MaterialDefines {
  88264. /** @hidden */
  88265. protected _keys: string[];
  88266. private _isDirty;
  88267. /** @hidden */
  88268. _renderId: number;
  88269. /** @hidden */
  88270. _areLightsDirty: boolean;
  88271. /** @hidden */
  88272. _areLightsDisposed: boolean;
  88273. /** @hidden */
  88274. _areAttributesDirty: boolean;
  88275. /** @hidden */
  88276. _areTexturesDirty: boolean;
  88277. /** @hidden */
  88278. _areFresnelDirty: boolean;
  88279. /** @hidden */
  88280. _areMiscDirty: boolean;
  88281. /** @hidden */
  88282. _areImageProcessingDirty: boolean;
  88283. /** @hidden */
  88284. _normals: boolean;
  88285. /** @hidden */
  88286. _uvs: boolean;
  88287. /** @hidden */
  88288. _needNormals: boolean;
  88289. /** @hidden */
  88290. _needUVs: boolean;
  88291. [id: string]: any;
  88292. /**
  88293. * Specifies if the material needs to be re-calculated
  88294. */
  88295. get isDirty(): boolean;
  88296. /**
  88297. * Marks the material to indicate that it has been re-calculated
  88298. */
  88299. markAsProcessed(): void;
  88300. /**
  88301. * Marks the material to indicate that it needs to be re-calculated
  88302. */
  88303. markAsUnprocessed(): void;
  88304. /**
  88305. * Marks the material to indicate all of its defines need to be re-calculated
  88306. */
  88307. markAllAsDirty(): void;
  88308. /**
  88309. * Marks the material to indicate that image processing needs to be re-calculated
  88310. */
  88311. markAsImageProcessingDirty(): void;
  88312. /**
  88313. * Marks the material to indicate the lights need to be re-calculated
  88314. * @param disposed Defines whether the light is dirty due to dispose or not
  88315. */
  88316. markAsLightDirty(disposed?: boolean): void;
  88317. /**
  88318. * Marks the attribute state as changed
  88319. */
  88320. markAsAttributesDirty(): void;
  88321. /**
  88322. * Marks the texture state as changed
  88323. */
  88324. markAsTexturesDirty(): void;
  88325. /**
  88326. * Marks the fresnel state as changed
  88327. */
  88328. markAsFresnelDirty(): void;
  88329. /**
  88330. * Marks the misc state as changed
  88331. */
  88332. markAsMiscDirty(): void;
  88333. /**
  88334. * Rebuilds the material defines
  88335. */
  88336. rebuild(): void;
  88337. /**
  88338. * Specifies if two material defines are equal
  88339. * @param other - A material define instance to compare to
  88340. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88341. */
  88342. isEqual(other: MaterialDefines): boolean;
  88343. /**
  88344. * Clones this instance's defines to another instance
  88345. * @param other - material defines to clone values to
  88346. */
  88347. cloneTo(other: MaterialDefines): void;
  88348. /**
  88349. * Resets the material define values
  88350. */
  88351. reset(): void;
  88352. /**
  88353. * Converts the material define values to a string
  88354. * @returns - String of material define information
  88355. */
  88356. toString(): string;
  88357. }
  88358. }
  88359. declare module BABYLON {
  88360. /**
  88361. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88362. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88363. * 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;
  88364. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88365. */
  88366. export class ColorCurves {
  88367. private _dirty;
  88368. private _tempColor;
  88369. private _globalCurve;
  88370. private _highlightsCurve;
  88371. private _midtonesCurve;
  88372. private _shadowsCurve;
  88373. private _positiveCurve;
  88374. private _negativeCurve;
  88375. private _globalHue;
  88376. private _globalDensity;
  88377. private _globalSaturation;
  88378. private _globalExposure;
  88379. /**
  88380. * Gets the global Hue value.
  88381. * 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).
  88382. */
  88383. get globalHue(): number;
  88384. /**
  88385. * Sets the global Hue value.
  88386. * 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).
  88387. */
  88388. set globalHue(value: number);
  88389. /**
  88390. * Gets the global Density value.
  88391. * 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.
  88392. * Values less than zero provide a filter of opposite hue.
  88393. */
  88394. get globalDensity(): number;
  88395. /**
  88396. * Sets the global Density value.
  88397. * 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.
  88398. * Values less than zero provide a filter of opposite hue.
  88399. */
  88400. set globalDensity(value: number);
  88401. /**
  88402. * Gets the global Saturation value.
  88403. * 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.
  88404. */
  88405. get globalSaturation(): number;
  88406. /**
  88407. * Sets the global Saturation value.
  88408. * 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.
  88409. */
  88410. set globalSaturation(value: number);
  88411. /**
  88412. * Gets the global Exposure value.
  88413. * 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.
  88414. */
  88415. get globalExposure(): number;
  88416. /**
  88417. * Sets the global Exposure value.
  88418. * 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.
  88419. */
  88420. set globalExposure(value: number);
  88421. private _highlightsHue;
  88422. private _highlightsDensity;
  88423. private _highlightsSaturation;
  88424. private _highlightsExposure;
  88425. /**
  88426. * Gets the highlights Hue value.
  88427. * 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).
  88428. */
  88429. get highlightsHue(): number;
  88430. /**
  88431. * Sets the highlights Hue value.
  88432. * 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).
  88433. */
  88434. set highlightsHue(value: number);
  88435. /**
  88436. * Gets the highlights Density value.
  88437. * 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.
  88438. * Values less than zero provide a filter of opposite hue.
  88439. */
  88440. get highlightsDensity(): number;
  88441. /**
  88442. * Sets the highlights Density value.
  88443. * 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.
  88444. * Values less than zero provide a filter of opposite hue.
  88445. */
  88446. set highlightsDensity(value: number);
  88447. /**
  88448. * Gets the highlights Saturation value.
  88449. * 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.
  88450. */
  88451. get highlightsSaturation(): number;
  88452. /**
  88453. * Sets the highlights Saturation value.
  88454. * 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.
  88455. */
  88456. set highlightsSaturation(value: number);
  88457. /**
  88458. * Gets the highlights Exposure value.
  88459. * 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.
  88460. */
  88461. get highlightsExposure(): number;
  88462. /**
  88463. * Sets the highlights Exposure value.
  88464. * 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.
  88465. */
  88466. set highlightsExposure(value: number);
  88467. private _midtonesHue;
  88468. private _midtonesDensity;
  88469. private _midtonesSaturation;
  88470. private _midtonesExposure;
  88471. /**
  88472. * Gets the midtones Hue value.
  88473. * 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).
  88474. */
  88475. get midtonesHue(): number;
  88476. /**
  88477. * Sets the midtones Hue value.
  88478. * 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).
  88479. */
  88480. set midtonesHue(value: number);
  88481. /**
  88482. * Gets the midtones Density value.
  88483. * 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.
  88484. * Values less than zero provide a filter of opposite hue.
  88485. */
  88486. get midtonesDensity(): number;
  88487. /**
  88488. * Sets the midtones Density value.
  88489. * 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.
  88490. * Values less than zero provide a filter of opposite hue.
  88491. */
  88492. set midtonesDensity(value: number);
  88493. /**
  88494. * Gets the midtones Saturation value.
  88495. * 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.
  88496. */
  88497. get midtonesSaturation(): number;
  88498. /**
  88499. * Sets the midtones Saturation value.
  88500. * 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.
  88501. */
  88502. set midtonesSaturation(value: number);
  88503. /**
  88504. * Gets the midtones Exposure value.
  88505. * 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.
  88506. */
  88507. get midtonesExposure(): number;
  88508. /**
  88509. * Sets the midtones Exposure value.
  88510. * 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.
  88511. */
  88512. set midtonesExposure(value: number);
  88513. private _shadowsHue;
  88514. private _shadowsDensity;
  88515. private _shadowsSaturation;
  88516. private _shadowsExposure;
  88517. /**
  88518. * Gets the shadows Hue value.
  88519. * 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).
  88520. */
  88521. get shadowsHue(): number;
  88522. /**
  88523. * Sets the shadows Hue value.
  88524. * 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).
  88525. */
  88526. set shadowsHue(value: number);
  88527. /**
  88528. * Gets the shadows Density value.
  88529. * 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.
  88530. * Values less than zero provide a filter of opposite hue.
  88531. */
  88532. get shadowsDensity(): number;
  88533. /**
  88534. * Sets the shadows Density value.
  88535. * 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.
  88536. * Values less than zero provide a filter of opposite hue.
  88537. */
  88538. set shadowsDensity(value: number);
  88539. /**
  88540. * Gets the shadows Saturation value.
  88541. * 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.
  88542. */
  88543. get shadowsSaturation(): number;
  88544. /**
  88545. * Sets the shadows Saturation value.
  88546. * 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.
  88547. */
  88548. set shadowsSaturation(value: number);
  88549. /**
  88550. * Gets the shadows Exposure value.
  88551. * 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.
  88552. */
  88553. get shadowsExposure(): number;
  88554. /**
  88555. * Sets the shadows Exposure value.
  88556. * 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.
  88557. */
  88558. set shadowsExposure(value: number);
  88559. /**
  88560. * Returns the class name
  88561. * @returns The class name
  88562. */
  88563. getClassName(): string;
  88564. /**
  88565. * Binds the color curves to the shader.
  88566. * @param colorCurves The color curve to bind
  88567. * @param effect The effect to bind to
  88568. * @param positiveUniform The positive uniform shader parameter
  88569. * @param neutralUniform The neutral uniform shader parameter
  88570. * @param negativeUniform The negative uniform shader parameter
  88571. */
  88572. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88573. /**
  88574. * Prepare the list of uniforms associated with the ColorCurves effects.
  88575. * @param uniformsList The list of uniforms used in the effect
  88576. */
  88577. static PrepareUniforms(uniformsList: string[]): void;
  88578. /**
  88579. * Returns color grading data based on a hue, density, saturation and exposure value.
  88580. * @param filterHue The hue of the color filter.
  88581. * @param filterDensity The density of the color filter.
  88582. * @param saturation The saturation.
  88583. * @param exposure The exposure.
  88584. * @param result The result data container.
  88585. */
  88586. private getColorGradingDataToRef;
  88587. /**
  88588. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88589. * @param value The input slider value in range [-100,100].
  88590. * @returns Adjusted value.
  88591. */
  88592. private static applyColorGradingSliderNonlinear;
  88593. /**
  88594. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88595. * @param hue The hue (H) input.
  88596. * @param saturation The saturation (S) input.
  88597. * @param brightness The brightness (B) input.
  88598. * @result An RGBA color represented as Vector4.
  88599. */
  88600. private static fromHSBToRef;
  88601. /**
  88602. * Returns a value clamped between min and max
  88603. * @param value The value to clamp
  88604. * @param min The minimum of value
  88605. * @param max The maximum of value
  88606. * @returns The clamped value.
  88607. */
  88608. private static clamp;
  88609. /**
  88610. * Clones the current color curve instance.
  88611. * @return The cloned curves
  88612. */
  88613. clone(): ColorCurves;
  88614. /**
  88615. * Serializes the current color curve instance to a json representation.
  88616. * @return a JSON representation
  88617. */
  88618. serialize(): any;
  88619. /**
  88620. * Parses the color curve from a json representation.
  88621. * @param source the JSON source to parse
  88622. * @return The parsed curves
  88623. */
  88624. static Parse(source: any): ColorCurves;
  88625. }
  88626. }
  88627. declare module BABYLON {
  88628. /**
  88629. * Interface to follow in your material defines to integrate easily the
  88630. * Image proccessing functions.
  88631. * @hidden
  88632. */
  88633. export interface IImageProcessingConfigurationDefines {
  88634. IMAGEPROCESSING: boolean;
  88635. VIGNETTE: boolean;
  88636. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88637. VIGNETTEBLENDMODEOPAQUE: boolean;
  88638. TONEMAPPING: boolean;
  88639. TONEMAPPING_ACES: boolean;
  88640. CONTRAST: boolean;
  88641. EXPOSURE: boolean;
  88642. COLORCURVES: boolean;
  88643. COLORGRADING: boolean;
  88644. COLORGRADING3D: boolean;
  88645. SAMPLER3DGREENDEPTH: boolean;
  88646. SAMPLER3DBGRMAP: boolean;
  88647. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88648. }
  88649. /**
  88650. * @hidden
  88651. */
  88652. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88653. IMAGEPROCESSING: boolean;
  88654. VIGNETTE: boolean;
  88655. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88656. VIGNETTEBLENDMODEOPAQUE: boolean;
  88657. TONEMAPPING: boolean;
  88658. TONEMAPPING_ACES: boolean;
  88659. CONTRAST: boolean;
  88660. COLORCURVES: boolean;
  88661. COLORGRADING: boolean;
  88662. COLORGRADING3D: boolean;
  88663. SAMPLER3DGREENDEPTH: boolean;
  88664. SAMPLER3DBGRMAP: boolean;
  88665. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88666. EXPOSURE: boolean;
  88667. constructor();
  88668. }
  88669. /**
  88670. * This groups together the common properties used for image processing either in direct forward pass
  88671. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88672. * or not.
  88673. */
  88674. export class ImageProcessingConfiguration {
  88675. /**
  88676. * Default tone mapping applied in BabylonJS.
  88677. */
  88678. static readonly TONEMAPPING_STANDARD: number;
  88679. /**
  88680. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88681. * to other engines rendering to increase portability.
  88682. */
  88683. static readonly TONEMAPPING_ACES: number;
  88684. /**
  88685. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88686. */
  88687. colorCurves: Nullable<ColorCurves>;
  88688. private _colorCurvesEnabled;
  88689. /**
  88690. * Gets wether the color curves effect is enabled.
  88691. */
  88692. get colorCurvesEnabled(): boolean;
  88693. /**
  88694. * Sets wether the color curves effect is enabled.
  88695. */
  88696. set colorCurvesEnabled(value: boolean);
  88697. private _colorGradingTexture;
  88698. /**
  88699. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88700. */
  88701. get colorGradingTexture(): Nullable<BaseTexture>;
  88702. /**
  88703. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88704. */
  88705. set colorGradingTexture(value: Nullable<BaseTexture>);
  88706. private _colorGradingEnabled;
  88707. /**
  88708. * Gets wether the color grading effect is enabled.
  88709. */
  88710. get colorGradingEnabled(): boolean;
  88711. /**
  88712. * Sets wether the color grading effect is enabled.
  88713. */
  88714. set colorGradingEnabled(value: boolean);
  88715. private _colorGradingWithGreenDepth;
  88716. /**
  88717. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88718. */
  88719. get colorGradingWithGreenDepth(): boolean;
  88720. /**
  88721. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88722. */
  88723. set colorGradingWithGreenDepth(value: boolean);
  88724. private _colorGradingBGR;
  88725. /**
  88726. * Gets wether the color grading texture contains BGR values.
  88727. */
  88728. get colorGradingBGR(): boolean;
  88729. /**
  88730. * Sets wether the color grading texture contains BGR values.
  88731. */
  88732. set colorGradingBGR(value: boolean);
  88733. /** @hidden */
  88734. _exposure: number;
  88735. /**
  88736. * Gets the Exposure used in the effect.
  88737. */
  88738. get exposure(): number;
  88739. /**
  88740. * Sets the Exposure used in the effect.
  88741. */
  88742. set exposure(value: number);
  88743. private _toneMappingEnabled;
  88744. /**
  88745. * Gets wether the tone mapping effect is enabled.
  88746. */
  88747. get toneMappingEnabled(): boolean;
  88748. /**
  88749. * Sets wether the tone mapping effect is enabled.
  88750. */
  88751. set toneMappingEnabled(value: boolean);
  88752. private _toneMappingType;
  88753. /**
  88754. * Gets the type of tone mapping effect.
  88755. */
  88756. get toneMappingType(): number;
  88757. /**
  88758. * Sets the type of tone mapping effect used in BabylonJS.
  88759. */
  88760. set toneMappingType(value: number);
  88761. protected _contrast: number;
  88762. /**
  88763. * Gets the contrast used in the effect.
  88764. */
  88765. get contrast(): number;
  88766. /**
  88767. * Sets the contrast used in the effect.
  88768. */
  88769. set contrast(value: number);
  88770. /**
  88771. * Vignette stretch size.
  88772. */
  88773. vignetteStretch: number;
  88774. /**
  88775. * Vignette centre X Offset.
  88776. */
  88777. vignetteCentreX: number;
  88778. /**
  88779. * Vignette centre Y Offset.
  88780. */
  88781. vignetteCentreY: number;
  88782. /**
  88783. * Vignette weight or intensity of the vignette effect.
  88784. */
  88785. vignetteWeight: number;
  88786. /**
  88787. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88788. * if vignetteEnabled is set to true.
  88789. */
  88790. vignetteColor: Color4;
  88791. /**
  88792. * Camera field of view used by the Vignette effect.
  88793. */
  88794. vignetteCameraFov: number;
  88795. private _vignetteBlendMode;
  88796. /**
  88797. * Gets the vignette blend mode allowing different kind of effect.
  88798. */
  88799. get vignetteBlendMode(): number;
  88800. /**
  88801. * Sets the vignette blend mode allowing different kind of effect.
  88802. */
  88803. set vignetteBlendMode(value: number);
  88804. private _vignetteEnabled;
  88805. /**
  88806. * Gets wether the vignette effect is enabled.
  88807. */
  88808. get vignetteEnabled(): boolean;
  88809. /**
  88810. * Sets wether the vignette effect is enabled.
  88811. */
  88812. set vignetteEnabled(value: boolean);
  88813. private _applyByPostProcess;
  88814. /**
  88815. * Gets wether the image processing is applied through a post process or not.
  88816. */
  88817. get applyByPostProcess(): boolean;
  88818. /**
  88819. * Sets wether the image processing is applied through a post process or not.
  88820. */
  88821. set applyByPostProcess(value: boolean);
  88822. private _isEnabled;
  88823. /**
  88824. * Gets wether the image processing is enabled or not.
  88825. */
  88826. get isEnabled(): boolean;
  88827. /**
  88828. * Sets wether the image processing is enabled or not.
  88829. */
  88830. set isEnabled(value: boolean);
  88831. /**
  88832. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88833. */
  88834. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88835. /**
  88836. * Method called each time the image processing information changes requires to recompile the effect.
  88837. */
  88838. protected _updateParameters(): void;
  88839. /**
  88840. * Gets the current class name.
  88841. * @return "ImageProcessingConfiguration"
  88842. */
  88843. getClassName(): string;
  88844. /**
  88845. * Prepare the list of uniforms associated with the Image Processing effects.
  88846. * @param uniforms The list of uniforms used in the effect
  88847. * @param defines the list of defines currently in use
  88848. */
  88849. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88850. /**
  88851. * Prepare the list of samplers associated with the Image Processing effects.
  88852. * @param samplersList The list of uniforms used in the effect
  88853. * @param defines the list of defines currently in use
  88854. */
  88855. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88856. /**
  88857. * Prepare the list of defines associated to the shader.
  88858. * @param defines the list of defines to complete
  88859. * @param forPostProcess Define if we are currently in post process mode or not
  88860. */
  88861. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88862. /**
  88863. * Returns true if all the image processing information are ready.
  88864. * @returns True if ready, otherwise, false
  88865. */
  88866. isReady(): boolean;
  88867. /**
  88868. * Binds the image processing to the shader.
  88869. * @param effect The effect to bind to
  88870. * @param overrideAspectRatio Override the aspect ratio of the effect
  88871. */
  88872. bind(effect: Effect, overrideAspectRatio?: number): void;
  88873. /**
  88874. * Clones the current image processing instance.
  88875. * @return The cloned image processing
  88876. */
  88877. clone(): ImageProcessingConfiguration;
  88878. /**
  88879. * Serializes the current image processing instance to a json representation.
  88880. * @return a JSON representation
  88881. */
  88882. serialize(): any;
  88883. /**
  88884. * Parses the image processing from a json representation.
  88885. * @param source the JSON source to parse
  88886. * @return The parsed image processing
  88887. */
  88888. static Parse(source: any): ImageProcessingConfiguration;
  88889. private static _VIGNETTEMODE_MULTIPLY;
  88890. private static _VIGNETTEMODE_OPAQUE;
  88891. /**
  88892. * Used to apply the vignette as a mix with the pixel color.
  88893. */
  88894. static get VIGNETTEMODE_MULTIPLY(): number;
  88895. /**
  88896. * Used to apply the vignette as a replacement of the pixel color.
  88897. */
  88898. static get VIGNETTEMODE_OPAQUE(): number;
  88899. }
  88900. }
  88901. declare module BABYLON {
  88902. /** @hidden */
  88903. export var postprocessVertexShader: {
  88904. name: string;
  88905. shader: string;
  88906. };
  88907. }
  88908. declare module BABYLON {
  88909. /**
  88910. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88911. */
  88912. export type RenderTargetTextureSize = number | {
  88913. width: number;
  88914. height: number;
  88915. layers?: number;
  88916. };
  88917. interface ThinEngine {
  88918. /**
  88919. * Creates a new render target texture
  88920. * @param size defines the size of the texture
  88921. * @param options defines the options used to create the texture
  88922. * @returns a new render target texture stored in an InternalTexture
  88923. */
  88924. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88925. /**
  88926. * Creates a depth stencil texture.
  88927. * This is only available in WebGL 2 or with the depth texture extension available.
  88928. * @param size The size of face edge in the texture.
  88929. * @param options The options defining the texture.
  88930. * @returns The texture
  88931. */
  88932. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88933. /** @hidden */
  88934. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88935. }
  88936. }
  88937. declare module BABYLON {
  88938. /**
  88939. * Defines the kind of connection point for node based material
  88940. */
  88941. export enum NodeMaterialBlockConnectionPointTypes {
  88942. /** Float */
  88943. Float = 1,
  88944. /** Int */
  88945. Int = 2,
  88946. /** Vector2 */
  88947. Vector2 = 4,
  88948. /** Vector3 */
  88949. Vector3 = 8,
  88950. /** Vector4 */
  88951. Vector4 = 16,
  88952. /** Color3 */
  88953. Color3 = 32,
  88954. /** Color4 */
  88955. Color4 = 64,
  88956. /** Matrix */
  88957. Matrix = 128,
  88958. /** Custom object */
  88959. Object = 256,
  88960. /** Detect type based on connection */
  88961. AutoDetect = 1024,
  88962. /** Output type that will be defined by input type */
  88963. BasedOnInput = 2048
  88964. }
  88965. }
  88966. declare module BABYLON {
  88967. /**
  88968. * Enum used to define the target of a block
  88969. */
  88970. export enum NodeMaterialBlockTargets {
  88971. /** Vertex shader */
  88972. Vertex = 1,
  88973. /** Fragment shader */
  88974. Fragment = 2,
  88975. /** Neutral */
  88976. Neutral = 4,
  88977. /** Vertex and Fragment */
  88978. VertexAndFragment = 3
  88979. }
  88980. }
  88981. declare module BABYLON {
  88982. /**
  88983. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88984. */
  88985. export enum NodeMaterialBlockConnectionPointMode {
  88986. /** Value is an uniform */
  88987. Uniform = 0,
  88988. /** Value is a mesh attribute */
  88989. Attribute = 1,
  88990. /** Value is a varying between vertex and fragment shaders */
  88991. Varying = 2,
  88992. /** Mode is undefined */
  88993. Undefined = 3
  88994. }
  88995. }
  88996. declare module BABYLON {
  88997. /**
  88998. * Enum used to define system values e.g. values automatically provided by the system
  88999. */
  89000. export enum NodeMaterialSystemValues {
  89001. /** World */
  89002. World = 1,
  89003. /** View */
  89004. View = 2,
  89005. /** Projection */
  89006. Projection = 3,
  89007. /** ViewProjection */
  89008. ViewProjection = 4,
  89009. /** WorldView */
  89010. WorldView = 5,
  89011. /** WorldViewProjection */
  89012. WorldViewProjection = 6,
  89013. /** CameraPosition */
  89014. CameraPosition = 7,
  89015. /** Fog Color */
  89016. FogColor = 8,
  89017. /** Delta time */
  89018. DeltaTime = 9
  89019. }
  89020. }
  89021. declare module BABYLON {
  89022. /** Defines supported spaces */
  89023. export enum Space {
  89024. /** Local (object) space */
  89025. LOCAL = 0,
  89026. /** World space */
  89027. WORLD = 1,
  89028. /** Bone space */
  89029. BONE = 2
  89030. }
  89031. /** Defines the 3 main axes */
  89032. export class Axis {
  89033. /** X axis */
  89034. static X: Vector3;
  89035. /** Y axis */
  89036. static Y: Vector3;
  89037. /** Z axis */
  89038. static Z: Vector3;
  89039. }
  89040. }
  89041. declare module BABYLON {
  89042. /**
  89043. * Represents a camera frustum
  89044. */
  89045. export class Frustum {
  89046. /**
  89047. * Gets the planes representing the frustum
  89048. * @param transform matrix to be applied to the returned planes
  89049. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89050. */
  89051. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89052. /**
  89053. * Gets the near frustum plane transformed by the transform matrix
  89054. * @param transform transformation matrix to be applied to the resulting frustum plane
  89055. * @param frustumPlane the resuling frustum plane
  89056. */
  89057. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89058. /**
  89059. * Gets the far frustum plane transformed by the transform matrix
  89060. * @param transform transformation matrix to be applied to the resulting frustum plane
  89061. * @param frustumPlane the resuling frustum plane
  89062. */
  89063. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89064. /**
  89065. * Gets the left frustum plane transformed by the transform matrix
  89066. * @param transform transformation matrix to be applied to the resulting frustum plane
  89067. * @param frustumPlane the resuling frustum plane
  89068. */
  89069. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89070. /**
  89071. * Gets the right frustum plane transformed by the transform matrix
  89072. * @param transform transformation matrix to be applied to the resulting frustum plane
  89073. * @param frustumPlane the resuling frustum plane
  89074. */
  89075. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89076. /**
  89077. * Gets the top frustum plane transformed by the transform matrix
  89078. * @param transform transformation matrix to be applied to the resulting frustum plane
  89079. * @param frustumPlane the resuling frustum plane
  89080. */
  89081. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89082. /**
  89083. * Gets the bottom frustum plane transformed by the transform matrix
  89084. * @param transform transformation matrix to be applied to the resulting frustum plane
  89085. * @param frustumPlane the resuling frustum plane
  89086. */
  89087. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89088. /**
  89089. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89090. * @param transform transformation matrix to be applied to the resulting frustum planes
  89091. * @param frustumPlanes the resuling frustum planes
  89092. */
  89093. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89094. }
  89095. }
  89096. declare module BABYLON {
  89097. /**
  89098. * Interface for the size containing width and height
  89099. */
  89100. export interface ISize {
  89101. /**
  89102. * Width
  89103. */
  89104. width: number;
  89105. /**
  89106. * Heighht
  89107. */
  89108. height: number;
  89109. }
  89110. /**
  89111. * Size containing widht and height
  89112. */
  89113. export class Size implements ISize {
  89114. /**
  89115. * Width
  89116. */
  89117. width: number;
  89118. /**
  89119. * Height
  89120. */
  89121. height: number;
  89122. /**
  89123. * Creates a Size object from the given width and height (floats).
  89124. * @param width width of the new size
  89125. * @param height height of the new size
  89126. */
  89127. constructor(width: number, height: number);
  89128. /**
  89129. * Returns a string with the Size width and height
  89130. * @returns a string with the Size width and height
  89131. */
  89132. toString(): string;
  89133. /**
  89134. * "Size"
  89135. * @returns the string "Size"
  89136. */
  89137. getClassName(): string;
  89138. /**
  89139. * Returns the Size hash code.
  89140. * @returns a hash code for a unique width and height
  89141. */
  89142. getHashCode(): number;
  89143. /**
  89144. * Updates the current size from the given one.
  89145. * @param src the given size
  89146. */
  89147. copyFrom(src: Size): void;
  89148. /**
  89149. * Updates in place the current Size from the given floats.
  89150. * @param width width of the new size
  89151. * @param height height of the new size
  89152. * @returns the updated Size.
  89153. */
  89154. copyFromFloats(width: number, height: number): Size;
  89155. /**
  89156. * Updates in place the current Size from the given floats.
  89157. * @param width width to set
  89158. * @param height height to set
  89159. * @returns the updated Size.
  89160. */
  89161. set(width: number, height: number): Size;
  89162. /**
  89163. * Multiplies the width and height by numbers
  89164. * @param w factor to multiple the width by
  89165. * @param h factor to multiple the height by
  89166. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89167. */
  89168. multiplyByFloats(w: number, h: number): Size;
  89169. /**
  89170. * Clones the size
  89171. * @returns a new Size copied from the given one.
  89172. */
  89173. clone(): Size;
  89174. /**
  89175. * True if the current Size and the given one width and height are strictly equal.
  89176. * @param other the other size to compare against
  89177. * @returns True if the current Size and the given one width and height are strictly equal.
  89178. */
  89179. equals(other: Size): boolean;
  89180. /**
  89181. * The surface of the Size : width * height (float).
  89182. */
  89183. get surface(): number;
  89184. /**
  89185. * Create a new size of zero
  89186. * @returns a new Size set to (0.0, 0.0)
  89187. */
  89188. static Zero(): Size;
  89189. /**
  89190. * Sums the width and height of two sizes
  89191. * @param otherSize size to add to this size
  89192. * @returns a new Size set as the addition result of the current Size and the given one.
  89193. */
  89194. add(otherSize: Size): Size;
  89195. /**
  89196. * Subtracts the width and height of two
  89197. * @param otherSize size to subtract to this size
  89198. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89199. */
  89200. subtract(otherSize: Size): Size;
  89201. /**
  89202. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89203. * @param start starting size to lerp between
  89204. * @param end end size to lerp between
  89205. * @param amount amount to lerp between the start and end values
  89206. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89207. */
  89208. static Lerp(start: Size, end: Size, amount: number): Size;
  89209. }
  89210. }
  89211. declare module BABYLON {
  89212. /**
  89213. * Contains position and normal vectors for a vertex
  89214. */
  89215. export class PositionNormalVertex {
  89216. /** the position of the vertex (defaut: 0,0,0) */
  89217. position: Vector3;
  89218. /** the normal of the vertex (defaut: 0,1,0) */
  89219. normal: Vector3;
  89220. /**
  89221. * Creates a PositionNormalVertex
  89222. * @param position the position of the vertex (defaut: 0,0,0)
  89223. * @param normal the normal of the vertex (defaut: 0,1,0)
  89224. */
  89225. constructor(
  89226. /** the position of the vertex (defaut: 0,0,0) */
  89227. position?: Vector3,
  89228. /** the normal of the vertex (defaut: 0,1,0) */
  89229. normal?: Vector3);
  89230. /**
  89231. * Clones the PositionNormalVertex
  89232. * @returns the cloned PositionNormalVertex
  89233. */
  89234. clone(): PositionNormalVertex;
  89235. }
  89236. /**
  89237. * Contains position, normal and uv vectors for a vertex
  89238. */
  89239. export class PositionNormalTextureVertex {
  89240. /** the position of the vertex (defaut: 0,0,0) */
  89241. position: Vector3;
  89242. /** the normal of the vertex (defaut: 0,1,0) */
  89243. normal: Vector3;
  89244. /** the uv of the vertex (default: 0,0) */
  89245. uv: Vector2;
  89246. /**
  89247. * Creates a PositionNormalTextureVertex
  89248. * @param position the position of the vertex (defaut: 0,0,0)
  89249. * @param normal the normal of the vertex (defaut: 0,1,0)
  89250. * @param uv the uv of the vertex (default: 0,0)
  89251. */
  89252. constructor(
  89253. /** the position of the vertex (defaut: 0,0,0) */
  89254. position?: Vector3,
  89255. /** the normal of the vertex (defaut: 0,1,0) */
  89256. normal?: Vector3,
  89257. /** the uv of the vertex (default: 0,0) */
  89258. uv?: Vector2);
  89259. /**
  89260. * Clones the PositionNormalTextureVertex
  89261. * @returns the cloned PositionNormalTextureVertex
  89262. */
  89263. clone(): PositionNormalTextureVertex;
  89264. }
  89265. }
  89266. declare module BABYLON {
  89267. /**
  89268. * Enum defining the type of animations supported by InputBlock
  89269. */
  89270. export enum AnimatedInputBlockTypes {
  89271. /** No animation */
  89272. None = 0,
  89273. /** Time based animation. Will only work for floats */
  89274. Time = 1
  89275. }
  89276. }
  89277. declare module BABYLON {
  89278. /**
  89279. * Interface describing all the common properties and methods a shadow light needs to implement.
  89280. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89281. * as well as binding the different shadow properties to the effects.
  89282. */
  89283. export interface IShadowLight extends Light {
  89284. /**
  89285. * The light id in the scene (used in scene.findLighById for instance)
  89286. */
  89287. id: string;
  89288. /**
  89289. * The position the shdow will be casted from.
  89290. */
  89291. position: Vector3;
  89292. /**
  89293. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89294. */
  89295. direction: Vector3;
  89296. /**
  89297. * The transformed position. Position of the light in world space taking parenting in account.
  89298. */
  89299. transformedPosition: Vector3;
  89300. /**
  89301. * The transformed direction. Direction of the light in world space taking parenting in account.
  89302. */
  89303. transformedDirection: Vector3;
  89304. /**
  89305. * The friendly name of the light in the scene.
  89306. */
  89307. name: string;
  89308. /**
  89309. * Defines the shadow projection clipping minimum z value.
  89310. */
  89311. shadowMinZ: number;
  89312. /**
  89313. * Defines the shadow projection clipping maximum z value.
  89314. */
  89315. shadowMaxZ: number;
  89316. /**
  89317. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89318. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89319. */
  89320. computeTransformedInformation(): boolean;
  89321. /**
  89322. * Gets the scene the light belongs to.
  89323. * @returns The scene
  89324. */
  89325. getScene(): Scene;
  89326. /**
  89327. * Callback defining a custom Projection Matrix Builder.
  89328. * This can be used to override the default projection matrix computation.
  89329. */
  89330. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89331. /**
  89332. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89333. * @param matrix The materix to updated with the projection information
  89334. * @param viewMatrix The transform matrix of the light
  89335. * @param renderList The list of mesh to render in the map
  89336. * @returns The current light
  89337. */
  89338. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89339. /**
  89340. * Gets the current depth scale used in ESM.
  89341. * @returns The scale
  89342. */
  89343. getDepthScale(): number;
  89344. /**
  89345. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89346. * @returns true if a cube texture needs to be use
  89347. */
  89348. needCube(): boolean;
  89349. /**
  89350. * Detects if the projection matrix requires to be recomputed this frame.
  89351. * @returns true if it requires to be recomputed otherwise, false.
  89352. */
  89353. needProjectionMatrixCompute(): boolean;
  89354. /**
  89355. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89356. */
  89357. forceProjectionMatrixCompute(): void;
  89358. /**
  89359. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89360. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89361. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89362. */
  89363. getShadowDirection(faceIndex?: number): Vector3;
  89364. /**
  89365. * Gets the minZ used for shadow according to both the scene and the light.
  89366. * @param activeCamera The camera we are returning the min for
  89367. * @returns the depth min z
  89368. */
  89369. getDepthMinZ(activeCamera: Camera): number;
  89370. /**
  89371. * Gets the maxZ used for shadow according to both the scene and the light.
  89372. * @param activeCamera The camera we are returning the max for
  89373. * @returns the depth max z
  89374. */
  89375. getDepthMaxZ(activeCamera: Camera): number;
  89376. }
  89377. /**
  89378. * Base implementation IShadowLight
  89379. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89380. */
  89381. export abstract class ShadowLight extends Light implements IShadowLight {
  89382. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89383. protected _position: Vector3;
  89384. protected _setPosition(value: Vector3): void;
  89385. /**
  89386. * Sets the position the shadow will be casted from. Also use as the light position for both
  89387. * point and spot lights.
  89388. */
  89389. get position(): Vector3;
  89390. /**
  89391. * Sets the position the shadow will be casted from. Also use as the light position for both
  89392. * point and spot lights.
  89393. */
  89394. set position(value: Vector3);
  89395. protected _direction: Vector3;
  89396. protected _setDirection(value: Vector3): void;
  89397. /**
  89398. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89399. * Also use as the light direction on spot and directional lights.
  89400. */
  89401. get direction(): Vector3;
  89402. /**
  89403. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89404. * Also use as the light direction on spot and directional lights.
  89405. */
  89406. set direction(value: Vector3);
  89407. protected _shadowMinZ: number;
  89408. /**
  89409. * Gets the shadow projection clipping minimum z value.
  89410. */
  89411. get shadowMinZ(): number;
  89412. /**
  89413. * Sets the shadow projection clipping minimum z value.
  89414. */
  89415. set shadowMinZ(value: number);
  89416. protected _shadowMaxZ: number;
  89417. /**
  89418. * Sets the shadow projection clipping maximum z value.
  89419. */
  89420. get shadowMaxZ(): number;
  89421. /**
  89422. * Gets the shadow projection clipping maximum z value.
  89423. */
  89424. set shadowMaxZ(value: number);
  89425. /**
  89426. * Callback defining a custom Projection Matrix Builder.
  89427. * This can be used to override the default projection matrix computation.
  89428. */
  89429. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89430. /**
  89431. * The transformed position. Position of the light in world space taking parenting in account.
  89432. */
  89433. transformedPosition: Vector3;
  89434. /**
  89435. * The transformed direction. Direction of the light in world space taking parenting in account.
  89436. */
  89437. transformedDirection: Vector3;
  89438. private _needProjectionMatrixCompute;
  89439. /**
  89440. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89441. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89442. */
  89443. computeTransformedInformation(): boolean;
  89444. /**
  89445. * Return the depth scale used for the shadow map.
  89446. * @returns the depth scale.
  89447. */
  89448. getDepthScale(): number;
  89449. /**
  89450. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89451. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89452. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89453. */
  89454. getShadowDirection(faceIndex?: number): Vector3;
  89455. /**
  89456. * Returns the ShadowLight absolute position in the World.
  89457. * @returns the position vector in world space
  89458. */
  89459. getAbsolutePosition(): Vector3;
  89460. /**
  89461. * Sets the ShadowLight direction toward the passed target.
  89462. * @param target The point to target in local space
  89463. * @returns the updated ShadowLight direction
  89464. */
  89465. setDirectionToTarget(target: Vector3): Vector3;
  89466. /**
  89467. * Returns the light rotation in euler definition.
  89468. * @returns the x y z rotation in local space.
  89469. */
  89470. getRotation(): Vector3;
  89471. /**
  89472. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89473. * @returns true if a cube texture needs to be use
  89474. */
  89475. needCube(): boolean;
  89476. /**
  89477. * Detects if the projection matrix requires to be recomputed this frame.
  89478. * @returns true if it requires to be recomputed otherwise, false.
  89479. */
  89480. needProjectionMatrixCompute(): boolean;
  89481. /**
  89482. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89483. */
  89484. forceProjectionMatrixCompute(): void;
  89485. /** @hidden */
  89486. _initCache(): void;
  89487. /** @hidden */
  89488. _isSynchronized(): boolean;
  89489. /**
  89490. * Computes the world matrix of the node
  89491. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89492. * @returns the world matrix
  89493. */
  89494. computeWorldMatrix(force?: boolean): Matrix;
  89495. /**
  89496. * Gets the minZ used for shadow according to both the scene and the light.
  89497. * @param activeCamera The camera we are returning the min for
  89498. * @returns the depth min z
  89499. */
  89500. getDepthMinZ(activeCamera: Camera): number;
  89501. /**
  89502. * Gets the maxZ used for shadow according to both the scene and the light.
  89503. * @param activeCamera The camera we are returning the max for
  89504. * @returns the depth max z
  89505. */
  89506. getDepthMaxZ(activeCamera: Camera): number;
  89507. /**
  89508. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89509. * @param matrix The materix to updated with the projection information
  89510. * @param viewMatrix The transform matrix of the light
  89511. * @param renderList The list of mesh to render in the map
  89512. * @returns The current light
  89513. */
  89514. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89515. }
  89516. }
  89517. declare module BABYLON {
  89518. /** @hidden */
  89519. export var packingFunctions: {
  89520. name: string;
  89521. shader: string;
  89522. };
  89523. }
  89524. declare module BABYLON {
  89525. /** @hidden */
  89526. export var bayerDitherFunctions: {
  89527. name: string;
  89528. shader: string;
  89529. };
  89530. }
  89531. declare module BABYLON {
  89532. /** @hidden */
  89533. export var shadowMapFragmentDeclaration: {
  89534. name: string;
  89535. shader: string;
  89536. };
  89537. }
  89538. declare module BABYLON {
  89539. /** @hidden */
  89540. export var clipPlaneFragmentDeclaration: {
  89541. name: string;
  89542. shader: string;
  89543. };
  89544. }
  89545. declare module BABYLON {
  89546. /** @hidden */
  89547. export var clipPlaneFragment: {
  89548. name: string;
  89549. shader: string;
  89550. };
  89551. }
  89552. declare module BABYLON {
  89553. /** @hidden */
  89554. export var shadowMapFragment: {
  89555. name: string;
  89556. shader: string;
  89557. };
  89558. }
  89559. declare module BABYLON {
  89560. /** @hidden */
  89561. export var shadowMapPixelShader: {
  89562. name: string;
  89563. shader: string;
  89564. };
  89565. }
  89566. declare module BABYLON {
  89567. /** @hidden */
  89568. export var bonesDeclaration: {
  89569. name: string;
  89570. shader: string;
  89571. };
  89572. }
  89573. declare module BABYLON {
  89574. /** @hidden */
  89575. export var morphTargetsVertexGlobalDeclaration: {
  89576. name: string;
  89577. shader: string;
  89578. };
  89579. }
  89580. declare module BABYLON {
  89581. /** @hidden */
  89582. export var morphTargetsVertexDeclaration: {
  89583. name: string;
  89584. shader: string;
  89585. };
  89586. }
  89587. declare module BABYLON {
  89588. /** @hidden */
  89589. export var instancesDeclaration: {
  89590. name: string;
  89591. shader: string;
  89592. };
  89593. }
  89594. declare module BABYLON {
  89595. /** @hidden */
  89596. export var helperFunctions: {
  89597. name: string;
  89598. shader: string;
  89599. };
  89600. }
  89601. declare module BABYLON {
  89602. /** @hidden */
  89603. export var shadowMapVertexDeclaration: {
  89604. name: string;
  89605. shader: string;
  89606. };
  89607. }
  89608. declare module BABYLON {
  89609. /** @hidden */
  89610. export var clipPlaneVertexDeclaration: {
  89611. name: string;
  89612. shader: string;
  89613. };
  89614. }
  89615. declare module BABYLON {
  89616. /** @hidden */
  89617. export var morphTargetsVertex: {
  89618. name: string;
  89619. shader: string;
  89620. };
  89621. }
  89622. declare module BABYLON {
  89623. /** @hidden */
  89624. export var instancesVertex: {
  89625. name: string;
  89626. shader: string;
  89627. };
  89628. }
  89629. declare module BABYLON {
  89630. /** @hidden */
  89631. export var bonesVertex: {
  89632. name: string;
  89633. shader: string;
  89634. };
  89635. }
  89636. declare module BABYLON {
  89637. /** @hidden */
  89638. export var shadowMapVertexNormalBias: {
  89639. name: string;
  89640. shader: string;
  89641. };
  89642. }
  89643. declare module BABYLON {
  89644. /** @hidden */
  89645. export var shadowMapVertexMetric: {
  89646. name: string;
  89647. shader: string;
  89648. };
  89649. }
  89650. declare module BABYLON {
  89651. /** @hidden */
  89652. export var clipPlaneVertex: {
  89653. name: string;
  89654. shader: string;
  89655. };
  89656. }
  89657. declare module BABYLON {
  89658. /** @hidden */
  89659. export var shadowMapVertexShader: {
  89660. name: string;
  89661. shader: string;
  89662. };
  89663. }
  89664. declare module BABYLON {
  89665. /** @hidden */
  89666. export var depthBoxBlurPixelShader: {
  89667. name: string;
  89668. shader: string;
  89669. };
  89670. }
  89671. declare module BABYLON {
  89672. /** @hidden */
  89673. export var shadowMapFragmentSoftTransparentShadow: {
  89674. name: string;
  89675. shader: string;
  89676. };
  89677. }
  89678. declare module BABYLON {
  89679. /**
  89680. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89681. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89682. */
  89683. export class EffectFallbacks implements IEffectFallbacks {
  89684. private _defines;
  89685. private _currentRank;
  89686. private _maxRank;
  89687. private _mesh;
  89688. /**
  89689. * Removes the fallback from the bound mesh.
  89690. */
  89691. unBindMesh(): void;
  89692. /**
  89693. * Adds a fallback on the specified property.
  89694. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89695. * @param define The name of the define in the shader
  89696. */
  89697. addFallback(rank: number, define: string): void;
  89698. /**
  89699. * Sets the mesh to use CPU skinning when needing to fallback.
  89700. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89701. * @param mesh The mesh to use the fallbacks.
  89702. */
  89703. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89704. /**
  89705. * Checks to see if more fallbacks are still availible.
  89706. */
  89707. get hasMoreFallbacks(): boolean;
  89708. /**
  89709. * Removes the defines that should be removed when falling back.
  89710. * @param currentDefines defines the current define statements for the shader.
  89711. * @param effect defines the current effect we try to compile
  89712. * @returns The resulting defines with defines of the current rank removed.
  89713. */
  89714. reduce(currentDefines: string, effect: Effect): string;
  89715. }
  89716. }
  89717. declare module BABYLON {
  89718. /**
  89719. * Interface used to define Action
  89720. */
  89721. export interface IAction {
  89722. /**
  89723. * Trigger for the action
  89724. */
  89725. trigger: number;
  89726. /** Options of the trigger */
  89727. triggerOptions: any;
  89728. /**
  89729. * Gets the trigger parameters
  89730. * @returns the trigger parameters
  89731. */
  89732. getTriggerParameter(): any;
  89733. /**
  89734. * Internal only - executes current action event
  89735. * @hidden
  89736. */
  89737. _executeCurrent(evt?: ActionEvent): void;
  89738. /**
  89739. * Serialize placeholder for child classes
  89740. * @param parent of child
  89741. * @returns the serialized object
  89742. */
  89743. serialize(parent: any): any;
  89744. /**
  89745. * Internal only
  89746. * @hidden
  89747. */
  89748. _prepare(): void;
  89749. /**
  89750. * Internal only - manager for action
  89751. * @hidden
  89752. */
  89753. _actionManager: Nullable<AbstractActionManager>;
  89754. /**
  89755. * Adds action to chain of actions, may be a DoNothingAction
  89756. * @param action defines the next action to execute
  89757. * @returns The action passed in
  89758. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89759. */
  89760. then(action: IAction): IAction;
  89761. }
  89762. /**
  89763. * The action to be carried out following a trigger
  89764. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89765. */
  89766. export class Action implements IAction {
  89767. /** the trigger, with or without parameters, for the action */
  89768. triggerOptions: any;
  89769. /**
  89770. * Trigger for the action
  89771. */
  89772. trigger: number;
  89773. /**
  89774. * Internal only - manager for action
  89775. * @hidden
  89776. */
  89777. _actionManager: ActionManager;
  89778. private _nextActiveAction;
  89779. private _child;
  89780. private _condition?;
  89781. private _triggerParameter;
  89782. /**
  89783. * An event triggered prior to action being executed.
  89784. */
  89785. onBeforeExecuteObservable: Observable<Action>;
  89786. /**
  89787. * Creates a new Action
  89788. * @param triggerOptions the trigger, with or without parameters, for the action
  89789. * @param condition an optional determinant of action
  89790. */
  89791. constructor(
  89792. /** the trigger, with or without parameters, for the action */
  89793. triggerOptions: any, condition?: Condition);
  89794. /**
  89795. * Internal only
  89796. * @hidden
  89797. */
  89798. _prepare(): void;
  89799. /**
  89800. * Gets the trigger parameters
  89801. * @returns the trigger parameters
  89802. */
  89803. getTriggerParameter(): any;
  89804. /**
  89805. * Internal only - executes current action event
  89806. * @hidden
  89807. */
  89808. _executeCurrent(evt?: ActionEvent): void;
  89809. /**
  89810. * Execute placeholder for child classes
  89811. * @param evt optional action event
  89812. */
  89813. execute(evt?: ActionEvent): void;
  89814. /**
  89815. * Skips to next active action
  89816. */
  89817. skipToNextActiveAction(): void;
  89818. /**
  89819. * Adds action to chain of actions, may be a DoNothingAction
  89820. * @param action defines the next action to execute
  89821. * @returns The action passed in
  89822. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89823. */
  89824. then(action: Action): Action;
  89825. /**
  89826. * Internal only
  89827. * @hidden
  89828. */
  89829. _getProperty(propertyPath: string): string;
  89830. /**
  89831. * Internal only
  89832. * @hidden
  89833. */
  89834. _getEffectiveTarget(target: any, propertyPath: string): any;
  89835. /**
  89836. * Serialize placeholder for child classes
  89837. * @param parent of child
  89838. * @returns the serialized object
  89839. */
  89840. serialize(parent: any): any;
  89841. /**
  89842. * Internal only called by serialize
  89843. * @hidden
  89844. */
  89845. protected _serialize(serializedAction: any, parent?: any): any;
  89846. /**
  89847. * Internal only
  89848. * @hidden
  89849. */
  89850. static _SerializeValueAsString: (value: any) => string;
  89851. /**
  89852. * Internal only
  89853. * @hidden
  89854. */
  89855. static _GetTargetProperty: (target: Scene | Node) => {
  89856. name: string;
  89857. targetType: string;
  89858. value: string;
  89859. };
  89860. }
  89861. }
  89862. declare module BABYLON {
  89863. /**
  89864. * A Condition applied to an Action
  89865. */
  89866. export class Condition {
  89867. /**
  89868. * Internal only - manager for action
  89869. * @hidden
  89870. */
  89871. _actionManager: ActionManager;
  89872. /**
  89873. * Internal only
  89874. * @hidden
  89875. */
  89876. _evaluationId: number;
  89877. /**
  89878. * Internal only
  89879. * @hidden
  89880. */
  89881. _currentResult: boolean;
  89882. /**
  89883. * Creates a new Condition
  89884. * @param actionManager the manager of the action the condition is applied to
  89885. */
  89886. constructor(actionManager: ActionManager);
  89887. /**
  89888. * Check if the current condition is valid
  89889. * @returns a boolean
  89890. */
  89891. isValid(): boolean;
  89892. /**
  89893. * Internal only
  89894. * @hidden
  89895. */
  89896. _getProperty(propertyPath: string): string;
  89897. /**
  89898. * Internal only
  89899. * @hidden
  89900. */
  89901. _getEffectiveTarget(target: any, propertyPath: string): any;
  89902. /**
  89903. * Serialize placeholder for child classes
  89904. * @returns the serialized object
  89905. */
  89906. serialize(): any;
  89907. /**
  89908. * Internal only
  89909. * @hidden
  89910. */
  89911. protected _serialize(serializedCondition: any): any;
  89912. }
  89913. /**
  89914. * Defines specific conditional operators as extensions of Condition
  89915. */
  89916. export class ValueCondition extends Condition {
  89917. /** path to specify the property of the target the conditional operator uses */
  89918. propertyPath: string;
  89919. /** the value compared by the conditional operator against the current value of the property */
  89920. value: any;
  89921. /** the conditional operator, default ValueCondition.IsEqual */
  89922. operator: number;
  89923. /**
  89924. * Internal only
  89925. * @hidden
  89926. */
  89927. private static _IsEqual;
  89928. /**
  89929. * Internal only
  89930. * @hidden
  89931. */
  89932. private static _IsDifferent;
  89933. /**
  89934. * Internal only
  89935. * @hidden
  89936. */
  89937. private static _IsGreater;
  89938. /**
  89939. * Internal only
  89940. * @hidden
  89941. */
  89942. private static _IsLesser;
  89943. /**
  89944. * returns the number for IsEqual
  89945. */
  89946. static get IsEqual(): number;
  89947. /**
  89948. * Returns the number for IsDifferent
  89949. */
  89950. static get IsDifferent(): number;
  89951. /**
  89952. * Returns the number for IsGreater
  89953. */
  89954. static get IsGreater(): number;
  89955. /**
  89956. * Returns the number for IsLesser
  89957. */
  89958. static get IsLesser(): number;
  89959. /**
  89960. * Internal only The action manager for the condition
  89961. * @hidden
  89962. */
  89963. _actionManager: ActionManager;
  89964. /**
  89965. * Internal only
  89966. * @hidden
  89967. */
  89968. private _target;
  89969. /**
  89970. * Internal only
  89971. * @hidden
  89972. */
  89973. private _effectiveTarget;
  89974. /**
  89975. * Internal only
  89976. * @hidden
  89977. */
  89978. private _property;
  89979. /**
  89980. * Creates a new ValueCondition
  89981. * @param actionManager manager for the action the condition applies to
  89982. * @param target for the action
  89983. * @param propertyPath path to specify the property of the target the conditional operator uses
  89984. * @param value the value compared by the conditional operator against the current value of the property
  89985. * @param operator the conditional operator, default ValueCondition.IsEqual
  89986. */
  89987. constructor(actionManager: ActionManager, target: any,
  89988. /** path to specify the property of the target the conditional operator uses */
  89989. propertyPath: string,
  89990. /** the value compared by the conditional operator against the current value of the property */
  89991. value: any,
  89992. /** the conditional operator, default ValueCondition.IsEqual */
  89993. operator?: number);
  89994. /**
  89995. * Compares the given value with the property value for the specified conditional operator
  89996. * @returns the result of the comparison
  89997. */
  89998. isValid(): boolean;
  89999. /**
  90000. * Serialize the ValueCondition into a JSON compatible object
  90001. * @returns serialization object
  90002. */
  90003. serialize(): any;
  90004. /**
  90005. * Gets the name of the conditional operator for the ValueCondition
  90006. * @param operator the conditional operator
  90007. * @returns the name
  90008. */
  90009. static GetOperatorName(operator: number): string;
  90010. }
  90011. /**
  90012. * Defines a predicate condition as an extension of Condition
  90013. */
  90014. export class PredicateCondition extends Condition {
  90015. /** defines the predicate function used to validate the condition */
  90016. predicate: () => boolean;
  90017. /**
  90018. * Internal only - manager for action
  90019. * @hidden
  90020. */
  90021. _actionManager: ActionManager;
  90022. /**
  90023. * Creates a new PredicateCondition
  90024. * @param actionManager manager for the action the condition applies to
  90025. * @param predicate defines the predicate function used to validate the condition
  90026. */
  90027. constructor(actionManager: ActionManager,
  90028. /** defines the predicate function used to validate the condition */
  90029. predicate: () => boolean);
  90030. /**
  90031. * @returns the validity of the predicate condition
  90032. */
  90033. isValid(): boolean;
  90034. }
  90035. /**
  90036. * Defines a state condition as an extension of Condition
  90037. */
  90038. export class StateCondition extends Condition {
  90039. /** Value to compare with target state */
  90040. value: string;
  90041. /**
  90042. * Internal only - manager for action
  90043. * @hidden
  90044. */
  90045. _actionManager: ActionManager;
  90046. /**
  90047. * Internal only
  90048. * @hidden
  90049. */
  90050. private _target;
  90051. /**
  90052. * Creates a new StateCondition
  90053. * @param actionManager manager for the action the condition applies to
  90054. * @param target of the condition
  90055. * @param value to compare with target state
  90056. */
  90057. constructor(actionManager: ActionManager, target: any,
  90058. /** Value to compare with target state */
  90059. value: string);
  90060. /**
  90061. * Gets a boolean indicating if the current condition is met
  90062. * @returns the validity of the state
  90063. */
  90064. isValid(): boolean;
  90065. /**
  90066. * Serialize the StateCondition into a JSON compatible object
  90067. * @returns serialization object
  90068. */
  90069. serialize(): any;
  90070. }
  90071. }
  90072. declare module BABYLON {
  90073. /**
  90074. * This defines an action responsible to toggle a boolean once triggered.
  90075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90076. */
  90077. export class SwitchBooleanAction extends Action {
  90078. /**
  90079. * The path to the boolean property in the target object
  90080. */
  90081. propertyPath: string;
  90082. private _target;
  90083. private _effectiveTarget;
  90084. private _property;
  90085. /**
  90086. * Instantiate the action
  90087. * @param triggerOptions defines the trigger options
  90088. * @param target defines the object containing the boolean
  90089. * @param propertyPath defines the path to the boolean property in the target object
  90090. * @param condition defines the trigger related conditions
  90091. */
  90092. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90093. /** @hidden */
  90094. _prepare(): void;
  90095. /**
  90096. * Execute the action toggle the boolean value.
  90097. */
  90098. execute(): void;
  90099. /**
  90100. * Serializes the actions and its related information.
  90101. * @param parent defines the object to serialize in
  90102. * @returns the serialized object
  90103. */
  90104. serialize(parent: any): any;
  90105. }
  90106. /**
  90107. * This defines an action responsible to set a the state field of the target
  90108. * to a desired value once triggered.
  90109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90110. */
  90111. export class SetStateAction extends Action {
  90112. /**
  90113. * The value to store in the state field.
  90114. */
  90115. value: string;
  90116. private _target;
  90117. /**
  90118. * Instantiate the action
  90119. * @param triggerOptions defines the trigger options
  90120. * @param target defines the object containing the state property
  90121. * @param value defines the value to store in the state field
  90122. * @param condition defines the trigger related conditions
  90123. */
  90124. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90125. /**
  90126. * Execute the action and store the value on the target state property.
  90127. */
  90128. execute(): void;
  90129. /**
  90130. * Serializes the actions and its related information.
  90131. * @param parent defines the object to serialize in
  90132. * @returns the serialized object
  90133. */
  90134. serialize(parent: any): any;
  90135. }
  90136. /**
  90137. * This defines an action responsible to set a property of the target
  90138. * to a desired value once triggered.
  90139. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90140. */
  90141. export class SetValueAction extends Action {
  90142. /**
  90143. * The path of the property to set in the target.
  90144. */
  90145. propertyPath: string;
  90146. /**
  90147. * The value to set in the property
  90148. */
  90149. value: any;
  90150. private _target;
  90151. private _effectiveTarget;
  90152. private _property;
  90153. /**
  90154. * Instantiate the action
  90155. * @param triggerOptions defines the trigger options
  90156. * @param target defines the object containing the property
  90157. * @param propertyPath defines the path of the property to set in the target
  90158. * @param value defines the value to set in the property
  90159. * @param condition defines the trigger related conditions
  90160. */
  90161. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90162. /** @hidden */
  90163. _prepare(): void;
  90164. /**
  90165. * Execute the action and set the targetted property to the desired value.
  90166. */
  90167. execute(): void;
  90168. /**
  90169. * Serializes the actions and its related information.
  90170. * @param parent defines the object to serialize in
  90171. * @returns the serialized object
  90172. */
  90173. serialize(parent: any): any;
  90174. }
  90175. /**
  90176. * This defines an action responsible to increment the target value
  90177. * to a desired value once triggered.
  90178. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90179. */
  90180. export class IncrementValueAction extends Action {
  90181. /**
  90182. * The path of the property to increment in the target.
  90183. */
  90184. propertyPath: string;
  90185. /**
  90186. * The value we should increment the property by.
  90187. */
  90188. value: any;
  90189. private _target;
  90190. private _effectiveTarget;
  90191. private _property;
  90192. /**
  90193. * Instantiate the action
  90194. * @param triggerOptions defines the trigger options
  90195. * @param target defines the object containing the property
  90196. * @param propertyPath defines the path of the property to increment in the target
  90197. * @param value defines the value value we should increment the property by
  90198. * @param condition defines the trigger related conditions
  90199. */
  90200. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90201. /** @hidden */
  90202. _prepare(): void;
  90203. /**
  90204. * Execute the action and increment the target of the value amount.
  90205. */
  90206. execute(): void;
  90207. /**
  90208. * Serializes the actions and its related information.
  90209. * @param parent defines the object to serialize in
  90210. * @returns the serialized object
  90211. */
  90212. serialize(parent: any): any;
  90213. }
  90214. /**
  90215. * This defines an action responsible to start an animation once triggered.
  90216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90217. */
  90218. export class PlayAnimationAction extends Action {
  90219. /**
  90220. * Where the animation should start (animation frame)
  90221. */
  90222. from: number;
  90223. /**
  90224. * Where the animation should stop (animation frame)
  90225. */
  90226. to: number;
  90227. /**
  90228. * Define if the animation should loop or stop after the first play.
  90229. */
  90230. loop?: boolean;
  90231. private _target;
  90232. /**
  90233. * Instantiate the action
  90234. * @param triggerOptions defines the trigger options
  90235. * @param target defines the target animation or animation name
  90236. * @param from defines from where the animation should start (animation frame)
  90237. * @param end defines where the animation should stop (animation frame)
  90238. * @param loop defines if the animation should loop or stop after the first play
  90239. * @param condition defines the trigger related conditions
  90240. */
  90241. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90242. /** @hidden */
  90243. _prepare(): void;
  90244. /**
  90245. * Execute the action and play the animation.
  90246. */
  90247. execute(): void;
  90248. /**
  90249. * Serializes the actions and its related information.
  90250. * @param parent defines the object to serialize in
  90251. * @returns the serialized object
  90252. */
  90253. serialize(parent: any): any;
  90254. }
  90255. /**
  90256. * This defines an action responsible to stop an animation once triggered.
  90257. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90258. */
  90259. export class StopAnimationAction extends Action {
  90260. private _target;
  90261. /**
  90262. * Instantiate the action
  90263. * @param triggerOptions defines the trigger options
  90264. * @param target defines the target animation or animation name
  90265. * @param condition defines the trigger related conditions
  90266. */
  90267. constructor(triggerOptions: any, target: any, condition?: Condition);
  90268. /** @hidden */
  90269. _prepare(): void;
  90270. /**
  90271. * Execute the action and stop the animation.
  90272. */
  90273. execute(): void;
  90274. /**
  90275. * Serializes the actions and its related information.
  90276. * @param parent defines the object to serialize in
  90277. * @returns the serialized object
  90278. */
  90279. serialize(parent: any): any;
  90280. }
  90281. /**
  90282. * This defines an action responsible that does nothing once triggered.
  90283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90284. */
  90285. export class DoNothingAction extends Action {
  90286. /**
  90287. * Instantiate the action
  90288. * @param triggerOptions defines the trigger options
  90289. * @param condition defines the trigger related conditions
  90290. */
  90291. constructor(triggerOptions?: any, condition?: Condition);
  90292. /**
  90293. * Execute the action and do nothing.
  90294. */
  90295. execute(): void;
  90296. /**
  90297. * Serializes the actions and its related information.
  90298. * @param parent defines the object to serialize in
  90299. * @returns the serialized object
  90300. */
  90301. serialize(parent: any): any;
  90302. }
  90303. /**
  90304. * This defines an action responsible to trigger several actions once triggered.
  90305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90306. */
  90307. export class CombineAction extends Action {
  90308. /**
  90309. * The list of aggregated animations to run.
  90310. */
  90311. children: Action[];
  90312. /**
  90313. * Instantiate the action
  90314. * @param triggerOptions defines the trigger options
  90315. * @param children defines the list of aggregated animations to run
  90316. * @param condition defines the trigger related conditions
  90317. */
  90318. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90319. /** @hidden */
  90320. _prepare(): void;
  90321. /**
  90322. * Execute the action and executes all the aggregated actions.
  90323. */
  90324. execute(evt: ActionEvent): void;
  90325. /**
  90326. * Serializes the actions and its related information.
  90327. * @param parent defines the object to serialize in
  90328. * @returns the serialized object
  90329. */
  90330. serialize(parent: any): any;
  90331. }
  90332. /**
  90333. * This defines an action responsible to run code (external event) once triggered.
  90334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90335. */
  90336. export class ExecuteCodeAction extends Action {
  90337. /**
  90338. * The callback function to run.
  90339. */
  90340. func: (evt: ActionEvent) => void;
  90341. /**
  90342. * Instantiate the action
  90343. * @param triggerOptions defines the trigger options
  90344. * @param func defines the callback function to run
  90345. * @param condition defines the trigger related conditions
  90346. */
  90347. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90348. /**
  90349. * Execute the action and run the attached code.
  90350. */
  90351. execute(evt: ActionEvent): void;
  90352. }
  90353. /**
  90354. * This defines an action responsible to set the parent property of the target once triggered.
  90355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90356. */
  90357. export class SetParentAction extends Action {
  90358. private _parent;
  90359. private _target;
  90360. /**
  90361. * Instantiate the action
  90362. * @param triggerOptions defines the trigger options
  90363. * @param target defines the target containing the parent property
  90364. * @param parent defines from where the animation should start (animation frame)
  90365. * @param condition defines the trigger related conditions
  90366. */
  90367. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90368. /** @hidden */
  90369. _prepare(): void;
  90370. /**
  90371. * Execute the action and set the parent property.
  90372. */
  90373. execute(): void;
  90374. /**
  90375. * Serializes the actions and its related information.
  90376. * @param parent defines the object to serialize in
  90377. * @returns the serialized object
  90378. */
  90379. serialize(parent: any): any;
  90380. }
  90381. }
  90382. declare module BABYLON {
  90383. /**
  90384. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90385. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90387. */
  90388. export class ActionManager extends AbstractActionManager {
  90389. /**
  90390. * Nothing
  90391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90392. */
  90393. static readonly NothingTrigger: number;
  90394. /**
  90395. * On pick
  90396. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90397. */
  90398. static readonly OnPickTrigger: number;
  90399. /**
  90400. * On left pick
  90401. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90402. */
  90403. static readonly OnLeftPickTrigger: number;
  90404. /**
  90405. * On right pick
  90406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90407. */
  90408. static readonly OnRightPickTrigger: number;
  90409. /**
  90410. * On center pick
  90411. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90412. */
  90413. static readonly OnCenterPickTrigger: number;
  90414. /**
  90415. * On pick down
  90416. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90417. */
  90418. static readonly OnPickDownTrigger: number;
  90419. /**
  90420. * On double pick
  90421. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90422. */
  90423. static readonly OnDoublePickTrigger: number;
  90424. /**
  90425. * On pick up
  90426. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90427. */
  90428. static readonly OnPickUpTrigger: number;
  90429. /**
  90430. * On pick out.
  90431. * This trigger will only be raised if you also declared a OnPickDown
  90432. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90433. */
  90434. static readonly OnPickOutTrigger: number;
  90435. /**
  90436. * On long press
  90437. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90438. */
  90439. static readonly OnLongPressTrigger: number;
  90440. /**
  90441. * On pointer over
  90442. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90443. */
  90444. static readonly OnPointerOverTrigger: number;
  90445. /**
  90446. * On pointer out
  90447. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90448. */
  90449. static readonly OnPointerOutTrigger: number;
  90450. /**
  90451. * On every frame
  90452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90453. */
  90454. static readonly OnEveryFrameTrigger: number;
  90455. /**
  90456. * On intersection enter
  90457. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90458. */
  90459. static readonly OnIntersectionEnterTrigger: number;
  90460. /**
  90461. * On intersection exit
  90462. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90463. */
  90464. static readonly OnIntersectionExitTrigger: number;
  90465. /**
  90466. * On key down
  90467. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90468. */
  90469. static readonly OnKeyDownTrigger: number;
  90470. /**
  90471. * On key up
  90472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90473. */
  90474. static readonly OnKeyUpTrigger: number;
  90475. private _scene;
  90476. /**
  90477. * Creates a new action manager
  90478. * @param scene defines the hosting scene
  90479. */
  90480. constructor(scene: Scene);
  90481. /**
  90482. * Releases all associated resources
  90483. */
  90484. dispose(): void;
  90485. /**
  90486. * Gets hosting scene
  90487. * @returns the hosting scene
  90488. */
  90489. getScene(): Scene;
  90490. /**
  90491. * Does this action manager handles actions of any of the given triggers
  90492. * @param triggers defines the triggers to be tested
  90493. * @return a boolean indicating whether one (or more) of the triggers is handled
  90494. */
  90495. hasSpecificTriggers(triggers: number[]): boolean;
  90496. /**
  90497. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90498. * speed.
  90499. * @param triggerA defines the trigger to be tested
  90500. * @param triggerB defines the trigger to be tested
  90501. * @return a boolean indicating whether one (or more) of the triggers is handled
  90502. */
  90503. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90504. /**
  90505. * Does this action manager handles actions of a given trigger
  90506. * @param trigger defines the trigger to be tested
  90507. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90508. * @return whether the trigger is handled
  90509. */
  90510. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90511. /**
  90512. * Does this action manager has pointer triggers
  90513. */
  90514. get hasPointerTriggers(): boolean;
  90515. /**
  90516. * Does this action manager has pick triggers
  90517. */
  90518. get hasPickTriggers(): boolean;
  90519. /**
  90520. * Registers an action to this action manager
  90521. * @param action defines the action to be registered
  90522. * @return the action amended (prepared) after registration
  90523. */
  90524. registerAction(action: IAction): Nullable<IAction>;
  90525. /**
  90526. * Unregisters an action to this action manager
  90527. * @param action defines the action to be unregistered
  90528. * @return a boolean indicating whether the action has been unregistered
  90529. */
  90530. unregisterAction(action: IAction): Boolean;
  90531. /**
  90532. * Process a specific trigger
  90533. * @param trigger defines the trigger to process
  90534. * @param evt defines the event details to be processed
  90535. */
  90536. processTrigger(trigger: number, evt?: IActionEvent): void;
  90537. /** @hidden */
  90538. _getEffectiveTarget(target: any, propertyPath: string): any;
  90539. /** @hidden */
  90540. _getProperty(propertyPath: string): string;
  90541. /**
  90542. * Serialize this manager to a JSON object
  90543. * @param name defines the property name to store this manager
  90544. * @returns a JSON representation of this manager
  90545. */
  90546. serialize(name: string): any;
  90547. /**
  90548. * Creates a new ActionManager from a JSON data
  90549. * @param parsedActions defines the JSON data to read from
  90550. * @param object defines the hosting mesh
  90551. * @param scene defines the hosting scene
  90552. */
  90553. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90554. /**
  90555. * Get a trigger name by index
  90556. * @param trigger defines the trigger index
  90557. * @returns a trigger name
  90558. */
  90559. static GetTriggerName(trigger: number): string;
  90560. }
  90561. }
  90562. declare module BABYLON {
  90563. /**
  90564. * Class used to represent a sprite
  90565. * @see https://doc.babylonjs.com/babylon101/sprites
  90566. */
  90567. export class Sprite implements IAnimatable {
  90568. /** defines the name */
  90569. name: string;
  90570. /** Gets or sets the current world position */
  90571. position: Vector3;
  90572. /** Gets or sets the main color */
  90573. color: Color4;
  90574. /** Gets or sets the width */
  90575. width: number;
  90576. /** Gets or sets the height */
  90577. height: number;
  90578. /** Gets or sets rotation angle */
  90579. angle: number;
  90580. /** Gets or sets the cell index in the sprite sheet */
  90581. cellIndex: number;
  90582. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90583. cellRef: string;
  90584. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90585. invertU: boolean;
  90586. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90587. invertV: boolean;
  90588. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90589. disposeWhenFinishedAnimating: boolean;
  90590. /** Gets the list of attached animations */
  90591. animations: Nullable<Array<Animation>>;
  90592. /** Gets or sets a boolean indicating if the sprite can be picked */
  90593. isPickable: boolean;
  90594. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90595. useAlphaForPicking: boolean;
  90596. /** @hidden */
  90597. _xOffset: number;
  90598. /** @hidden */
  90599. _yOffset: number;
  90600. /** @hidden */
  90601. _xSize: number;
  90602. /** @hidden */
  90603. _ySize: number;
  90604. /**
  90605. * Gets or sets the associated action manager
  90606. */
  90607. actionManager: Nullable<ActionManager>;
  90608. /**
  90609. * An event triggered when the control has been disposed
  90610. */
  90611. onDisposeObservable: Observable<Sprite>;
  90612. private _animationStarted;
  90613. private _loopAnimation;
  90614. private _fromIndex;
  90615. private _toIndex;
  90616. private _delay;
  90617. private _direction;
  90618. private _manager;
  90619. private _time;
  90620. private _onAnimationEnd;
  90621. /**
  90622. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90623. */
  90624. isVisible: boolean;
  90625. /**
  90626. * Gets or sets the sprite size
  90627. */
  90628. get size(): number;
  90629. set size(value: number);
  90630. /**
  90631. * Returns a boolean indicating if the animation is started
  90632. */
  90633. get animationStarted(): boolean;
  90634. /**
  90635. * Gets or sets the unique id of the sprite
  90636. */
  90637. uniqueId: number;
  90638. /**
  90639. * Gets the manager of this sprite
  90640. */
  90641. get manager(): ISpriteManager;
  90642. /**
  90643. * Creates a new Sprite
  90644. * @param name defines the name
  90645. * @param manager defines the manager
  90646. */
  90647. constructor(
  90648. /** defines the name */
  90649. name: string, manager: ISpriteManager);
  90650. /**
  90651. * Returns the string "Sprite"
  90652. * @returns "Sprite"
  90653. */
  90654. getClassName(): string;
  90655. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90656. get fromIndex(): number;
  90657. set fromIndex(value: number);
  90658. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90659. get toIndex(): number;
  90660. set toIndex(value: number);
  90661. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90662. get loopAnimation(): boolean;
  90663. set loopAnimation(value: boolean);
  90664. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90665. get delay(): number;
  90666. set delay(value: number);
  90667. /**
  90668. * Starts an animation
  90669. * @param from defines the initial key
  90670. * @param to defines the end key
  90671. * @param loop defines if the animation must loop
  90672. * @param delay defines the start delay (in ms)
  90673. * @param onAnimationEnd defines a callback to call when animation ends
  90674. */
  90675. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90676. /** Stops current animation (if any) */
  90677. stopAnimation(): void;
  90678. /** @hidden */
  90679. _animate(deltaTime: number): void;
  90680. /** Release associated resources */
  90681. dispose(): void;
  90682. /**
  90683. * Serializes the sprite to a JSON object
  90684. * @returns the JSON object
  90685. */
  90686. serialize(): any;
  90687. /**
  90688. * Parses a JSON object to create a new sprite
  90689. * @param parsedSprite The JSON object to parse
  90690. * @param manager defines the hosting manager
  90691. * @returns the new sprite
  90692. */
  90693. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90694. }
  90695. }
  90696. declare module BABYLON {
  90697. /**
  90698. * Information about the result of picking within a scene
  90699. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90700. */
  90701. export class PickingInfo {
  90702. /** @hidden */
  90703. _pickingUnavailable: boolean;
  90704. /**
  90705. * If the pick collided with an object
  90706. */
  90707. hit: boolean;
  90708. /**
  90709. * Distance away where the pick collided
  90710. */
  90711. distance: number;
  90712. /**
  90713. * The location of pick collision
  90714. */
  90715. pickedPoint: Nullable<Vector3>;
  90716. /**
  90717. * The mesh corresponding the the pick collision
  90718. */
  90719. pickedMesh: Nullable<AbstractMesh>;
  90720. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90721. bu: number;
  90722. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90723. bv: number;
  90724. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90725. faceId: number;
  90726. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90727. subMeshFaceId: number;
  90728. /** Id of the the submesh that was picked */
  90729. subMeshId: number;
  90730. /** If a sprite was picked, this will be the sprite the pick collided with */
  90731. pickedSprite: Nullable<Sprite>;
  90732. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90733. thinInstanceIndex: number;
  90734. /**
  90735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90736. */
  90737. originMesh: Nullable<AbstractMesh>;
  90738. /**
  90739. * The ray that was used to perform the picking.
  90740. */
  90741. ray: Nullable<Ray>;
  90742. /**
  90743. * Gets the normal correspodning to the face the pick collided with
  90744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90746. * @returns The normal correspodning to the face the pick collided with
  90747. */
  90748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90749. /**
  90750. * Gets the texture coordinates of where the pick occured
  90751. * @returns the vector containing the coordnates of the texture
  90752. */
  90753. getTextureCoordinates(): Nullable<Vector2>;
  90754. }
  90755. }
  90756. declare module BABYLON {
  90757. /**
  90758. * Class representing a ray with position and direction
  90759. */
  90760. export class Ray {
  90761. /** origin point */
  90762. origin: Vector3;
  90763. /** direction */
  90764. direction: Vector3;
  90765. /** length of the ray */
  90766. length: number;
  90767. private static readonly _TmpVector3;
  90768. private _tmpRay;
  90769. /**
  90770. * Creates a new ray
  90771. * @param origin origin point
  90772. * @param direction direction
  90773. * @param length length of the ray
  90774. */
  90775. constructor(
  90776. /** origin point */
  90777. origin: Vector3,
  90778. /** direction */
  90779. direction: Vector3,
  90780. /** length of the ray */
  90781. length?: number);
  90782. /**
  90783. * Checks if the ray intersects a box
  90784. * This does not account for the ray lenght by design to improve perfs.
  90785. * @param minimum bound of the box
  90786. * @param maximum bound of the box
  90787. * @param intersectionTreshold extra extend to be added to the box in all direction
  90788. * @returns if the box was hit
  90789. */
  90790. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90791. /**
  90792. * Checks if the ray intersects a box
  90793. * This does not account for the ray lenght by design to improve perfs.
  90794. * @param box the bounding box to check
  90795. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90796. * @returns if the box was hit
  90797. */
  90798. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90799. /**
  90800. * If the ray hits a sphere
  90801. * @param sphere the bounding sphere to check
  90802. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90803. * @returns true if it hits the sphere
  90804. */
  90805. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90806. /**
  90807. * If the ray hits a triange
  90808. * @param vertex0 triangle vertex
  90809. * @param vertex1 triangle vertex
  90810. * @param vertex2 triangle vertex
  90811. * @returns intersection information if hit
  90812. */
  90813. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90814. /**
  90815. * Checks if ray intersects a plane
  90816. * @param plane the plane to check
  90817. * @returns the distance away it was hit
  90818. */
  90819. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90820. /**
  90821. * Calculate the intercept of a ray on a given axis
  90822. * @param axis to check 'x' | 'y' | 'z'
  90823. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90824. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90825. */
  90826. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90827. /**
  90828. * Checks if ray intersects a mesh
  90829. * @param mesh the mesh to check
  90830. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90831. * @returns picking info of the intersecton
  90832. */
  90833. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90834. /**
  90835. * Checks if ray intersects a mesh
  90836. * @param meshes the meshes to check
  90837. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90838. * @param results array to store result in
  90839. * @returns Array of picking infos
  90840. */
  90841. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90842. private _comparePickingInfo;
  90843. private static smallnum;
  90844. private static rayl;
  90845. /**
  90846. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90847. * @param sega the first point of the segment to test the intersection against
  90848. * @param segb the second point of the segment to test the intersection against
  90849. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90850. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90851. */
  90852. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90853. /**
  90854. * Update the ray from viewport position
  90855. * @param x position
  90856. * @param y y position
  90857. * @param viewportWidth viewport width
  90858. * @param viewportHeight viewport height
  90859. * @param world world matrix
  90860. * @param view view matrix
  90861. * @param projection projection matrix
  90862. * @returns this ray updated
  90863. */
  90864. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90865. /**
  90866. * Creates a ray with origin and direction of 0,0,0
  90867. * @returns the new ray
  90868. */
  90869. static Zero(): Ray;
  90870. /**
  90871. * Creates a new ray from screen space and viewport
  90872. * @param x position
  90873. * @param y y position
  90874. * @param viewportWidth viewport width
  90875. * @param viewportHeight viewport height
  90876. * @param world world matrix
  90877. * @param view view matrix
  90878. * @param projection projection matrix
  90879. * @returns new ray
  90880. */
  90881. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90882. /**
  90883. * 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
  90884. * transformed to the given world matrix.
  90885. * @param origin The origin point
  90886. * @param end The end point
  90887. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90888. * @returns the new ray
  90889. */
  90890. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90891. /**
  90892. * Transforms a ray by a matrix
  90893. * @param ray ray to transform
  90894. * @param matrix matrix to apply
  90895. * @returns the resulting new ray
  90896. */
  90897. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90898. /**
  90899. * Transforms a ray by a matrix
  90900. * @param ray ray to transform
  90901. * @param matrix matrix to apply
  90902. * @param result ray to store result in
  90903. */
  90904. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90905. /**
  90906. * Unproject a ray from screen space to object space
  90907. * @param sourceX defines the screen space x coordinate to use
  90908. * @param sourceY defines the screen space y coordinate to use
  90909. * @param viewportWidth defines the current width of the viewport
  90910. * @param viewportHeight defines the current height of the viewport
  90911. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90912. * @param view defines the view matrix to use
  90913. * @param projection defines the projection matrix to use
  90914. */
  90915. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90916. }
  90917. /**
  90918. * Type used to define predicate used to select faces when a mesh intersection is detected
  90919. */
  90920. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90921. interface Scene {
  90922. /** @hidden */
  90923. _tempPickingRay: Nullable<Ray>;
  90924. /** @hidden */
  90925. _cachedRayForTransform: Ray;
  90926. /** @hidden */
  90927. _pickWithRayInverseMatrix: Matrix;
  90928. /** @hidden */
  90929. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90930. /** @hidden */
  90931. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90932. /** @hidden */
  90933. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90934. }
  90935. }
  90936. declare module BABYLON {
  90937. /**
  90938. * Groups all the scene component constants in one place to ease maintenance.
  90939. * @hidden
  90940. */
  90941. export class SceneComponentConstants {
  90942. static readonly NAME_EFFECTLAYER: string;
  90943. static readonly NAME_LAYER: string;
  90944. static readonly NAME_LENSFLARESYSTEM: string;
  90945. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90946. static readonly NAME_PARTICLESYSTEM: string;
  90947. static readonly NAME_GAMEPAD: string;
  90948. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90949. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90950. static readonly NAME_PREPASSRENDERER: string;
  90951. static readonly NAME_DEPTHRENDERER: string;
  90952. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90953. static readonly NAME_SPRITE: string;
  90954. static readonly NAME_SUBSURFACE: string;
  90955. static readonly NAME_OUTLINERENDERER: string;
  90956. static readonly NAME_PROCEDURALTEXTURE: string;
  90957. static readonly NAME_SHADOWGENERATOR: string;
  90958. static readonly NAME_OCTREE: string;
  90959. static readonly NAME_PHYSICSENGINE: string;
  90960. static readonly NAME_AUDIO: string;
  90961. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90962. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90963. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90964. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90965. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90966. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90967. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90968. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90969. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90970. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90971. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90972. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90973. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90974. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90975. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90976. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90977. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90978. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90979. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90980. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90981. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90982. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90983. static readonly STEP_AFTERRENDER_AUDIO: number;
  90984. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90985. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90986. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90987. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90988. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90989. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90990. static readonly STEP_POINTERMOVE_SPRITE: number;
  90991. static readonly STEP_POINTERDOWN_SPRITE: number;
  90992. static readonly STEP_POINTERUP_SPRITE: number;
  90993. }
  90994. /**
  90995. * This represents a scene component.
  90996. *
  90997. * This is used to decouple the dependency the scene is having on the different workloads like
  90998. * layers, post processes...
  90999. */
  91000. export interface ISceneComponent {
  91001. /**
  91002. * The name of the component. Each component must have a unique name.
  91003. */
  91004. name: string;
  91005. /**
  91006. * The scene the component belongs to.
  91007. */
  91008. scene: Scene;
  91009. /**
  91010. * Register the component to one instance of a scene.
  91011. */
  91012. register(): void;
  91013. /**
  91014. * Rebuilds the elements related to this component in case of
  91015. * context lost for instance.
  91016. */
  91017. rebuild(): void;
  91018. /**
  91019. * Disposes the component and the associated ressources.
  91020. */
  91021. dispose(): void;
  91022. }
  91023. /**
  91024. * This represents a SERIALIZABLE scene component.
  91025. *
  91026. * This extends Scene Component to add Serialization methods on top.
  91027. */
  91028. export interface ISceneSerializableComponent extends ISceneComponent {
  91029. /**
  91030. * Adds all the elements from the container to the scene
  91031. * @param container the container holding the elements
  91032. */
  91033. addFromContainer(container: AbstractScene): void;
  91034. /**
  91035. * Removes all the elements in the container from the scene
  91036. * @param container contains the elements to remove
  91037. * @param dispose if the removed element should be disposed (default: false)
  91038. */
  91039. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91040. /**
  91041. * Serializes the component data to the specified json object
  91042. * @param serializationObject The object to serialize to
  91043. */
  91044. serialize(serializationObject: any): void;
  91045. }
  91046. /**
  91047. * Strong typing of a Mesh related stage step action
  91048. */
  91049. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91050. /**
  91051. * Strong typing of a Evaluate Sub Mesh related stage step action
  91052. */
  91053. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91054. /**
  91055. * Strong typing of a Active Mesh related stage step action
  91056. */
  91057. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91058. /**
  91059. * Strong typing of a Camera related stage step action
  91060. */
  91061. export type CameraStageAction = (camera: Camera) => void;
  91062. /**
  91063. * Strong typing of a Camera Frame buffer related stage step action
  91064. */
  91065. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91066. /**
  91067. * Strong typing of a Render Target related stage step action
  91068. */
  91069. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91070. /**
  91071. * Strong typing of a RenderingGroup related stage step action
  91072. */
  91073. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91074. /**
  91075. * Strong typing of a Mesh Render related stage step action
  91076. */
  91077. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91078. /**
  91079. * Strong typing of a simple stage step action
  91080. */
  91081. export type SimpleStageAction = () => void;
  91082. /**
  91083. * Strong typing of a render target action.
  91084. */
  91085. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91086. /**
  91087. * Strong typing of a pointer move action.
  91088. */
  91089. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91090. /**
  91091. * Strong typing of a pointer up/down action.
  91092. */
  91093. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91094. /**
  91095. * Representation of a stage in the scene (Basically a list of ordered steps)
  91096. * @hidden
  91097. */
  91098. export class Stage<T extends Function> extends Array<{
  91099. index: number;
  91100. component: ISceneComponent;
  91101. action: T;
  91102. }> {
  91103. /**
  91104. * Hide ctor from the rest of the world.
  91105. * @param items The items to add.
  91106. */
  91107. private constructor();
  91108. /**
  91109. * Creates a new Stage.
  91110. * @returns A new instance of a Stage
  91111. */
  91112. static Create<T extends Function>(): Stage<T>;
  91113. /**
  91114. * Registers a step in an ordered way in the targeted stage.
  91115. * @param index Defines the position to register the step in
  91116. * @param component Defines the component attached to the step
  91117. * @param action Defines the action to launch during the step
  91118. */
  91119. registerStep(index: number, component: ISceneComponent, action: T): void;
  91120. /**
  91121. * Clears all the steps from the stage.
  91122. */
  91123. clear(): void;
  91124. }
  91125. }
  91126. declare module BABYLON {
  91127. interface Scene {
  91128. /** @hidden */
  91129. _pointerOverSprite: Nullable<Sprite>;
  91130. /** @hidden */
  91131. _pickedDownSprite: Nullable<Sprite>;
  91132. /** @hidden */
  91133. _tempSpritePickingRay: Nullable<Ray>;
  91134. /**
  91135. * All of the sprite managers added to this scene
  91136. * @see https://doc.babylonjs.com/babylon101/sprites
  91137. */
  91138. spriteManagers: Array<ISpriteManager>;
  91139. /**
  91140. * An event triggered when sprites rendering is about to start
  91141. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91142. */
  91143. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91144. /**
  91145. * An event triggered when sprites rendering is done
  91146. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91147. */
  91148. onAfterSpritesRenderingObservable: Observable<Scene>;
  91149. /** @hidden */
  91150. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91151. /** Launch a ray to try to pick a sprite in the scene
  91152. * @param x position on screen
  91153. * @param y position on screen
  91154. * @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
  91155. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91156. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91157. * @returns a PickingInfo
  91158. */
  91159. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91160. /** Use the given ray to pick a sprite in the scene
  91161. * @param ray The ray (in world space) to use to pick meshes
  91162. * @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
  91163. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91164. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91165. * @returns a PickingInfo
  91166. */
  91167. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91168. /** @hidden */
  91169. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91170. /** Launch a ray to try to pick sprites in the scene
  91171. * @param x position on screen
  91172. * @param y position on screen
  91173. * @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
  91174. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91175. * @returns a PickingInfo array
  91176. */
  91177. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91178. /** Use the given ray to pick sprites in the scene
  91179. * @param ray The ray (in world space) to use to pick meshes
  91180. * @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
  91181. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91182. * @returns a PickingInfo array
  91183. */
  91184. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91185. /**
  91186. * Force the sprite under the pointer
  91187. * @param sprite defines the sprite to use
  91188. */
  91189. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91190. /**
  91191. * Gets the sprite under the pointer
  91192. * @returns a Sprite or null if no sprite is under the pointer
  91193. */
  91194. getPointerOverSprite(): Nullable<Sprite>;
  91195. }
  91196. /**
  91197. * Defines the sprite scene component responsible to manage sprites
  91198. * in a given scene.
  91199. */
  91200. export class SpriteSceneComponent implements ISceneComponent {
  91201. /**
  91202. * The component name helpfull to identify the component in the list of scene components.
  91203. */
  91204. readonly name: string;
  91205. /**
  91206. * The scene the component belongs to.
  91207. */
  91208. scene: Scene;
  91209. /** @hidden */
  91210. private _spritePredicate;
  91211. /**
  91212. * Creates a new instance of the component for the given scene
  91213. * @param scene Defines the scene to register the component in
  91214. */
  91215. constructor(scene: Scene);
  91216. /**
  91217. * Registers the component in a given scene
  91218. */
  91219. register(): void;
  91220. /**
  91221. * Rebuilds the elements related to this component in case of
  91222. * context lost for instance.
  91223. */
  91224. rebuild(): void;
  91225. /**
  91226. * Disposes the component and the associated ressources.
  91227. */
  91228. dispose(): void;
  91229. private _pickSpriteButKeepRay;
  91230. private _pointerMove;
  91231. private _pointerDown;
  91232. private _pointerUp;
  91233. }
  91234. }
  91235. declare module BABYLON {
  91236. /** @hidden */
  91237. export var fogFragmentDeclaration: {
  91238. name: string;
  91239. shader: string;
  91240. };
  91241. }
  91242. declare module BABYLON {
  91243. /** @hidden */
  91244. export var fogFragment: {
  91245. name: string;
  91246. shader: string;
  91247. };
  91248. }
  91249. declare module BABYLON {
  91250. /** @hidden */
  91251. export var spritesPixelShader: {
  91252. name: string;
  91253. shader: string;
  91254. };
  91255. }
  91256. declare module BABYLON {
  91257. /** @hidden */
  91258. export var fogVertexDeclaration: {
  91259. name: string;
  91260. shader: string;
  91261. };
  91262. }
  91263. declare module BABYLON {
  91264. /** @hidden */
  91265. export var spritesVertexShader: {
  91266. name: string;
  91267. shader: string;
  91268. };
  91269. }
  91270. declare module BABYLON {
  91271. /**
  91272. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91273. */
  91274. export interface ISpriteManager extends IDisposable {
  91275. /**
  91276. * Gets manager's name
  91277. */
  91278. name: string;
  91279. /**
  91280. * Restricts the camera to viewing objects with the same layerMask.
  91281. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91282. */
  91283. layerMask: number;
  91284. /**
  91285. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91286. */
  91287. isPickable: boolean;
  91288. /**
  91289. * Gets the hosting scene
  91290. */
  91291. scene: Scene;
  91292. /**
  91293. * Specifies the rendering group id for this mesh (0 by default)
  91294. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91295. */
  91296. renderingGroupId: number;
  91297. /**
  91298. * Defines the list of sprites managed by the manager.
  91299. */
  91300. sprites: Array<Sprite>;
  91301. /**
  91302. * Gets or sets the spritesheet texture
  91303. */
  91304. texture: Texture;
  91305. /** Defines the default width of a cell in the spritesheet */
  91306. cellWidth: number;
  91307. /** Defines the default height of a cell in the spritesheet */
  91308. cellHeight: number;
  91309. /**
  91310. * Tests the intersection of a sprite with a specific ray.
  91311. * @param ray The ray we are sending to test the collision
  91312. * @param camera The camera space we are sending rays in
  91313. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91314. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91315. * @returns picking info or null.
  91316. */
  91317. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91318. /**
  91319. * Intersects the sprites with a ray
  91320. * @param ray defines the ray to intersect with
  91321. * @param camera defines the current active camera
  91322. * @param predicate defines a predicate used to select candidate sprites
  91323. * @returns null if no hit or a PickingInfo array
  91324. */
  91325. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91326. /**
  91327. * Renders the list of sprites on screen.
  91328. */
  91329. render(): void;
  91330. }
  91331. /**
  91332. * Class used to manage multiple sprites on the same spritesheet
  91333. * @see https://doc.babylonjs.com/babylon101/sprites
  91334. */
  91335. export class SpriteManager implements ISpriteManager {
  91336. /** defines the manager's name */
  91337. name: string;
  91338. /** Define the Url to load snippets */
  91339. static SnippetUrl: string;
  91340. /** Snippet ID if the manager was created from the snippet server */
  91341. snippetId: string;
  91342. /** Gets the list of sprites */
  91343. sprites: Sprite[];
  91344. /** Gets or sets the rendering group id (0 by default) */
  91345. renderingGroupId: number;
  91346. /** Gets or sets camera layer mask */
  91347. layerMask: number;
  91348. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91349. fogEnabled: boolean;
  91350. /** Gets or sets a boolean indicating if the sprites are pickable */
  91351. isPickable: boolean;
  91352. /** Defines the default width of a cell in the spritesheet */
  91353. cellWidth: number;
  91354. /** Defines the default height of a cell in the spritesheet */
  91355. cellHeight: number;
  91356. /** Associative array from JSON sprite data file */
  91357. private _cellData;
  91358. /** Array of sprite names from JSON sprite data file */
  91359. private _spriteMap;
  91360. /** True when packed cell data from JSON file is ready*/
  91361. private _packedAndReady;
  91362. private _textureContent;
  91363. private _useInstancing;
  91364. /**
  91365. * An event triggered when the manager is disposed.
  91366. */
  91367. onDisposeObservable: Observable<SpriteManager>;
  91368. private _onDisposeObserver;
  91369. /**
  91370. * Callback called when the manager is disposed
  91371. */
  91372. set onDispose(callback: () => void);
  91373. private _capacity;
  91374. private _fromPacked;
  91375. private _spriteTexture;
  91376. private _epsilon;
  91377. private _scene;
  91378. private _vertexData;
  91379. private _buffer;
  91380. private _vertexBuffers;
  91381. private _spriteBuffer;
  91382. private _indexBuffer;
  91383. private _effectBase;
  91384. private _effectFog;
  91385. private _vertexBufferSize;
  91386. /**
  91387. * Gets or sets the unique id of the sprite
  91388. */
  91389. uniqueId: number;
  91390. /**
  91391. * Gets the array of sprites
  91392. */
  91393. get children(): Sprite[];
  91394. /**
  91395. * Gets the hosting scene
  91396. */
  91397. get scene(): Scene;
  91398. /**
  91399. * Gets the capacity of the manager
  91400. */
  91401. get capacity(): number;
  91402. /**
  91403. * Gets or sets the spritesheet texture
  91404. */
  91405. get texture(): Texture;
  91406. set texture(value: Texture);
  91407. private _blendMode;
  91408. /**
  91409. * Blend mode use to render the particle, it can be any of
  91410. * the static Constants.ALPHA_x properties provided in this class.
  91411. * Default value is Constants.ALPHA_COMBINE
  91412. */
  91413. get blendMode(): number;
  91414. set blendMode(blendMode: number);
  91415. /** Disables writing to the depth buffer when rendering the sprites.
  91416. * It can be handy to disable depth writing when using textures without alpha channel
  91417. * and setting some specific blend modes.
  91418. */
  91419. disableDepthWrite: boolean;
  91420. /**
  91421. * Creates a new sprite manager
  91422. * @param name defines the manager's name
  91423. * @param imgUrl defines the sprite sheet url
  91424. * @param capacity defines the maximum allowed number of sprites
  91425. * @param cellSize defines the size of a sprite cell
  91426. * @param scene defines the hosting scene
  91427. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91428. * @param samplingMode defines the smapling mode to use with spritesheet
  91429. * @param fromPacked set to false; do not alter
  91430. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91431. */
  91432. constructor(
  91433. /** defines the manager's name */
  91434. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91435. /**
  91436. * Returns the string "SpriteManager"
  91437. * @returns "SpriteManager"
  91438. */
  91439. getClassName(): string;
  91440. private _makePacked;
  91441. private _appendSpriteVertex;
  91442. private _checkTextureAlpha;
  91443. /**
  91444. * Intersects the sprites with a ray
  91445. * @param ray defines the ray to intersect with
  91446. * @param camera defines the current active camera
  91447. * @param predicate defines a predicate used to select candidate sprites
  91448. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91449. * @returns null if no hit or a PickingInfo
  91450. */
  91451. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91452. /**
  91453. * Intersects the sprites with a ray
  91454. * @param ray defines the ray to intersect with
  91455. * @param camera defines the current active camera
  91456. * @param predicate defines a predicate used to select candidate sprites
  91457. * @returns null if no hit or a PickingInfo array
  91458. */
  91459. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91460. /**
  91461. * Render all child sprites
  91462. */
  91463. render(): void;
  91464. /**
  91465. * Release associated resources
  91466. */
  91467. dispose(): void;
  91468. /**
  91469. * Serializes the sprite manager to a JSON object
  91470. * @param serializeTexture defines if the texture must be serialized as well
  91471. * @returns the JSON object
  91472. */
  91473. serialize(serializeTexture?: boolean): any;
  91474. /**
  91475. * Parses a JSON object to create a new sprite manager.
  91476. * @param parsedManager The JSON object to parse
  91477. * @param scene The scene to create the sprite managerin
  91478. * @param rootUrl The root url to use to load external dependencies like texture
  91479. * @returns the new sprite manager
  91480. */
  91481. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91482. /**
  91483. * Creates a sprite manager from a snippet saved in a remote file
  91484. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91485. * @param url defines the url to load from
  91486. * @param scene defines the hosting scene
  91487. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91488. * @returns a promise that will resolve to the new sprite manager
  91489. */
  91490. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91491. /**
  91492. * Creates a sprite manager from a snippet saved by the sprite editor
  91493. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91494. * @param scene defines the hosting scene
  91495. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91496. * @returns a promise that will resolve to the new sprite manager
  91497. */
  91498. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91499. }
  91500. }
  91501. declare module BABYLON {
  91502. /** Interface used by value gradients (color, factor, ...) */
  91503. export interface IValueGradient {
  91504. /**
  91505. * Gets or sets the gradient value (between 0 and 1)
  91506. */
  91507. gradient: number;
  91508. }
  91509. /** Class used to store color4 gradient */
  91510. export class ColorGradient implements IValueGradient {
  91511. /**
  91512. * Gets or sets the gradient value (between 0 and 1)
  91513. */
  91514. gradient: number;
  91515. /**
  91516. * Gets or sets first associated color
  91517. */
  91518. color1: Color4;
  91519. /**
  91520. * Gets or sets second associated color
  91521. */
  91522. color2?: Color4 | undefined;
  91523. /**
  91524. * Creates a new color4 gradient
  91525. * @param gradient gets or sets the gradient value (between 0 and 1)
  91526. * @param color1 gets or sets first associated color
  91527. * @param color2 gets or sets first second color
  91528. */
  91529. constructor(
  91530. /**
  91531. * Gets or sets the gradient value (between 0 and 1)
  91532. */
  91533. gradient: number,
  91534. /**
  91535. * Gets or sets first associated color
  91536. */
  91537. color1: Color4,
  91538. /**
  91539. * Gets or sets second associated color
  91540. */
  91541. color2?: Color4 | undefined);
  91542. /**
  91543. * Will get a color picked randomly between color1 and color2.
  91544. * If color2 is undefined then color1 will be used
  91545. * @param result defines the target Color4 to store the result in
  91546. */
  91547. getColorToRef(result: Color4): void;
  91548. }
  91549. /** Class used to store color 3 gradient */
  91550. export class Color3Gradient implements IValueGradient {
  91551. /**
  91552. * Gets or sets the gradient value (between 0 and 1)
  91553. */
  91554. gradient: number;
  91555. /**
  91556. * Gets or sets the associated color
  91557. */
  91558. color: Color3;
  91559. /**
  91560. * Creates a new color3 gradient
  91561. * @param gradient gets or sets the gradient value (between 0 and 1)
  91562. * @param color gets or sets associated color
  91563. */
  91564. constructor(
  91565. /**
  91566. * Gets or sets the gradient value (between 0 and 1)
  91567. */
  91568. gradient: number,
  91569. /**
  91570. * Gets or sets the associated color
  91571. */
  91572. color: Color3);
  91573. }
  91574. /** Class used to store factor gradient */
  91575. export class FactorGradient implements IValueGradient {
  91576. /**
  91577. * Gets or sets the gradient value (between 0 and 1)
  91578. */
  91579. gradient: number;
  91580. /**
  91581. * Gets or sets first associated factor
  91582. */
  91583. factor1: number;
  91584. /**
  91585. * Gets or sets second associated factor
  91586. */
  91587. factor2?: number | undefined;
  91588. /**
  91589. * Creates a new factor gradient
  91590. * @param gradient gets or sets the gradient value (between 0 and 1)
  91591. * @param factor1 gets or sets first associated factor
  91592. * @param factor2 gets or sets second associated factor
  91593. */
  91594. constructor(
  91595. /**
  91596. * Gets or sets the gradient value (between 0 and 1)
  91597. */
  91598. gradient: number,
  91599. /**
  91600. * Gets or sets first associated factor
  91601. */
  91602. factor1: number,
  91603. /**
  91604. * Gets or sets second associated factor
  91605. */
  91606. factor2?: number | undefined);
  91607. /**
  91608. * Will get a number picked randomly between factor1 and factor2.
  91609. * If factor2 is undefined then factor1 will be used
  91610. * @returns the picked number
  91611. */
  91612. getFactor(): number;
  91613. }
  91614. /**
  91615. * Helper used to simplify some generic gradient tasks
  91616. */
  91617. export class GradientHelper {
  91618. /**
  91619. * Gets the current gradient from an array of IValueGradient
  91620. * @param ratio defines the current ratio to get
  91621. * @param gradients defines the array of IValueGradient
  91622. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91623. */
  91624. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91625. }
  91626. }
  91627. declare module BABYLON {
  91628. interface ThinEngine {
  91629. /**
  91630. * Creates a raw texture
  91631. * @param data defines the data to store in the texture
  91632. * @param width defines the width of the texture
  91633. * @param height defines the height of the texture
  91634. * @param format defines the format of the data
  91635. * @param generateMipMaps defines if the engine should generate the mip levels
  91636. * @param invertY defines if data must be stored with Y axis inverted
  91637. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91638. * @param compression defines the compression used (null by default)
  91639. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91640. * @returns the raw texture inside an InternalTexture
  91641. */
  91642. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91643. /**
  91644. * Update a raw texture
  91645. * @param texture defines the texture to update
  91646. * @param data defines the data to store in the texture
  91647. * @param format defines the format of the data
  91648. * @param invertY defines if data must be stored with Y axis inverted
  91649. */
  91650. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91651. /**
  91652. * Update a raw texture
  91653. * @param texture defines the texture to update
  91654. * @param data defines the data to store in the texture
  91655. * @param format defines the format of the data
  91656. * @param invertY defines if data must be stored with Y axis inverted
  91657. * @param compression defines the compression used (null by default)
  91658. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91659. */
  91660. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91661. /**
  91662. * Creates a new raw cube texture
  91663. * @param data defines the array of data to use to create each face
  91664. * @param size defines the size of the textures
  91665. * @param format defines the format of the data
  91666. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91667. * @param generateMipMaps defines if the engine should generate the mip levels
  91668. * @param invertY defines if data must be stored with Y axis inverted
  91669. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91670. * @param compression defines the compression used (null by default)
  91671. * @returns the cube texture as an InternalTexture
  91672. */
  91673. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91674. /**
  91675. * Update a raw cube texture
  91676. * @param texture defines the texture to udpdate
  91677. * @param data defines the data to store
  91678. * @param format defines the data format
  91679. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91680. * @param invertY defines if data must be stored with Y axis inverted
  91681. */
  91682. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91683. /**
  91684. * Update a raw cube texture
  91685. * @param texture defines the texture to udpdate
  91686. * @param data defines the data to store
  91687. * @param format defines the data format
  91688. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91689. * @param invertY defines if data must be stored with Y axis inverted
  91690. * @param compression defines the compression used (null by default)
  91691. */
  91692. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91693. /**
  91694. * Update a raw cube texture
  91695. * @param texture defines the texture to udpdate
  91696. * @param data defines the data to store
  91697. * @param format defines the data format
  91698. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91699. * @param invertY defines if data must be stored with Y axis inverted
  91700. * @param compression defines the compression used (null by default)
  91701. * @param level defines which level of the texture to update
  91702. */
  91703. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91704. /**
  91705. * Creates a new raw cube texture from a specified url
  91706. * @param url defines the url where the data is located
  91707. * @param scene defines the current scene
  91708. * @param size defines the size of the textures
  91709. * @param format defines the format of the data
  91710. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91711. * @param noMipmap defines if the engine should avoid generating the mip levels
  91712. * @param callback defines a callback used to extract texture data from loaded data
  91713. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91714. * @param onLoad defines a callback called when texture is loaded
  91715. * @param onError defines a callback called if there is an error
  91716. * @returns the cube texture as an InternalTexture
  91717. */
  91718. 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;
  91719. /**
  91720. * Creates a new raw cube texture from a specified url
  91721. * @param url defines the url where the data is located
  91722. * @param scene defines the current scene
  91723. * @param size defines the size of the textures
  91724. * @param format defines the format of the data
  91725. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91726. * @param noMipmap defines if the engine should avoid generating the mip levels
  91727. * @param callback defines a callback used to extract texture data from loaded data
  91728. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91729. * @param onLoad defines a callback called when texture is loaded
  91730. * @param onError defines a callback called if there is an error
  91731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91732. * @param invertY defines if data must be stored with Y axis inverted
  91733. * @returns the cube texture as an InternalTexture
  91734. */
  91735. 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;
  91736. /**
  91737. * Creates a new raw 3D texture
  91738. * @param data defines the data used to create the texture
  91739. * @param width defines the width of the texture
  91740. * @param height defines the height of the texture
  91741. * @param depth defines the depth of the texture
  91742. * @param format defines the format of the texture
  91743. * @param generateMipMaps defines if the engine must generate mip levels
  91744. * @param invertY defines if data must be stored with Y axis inverted
  91745. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91746. * @param compression defines the compressed used (can be null)
  91747. * @param textureType defines the compressed used (can be null)
  91748. * @returns a new raw 3D texture (stored in an InternalTexture)
  91749. */
  91750. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91751. /**
  91752. * Update a raw 3D texture
  91753. * @param texture defines the texture to update
  91754. * @param data defines the data to store
  91755. * @param format defines the data format
  91756. * @param invertY defines if data must be stored with Y axis inverted
  91757. */
  91758. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91759. /**
  91760. * Update a raw 3D texture
  91761. * @param texture defines the texture to update
  91762. * @param data defines the data to store
  91763. * @param format defines the data format
  91764. * @param invertY defines if data must be stored with Y axis inverted
  91765. * @param compression defines the used compression (can be null)
  91766. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91767. */
  91768. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91769. /**
  91770. * Creates a new raw 2D array texture
  91771. * @param data defines the data used to create the texture
  91772. * @param width defines the width of the texture
  91773. * @param height defines the height of the texture
  91774. * @param depth defines the number of layers of the texture
  91775. * @param format defines the format of the texture
  91776. * @param generateMipMaps defines if the engine must generate mip levels
  91777. * @param invertY defines if data must be stored with Y axis inverted
  91778. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91779. * @param compression defines the compressed used (can be null)
  91780. * @param textureType defines the compressed used (can be null)
  91781. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91782. */
  91783. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91784. /**
  91785. * Update a raw 2D array texture
  91786. * @param texture defines the texture to update
  91787. * @param data defines the data to store
  91788. * @param format defines the data format
  91789. * @param invertY defines if data must be stored with Y axis inverted
  91790. */
  91791. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91792. /**
  91793. * Update a raw 2D array texture
  91794. * @param texture defines the texture to update
  91795. * @param data defines the data to store
  91796. * @param format defines the data format
  91797. * @param invertY defines if data must be stored with Y axis inverted
  91798. * @param compression defines the used compression (can be null)
  91799. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91800. */
  91801. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91802. }
  91803. }
  91804. declare module BABYLON {
  91805. /**
  91806. * Raw texture can help creating a texture directly from an array of data.
  91807. * This can be super useful if you either get the data from an uncompressed source or
  91808. * if you wish to create your texture pixel by pixel.
  91809. */
  91810. export class RawTexture extends Texture {
  91811. /**
  91812. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91813. */
  91814. format: number;
  91815. /**
  91816. * Instantiates a new RawTexture.
  91817. * Raw texture can help creating a texture directly from an array of data.
  91818. * This can be super useful if you either get the data from an uncompressed source or
  91819. * if you wish to create your texture pixel by pixel.
  91820. * @param data define the array of data to use to create the texture
  91821. * @param width define the width of the texture
  91822. * @param height define the height of the texture
  91823. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91824. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91825. * @param generateMipMaps define whether mip maps should be generated or not
  91826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91828. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91829. */
  91830. constructor(data: ArrayBufferView, width: number, height: number,
  91831. /**
  91832. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91833. */
  91834. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91835. /**
  91836. * Updates the texture underlying data.
  91837. * @param data Define the new data of the texture
  91838. */
  91839. update(data: ArrayBufferView): void;
  91840. /**
  91841. * Creates a luminance texture from some data.
  91842. * @param data Define the texture data
  91843. * @param width Define the width of the texture
  91844. * @param height Define the height of the texture
  91845. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91846. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91847. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91848. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91849. * @returns the luminance texture
  91850. */
  91851. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91852. /**
  91853. * Creates a luminance alpha texture from some data.
  91854. * @param data Define the texture data
  91855. * @param width Define the width of the texture
  91856. * @param height Define the height of the texture
  91857. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91861. * @returns the luminance alpha texture
  91862. */
  91863. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91864. /**
  91865. * Creates an alpha texture from some data.
  91866. * @param data Define the texture data
  91867. * @param width Define the width of the texture
  91868. * @param height Define the height of the texture
  91869. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91870. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91871. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91872. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91873. * @returns the alpha texture
  91874. */
  91875. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91876. /**
  91877. * Creates a RGB texture from some data.
  91878. * @param data Define the texture data
  91879. * @param width Define the width of the texture
  91880. * @param height Define the height of the texture
  91881. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91885. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91886. * @returns the RGB alpha texture
  91887. */
  91888. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91889. /**
  91890. * Creates a RGBA texture from some data.
  91891. * @param data Define the texture data
  91892. * @param width Define the width of the texture
  91893. * @param height Define the height of the texture
  91894. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91898. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91899. * @returns the RGBA texture
  91900. */
  91901. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91902. /**
  91903. * Creates a R texture from some data.
  91904. * @param data Define the texture data
  91905. * @param width Define the width of the texture
  91906. * @param height Define the height of the texture
  91907. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91911. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91912. * @returns the R texture
  91913. */
  91914. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91915. }
  91916. }
  91917. declare module BABYLON {
  91918. interface ThinEngine {
  91919. /**
  91920. * Update a dynamic index buffer
  91921. * @param indexBuffer defines the target index buffer
  91922. * @param indices defines the data to update
  91923. * @param offset defines the offset in the target index buffer where update should start
  91924. */
  91925. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91926. /**
  91927. * Updates a dynamic vertex buffer.
  91928. * @param vertexBuffer the vertex buffer to update
  91929. * @param data the data used to update the vertex buffer
  91930. * @param byteOffset the byte offset of the data
  91931. * @param byteLength the byte length of the data
  91932. */
  91933. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91934. }
  91935. }
  91936. declare module BABYLON {
  91937. interface AbstractScene {
  91938. /**
  91939. * The list of procedural textures added to the scene
  91940. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91941. */
  91942. proceduralTextures: Array<ProceduralTexture>;
  91943. }
  91944. /**
  91945. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91946. * in a given scene.
  91947. */
  91948. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91949. /**
  91950. * The component name helpfull to identify the component in the list of scene components.
  91951. */
  91952. readonly name: string;
  91953. /**
  91954. * The scene the component belongs to.
  91955. */
  91956. scene: Scene;
  91957. /**
  91958. * Creates a new instance of the component for the given scene
  91959. * @param scene Defines the scene to register the component in
  91960. */
  91961. constructor(scene: Scene);
  91962. /**
  91963. * Registers the component in a given scene
  91964. */
  91965. register(): void;
  91966. /**
  91967. * Rebuilds the elements related to this component in case of
  91968. * context lost for instance.
  91969. */
  91970. rebuild(): void;
  91971. /**
  91972. * Disposes the component and the associated ressources.
  91973. */
  91974. dispose(): void;
  91975. private _beforeClear;
  91976. }
  91977. }
  91978. declare module BABYLON {
  91979. interface ThinEngine {
  91980. /**
  91981. * Creates a new render target cube texture
  91982. * @param size defines the size of the texture
  91983. * @param options defines the options used to create the texture
  91984. * @returns a new render target cube texture stored in an InternalTexture
  91985. */
  91986. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91987. }
  91988. }
  91989. declare module BABYLON {
  91990. /** @hidden */
  91991. export var proceduralVertexShader: {
  91992. name: string;
  91993. shader: string;
  91994. };
  91995. }
  91996. declare module BABYLON {
  91997. /**
  91998. * 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.
  91999. * This is the base class of any Procedural texture and contains most of the shareable code.
  92000. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92001. */
  92002. export class ProceduralTexture extends Texture {
  92003. /**
  92004. * Define if the texture is enabled or not (disabled texture will not render)
  92005. */
  92006. isEnabled: boolean;
  92007. /**
  92008. * Define if the texture must be cleared before rendering (default is true)
  92009. */
  92010. autoClear: boolean;
  92011. /**
  92012. * Callback called when the texture is generated
  92013. */
  92014. onGenerated: () => void;
  92015. /**
  92016. * Event raised when the texture is generated
  92017. */
  92018. onGeneratedObservable: Observable<ProceduralTexture>;
  92019. /**
  92020. * Event raised before the texture is generated
  92021. */
  92022. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92023. /**
  92024. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92025. */
  92026. nodeMaterialSource: Nullable<NodeMaterial>;
  92027. /** @hidden */
  92028. _generateMipMaps: boolean;
  92029. /** @hidden **/
  92030. _effect: Effect;
  92031. /** @hidden */
  92032. _textures: {
  92033. [key: string]: Texture;
  92034. };
  92035. /** @hidden */
  92036. protected _fallbackTexture: Nullable<Texture>;
  92037. private _size;
  92038. private _currentRefreshId;
  92039. private _frameId;
  92040. private _refreshRate;
  92041. private _vertexBuffers;
  92042. private _indexBuffer;
  92043. private _uniforms;
  92044. private _samplers;
  92045. private _fragment;
  92046. private _floats;
  92047. private _ints;
  92048. private _floatsArrays;
  92049. private _colors3;
  92050. private _colors4;
  92051. private _vectors2;
  92052. private _vectors3;
  92053. private _matrices;
  92054. private _fallbackTextureUsed;
  92055. private _fullEngine;
  92056. private _cachedDefines;
  92057. private _contentUpdateId;
  92058. private _contentData;
  92059. /**
  92060. * Instantiates a new procedural texture.
  92061. * 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.
  92062. * This is the base class of any Procedural texture and contains most of the shareable code.
  92063. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92064. * @param name Define the name of the texture
  92065. * @param size Define the size of the texture to create
  92066. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92067. * @param scene Define the scene the texture belongs to
  92068. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92069. * @param generateMipMaps Define if the texture should creates mip maps or not
  92070. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92071. */
  92072. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92073. /**
  92074. * The effect that is created when initializing the post process.
  92075. * @returns The created effect corresponding the the postprocess.
  92076. */
  92077. getEffect(): Effect;
  92078. /**
  92079. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92080. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92081. */
  92082. getContent(): Nullable<ArrayBufferView>;
  92083. private _createIndexBuffer;
  92084. /** @hidden */
  92085. _rebuild(): void;
  92086. /**
  92087. * Resets the texture in order to recreate its associated resources.
  92088. * This can be called in case of context loss
  92089. */
  92090. reset(): void;
  92091. protected _getDefines(): string;
  92092. /**
  92093. * Is the texture ready to be used ? (rendered at least once)
  92094. * @returns true if ready, otherwise, false.
  92095. */
  92096. isReady(): boolean;
  92097. /**
  92098. * Resets the refresh counter of the texture and start bak from scratch.
  92099. * Could be useful to regenerate the texture if it is setup to render only once.
  92100. */
  92101. resetRefreshCounter(): void;
  92102. /**
  92103. * Set the fragment shader to use in order to render the texture.
  92104. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92105. */
  92106. setFragment(fragment: any): void;
  92107. /**
  92108. * Define the refresh rate of the texture or the rendering frequency.
  92109. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92110. */
  92111. get refreshRate(): number;
  92112. set refreshRate(value: number);
  92113. /** @hidden */
  92114. _shouldRender(): boolean;
  92115. /**
  92116. * Get the size the texture is rendering at.
  92117. * @returns the size (on cube texture it is always squared)
  92118. */
  92119. getRenderSize(): RenderTargetTextureSize;
  92120. /**
  92121. * Resize the texture to new value.
  92122. * @param size Define the new size the texture should have
  92123. * @param generateMipMaps Define whether the new texture should create mip maps
  92124. */
  92125. resize(size: number, generateMipMaps: boolean): void;
  92126. private _checkUniform;
  92127. /**
  92128. * Set a texture in the shader program used to render.
  92129. * @param name Define the name of the uniform samplers as defined in the shader
  92130. * @param texture Define the texture to bind to this sampler
  92131. * @return the texture itself allowing "fluent" like uniform updates
  92132. */
  92133. setTexture(name: string, texture: Texture): ProceduralTexture;
  92134. /**
  92135. * Set a float in the shader.
  92136. * @param name Define the name of the uniform as defined in the shader
  92137. * @param value Define the value to give to the uniform
  92138. * @return the texture itself allowing "fluent" like uniform updates
  92139. */
  92140. setFloat(name: string, value: number): ProceduralTexture;
  92141. /**
  92142. * Set a int in the shader.
  92143. * @param name Define the name of the uniform as defined in the shader
  92144. * @param value Define the value to give to the uniform
  92145. * @return the texture itself allowing "fluent" like uniform updates
  92146. */
  92147. setInt(name: string, value: number): ProceduralTexture;
  92148. /**
  92149. * Set an array of floats in the shader.
  92150. * @param name Define the name of the uniform as defined in the shader
  92151. * @param value Define the value to give to the uniform
  92152. * @return the texture itself allowing "fluent" like uniform updates
  92153. */
  92154. setFloats(name: string, value: number[]): ProceduralTexture;
  92155. /**
  92156. * Set a vec3 in the shader from a Color3.
  92157. * @param name Define the name of the uniform as defined in the shader
  92158. * @param value Define the value to give to the uniform
  92159. * @return the texture itself allowing "fluent" like uniform updates
  92160. */
  92161. setColor3(name: string, value: Color3): ProceduralTexture;
  92162. /**
  92163. * Set a vec4 in the shader from a Color4.
  92164. * @param name Define the name of the uniform as defined in the shader
  92165. * @param value Define the value to give to the uniform
  92166. * @return the texture itself allowing "fluent" like uniform updates
  92167. */
  92168. setColor4(name: string, value: Color4): ProceduralTexture;
  92169. /**
  92170. * Set a vec2 in the shader from a Vector2.
  92171. * @param name Define the name of the uniform as defined in the shader
  92172. * @param value Define the value to give to the uniform
  92173. * @return the texture itself allowing "fluent" like uniform updates
  92174. */
  92175. setVector2(name: string, value: Vector2): ProceduralTexture;
  92176. /**
  92177. * Set a vec3 in the shader from a Vector3.
  92178. * @param name Define the name of the uniform as defined in the shader
  92179. * @param value Define the value to give to the uniform
  92180. * @return the texture itself allowing "fluent" like uniform updates
  92181. */
  92182. setVector3(name: string, value: Vector3): ProceduralTexture;
  92183. /**
  92184. * Set a mat4 in the shader from a MAtrix.
  92185. * @param name Define the name of the uniform as defined in the shader
  92186. * @param value Define the value to give to the uniform
  92187. * @return the texture itself allowing "fluent" like uniform updates
  92188. */
  92189. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92190. /**
  92191. * Render the texture to its associated render target.
  92192. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92193. */
  92194. render(useCameraPostProcess?: boolean): void;
  92195. /**
  92196. * Clone the texture.
  92197. * @returns the cloned texture
  92198. */
  92199. clone(): ProceduralTexture;
  92200. /**
  92201. * Dispose the texture and release its asoociated resources.
  92202. */
  92203. dispose(): void;
  92204. }
  92205. }
  92206. declare module BABYLON {
  92207. /**
  92208. * This represents the base class for particle system in Babylon.
  92209. * 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.
  92210. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92211. * @example https://doc.babylonjs.com/babylon101/particles
  92212. */
  92213. export class BaseParticleSystem {
  92214. /**
  92215. * Source color is added to the destination color without alpha affecting the result
  92216. */
  92217. static BLENDMODE_ONEONE: number;
  92218. /**
  92219. * Blend current color and particle color using particle’s alpha
  92220. */
  92221. static BLENDMODE_STANDARD: number;
  92222. /**
  92223. * Add current color and particle color multiplied by particle’s alpha
  92224. */
  92225. static BLENDMODE_ADD: number;
  92226. /**
  92227. * Multiply current color with particle color
  92228. */
  92229. static BLENDMODE_MULTIPLY: number;
  92230. /**
  92231. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92232. */
  92233. static BLENDMODE_MULTIPLYADD: number;
  92234. /**
  92235. * List of animations used by the particle system.
  92236. */
  92237. animations: Animation[];
  92238. /**
  92239. * Gets or sets the unique id of the particle system
  92240. */
  92241. uniqueId: number;
  92242. /**
  92243. * The id of the Particle system.
  92244. */
  92245. id: string;
  92246. /**
  92247. * The friendly name of the Particle system.
  92248. */
  92249. name: string;
  92250. /**
  92251. * Snippet ID if the particle system was created from the snippet server
  92252. */
  92253. snippetId: string;
  92254. /**
  92255. * The rendering group used by the Particle system to chose when to render.
  92256. */
  92257. renderingGroupId: number;
  92258. /**
  92259. * The emitter represents the Mesh or position we are attaching the particle system to.
  92260. */
  92261. emitter: Nullable<AbstractMesh | Vector3>;
  92262. /**
  92263. * The maximum number of particles to emit per frame
  92264. */
  92265. emitRate: number;
  92266. /**
  92267. * If you want to launch only a few particles at once, that can be done, as well.
  92268. */
  92269. manualEmitCount: number;
  92270. /**
  92271. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92272. */
  92273. updateSpeed: number;
  92274. /**
  92275. * The amount of time the particle system is running (depends of the overall update speed).
  92276. */
  92277. targetStopDuration: number;
  92278. /**
  92279. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92280. */
  92281. disposeOnStop: boolean;
  92282. /**
  92283. * Minimum power of emitting particles.
  92284. */
  92285. minEmitPower: number;
  92286. /**
  92287. * Maximum power of emitting particles.
  92288. */
  92289. maxEmitPower: number;
  92290. /**
  92291. * Minimum life time of emitting particles.
  92292. */
  92293. minLifeTime: number;
  92294. /**
  92295. * Maximum life time of emitting particles.
  92296. */
  92297. maxLifeTime: number;
  92298. /**
  92299. * Minimum Size of emitting particles.
  92300. */
  92301. minSize: number;
  92302. /**
  92303. * Maximum Size of emitting particles.
  92304. */
  92305. maxSize: number;
  92306. /**
  92307. * Minimum scale of emitting particles on X axis.
  92308. */
  92309. minScaleX: number;
  92310. /**
  92311. * Maximum scale of emitting particles on X axis.
  92312. */
  92313. maxScaleX: number;
  92314. /**
  92315. * Minimum scale of emitting particles on Y axis.
  92316. */
  92317. minScaleY: number;
  92318. /**
  92319. * Maximum scale of emitting particles on Y axis.
  92320. */
  92321. maxScaleY: number;
  92322. /**
  92323. * Gets or sets the minimal initial rotation in radians.
  92324. */
  92325. minInitialRotation: number;
  92326. /**
  92327. * Gets or sets the maximal initial rotation in radians.
  92328. */
  92329. maxInitialRotation: number;
  92330. /**
  92331. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92332. */
  92333. minAngularSpeed: number;
  92334. /**
  92335. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92336. */
  92337. maxAngularSpeed: number;
  92338. /**
  92339. * The texture used to render each particle. (this can be a spritesheet)
  92340. */
  92341. particleTexture: Nullable<BaseTexture>;
  92342. /**
  92343. * The layer mask we are rendering the particles through.
  92344. */
  92345. layerMask: number;
  92346. /**
  92347. * This can help using your own shader to render the particle system.
  92348. * The according effect will be created
  92349. */
  92350. customShader: any;
  92351. /**
  92352. * By default particle system starts as soon as they are created. This prevents the
  92353. * automatic start to happen and let you decide when to start emitting particles.
  92354. */
  92355. preventAutoStart: boolean;
  92356. private _noiseTexture;
  92357. /**
  92358. * Gets or sets a texture used to add random noise to particle positions
  92359. */
  92360. get noiseTexture(): Nullable<ProceduralTexture>;
  92361. set noiseTexture(value: Nullable<ProceduralTexture>);
  92362. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92363. noiseStrength: Vector3;
  92364. /**
  92365. * Callback triggered when the particle animation is ending.
  92366. */
  92367. onAnimationEnd: Nullable<() => void>;
  92368. /**
  92369. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92370. */
  92371. blendMode: number;
  92372. /**
  92373. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92374. * to override the particles.
  92375. */
  92376. forceDepthWrite: boolean;
  92377. /** 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 */
  92378. preWarmCycles: number;
  92379. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92380. preWarmStepOffset: number;
  92381. /**
  92382. * 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)
  92383. */
  92384. spriteCellChangeSpeed: number;
  92385. /**
  92386. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92387. */
  92388. startSpriteCellID: number;
  92389. /**
  92390. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92391. */
  92392. endSpriteCellID: number;
  92393. /**
  92394. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92395. */
  92396. spriteCellWidth: number;
  92397. /**
  92398. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92399. */
  92400. spriteCellHeight: number;
  92401. /**
  92402. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92403. */
  92404. spriteRandomStartCell: boolean;
  92405. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92406. translationPivot: Vector2;
  92407. /** @hidden */
  92408. protected _isAnimationSheetEnabled: boolean;
  92409. /**
  92410. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92411. */
  92412. beginAnimationOnStart: boolean;
  92413. /**
  92414. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92415. */
  92416. beginAnimationFrom: number;
  92417. /**
  92418. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92419. */
  92420. beginAnimationTo: number;
  92421. /**
  92422. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92423. */
  92424. beginAnimationLoop: boolean;
  92425. /**
  92426. * Gets or sets a world offset applied to all particles
  92427. */
  92428. worldOffset: Vector3;
  92429. /**
  92430. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92431. */
  92432. get isAnimationSheetEnabled(): boolean;
  92433. set isAnimationSheetEnabled(value: boolean);
  92434. /**
  92435. * Get hosting scene
  92436. * @returns the scene
  92437. */
  92438. getScene(): Nullable<Scene>;
  92439. /**
  92440. * You can use gravity if you want to give an orientation to your particles.
  92441. */
  92442. gravity: Vector3;
  92443. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92444. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92445. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92446. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92447. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92448. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92449. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92450. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92451. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92452. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92453. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92454. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92455. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92456. /**
  92457. * Defines the delay in milliseconds before starting the system (0 by default)
  92458. */
  92459. startDelay: number;
  92460. /**
  92461. * Gets the current list of drag gradients.
  92462. * You must use addDragGradient and removeDragGradient to udpate this list
  92463. * @returns the list of drag gradients
  92464. */
  92465. getDragGradients(): Nullable<Array<FactorGradient>>;
  92466. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92467. limitVelocityDamping: number;
  92468. /**
  92469. * Gets the current list of limit velocity gradients.
  92470. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92471. * @returns the list of limit velocity gradients
  92472. */
  92473. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92474. /**
  92475. * Gets the current list of color gradients.
  92476. * You must use addColorGradient and removeColorGradient to udpate this list
  92477. * @returns the list of color gradients
  92478. */
  92479. getColorGradients(): Nullable<Array<ColorGradient>>;
  92480. /**
  92481. * Gets the current list of size gradients.
  92482. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92483. * @returns the list of size gradients
  92484. */
  92485. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92486. /**
  92487. * Gets the current list of color remap gradients.
  92488. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92489. * @returns the list of color remap gradients
  92490. */
  92491. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92492. /**
  92493. * Gets the current list of alpha remap gradients.
  92494. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92495. * @returns the list of alpha remap gradients
  92496. */
  92497. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92498. /**
  92499. * Gets the current list of life time gradients.
  92500. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92501. * @returns the list of life time gradients
  92502. */
  92503. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92504. /**
  92505. * Gets the current list of angular speed gradients.
  92506. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92507. * @returns the list of angular speed gradients
  92508. */
  92509. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92510. /**
  92511. * Gets the current list of velocity gradients.
  92512. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92513. * @returns the list of velocity gradients
  92514. */
  92515. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92516. /**
  92517. * Gets the current list of start size gradients.
  92518. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92519. * @returns the list of start size gradients
  92520. */
  92521. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92522. /**
  92523. * Gets the current list of emit rate gradients.
  92524. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92525. * @returns the list of emit rate gradients
  92526. */
  92527. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92528. /**
  92529. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92530. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92531. */
  92532. get direction1(): Vector3;
  92533. set direction1(value: Vector3);
  92534. /**
  92535. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92536. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92537. */
  92538. get direction2(): Vector3;
  92539. set direction2(value: Vector3);
  92540. /**
  92541. * 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.
  92542. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92543. */
  92544. get minEmitBox(): Vector3;
  92545. set minEmitBox(value: Vector3);
  92546. /**
  92547. * 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.
  92548. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92549. */
  92550. get maxEmitBox(): Vector3;
  92551. set maxEmitBox(value: Vector3);
  92552. /**
  92553. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92554. */
  92555. color1: Color4;
  92556. /**
  92557. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92558. */
  92559. color2: Color4;
  92560. /**
  92561. * Color the particle will have at the end of its lifetime
  92562. */
  92563. colorDead: Color4;
  92564. /**
  92565. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92566. */
  92567. textureMask: Color4;
  92568. /**
  92569. * The particle emitter type defines the emitter used by the particle system.
  92570. * It can be for example box, sphere, or cone...
  92571. */
  92572. particleEmitterType: IParticleEmitterType;
  92573. /** @hidden */
  92574. _isSubEmitter: boolean;
  92575. /**
  92576. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92577. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92578. */
  92579. billboardMode: number;
  92580. protected _isBillboardBased: boolean;
  92581. /**
  92582. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92583. */
  92584. get isBillboardBased(): boolean;
  92585. set isBillboardBased(value: boolean);
  92586. /**
  92587. * The scene the particle system belongs to.
  92588. */
  92589. protected _scene: Nullable<Scene>;
  92590. /**
  92591. * The engine the particle system belongs to.
  92592. */
  92593. protected _engine: ThinEngine;
  92594. /**
  92595. * Local cache of defines for image processing.
  92596. */
  92597. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92598. /**
  92599. * Default configuration related to image processing available in the standard Material.
  92600. */
  92601. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92602. /**
  92603. * Gets the image processing configuration used either in this material.
  92604. */
  92605. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92606. /**
  92607. * Sets the Default image processing configuration used either in the this material.
  92608. *
  92609. * If sets to null, the scene one is in use.
  92610. */
  92611. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92612. /**
  92613. * Attaches a new image processing configuration to the Standard Material.
  92614. * @param configuration
  92615. */
  92616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92617. /** @hidden */
  92618. protected _reset(): void;
  92619. /** @hidden */
  92620. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92621. /**
  92622. * Instantiates a particle system.
  92623. * 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.
  92624. * @param name The name of the particle system
  92625. */
  92626. constructor(name: string);
  92627. /**
  92628. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92631. * @returns the emitter
  92632. */
  92633. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92634. /**
  92635. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92636. * @param radius The radius of the hemisphere to emit from
  92637. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92638. * @returns the emitter
  92639. */
  92640. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92641. /**
  92642. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92643. * @param radius The radius of the sphere to emit from
  92644. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92645. * @returns the emitter
  92646. */
  92647. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92648. /**
  92649. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92650. * @param radius The radius of the sphere to emit from
  92651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92653. * @returns the emitter
  92654. */
  92655. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92656. /**
  92657. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92658. * @param radius The radius of the emission cylinder
  92659. * @param height The height of the emission cylinder
  92660. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92661. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92662. * @returns the emitter
  92663. */
  92664. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92665. /**
  92666. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92667. * @param radius The radius of the cylinder to emit from
  92668. * @param height The height of the emission cylinder
  92669. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92672. * @returns the emitter
  92673. */
  92674. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92675. /**
  92676. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92677. * @param radius The radius of the cone to emit from
  92678. * @param angle The base angle of the cone
  92679. * @returns the emitter
  92680. */
  92681. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92682. /**
  92683. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92686. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92687. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92688. * @returns the emitter
  92689. */
  92690. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92691. }
  92692. }
  92693. declare module BABYLON {
  92694. /**
  92695. * Type of sub emitter
  92696. */
  92697. export enum SubEmitterType {
  92698. /**
  92699. * Attached to the particle over it's lifetime
  92700. */
  92701. ATTACHED = 0,
  92702. /**
  92703. * Created when the particle dies
  92704. */
  92705. END = 1
  92706. }
  92707. /**
  92708. * Sub emitter class used to emit particles from an existing particle
  92709. */
  92710. export class SubEmitter {
  92711. /**
  92712. * the particle system to be used by the sub emitter
  92713. */
  92714. particleSystem: ParticleSystem;
  92715. /**
  92716. * Type of the submitter (Default: END)
  92717. */
  92718. type: SubEmitterType;
  92719. /**
  92720. * 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)
  92721. * Note: This only is supported when using an emitter of type Mesh
  92722. */
  92723. inheritDirection: boolean;
  92724. /**
  92725. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92726. */
  92727. inheritedVelocityAmount: number;
  92728. /**
  92729. * Creates a sub emitter
  92730. * @param particleSystem the particle system to be used by the sub emitter
  92731. */
  92732. constructor(
  92733. /**
  92734. * the particle system to be used by the sub emitter
  92735. */
  92736. particleSystem: ParticleSystem);
  92737. /**
  92738. * Clones the sub emitter
  92739. * @returns the cloned sub emitter
  92740. */
  92741. clone(): SubEmitter;
  92742. /**
  92743. * Serialize current object to a JSON object
  92744. * @returns the serialized object
  92745. */
  92746. serialize(): any;
  92747. /** @hidden */
  92748. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92749. /**
  92750. * Creates a new SubEmitter from a serialized JSON version
  92751. * @param serializationObject defines the JSON object to read from
  92752. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92753. * @param rootUrl defines the rootUrl for data loading
  92754. * @returns a new SubEmitter
  92755. */
  92756. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92757. /** Release associated resources */
  92758. dispose(): void;
  92759. }
  92760. }
  92761. declare module BABYLON {
  92762. /** @hidden */
  92763. export var imageProcessingDeclaration: {
  92764. name: string;
  92765. shader: string;
  92766. };
  92767. }
  92768. declare module BABYLON {
  92769. /** @hidden */
  92770. export var imageProcessingFunctions: {
  92771. name: string;
  92772. shader: string;
  92773. };
  92774. }
  92775. declare module BABYLON {
  92776. /** @hidden */
  92777. export var particlesPixelShader: {
  92778. name: string;
  92779. shader: string;
  92780. };
  92781. }
  92782. declare module BABYLON {
  92783. /** @hidden */
  92784. export var particlesVertexShader: {
  92785. name: string;
  92786. shader: string;
  92787. };
  92788. }
  92789. declare module BABYLON {
  92790. /**
  92791. * Interface used to define entities containing multiple clip planes
  92792. */
  92793. export interface IClipPlanesHolder {
  92794. /**
  92795. * Gets or sets the active clipplane 1
  92796. */
  92797. clipPlane: Nullable<Plane>;
  92798. /**
  92799. * Gets or sets the active clipplane 2
  92800. */
  92801. clipPlane2: Nullable<Plane>;
  92802. /**
  92803. * Gets or sets the active clipplane 3
  92804. */
  92805. clipPlane3: Nullable<Plane>;
  92806. /**
  92807. * Gets or sets the active clipplane 4
  92808. */
  92809. clipPlane4: Nullable<Plane>;
  92810. /**
  92811. * Gets or sets the active clipplane 5
  92812. */
  92813. clipPlane5: Nullable<Plane>;
  92814. /**
  92815. * Gets or sets the active clipplane 6
  92816. */
  92817. clipPlane6: Nullable<Plane>;
  92818. }
  92819. }
  92820. declare module BABYLON {
  92821. /**
  92822. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92823. *
  92824. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92825. *
  92826. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92827. */
  92828. export class ThinMaterialHelper {
  92829. /**
  92830. * Binds the clip plane information from the holder to the effect.
  92831. * @param effect The effect we are binding the data to
  92832. * @param holder The entity containing the clip plane information
  92833. */
  92834. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92835. }
  92836. }
  92837. declare module BABYLON {
  92838. interface ThinEngine {
  92839. /**
  92840. * Sets alpha constants used by some alpha blending modes
  92841. * @param r defines the red component
  92842. * @param g defines the green component
  92843. * @param b defines the blue component
  92844. * @param a defines the alpha component
  92845. */
  92846. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92847. /**
  92848. * Sets the current alpha mode
  92849. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92850. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92851. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92852. */
  92853. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92854. /**
  92855. * Gets the current alpha mode
  92856. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92857. * @returns the current alpha mode
  92858. */
  92859. getAlphaMode(): number;
  92860. /**
  92861. * Sets the current alpha equation
  92862. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92863. */
  92864. setAlphaEquation(equation: number): void;
  92865. /**
  92866. * Gets the current alpha equation.
  92867. * @returns the current alpha equation
  92868. */
  92869. getAlphaEquation(): number;
  92870. }
  92871. }
  92872. declare module BABYLON {
  92873. /**
  92874. * This represents a particle system in Babylon.
  92875. * 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.
  92876. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92877. * @example https://doc.babylonjs.com/babylon101/particles
  92878. */
  92879. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92880. /**
  92881. * Billboard mode will only apply to Y axis
  92882. */
  92883. static readonly BILLBOARDMODE_Y: number;
  92884. /**
  92885. * Billboard mode will apply to all axes
  92886. */
  92887. static readonly BILLBOARDMODE_ALL: number;
  92888. /**
  92889. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92890. */
  92891. static readonly BILLBOARDMODE_STRETCHED: number;
  92892. /**
  92893. * This function can be defined to provide custom update for active particles.
  92894. * This function will be called instead of regular update (age, position, color, etc.).
  92895. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92896. */
  92897. updateFunction: (particles: Particle[]) => void;
  92898. private _emitterWorldMatrix;
  92899. /**
  92900. * This function can be defined to specify initial direction for every new particle.
  92901. * It by default use the emitterType defined function
  92902. */
  92903. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92904. /**
  92905. * This function can be defined to specify initial position for every new particle.
  92906. * It by default use the emitterType defined function
  92907. */
  92908. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92909. /**
  92910. * @hidden
  92911. */
  92912. _inheritedVelocityOffset: Vector3;
  92913. /**
  92914. * An event triggered when the system is disposed
  92915. */
  92916. onDisposeObservable: Observable<IParticleSystem>;
  92917. private _onDisposeObserver;
  92918. /**
  92919. * Sets a callback that will be triggered when the system is disposed
  92920. */
  92921. set onDispose(callback: () => void);
  92922. private _particles;
  92923. private _epsilon;
  92924. private _capacity;
  92925. private _stockParticles;
  92926. private _newPartsExcess;
  92927. private _vertexData;
  92928. private _vertexBuffer;
  92929. private _vertexBuffers;
  92930. private _spriteBuffer;
  92931. private _indexBuffer;
  92932. private _effect;
  92933. private _customEffect;
  92934. private _cachedDefines;
  92935. private _scaledColorStep;
  92936. private _colorDiff;
  92937. private _scaledDirection;
  92938. private _scaledGravity;
  92939. private _currentRenderId;
  92940. private _alive;
  92941. private _useInstancing;
  92942. private _started;
  92943. private _stopped;
  92944. private _actualFrame;
  92945. private _scaledUpdateSpeed;
  92946. private _vertexBufferSize;
  92947. /** @hidden */
  92948. _currentEmitRateGradient: Nullable<FactorGradient>;
  92949. /** @hidden */
  92950. _currentEmitRate1: number;
  92951. /** @hidden */
  92952. _currentEmitRate2: number;
  92953. /** @hidden */
  92954. _currentStartSizeGradient: Nullable<FactorGradient>;
  92955. /** @hidden */
  92956. _currentStartSize1: number;
  92957. /** @hidden */
  92958. _currentStartSize2: number;
  92959. private readonly _rawTextureWidth;
  92960. private _rampGradientsTexture;
  92961. private _useRampGradients;
  92962. /** Gets or sets a matrix to use to compute projection */
  92963. defaultProjectionMatrix: Matrix;
  92964. /** Gets or sets a matrix to use to compute view */
  92965. defaultViewMatrix: Matrix;
  92966. /** Gets or sets a boolean indicating that ramp gradients must be used
  92967. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92968. */
  92969. get useRampGradients(): boolean;
  92970. set useRampGradients(value: boolean);
  92971. /**
  92972. * 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.
  92973. * 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: [])
  92974. */
  92975. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92976. private _subEmitters;
  92977. /**
  92978. * @hidden
  92979. * If the particle systems emitter should be disposed when the particle system is disposed
  92980. */
  92981. _disposeEmitterOnDispose: boolean;
  92982. /**
  92983. * The current active Sub-systems, this property is used by the root particle system only.
  92984. */
  92985. activeSubSystems: Array<ParticleSystem>;
  92986. /**
  92987. * Specifies if the particles are updated in emitter local space or world space
  92988. */
  92989. isLocal: boolean;
  92990. private _rootParticleSystem;
  92991. /**
  92992. * Gets the current list of active particles
  92993. */
  92994. get particles(): Particle[];
  92995. /**
  92996. * Gets the number of particles active at the same time.
  92997. * @returns The number of active particles.
  92998. */
  92999. getActiveCount(): number;
  93000. /**
  93001. * Returns the string "ParticleSystem"
  93002. * @returns a string containing the class name
  93003. */
  93004. getClassName(): string;
  93005. /**
  93006. * Gets a boolean indicating that the system is stopping
  93007. * @returns true if the system is currently stopping
  93008. */
  93009. isStopping(): boolean;
  93010. /**
  93011. * Gets the custom effect used to render the particles
  93012. * @param blendMode Blend mode for which the effect should be retrieved
  93013. * @returns The effect
  93014. */
  93015. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93016. /**
  93017. * Sets the custom effect used to render the particles
  93018. * @param effect The effect to set
  93019. * @param blendMode Blend mode for which the effect should be set
  93020. */
  93021. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93022. /** @hidden */
  93023. private _onBeforeDrawParticlesObservable;
  93024. /**
  93025. * Observable that will be called just before the particles are drawn
  93026. */
  93027. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93028. /**
  93029. * Gets the name of the particle vertex shader
  93030. */
  93031. get vertexShaderName(): string;
  93032. /**
  93033. * Instantiates a particle system.
  93034. * 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.
  93035. * @param name The name of the particle system
  93036. * @param capacity The max number of particles alive at the same time
  93037. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93038. * @param customEffect a custom effect used to change the way particles are rendered by default
  93039. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93040. * @param epsilon Offset used to render the particles
  93041. */
  93042. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93043. private _addFactorGradient;
  93044. private _removeFactorGradient;
  93045. /**
  93046. * Adds a new life time gradient
  93047. * @param gradient defines the gradient to use (between 0 and 1)
  93048. * @param factor defines the life time factor to affect to the specified gradient
  93049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93050. * @returns the current particle system
  93051. */
  93052. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93053. /**
  93054. * Remove a specific life time gradient
  93055. * @param gradient defines the gradient to remove
  93056. * @returns the current particle system
  93057. */
  93058. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93059. /**
  93060. * Adds a new size gradient
  93061. * @param gradient defines the gradient to use (between 0 and 1)
  93062. * @param factor defines the size factor to affect to the specified gradient
  93063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93064. * @returns the current particle system
  93065. */
  93066. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93067. /**
  93068. * Remove a specific size gradient
  93069. * @param gradient defines the gradient to remove
  93070. * @returns the current particle system
  93071. */
  93072. removeSizeGradient(gradient: number): IParticleSystem;
  93073. /**
  93074. * Adds a new color remap gradient
  93075. * @param gradient defines the gradient to use (between 0 and 1)
  93076. * @param min defines the color remap minimal range
  93077. * @param max defines the color remap maximal range
  93078. * @returns the current particle system
  93079. */
  93080. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93081. /**
  93082. * Remove a specific color remap gradient
  93083. * @param gradient defines the gradient to remove
  93084. * @returns the current particle system
  93085. */
  93086. removeColorRemapGradient(gradient: number): IParticleSystem;
  93087. /**
  93088. * Adds a new alpha remap gradient
  93089. * @param gradient defines the gradient to use (between 0 and 1)
  93090. * @param min defines the alpha remap minimal range
  93091. * @param max defines the alpha remap maximal range
  93092. * @returns the current particle system
  93093. */
  93094. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93095. /**
  93096. * Remove a specific alpha remap gradient
  93097. * @param gradient defines the gradient to remove
  93098. * @returns the current particle system
  93099. */
  93100. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93101. /**
  93102. * Adds a new angular speed gradient
  93103. * @param gradient defines the gradient to use (between 0 and 1)
  93104. * @param factor defines the angular speed to affect to the specified gradient
  93105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93106. * @returns the current particle system
  93107. */
  93108. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93109. /**
  93110. * Remove a specific angular speed gradient
  93111. * @param gradient defines the gradient to remove
  93112. * @returns the current particle system
  93113. */
  93114. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93115. /**
  93116. * Adds a new velocity gradient
  93117. * @param gradient defines the gradient to use (between 0 and 1)
  93118. * @param factor defines the velocity to affect to the specified gradient
  93119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93120. * @returns the current particle system
  93121. */
  93122. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93123. /**
  93124. * Remove a specific velocity gradient
  93125. * @param gradient defines the gradient to remove
  93126. * @returns the current particle system
  93127. */
  93128. removeVelocityGradient(gradient: number): IParticleSystem;
  93129. /**
  93130. * Adds a new limit velocity gradient
  93131. * @param gradient defines the gradient to use (between 0 and 1)
  93132. * @param factor defines the limit velocity value to affect to the specified gradient
  93133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93134. * @returns the current particle system
  93135. */
  93136. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93137. /**
  93138. * Remove a specific limit velocity gradient
  93139. * @param gradient defines the gradient to remove
  93140. * @returns the current particle system
  93141. */
  93142. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93143. /**
  93144. * Adds a new drag gradient
  93145. * @param gradient defines the gradient to use (between 0 and 1)
  93146. * @param factor defines the drag value to affect to the specified gradient
  93147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93148. * @returns the current particle system
  93149. */
  93150. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93151. /**
  93152. * Remove a specific drag gradient
  93153. * @param gradient defines the gradient to remove
  93154. * @returns the current particle system
  93155. */
  93156. removeDragGradient(gradient: number): IParticleSystem;
  93157. /**
  93158. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93159. * @param gradient defines the gradient to use (between 0 and 1)
  93160. * @param factor defines the emit rate value to affect to the specified gradient
  93161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93162. * @returns the current particle system
  93163. */
  93164. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93165. /**
  93166. * Remove a specific emit rate gradient
  93167. * @param gradient defines the gradient to remove
  93168. * @returns the current particle system
  93169. */
  93170. removeEmitRateGradient(gradient: number): IParticleSystem;
  93171. /**
  93172. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93173. * @param gradient defines the gradient to use (between 0 and 1)
  93174. * @param factor defines the start size value to affect to the specified gradient
  93175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93176. * @returns the current particle system
  93177. */
  93178. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93179. /**
  93180. * Remove a specific start size gradient
  93181. * @param gradient defines the gradient to remove
  93182. * @returns the current particle system
  93183. */
  93184. removeStartSizeGradient(gradient: number): IParticleSystem;
  93185. private _createRampGradientTexture;
  93186. /**
  93187. * Gets the current list of ramp gradients.
  93188. * You must use addRampGradient and removeRampGradient to udpate this list
  93189. * @returns the list of ramp gradients
  93190. */
  93191. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93192. /** Force the system to rebuild all gradients that need to be resync */
  93193. forceRefreshGradients(): void;
  93194. private _syncRampGradientTexture;
  93195. /**
  93196. * Adds a new ramp gradient used to remap particle colors
  93197. * @param gradient defines the gradient to use (between 0 and 1)
  93198. * @param color defines the color to affect to the specified gradient
  93199. * @returns the current particle system
  93200. */
  93201. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93202. /**
  93203. * Remove a specific ramp gradient
  93204. * @param gradient defines the gradient to remove
  93205. * @returns the current particle system
  93206. */
  93207. removeRampGradient(gradient: number): ParticleSystem;
  93208. /**
  93209. * Adds a new color gradient
  93210. * @param gradient defines the gradient to use (between 0 and 1)
  93211. * @param color1 defines the color to affect to the specified gradient
  93212. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93213. * @returns this particle system
  93214. */
  93215. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93216. /**
  93217. * Remove a specific color gradient
  93218. * @param gradient defines the gradient to remove
  93219. * @returns this particle system
  93220. */
  93221. removeColorGradient(gradient: number): IParticleSystem;
  93222. private _fetchR;
  93223. protected _reset(): void;
  93224. private _resetEffect;
  93225. private _createVertexBuffers;
  93226. private _createIndexBuffer;
  93227. /**
  93228. * Gets the maximum number of particles active at the same time.
  93229. * @returns The max number of active particles.
  93230. */
  93231. getCapacity(): number;
  93232. /**
  93233. * Gets whether there are still active particles in the system.
  93234. * @returns True if it is alive, otherwise false.
  93235. */
  93236. isAlive(): boolean;
  93237. /**
  93238. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93239. * @returns True if it has been started, otherwise false.
  93240. */
  93241. isStarted(): boolean;
  93242. private _prepareSubEmitterInternalArray;
  93243. /**
  93244. * Starts the particle system and begins to emit
  93245. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93246. */
  93247. start(delay?: number): void;
  93248. /**
  93249. * Stops the particle system.
  93250. * @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.
  93251. */
  93252. stop(stopSubEmitters?: boolean): void;
  93253. /**
  93254. * Remove all active particles
  93255. */
  93256. reset(): void;
  93257. /**
  93258. * @hidden (for internal use only)
  93259. */
  93260. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93261. /**
  93262. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93263. * Its lifetime will start back at 0.
  93264. */
  93265. recycleParticle: (particle: Particle) => void;
  93266. private _stopSubEmitters;
  93267. private _createParticle;
  93268. private _removeFromRoot;
  93269. private _emitFromParticle;
  93270. private _update;
  93271. /** @hidden */
  93272. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93273. /** @hidden */
  93274. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93275. /**
  93276. * Fill the defines array according to the current settings of the particle system
  93277. * @param defines Array to be updated
  93278. * @param blendMode blend mode to take into account when updating the array
  93279. */
  93280. fillDefines(defines: Array<string>, blendMode: number): void;
  93281. /**
  93282. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93283. * @param uniforms Uniforms array to fill
  93284. * @param attributes Attributes array to fill
  93285. * @param samplers Samplers array to fill
  93286. */
  93287. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93288. /** @hidden */
  93289. private _getEffect;
  93290. /**
  93291. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93292. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93293. */
  93294. animate(preWarmOnly?: boolean): void;
  93295. private _appendParticleVertices;
  93296. /**
  93297. * Rebuilds the particle system.
  93298. */
  93299. rebuild(): void;
  93300. /**
  93301. * Is this system ready to be used/rendered
  93302. * @return true if the system is ready
  93303. */
  93304. isReady(): boolean;
  93305. private _render;
  93306. /**
  93307. * Renders the particle system in its current state.
  93308. * @returns the current number of particles
  93309. */
  93310. render(): number;
  93311. /**
  93312. * Disposes the particle system and free the associated resources
  93313. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93314. */
  93315. dispose(disposeTexture?: boolean): void;
  93316. /**
  93317. * Clones the particle system.
  93318. * @param name The name of the cloned object
  93319. * @param newEmitter The new emitter to use
  93320. * @returns the cloned particle system
  93321. */
  93322. clone(name: string, newEmitter: any): ParticleSystem;
  93323. /**
  93324. * Serializes the particle system to a JSON object
  93325. * @param serializeTexture defines if the texture must be serialized as well
  93326. * @returns the JSON object
  93327. */
  93328. serialize(serializeTexture?: boolean): any;
  93329. /** @hidden */
  93330. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93331. /** @hidden */
  93332. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93333. /**
  93334. * Parses a JSON object to create a particle system.
  93335. * @param parsedParticleSystem The JSON object to parse
  93336. * @param sceneOrEngine The scene or the engine to create the particle system in
  93337. * @param rootUrl The root url to use to load external dependencies like texture
  93338. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93339. * @returns the Parsed particle system
  93340. */
  93341. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93342. }
  93343. }
  93344. declare module BABYLON {
  93345. /**
  93346. * A particle represents one of the element emitted by a particle system.
  93347. * This is mainly define by its coordinates, direction, velocity and age.
  93348. */
  93349. export class Particle {
  93350. /**
  93351. * The particle system the particle belongs to.
  93352. */
  93353. particleSystem: ParticleSystem;
  93354. private static _Count;
  93355. /**
  93356. * Unique ID of the particle
  93357. */
  93358. id: number;
  93359. /**
  93360. * The world position of the particle in the scene.
  93361. */
  93362. position: Vector3;
  93363. /**
  93364. * The world direction of the particle in the scene.
  93365. */
  93366. direction: Vector3;
  93367. /**
  93368. * The color of the particle.
  93369. */
  93370. color: Color4;
  93371. /**
  93372. * The color change of the particle per step.
  93373. */
  93374. colorStep: Color4;
  93375. /**
  93376. * Defines how long will the life of the particle be.
  93377. */
  93378. lifeTime: number;
  93379. /**
  93380. * The current age of the particle.
  93381. */
  93382. age: number;
  93383. /**
  93384. * The current size of the particle.
  93385. */
  93386. size: number;
  93387. /**
  93388. * The current scale of the particle.
  93389. */
  93390. scale: Vector2;
  93391. /**
  93392. * The current angle of the particle.
  93393. */
  93394. angle: number;
  93395. /**
  93396. * Defines how fast is the angle changing.
  93397. */
  93398. angularSpeed: number;
  93399. /**
  93400. * Defines the cell index used by the particle to be rendered from a sprite.
  93401. */
  93402. cellIndex: number;
  93403. /**
  93404. * The information required to support color remapping
  93405. */
  93406. remapData: Vector4;
  93407. /** @hidden */
  93408. _randomCellOffset?: number;
  93409. /** @hidden */
  93410. _initialDirection: Nullable<Vector3>;
  93411. /** @hidden */
  93412. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93413. /** @hidden */
  93414. _initialStartSpriteCellID: number;
  93415. /** @hidden */
  93416. _initialEndSpriteCellID: number;
  93417. /** @hidden */
  93418. _currentColorGradient: Nullable<ColorGradient>;
  93419. /** @hidden */
  93420. _currentColor1: Color4;
  93421. /** @hidden */
  93422. _currentColor2: Color4;
  93423. /** @hidden */
  93424. _currentSizeGradient: Nullable<FactorGradient>;
  93425. /** @hidden */
  93426. _currentSize1: number;
  93427. /** @hidden */
  93428. _currentSize2: number;
  93429. /** @hidden */
  93430. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93431. /** @hidden */
  93432. _currentAngularSpeed1: number;
  93433. /** @hidden */
  93434. _currentAngularSpeed2: number;
  93435. /** @hidden */
  93436. _currentVelocityGradient: Nullable<FactorGradient>;
  93437. /** @hidden */
  93438. _currentVelocity1: number;
  93439. /** @hidden */
  93440. _currentVelocity2: number;
  93441. /** @hidden */
  93442. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93443. /** @hidden */
  93444. _currentLimitVelocity1: number;
  93445. /** @hidden */
  93446. _currentLimitVelocity2: number;
  93447. /** @hidden */
  93448. _currentDragGradient: Nullable<FactorGradient>;
  93449. /** @hidden */
  93450. _currentDrag1: number;
  93451. /** @hidden */
  93452. _currentDrag2: number;
  93453. /** @hidden */
  93454. _randomNoiseCoordinates1: Vector3;
  93455. /** @hidden */
  93456. _randomNoiseCoordinates2: Vector3;
  93457. /** @hidden */
  93458. _localPosition?: Vector3;
  93459. /**
  93460. * Creates a new instance Particle
  93461. * @param particleSystem the particle system the particle belongs to
  93462. */
  93463. constructor(
  93464. /**
  93465. * The particle system the particle belongs to.
  93466. */
  93467. particleSystem: ParticleSystem);
  93468. private updateCellInfoFromSystem;
  93469. /**
  93470. * Defines how the sprite cell index is updated for the particle
  93471. */
  93472. updateCellIndex(): void;
  93473. /** @hidden */
  93474. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93475. /** @hidden */
  93476. _inheritParticleInfoToSubEmitters(): void;
  93477. /** @hidden */
  93478. _reset(): void;
  93479. /**
  93480. * Copy the properties of particle to another one.
  93481. * @param other the particle to copy the information to.
  93482. */
  93483. copyTo(other: Particle): void;
  93484. }
  93485. }
  93486. declare module BABYLON {
  93487. /**
  93488. * Particle emitter represents a volume emitting particles.
  93489. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93490. */
  93491. export interface IParticleEmitterType {
  93492. /**
  93493. * Called by the particle System when the direction is computed for the created particle.
  93494. * @param worldMatrix is the world matrix of the particle system
  93495. * @param directionToUpdate is the direction vector to update with the result
  93496. * @param particle is the particle we are computed the direction for
  93497. * @param isLocal defines if the direction should be set in local space
  93498. */
  93499. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93500. /**
  93501. * Called by the particle System when the position is computed for the created particle.
  93502. * @param worldMatrix is the world matrix of the particle system
  93503. * @param positionToUpdate is the position vector to update with the result
  93504. * @param particle is the particle we are computed the position for
  93505. * @param isLocal defines if the position should be set in local space
  93506. */
  93507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93508. /**
  93509. * Clones the current emitter and returns a copy of it
  93510. * @returns the new emitter
  93511. */
  93512. clone(): IParticleEmitterType;
  93513. /**
  93514. * Called by the GPUParticleSystem to setup the update shader
  93515. * @param effect defines the update shader
  93516. */
  93517. applyToShader(effect: Effect): void;
  93518. /**
  93519. * Returns a string to use to update the GPU particles update shader
  93520. * @returns the effect defines string
  93521. */
  93522. getEffectDefines(): string;
  93523. /**
  93524. * Returns a string representing the class name
  93525. * @returns a string containing the class name
  93526. */
  93527. getClassName(): string;
  93528. /**
  93529. * Serializes the particle system to a JSON object.
  93530. * @returns the JSON object
  93531. */
  93532. serialize(): any;
  93533. /**
  93534. * Parse properties from a JSON object
  93535. * @param serializationObject defines the JSON object
  93536. * @param scene defines the hosting scene
  93537. */
  93538. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93539. }
  93540. }
  93541. declare module BABYLON {
  93542. /**
  93543. * Particle emitter emitting particles from the inside of a box.
  93544. * It emits the particles randomly between 2 given directions.
  93545. */
  93546. export class BoxParticleEmitter implements IParticleEmitterType {
  93547. /**
  93548. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93549. */
  93550. direction1: Vector3;
  93551. /**
  93552. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93553. */
  93554. direction2: Vector3;
  93555. /**
  93556. * 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.
  93557. */
  93558. minEmitBox: Vector3;
  93559. /**
  93560. * 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.
  93561. */
  93562. maxEmitBox: Vector3;
  93563. /**
  93564. * Creates a new instance BoxParticleEmitter
  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(): BoxParticleEmitter;
  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 "BoxParticleEmitter"
  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 cone.
  93618. * It emits the particles alongside the cone volume from the base to the particle.
  93619. * The emission direction might be randomized.
  93620. */
  93621. export class ConeParticleEmitter implements IParticleEmitterType {
  93622. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93623. directionRandomizer: number;
  93624. private _radius;
  93625. private _angle;
  93626. private _height;
  93627. /**
  93628. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93629. */
  93630. radiusRange: number;
  93631. /**
  93632. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93633. */
  93634. heightRange: number;
  93635. /**
  93636. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93637. */
  93638. emitFromSpawnPointOnly: boolean;
  93639. /**
  93640. * Gets or sets the radius of the emission cone
  93641. */
  93642. get radius(): number;
  93643. set radius(value: number);
  93644. /**
  93645. * Gets or sets the angle of the emission cone
  93646. */
  93647. get angle(): number;
  93648. set angle(value: number);
  93649. private _buildHeight;
  93650. /**
  93651. * Creates a new instance ConeParticleEmitter
  93652. * @param radius the radius of the emission cone (1 by default)
  93653. * @param angle the cone base angle (PI by default)
  93654. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93655. */
  93656. constructor(radius?: number, angle?: number,
  93657. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93658. directionRandomizer?: number);
  93659. /**
  93660. * Called by the particle System when the direction is computed for the created particle.
  93661. * @param worldMatrix is the world matrix of the particle system
  93662. * @param directionToUpdate is the direction vector to update with the result
  93663. * @param particle is the particle we are computed the direction for
  93664. * @param isLocal defines if the direction should be set in local space
  93665. */
  93666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93667. /**
  93668. * Called by the particle System when the position is computed for the created particle.
  93669. * @param worldMatrix is the world matrix of the particle system
  93670. * @param positionToUpdate is the position vector to update with the result
  93671. * @param particle is the particle we are computed the position for
  93672. * @param isLocal defines if the position should be set in local space
  93673. */
  93674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93675. /**
  93676. * Clones the current emitter and returns a copy of it
  93677. * @returns the new emitter
  93678. */
  93679. clone(): ConeParticleEmitter;
  93680. /**
  93681. * Called by the GPUParticleSystem to setup the update shader
  93682. * @param effect defines the update shader
  93683. */
  93684. applyToShader(effect: Effect): void;
  93685. /**
  93686. * Returns a string to use to update the GPU particles update shader
  93687. * @returns a string containng the defines string
  93688. */
  93689. getEffectDefines(): string;
  93690. /**
  93691. * Returns the string "ConeParticleEmitter"
  93692. * @returns a string containing the class name
  93693. */
  93694. getClassName(): string;
  93695. /**
  93696. * Serializes the particle system to a JSON object.
  93697. * @returns the JSON object
  93698. */
  93699. serialize(): any;
  93700. /**
  93701. * Parse properties from a JSON object
  93702. * @param serializationObject defines the JSON object
  93703. */
  93704. parse(serializationObject: any): void;
  93705. }
  93706. }
  93707. declare module BABYLON {
  93708. /**
  93709. * Particle emitter emitting particles from the inside of a cylinder.
  93710. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93711. */
  93712. export class CylinderParticleEmitter implements IParticleEmitterType {
  93713. /**
  93714. * The radius of the emission cylinder.
  93715. */
  93716. radius: number;
  93717. /**
  93718. * The height of the emission cylinder.
  93719. */
  93720. height: number;
  93721. /**
  93722. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93723. */
  93724. radiusRange: number;
  93725. /**
  93726. * How much to randomize the particle direction [0-1].
  93727. */
  93728. directionRandomizer: number;
  93729. /**
  93730. * Creates a new instance CylinderParticleEmitter
  93731. * @param radius the radius of the emission cylinder (1 by default)
  93732. * @param height the height of the emission cylinder (1 by default)
  93733. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93734. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93735. */
  93736. constructor(
  93737. /**
  93738. * The radius of the emission cylinder.
  93739. */
  93740. radius?: number,
  93741. /**
  93742. * The height of the emission cylinder.
  93743. */
  93744. height?: number,
  93745. /**
  93746. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93747. */
  93748. radiusRange?: number,
  93749. /**
  93750. * How much to randomize the particle direction [0-1].
  93751. */
  93752. directionRandomizer?: number);
  93753. /**
  93754. * Called by the particle System when the direction is computed for the created particle.
  93755. * @param worldMatrix is the world matrix of the particle system
  93756. * @param directionToUpdate is the direction vector to update with the result
  93757. * @param particle is the particle we are computed the direction for
  93758. * @param isLocal defines if the direction should be set in local space
  93759. */
  93760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93761. /**
  93762. * Called by the particle System when the position is computed for the created particle.
  93763. * @param worldMatrix is the world matrix of the particle system
  93764. * @param positionToUpdate is the position vector to update with the result
  93765. * @param particle is the particle we are computed the position for
  93766. * @param isLocal defines if the position should be set in local space
  93767. */
  93768. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93769. /**
  93770. * Clones the current emitter and returns a copy of it
  93771. * @returns the new emitter
  93772. */
  93773. clone(): CylinderParticleEmitter;
  93774. /**
  93775. * Called by the GPUParticleSystem to setup the update shader
  93776. * @param effect defines the update shader
  93777. */
  93778. applyToShader(effect: Effect): void;
  93779. /**
  93780. * Returns a string to use to update the GPU particles update shader
  93781. * @returns a string containng the defines string
  93782. */
  93783. getEffectDefines(): string;
  93784. /**
  93785. * Returns the string "CylinderParticleEmitter"
  93786. * @returns a string containing the class name
  93787. */
  93788. getClassName(): string;
  93789. /**
  93790. * Serializes the particle system to a JSON object.
  93791. * @returns the JSON object
  93792. */
  93793. serialize(): any;
  93794. /**
  93795. * Parse properties from a JSON object
  93796. * @param serializationObject defines the JSON object
  93797. */
  93798. parse(serializationObject: any): void;
  93799. }
  93800. /**
  93801. * Particle emitter emitting particles from the inside of a cylinder.
  93802. * It emits the particles randomly between two vectors.
  93803. */
  93804. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93805. /**
  93806. * The min limit of the emission direction.
  93807. */
  93808. direction1: Vector3;
  93809. /**
  93810. * The max limit of the emission direction.
  93811. */
  93812. direction2: Vector3;
  93813. /**
  93814. * Creates a new instance CylinderDirectedParticleEmitter
  93815. * @param radius the radius of the emission cylinder (1 by default)
  93816. * @param height the height of the emission cylinder (1 by default)
  93817. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93818. * @param direction1 the min limit of the emission direction (up vector by default)
  93819. * @param direction2 the max limit of the emission direction (up vector by default)
  93820. */
  93821. constructor(radius?: number, height?: number, radiusRange?: number,
  93822. /**
  93823. * The min limit of the emission direction.
  93824. */
  93825. direction1?: Vector3,
  93826. /**
  93827. * The max limit of the emission direction.
  93828. */
  93829. direction2?: Vector3);
  93830. /**
  93831. * Called by the particle System when the direction is computed for the created particle.
  93832. * @param worldMatrix is the world matrix of the particle system
  93833. * @param directionToUpdate is the direction vector to update with the result
  93834. * @param particle is the particle we are computed the direction for
  93835. */
  93836. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93837. /**
  93838. * Clones the current emitter and returns a copy of it
  93839. * @returns the new emitter
  93840. */
  93841. clone(): CylinderDirectedParticleEmitter;
  93842. /**
  93843. * Called by the GPUParticleSystem to setup the update shader
  93844. * @param effect defines the update shader
  93845. */
  93846. applyToShader(effect: Effect): void;
  93847. /**
  93848. * Returns a string to use to update the GPU particles update shader
  93849. * @returns a string containng the defines string
  93850. */
  93851. getEffectDefines(): string;
  93852. /**
  93853. * Returns the string "CylinderDirectedParticleEmitter"
  93854. * @returns a string containing the class name
  93855. */
  93856. getClassName(): string;
  93857. /**
  93858. * Serializes the particle system to a JSON object.
  93859. * @returns the JSON object
  93860. */
  93861. serialize(): any;
  93862. /**
  93863. * Parse properties from a JSON object
  93864. * @param serializationObject defines the JSON object
  93865. */
  93866. parse(serializationObject: any): void;
  93867. }
  93868. }
  93869. declare module BABYLON {
  93870. /**
  93871. * Particle emitter emitting particles from the inside of a hemisphere.
  93872. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93873. */
  93874. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93875. /**
  93876. * The radius of the emission hemisphere.
  93877. */
  93878. radius: number;
  93879. /**
  93880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93881. */
  93882. radiusRange: number;
  93883. /**
  93884. * How much to randomize the particle direction [0-1].
  93885. */
  93886. directionRandomizer: number;
  93887. /**
  93888. * Creates a new instance HemisphericParticleEmitter
  93889. * @param radius the radius of the emission hemisphere (1 by default)
  93890. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93891. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93892. */
  93893. constructor(
  93894. /**
  93895. * The radius of the emission hemisphere.
  93896. */
  93897. radius?: number,
  93898. /**
  93899. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93900. */
  93901. radiusRange?: number,
  93902. /**
  93903. * How much to randomize the particle direction [0-1].
  93904. */
  93905. directionRandomizer?: number);
  93906. /**
  93907. * Called by the particle System when the direction is computed for the created particle.
  93908. * @param worldMatrix is the world matrix of the particle system
  93909. * @param directionToUpdate is the direction vector to update with the result
  93910. * @param particle is the particle we are computed the direction for
  93911. * @param isLocal defines if the direction should be set in local space
  93912. */
  93913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93914. /**
  93915. * Called by the particle System when the position is computed for the created particle.
  93916. * @param worldMatrix is the world matrix of the particle system
  93917. * @param positionToUpdate is the position vector to update with the result
  93918. * @param particle is the particle we are computed the position for
  93919. * @param isLocal defines if the position should be set in local space
  93920. */
  93921. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93922. /**
  93923. * Clones the current emitter and returns a copy of it
  93924. * @returns the new emitter
  93925. */
  93926. clone(): HemisphericParticleEmitter;
  93927. /**
  93928. * Called by the GPUParticleSystem to setup the update shader
  93929. * @param effect defines the update shader
  93930. */
  93931. applyToShader(effect: Effect): void;
  93932. /**
  93933. * Returns a string to use to update the GPU particles update shader
  93934. * @returns a string containng the defines string
  93935. */
  93936. getEffectDefines(): string;
  93937. /**
  93938. * Returns the string "HemisphericParticleEmitter"
  93939. * @returns a string containing the class name
  93940. */
  93941. getClassName(): string;
  93942. /**
  93943. * Serializes the particle system to a JSON object.
  93944. * @returns the JSON object
  93945. */
  93946. serialize(): any;
  93947. /**
  93948. * Parse properties from a JSON object
  93949. * @param serializationObject defines the JSON object
  93950. */
  93951. parse(serializationObject: any): void;
  93952. }
  93953. }
  93954. declare module BABYLON {
  93955. /**
  93956. * Particle emitter emitting particles from a point.
  93957. * It emits the particles randomly between 2 given directions.
  93958. */
  93959. export class PointParticleEmitter implements IParticleEmitterType {
  93960. /**
  93961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93962. */
  93963. direction1: Vector3;
  93964. /**
  93965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93966. */
  93967. direction2: Vector3;
  93968. /**
  93969. * Creates a new instance PointParticleEmitter
  93970. */
  93971. constructor();
  93972. /**
  93973. * Called by the particle System when the direction is computed for the created particle.
  93974. * @param worldMatrix is the world matrix of the particle system
  93975. * @param directionToUpdate is the direction vector to update with the result
  93976. * @param particle is the particle we are computed the direction for
  93977. * @param isLocal defines if the direction should be set in local space
  93978. */
  93979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93980. /**
  93981. * Called by the particle System when the position is computed for the created particle.
  93982. * @param worldMatrix is the world matrix of the particle system
  93983. * @param positionToUpdate is the position vector to update with the result
  93984. * @param particle is the particle we are computed the position for
  93985. * @param isLocal defines if the position should be set in local space
  93986. */
  93987. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93988. /**
  93989. * Clones the current emitter and returns a copy of it
  93990. * @returns the new emitter
  93991. */
  93992. clone(): PointParticleEmitter;
  93993. /**
  93994. * Called by the GPUParticleSystem to setup the update shader
  93995. * @param effect defines the update shader
  93996. */
  93997. applyToShader(effect: Effect): void;
  93998. /**
  93999. * Returns a string to use to update the GPU particles update shader
  94000. * @returns a string containng the defines string
  94001. */
  94002. getEffectDefines(): string;
  94003. /**
  94004. * Returns the string "PointParticleEmitter"
  94005. * @returns a string containing the class name
  94006. */
  94007. getClassName(): string;
  94008. /**
  94009. * Serializes the particle system to a JSON object.
  94010. * @returns the JSON object
  94011. */
  94012. serialize(): any;
  94013. /**
  94014. * Parse properties from a JSON object
  94015. * @param serializationObject defines the JSON object
  94016. */
  94017. parse(serializationObject: any): void;
  94018. }
  94019. }
  94020. declare module BABYLON {
  94021. /**
  94022. * Particle emitter emitting particles from the inside of a sphere.
  94023. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94024. */
  94025. export class SphereParticleEmitter implements IParticleEmitterType {
  94026. /**
  94027. * The radius of the emission sphere.
  94028. */
  94029. radius: number;
  94030. /**
  94031. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94032. */
  94033. radiusRange: number;
  94034. /**
  94035. * How much to randomize the particle direction [0-1].
  94036. */
  94037. directionRandomizer: number;
  94038. /**
  94039. * Creates a new instance SphereParticleEmitter
  94040. * @param radius the radius of the emission sphere (1 by default)
  94041. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94042. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94043. */
  94044. constructor(
  94045. /**
  94046. * The radius of the emission sphere.
  94047. */
  94048. radius?: number,
  94049. /**
  94050. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94051. */
  94052. radiusRange?: number,
  94053. /**
  94054. * How much to randomize the particle direction [0-1].
  94055. */
  94056. directionRandomizer?: number);
  94057. /**
  94058. * Called by the particle System when the direction is computed for the created particle.
  94059. * @param worldMatrix is the world matrix of the particle system
  94060. * @param directionToUpdate is the direction vector to update with the result
  94061. * @param particle is the particle we are computed the direction for
  94062. * @param isLocal defines if the direction should be set in local space
  94063. */
  94064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94065. /**
  94066. * Called by the particle System when the position is computed for the created particle.
  94067. * @param worldMatrix is the world matrix of the particle system
  94068. * @param positionToUpdate is the position vector to update with the result
  94069. * @param particle is the particle we are computed the position for
  94070. * @param isLocal defines if the position should be set in local space
  94071. */
  94072. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94073. /**
  94074. * Clones the current emitter and returns a copy of it
  94075. * @returns the new emitter
  94076. */
  94077. clone(): SphereParticleEmitter;
  94078. /**
  94079. * Called by the GPUParticleSystem to setup the update shader
  94080. * @param effect defines the update shader
  94081. */
  94082. applyToShader(effect: Effect): void;
  94083. /**
  94084. * Returns a string to use to update the GPU particles update shader
  94085. * @returns a string containng the defines string
  94086. */
  94087. getEffectDefines(): string;
  94088. /**
  94089. * Returns the string "SphereParticleEmitter"
  94090. * @returns a string containing the class name
  94091. */
  94092. getClassName(): string;
  94093. /**
  94094. * Serializes the particle system to a JSON object.
  94095. * @returns the JSON object
  94096. */
  94097. serialize(): any;
  94098. /**
  94099. * Parse properties from a JSON object
  94100. * @param serializationObject defines the JSON object
  94101. */
  94102. parse(serializationObject: any): void;
  94103. }
  94104. /**
  94105. * Particle emitter emitting particles from the inside of a sphere.
  94106. * It emits the particles randomly between two vectors.
  94107. */
  94108. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94109. /**
  94110. * The min limit of the emission direction.
  94111. */
  94112. direction1: Vector3;
  94113. /**
  94114. * The max limit of the emission direction.
  94115. */
  94116. direction2: Vector3;
  94117. /**
  94118. * Creates a new instance SphereDirectedParticleEmitter
  94119. * @param radius the radius of the emission sphere (1 by default)
  94120. * @param direction1 the min limit of the emission direction (up vector by default)
  94121. * @param direction2 the max limit of the emission direction (up vector by default)
  94122. */
  94123. constructor(radius?: number,
  94124. /**
  94125. * The min limit of the emission direction.
  94126. */
  94127. direction1?: Vector3,
  94128. /**
  94129. * The max limit of the emission direction.
  94130. */
  94131. direction2?: Vector3);
  94132. /**
  94133. * Called by the particle System when the direction is computed for the created particle.
  94134. * @param worldMatrix is the world matrix of the particle system
  94135. * @param directionToUpdate is the direction vector to update with the result
  94136. * @param particle is the particle we are computed the direction for
  94137. */
  94138. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94139. /**
  94140. * Clones the current emitter and returns a copy of it
  94141. * @returns the new emitter
  94142. */
  94143. clone(): SphereDirectedParticleEmitter;
  94144. /**
  94145. * Called by the GPUParticleSystem to setup the update shader
  94146. * @param effect defines the update shader
  94147. */
  94148. applyToShader(effect: Effect): void;
  94149. /**
  94150. * Returns a string to use to update the GPU particles update shader
  94151. * @returns a string containng the defines string
  94152. */
  94153. getEffectDefines(): string;
  94154. /**
  94155. * Returns the string "SphereDirectedParticleEmitter"
  94156. * @returns a string containing the class name
  94157. */
  94158. getClassName(): string;
  94159. /**
  94160. * Serializes the particle system to a JSON object.
  94161. * @returns the JSON object
  94162. */
  94163. serialize(): any;
  94164. /**
  94165. * Parse properties from a JSON object
  94166. * @param serializationObject defines the JSON object
  94167. */
  94168. parse(serializationObject: any): void;
  94169. }
  94170. }
  94171. declare module BABYLON {
  94172. /**
  94173. * Particle emitter emitting particles from a custom list of positions.
  94174. */
  94175. export class CustomParticleEmitter implements IParticleEmitterType {
  94176. /**
  94177. * Gets or sets the position generator that will create the inital position of each particle.
  94178. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94179. */
  94180. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94181. /**
  94182. * Gets or sets the destination generator that will create the final destination of each particle.
  94183. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94184. */
  94185. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94186. /**
  94187. * Creates a new instance CustomParticleEmitter
  94188. */
  94189. constructor();
  94190. /**
  94191. * Called by the particle System when the direction is computed for the created particle.
  94192. * @param worldMatrix is the world matrix of the particle system
  94193. * @param directionToUpdate is the direction vector to update with the result
  94194. * @param particle is the particle we are computed the direction for
  94195. * @param isLocal defines if the direction should be set in local space
  94196. */
  94197. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94198. /**
  94199. * Called by the particle System when the position is computed for the created particle.
  94200. * @param worldMatrix is the world matrix of the particle system
  94201. * @param positionToUpdate is the position vector to update with the result
  94202. * @param particle is the particle we are computed the position for
  94203. * @param isLocal defines if the position should be set in local space
  94204. */
  94205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94206. /**
  94207. * Clones the current emitter and returns a copy of it
  94208. * @returns the new emitter
  94209. */
  94210. clone(): CustomParticleEmitter;
  94211. /**
  94212. * Called by the GPUParticleSystem to setup the update shader
  94213. * @param effect defines the update shader
  94214. */
  94215. applyToShader(effect: Effect): void;
  94216. /**
  94217. * Returns a string to use to update the GPU particles update shader
  94218. * @returns a string containng the defines string
  94219. */
  94220. getEffectDefines(): string;
  94221. /**
  94222. * Returns the string "PointParticleEmitter"
  94223. * @returns a string containing the class name
  94224. */
  94225. getClassName(): string;
  94226. /**
  94227. * Serializes the particle system to a JSON object.
  94228. * @returns the JSON object
  94229. */
  94230. serialize(): any;
  94231. /**
  94232. * Parse properties from a JSON object
  94233. * @param serializationObject defines the JSON object
  94234. */
  94235. parse(serializationObject: any): void;
  94236. }
  94237. }
  94238. declare module BABYLON {
  94239. /**
  94240. * Particle emitter emitting particles from the inside of a box.
  94241. * It emits the particles randomly between 2 given directions.
  94242. */
  94243. export class MeshParticleEmitter implements IParticleEmitterType {
  94244. private _indices;
  94245. private _positions;
  94246. private _normals;
  94247. private _storedNormal;
  94248. private _mesh;
  94249. /**
  94250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94251. */
  94252. direction1: Vector3;
  94253. /**
  94254. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94255. */
  94256. direction2: Vector3;
  94257. /**
  94258. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94259. */
  94260. useMeshNormalsForDirection: boolean;
  94261. /** Defines the mesh to use as source */
  94262. get mesh(): Nullable<AbstractMesh>;
  94263. set mesh(value: Nullable<AbstractMesh>);
  94264. /**
  94265. * Creates a new instance MeshParticleEmitter
  94266. * @param mesh defines the mesh to use as source
  94267. */
  94268. constructor(mesh?: Nullable<AbstractMesh>);
  94269. /**
  94270. * Called by the particle System when the direction is computed for the created particle.
  94271. * @param worldMatrix is the world matrix of the particle system
  94272. * @param directionToUpdate is the direction vector to update with the result
  94273. * @param particle is the particle we are computed the direction for
  94274. * @param isLocal defines if the direction should be set in local space
  94275. */
  94276. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94277. /**
  94278. * Called by the particle System when the position is computed for the created particle.
  94279. * @param worldMatrix is the world matrix of the particle system
  94280. * @param positionToUpdate is the position vector to update with the result
  94281. * @param particle is the particle we are computed the position for
  94282. * @param isLocal defines if the position should be set in local space
  94283. */
  94284. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94285. /**
  94286. * Clones the current emitter and returns a copy of it
  94287. * @returns the new emitter
  94288. */
  94289. clone(): MeshParticleEmitter;
  94290. /**
  94291. * Called by the GPUParticleSystem to setup the update shader
  94292. * @param effect defines the update shader
  94293. */
  94294. applyToShader(effect: Effect): void;
  94295. /**
  94296. * Returns a string to use to update the GPU particles update shader
  94297. * @returns a string containng the defines string
  94298. */
  94299. getEffectDefines(): string;
  94300. /**
  94301. * Returns the string "BoxParticleEmitter"
  94302. * @returns a string containing the class name
  94303. */
  94304. getClassName(): string;
  94305. /**
  94306. * Serializes the particle system to a JSON object.
  94307. * @returns the JSON object
  94308. */
  94309. serialize(): any;
  94310. /**
  94311. * Parse properties from a JSON object
  94312. * @param serializationObject defines the JSON object
  94313. * @param scene defines the hosting scene
  94314. */
  94315. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94316. }
  94317. }
  94318. declare module BABYLON {
  94319. /**
  94320. * Interface representing a particle system in Babylon.js.
  94321. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94322. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94323. */
  94324. export interface IParticleSystem {
  94325. /**
  94326. * List of animations used by the particle system.
  94327. */
  94328. animations: Animation[];
  94329. /**
  94330. * The id of the Particle system.
  94331. */
  94332. id: string;
  94333. /**
  94334. * The name of the Particle system.
  94335. */
  94336. name: string;
  94337. /**
  94338. * The emitter represents the Mesh or position we are attaching the particle system to.
  94339. */
  94340. emitter: Nullable<AbstractMesh | Vector3>;
  94341. /**
  94342. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94343. */
  94344. isBillboardBased: boolean;
  94345. /**
  94346. * The rendering group used by the Particle system to chose when to render.
  94347. */
  94348. renderingGroupId: number;
  94349. /**
  94350. * The layer mask we are rendering the particles through.
  94351. */
  94352. layerMask: number;
  94353. /**
  94354. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94355. */
  94356. updateSpeed: number;
  94357. /**
  94358. * The amount of time the particle system is running (depends of the overall update speed).
  94359. */
  94360. targetStopDuration: number;
  94361. /**
  94362. * The texture used to render each particle. (this can be a spritesheet)
  94363. */
  94364. particleTexture: Nullable<BaseTexture>;
  94365. /**
  94366. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94367. */
  94368. blendMode: number;
  94369. /**
  94370. * Minimum life time of emitting particles.
  94371. */
  94372. minLifeTime: number;
  94373. /**
  94374. * Maximum life time of emitting particles.
  94375. */
  94376. maxLifeTime: number;
  94377. /**
  94378. * Minimum Size of emitting particles.
  94379. */
  94380. minSize: number;
  94381. /**
  94382. * Maximum Size of emitting particles.
  94383. */
  94384. maxSize: number;
  94385. /**
  94386. * Minimum scale of emitting particles on X axis.
  94387. */
  94388. minScaleX: number;
  94389. /**
  94390. * Maximum scale of emitting particles on X axis.
  94391. */
  94392. maxScaleX: number;
  94393. /**
  94394. * Minimum scale of emitting particles on Y axis.
  94395. */
  94396. minScaleY: number;
  94397. /**
  94398. * Maximum scale of emitting particles on Y axis.
  94399. */
  94400. maxScaleY: number;
  94401. /**
  94402. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94403. */
  94404. color1: Color4;
  94405. /**
  94406. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94407. */
  94408. color2: Color4;
  94409. /**
  94410. * Color the particle will have at the end of its lifetime.
  94411. */
  94412. colorDead: Color4;
  94413. /**
  94414. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94415. */
  94416. emitRate: number;
  94417. /**
  94418. * You can use gravity if you want to give an orientation to your particles.
  94419. */
  94420. gravity: Vector3;
  94421. /**
  94422. * Minimum power of emitting particles.
  94423. */
  94424. minEmitPower: number;
  94425. /**
  94426. * Maximum power of emitting particles.
  94427. */
  94428. maxEmitPower: number;
  94429. /**
  94430. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94431. */
  94432. minAngularSpeed: number;
  94433. /**
  94434. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94435. */
  94436. maxAngularSpeed: number;
  94437. /**
  94438. * Gets or sets the minimal initial rotation in radians.
  94439. */
  94440. minInitialRotation: number;
  94441. /**
  94442. * Gets or sets the maximal initial rotation in radians.
  94443. */
  94444. maxInitialRotation: number;
  94445. /**
  94446. * The particle emitter type defines the emitter used by the particle system.
  94447. * It can be for example box, sphere, or cone...
  94448. */
  94449. particleEmitterType: Nullable<IParticleEmitterType>;
  94450. /**
  94451. * Defines the delay in milliseconds before starting the system (0 by default)
  94452. */
  94453. startDelay: number;
  94454. /**
  94455. * 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
  94456. */
  94457. preWarmCycles: number;
  94458. /**
  94459. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94460. */
  94461. preWarmStepOffset: number;
  94462. /**
  94463. * 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)
  94464. */
  94465. spriteCellChangeSpeed: number;
  94466. /**
  94467. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94468. */
  94469. startSpriteCellID: number;
  94470. /**
  94471. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94472. */
  94473. endSpriteCellID: number;
  94474. /**
  94475. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94476. */
  94477. spriteCellWidth: number;
  94478. /**
  94479. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94480. */
  94481. spriteCellHeight: number;
  94482. /**
  94483. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94484. */
  94485. spriteRandomStartCell: boolean;
  94486. /**
  94487. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94488. */
  94489. isAnimationSheetEnabled: boolean;
  94490. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94491. translationPivot: Vector2;
  94492. /**
  94493. * Gets or sets a texture used to add random noise to particle positions
  94494. */
  94495. noiseTexture: Nullable<BaseTexture>;
  94496. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94497. noiseStrength: Vector3;
  94498. /**
  94499. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94500. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94501. */
  94502. billboardMode: number;
  94503. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94504. limitVelocityDamping: number;
  94505. /**
  94506. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94507. */
  94508. beginAnimationOnStart: boolean;
  94509. /**
  94510. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94511. */
  94512. beginAnimationFrom: number;
  94513. /**
  94514. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94515. */
  94516. beginAnimationTo: number;
  94517. /**
  94518. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94519. */
  94520. beginAnimationLoop: boolean;
  94521. /**
  94522. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94523. */
  94524. disposeOnStop: boolean;
  94525. /**
  94526. * Specifies if the particles are updated in emitter local space or world space
  94527. */
  94528. isLocal: boolean;
  94529. /** Snippet ID if the particle system was created from the snippet server */
  94530. snippetId: string;
  94531. /** Gets or sets a matrix to use to compute projection */
  94532. defaultProjectionMatrix: Matrix;
  94533. /**
  94534. * Gets the maximum number of particles active at the same time.
  94535. * @returns The max number of active particles.
  94536. */
  94537. getCapacity(): number;
  94538. /**
  94539. * Gets the number of particles active at the same time.
  94540. * @returns The number of active particles.
  94541. */
  94542. getActiveCount(): number;
  94543. /**
  94544. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94545. * @returns True if it has been started, otherwise false.
  94546. */
  94547. isStarted(): boolean;
  94548. /**
  94549. * Animates the particle system for this frame.
  94550. */
  94551. animate(): void;
  94552. /**
  94553. * Renders the particle system in its current state.
  94554. * @returns the current number of particles
  94555. */
  94556. render(): number;
  94557. /**
  94558. * Dispose the particle system and frees its associated resources.
  94559. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94560. */
  94561. dispose(disposeTexture?: boolean): void;
  94562. /**
  94563. * An event triggered when the system is disposed
  94564. */
  94565. onDisposeObservable: Observable<IParticleSystem>;
  94566. /**
  94567. * Clones the particle system.
  94568. * @param name The name of the cloned object
  94569. * @param newEmitter The new emitter to use
  94570. * @returns the cloned particle system
  94571. */
  94572. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94573. /**
  94574. * Serializes the particle system to a JSON object
  94575. * @param serializeTexture defines if the texture must be serialized as well
  94576. * @returns the JSON object
  94577. */
  94578. serialize(serializeTexture: boolean): any;
  94579. /**
  94580. * Rebuild the particle system
  94581. */
  94582. rebuild(): void;
  94583. /** Force the system to rebuild all gradients that need to be resync */
  94584. forceRefreshGradients(): void;
  94585. /**
  94586. * Starts the particle system and begins to emit
  94587. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94588. */
  94589. start(delay?: number): void;
  94590. /**
  94591. * Stops the particle system.
  94592. */
  94593. stop(): void;
  94594. /**
  94595. * Remove all active particles
  94596. */
  94597. reset(): void;
  94598. /**
  94599. * Gets a boolean indicating that the system is stopping
  94600. * @returns true if the system is currently stopping
  94601. */
  94602. isStopping(): boolean;
  94603. /**
  94604. * Is this system ready to be used/rendered
  94605. * @return true if the system is ready
  94606. */
  94607. isReady(): boolean;
  94608. /**
  94609. * Returns the string "ParticleSystem"
  94610. * @returns a string containing the class name
  94611. */
  94612. getClassName(): string;
  94613. /**
  94614. * Gets the custom effect used to render the particles
  94615. * @param blendMode Blend mode for which the effect should be retrieved
  94616. * @returns The effect
  94617. */
  94618. getCustomEffect(blendMode: number): Nullable<Effect>;
  94619. /**
  94620. * Sets the custom effect used to render the particles
  94621. * @param effect The effect to set
  94622. * @param blendMode Blend mode for which the effect should be set
  94623. */
  94624. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94625. /**
  94626. * Fill the defines array according to the current settings of the particle system
  94627. * @param defines Array to be updated
  94628. * @param blendMode blend mode to take into account when updating the array
  94629. */
  94630. fillDefines(defines: Array<string>, blendMode: number): void;
  94631. /**
  94632. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94633. * @param uniforms Uniforms array to fill
  94634. * @param attributes Attributes array to fill
  94635. * @param samplers Samplers array to fill
  94636. */
  94637. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94638. /**
  94639. * Observable that will be called just before the particles are drawn
  94640. */
  94641. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94642. /**
  94643. * Gets the name of the particle vertex shader
  94644. */
  94645. vertexShaderName: string;
  94646. /**
  94647. * Adds a new color gradient
  94648. * @param gradient defines the gradient to use (between 0 and 1)
  94649. * @param color1 defines the color to affect to the specified gradient
  94650. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94651. * @returns the current particle system
  94652. */
  94653. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94654. /**
  94655. * Remove a specific color gradient
  94656. * @param gradient defines the gradient to remove
  94657. * @returns the current particle system
  94658. */
  94659. removeColorGradient(gradient: number): IParticleSystem;
  94660. /**
  94661. * Adds a new size gradient
  94662. * @param gradient defines the gradient to use (between 0 and 1)
  94663. * @param factor defines the size factor to affect to the specified gradient
  94664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94665. * @returns the current particle system
  94666. */
  94667. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94668. /**
  94669. * Remove a specific size gradient
  94670. * @param gradient defines the gradient to remove
  94671. * @returns the current particle system
  94672. */
  94673. removeSizeGradient(gradient: number): IParticleSystem;
  94674. /**
  94675. * Gets the current list of color gradients.
  94676. * You must use addColorGradient and removeColorGradient to udpate this list
  94677. * @returns the list of color gradients
  94678. */
  94679. getColorGradients(): Nullable<Array<ColorGradient>>;
  94680. /**
  94681. * Gets the current list of size gradients.
  94682. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94683. * @returns the list of size gradients
  94684. */
  94685. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94686. /**
  94687. * Gets the current list of angular speed gradients.
  94688. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94689. * @returns the list of angular speed gradients
  94690. */
  94691. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94692. /**
  94693. * Adds a new angular speed gradient
  94694. * @param gradient defines the gradient to use (between 0 and 1)
  94695. * @param factor defines the angular speed to affect to the specified gradient
  94696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94697. * @returns the current particle system
  94698. */
  94699. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94700. /**
  94701. * Remove a specific angular speed gradient
  94702. * @param gradient defines the gradient to remove
  94703. * @returns the current particle system
  94704. */
  94705. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94706. /**
  94707. * Gets the current list of velocity gradients.
  94708. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94709. * @returns the list of velocity gradients
  94710. */
  94711. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94712. /**
  94713. * Adds a new velocity gradient
  94714. * @param gradient defines the gradient to use (between 0 and 1)
  94715. * @param factor defines the velocity to affect to the specified gradient
  94716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94717. * @returns the current particle system
  94718. */
  94719. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94720. /**
  94721. * Remove a specific velocity gradient
  94722. * @param gradient defines the gradient to remove
  94723. * @returns the current particle system
  94724. */
  94725. removeVelocityGradient(gradient: number): IParticleSystem;
  94726. /**
  94727. * Gets the current list of limit velocity gradients.
  94728. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94729. * @returns the list of limit velocity gradients
  94730. */
  94731. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94732. /**
  94733. * Adds a new limit velocity gradient
  94734. * @param gradient defines the gradient to use (between 0 and 1)
  94735. * @param factor defines the limit velocity to affect to the specified gradient
  94736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94737. * @returns the current particle system
  94738. */
  94739. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94740. /**
  94741. * Remove a specific limit velocity gradient
  94742. * @param gradient defines the gradient to remove
  94743. * @returns the current particle system
  94744. */
  94745. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94746. /**
  94747. * Adds a new drag gradient
  94748. * @param gradient defines the gradient to use (between 0 and 1)
  94749. * @param factor defines the drag to affect to the specified gradient
  94750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94751. * @returns the current particle system
  94752. */
  94753. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94754. /**
  94755. * Remove a specific drag gradient
  94756. * @param gradient defines the gradient to remove
  94757. * @returns the current particle system
  94758. */
  94759. removeDragGradient(gradient: number): IParticleSystem;
  94760. /**
  94761. * Gets the current list of drag gradients.
  94762. * You must use addDragGradient and removeDragGradient to udpate this list
  94763. * @returns the list of drag gradients
  94764. */
  94765. getDragGradients(): Nullable<Array<FactorGradient>>;
  94766. /**
  94767. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94768. * @param gradient defines the gradient to use (between 0 and 1)
  94769. * @param factor defines the emit rate to affect to the specified gradient
  94770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94771. * @returns the current particle system
  94772. */
  94773. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94774. /**
  94775. * Remove a specific emit rate gradient
  94776. * @param gradient defines the gradient to remove
  94777. * @returns the current particle system
  94778. */
  94779. removeEmitRateGradient(gradient: number): IParticleSystem;
  94780. /**
  94781. * Gets the current list of emit rate gradients.
  94782. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94783. * @returns the list of emit rate gradients
  94784. */
  94785. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94786. /**
  94787. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94788. * @param gradient defines the gradient to use (between 0 and 1)
  94789. * @param factor defines the start size to affect to the specified gradient
  94790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94791. * @returns the current particle system
  94792. */
  94793. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94794. /**
  94795. * Remove a specific start size gradient
  94796. * @param gradient defines the gradient to remove
  94797. * @returns the current particle system
  94798. */
  94799. removeStartSizeGradient(gradient: number): IParticleSystem;
  94800. /**
  94801. * Gets the current list of start size gradients.
  94802. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94803. * @returns the list of start size gradients
  94804. */
  94805. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94806. /**
  94807. * Adds a new life time gradient
  94808. * @param gradient defines the gradient to use (between 0 and 1)
  94809. * @param factor defines the life time factor to affect to the specified gradient
  94810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94811. * @returns the current particle system
  94812. */
  94813. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94814. /**
  94815. * Remove a specific life time gradient
  94816. * @param gradient defines the gradient to remove
  94817. * @returns the current particle system
  94818. */
  94819. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94820. /**
  94821. * Gets the current list of life time gradients.
  94822. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94823. * @returns the list of life time gradients
  94824. */
  94825. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94826. /**
  94827. * Gets the current list of color gradients.
  94828. * You must use addColorGradient and removeColorGradient to udpate this list
  94829. * @returns the list of color gradients
  94830. */
  94831. getColorGradients(): Nullable<Array<ColorGradient>>;
  94832. /**
  94833. * Adds a new ramp gradient used to remap particle colors
  94834. * @param gradient defines the gradient to use (between 0 and 1)
  94835. * @param color defines the color to affect to the specified gradient
  94836. * @returns the current particle system
  94837. */
  94838. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94839. /**
  94840. * Gets the current list of ramp gradients.
  94841. * You must use addRampGradient and removeRampGradient to udpate this list
  94842. * @returns the list of ramp gradients
  94843. */
  94844. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94845. /** Gets or sets a boolean indicating that ramp gradients must be used
  94846. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94847. */
  94848. useRampGradients: boolean;
  94849. /**
  94850. * Adds a new color remap gradient
  94851. * @param gradient defines the gradient to use (between 0 and 1)
  94852. * @param min defines the color remap minimal range
  94853. * @param max defines the color remap maximal range
  94854. * @returns the current particle system
  94855. */
  94856. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94857. /**
  94858. * Gets the current list of color remap gradients.
  94859. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94860. * @returns the list of color remap gradients
  94861. */
  94862. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94863. /**
  94864. * Adds a new alpha remap gradient
  94865. * @param gradient defines the gradient to use (between 0 and 1)
  94866. * @param min defines the alpha remap minimal range
  94867. * @param max defines the alpha remap maximal range
  94868. * @returns the current particle system
  94869. */
  94870. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94871. /**
  94872. * Gets the current list of alpha remap gradients.
  94873. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94874. * @returns the list of alpha remap gradients
  94875. */
  94876. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94877. /**
  94878. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94879. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94880. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94881. * @returns the emitter
  94882. */
  94883. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94884. /**
  94885. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94886. * @param radius The radius of the hemisphere to emit from
  94887. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94888. * @returns the emitter
  94889. */
  94890. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94891. /**
  94892. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94893. * @param radius The radius of the sphere to emit from
  94894. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94895. * @returns the emitter
  94896. */
  94897. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94898. /**
  94899. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94900. * @param radius The radius of the sphere to emit from
  94901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94903. * @returns the emitter
  94904. */
  94905. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94906. /**
  94907. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94908. * @param radius The radius of the emission cylinder
  94909. * @param height The height of the emission cylinder
  94910. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94911. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94912. * @returns the emitter
  94913. */
  94914. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94915. /**
  94916. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94917. * @param radius The radius of the cylinder to emit from
  94918. * @param height The height of the emission cylinder
  94919. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94920. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94921. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94922. * @returns the emitter
  94923. */
  94924. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94925. /**
  94926. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94927. * @param radius The radius of the cone to emit from
  94928. * @param angle The base angle of the cone
  94929. * @returns the emitter
  94930. */
  94931. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94932. /**
  94933. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94936. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94937. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94938. * @returns the emitter
  94939. */
  94940. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94941. /**
  94942. * Get hosting scene
  94943. * @returns the scene
  94944. */
  94945. getScene(): Nullable<Scene>;
  94946. }
  94947. }
  94948. declare module BABYLON {
  94949. /**
  94950. * 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.
  94951. * @see https://doc.babylonjs.com/how_to/transformnode
  94952. */
  94953. export class TransformNode extends Node {
  94954. /**
  94955. * Object will not rotate to face the camera
  94956. */
  94957. static BILLBOARDMODE_NONE: number;
  94958. /**
  94959. * Object will rotate to face the camera but only on the x axis
  94960. */
  94961. static BILLBOARDMODE_X: number;
  94962. /**
  94963. * Object will rotate to face the camera but only on the y axis
  94964. */
  94965. static BILLBOARDMODE_Y: number;
  94966. /**
  94967. * Object will rotate to face the camera but only on the z axis
  94968. */
  94969. static BILLBOARDMODE_Z: number;
  94970. /**
  94971. * Object will rotate to face the camera
  94972. */
  94973. static BILLBOARDMODE_ALL: number;
  94974. /**
  94975. * Object will rotate to face the camera's position instead of orientation
  94976. */
  94977. static BILLBOARDMODE_USE_POSITION: number;
  94978. private static _TmpRotation;
  94979. private static _TmpScaling;
  94980. private static _TmpTranslation;
  94981. private _forward;
  94982. private _forwardInverted;
  94983. private _up;
  94984. private _right;
  94985. private _rightInverted;
  94986. private _position;
  94987. private _rotation;
  94988. private _rotationQuaternion;
  94989. protected _scaling: Vector3;
  94990. protected _isDirty: boolean;
  94991. private _transformToBoneReferal;
  94992. private _isAbsoluteSynced;
  94993. private _billboardMode;
  94994. /**
  94995. * Gets or sets the billboard mode. Default is 0.
  94996. *
  94997. * | Value | Type | Description |
  94998. * | --- | --- | --- |
  94999. * | 0 | BILLBOARDMODE_NONE | |
  95000. * | 1 | BILLBOARDMODE_X | |
  95001. * | 2 | BILLBOARDMODE_Y | |
  95002. * | 4 | BILLBOARDMODE_Z | |
  95003. * | 7 | BILLBOARDMODE_ALL | |
  95004. *
  95005. */
  95006. get billboardMode(): number;
  95007. set billboardMode(value: number);
  95008. private _preserveParentRotationForBillboard;
  95009. /**
  95010. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95011. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95012. */
  95013. get preserveParentRotationForBillboard(): boolean;
  95014. set preserveParentRotationForBillboard(value: boolean);
  95015. /**
  95016. * 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
  95017. */
  95018. scalingDeterminant: number;
  95019. private _infiniteDistance;
  95020. /**
  95021. * Gets or sets the distance of the object to max, often used by skybox
  95022. */
  95023. get infiniteDistance(): boolean;
  95024. set infiniteDistance(value: boolean);
  95025. /**
  95026. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95027. * By default the system will update normals to compensate
  95028. */
  95029. ignoreNonUniformScaling: boolean;
  95030. /**
  95031. * 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
  95032. */
  95033. reIntegrateRotationIntoRotationQuaternion: boolean;
  95034. /** @hidden */
  95035. _poseMatrix: Nullable<Matrix>;
  95036. /** @hidden */
  95037. _localMatrix: Matrix;
  95038. private _usePivotMatrix;
  95039. private _absolutePosition;
  95040. private _absoluteScaling;
  95041. private _absoluteRotationQuaternion;
  95042. private _pivotMatrix;
  95043. private _pivotMatrixInverse;
  95044. /** @hidden */
  95045. _postMultiplyPivotMatrix: boolean;
  95046. protected _isWorldMatrixFrozen: boolean;
  95047. /** @hidden */
  95048. _indexInSceneTransformNodesArray: number;
  95049. /**
  95050. * An event triggered after the world matrix is updated
  95051. */
  95052. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95053. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95054. /**
  95055. * Gets a string identifying the name of the class
  95056. * @returns "TransformNode" string
  95057. */
  95058. getClassName(): string;
  95059. /**
  95060. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95061. */
  95062. get position(): Vector3;
  95063. set position(newPosition: Vector3);
  95064. /**
  95065. * 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)).
  95066. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95067. */
  95068. get rotation(): Vector3;
  95069. set rotation(newRotation: Vector3);
  95070. /**
  95071. * 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)).
  95072. */
  95073. get scaling(): Vector3;
  95074. set scaling(newScaling: Vector3);
  95075. /**
  95076. * 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).
  95077. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95078. */
  95079. get rotationQuaternion(): Nullable<Quaternion>;
  95080. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95081. /**
  95082. * The forward direction of that transform in world space.
  95083. */
  95084. get forward(): Vector3;
  95085. /**
  95086. * The up direction of that transform in world space.
  95087. */
  95088. get up(): Vector3;
  95089. /**
  95090. * The right direction of that transform in world space.
  95091. */
  95092. get right(): Vector3;
  95093. /**
  95094. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95095. * @param matrix the matrix to copy the pose from
  95096. * @returns this TransformNode.
  95097. */
  95098. updatePoseMatrix(matrix: Matrix): TransformNode;
  95099. /**
  95100. * Returns the mesh Pose matrix.
  95101. * @returns the pose matrix
  95102. */
  95103. getPoseMatrix(): Matrix;
  95104. /** @hidden */
  95105. _isSynchronized(): boolean;
  95106. /** @hidden */
  95107. _initCache(): void;
  95108. /**
  95109. * Flag the transform node as dirty (Forcing it to update everything)
  95110. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95111. * @returns this transform node
  95112. */
  95113. markAsDirty(property: string): TransformNode;
  95114. /**
  95115. * Returns the current mesh absolute position.
  95116. * Returns a Vector3.
  95117. */
  95118. get absolutePosition(): Vector3;
  95119. /**
  95120. * Returns the current mesh absolute scaling.
  95121. * Returns a Vector3.
  95122. */
  95123. get absoluteScaling(): Vector3;
  95124. /**
  95125. * Returns the current mesh absolute rotation.
  95126. * Returns a Quaternion.
  95127. */
  95128. get absoluteRotationQuaternion(): Quaternion;
  95129. /**
  95130. * Sets a new matrix to apply before all other transformation
  95131. * @param matrix defines the transform matrix
  95132. * @returns the current TransformNode
  95133. */
  95134. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95135. /**
  95136. * Sets a new pivot matrix to the current node
  95137. * @param matrix defines the new pivot matrix to use
  95138. * @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
  95139. * @returns the current TransformNode
  95140. */
  95141. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95142. /**
  95143. * Returns the mesh pivot matrix.
  95144. * Default : Identity.
  95145. * @returns the matrix
  95146. */
  95147. getPivotMatrix(): Matrix;
  95148. /**
  95149. * Instantiate (when possible) or clone that node with its hierarchy
  95150. * @param newParent defines the new parent to use for the instance (or clone)
  95151. * @param options defines options to configure how copy is done
  95152. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95153. * @returns an instance (or a clone) of the current node with its hiearchy
  95154. */
  95155. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95156. doNotInstantiate: boolean;
  95157. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95158. /**
  95159. * Prevents the World matrix to be computed any longer
  95160. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95161. * @returns the TransformNode.
  95162. */
  95163. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95164. /**
  95165. * Allows back the World matrix computation.
  95166. * @returns the TransformNode.
  95167. */
  95168. unfreezeWorldMatrix(): this;
  95169. /**
  95170. * True if the World matrix has been frozen.
  95171. */
  95172. get isWorldMatrixFrozen(): boolean;
  95173. /**
  95174. * Retuns the mesh absolute position in the World.
  95175. * @returns a Vector3.
  95176. */
  95177. getAbsolutePosition(): Vector3;
  95178. /**
  95179. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95180. * @param absolutePosition the absolute position to set
  95181. * @returns the TransformNode.
  95182. */
  95183. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95184. /**
  95185. * Sets the mesh position in its local space.
  95186. * @param vector3 the position to set in localspace
  95187. * @returns the TransformNode.
  95188. */
  95189. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95190. /**
  95191. * Returns the mesh position in the local space from the current World matrix values.
  95192. * @returns a new Vector3.
  95193. */
  95194. getPositionExpressedInLocalSpace(): Vector3;
  95195. /**
  95196. * Translates the mesh along the passed Vector3 in its local space.
  95197. * @param vector3 the distance to translate in localspace
  95198. * @returns the TransformNode.
  95199. */
  95200. locallyTranslate(vector3: Vector3): TransformNode;
  95201. private static _lookAtVectorCache;
  95202. /**
  95203. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95204. * @param targetPoint the position (must be in same space as current mesh) to look at
  95205. * @param yawCor optional yaw (y-axis) correction in radians
  95206. * @param pitchCor optional pitch (x-axis) correction in radians
  95207. * @param rollCor optional roll (z-axis) correction in radians
  95208. * @param space the choosen space of the target
  95209. * @returns the TransformNode.
  95210. */
  95211. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95212. /**
  95213. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95214. * This Vector3 is expressed in the World space.
  95215. * @param localAxis axis to rotate
  95216. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95217. */
  95218. getDirection(localAxis: Vector3): Vector3;
  95219. /**
  95220. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95221. * localAxis is expressed in the mesh local space.
  95222. * result is computed in the Wordl space from the mesh World matrix.
  95223. * @param localAxis axis to rotate
  95224. * @param result the resulting transformnode
  95225. * @returns this TransformNode.
  95226. */
  95227. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95228. /**
  95229. * Sets this transform node rotation to the given local axis.
  95230. * @param localAxis the axis in local space
  95231. * @param yawCor optional yaw (y-axis) correction in radians
  95232. * @param pitchCor optional pitch (x-axis) correction in radians
  95233. * @param rollCor optional roll (z-axis) correction in radians
  95234. * @returns this TransformNode
  95235. */
  95236. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95237. /**
  95238. * Sets a new pivot point to the current node
  95239. * @param point defines the new pivot point to use
  95240. * @param space defines if the point is in world or local space (local by default)
  95241. * @returns the current TransformNode
  95242. */
  95243. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95244. /**
  95245. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95246. * @returns the pivot point
  95247. */
  95248. getPivotPoint(): Vector3;
  95249. /**
  95250. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95251. * @param result the vector3 to store the result
  95252. * @returns this TransformNode.
  95253. */
  95254. getPivotPointToRef(result: Vector3): TransformNode;
  95255. /**
  95256. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95257. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95258. */
  95259. getAbsolutePivotPoint(): Vector3;
  95260. /**
  95261. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95262. * @param result vector3 to store the result
  95263. * @returns this TransformNode.
  95264. */
  95265. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95266. /**
  95267. * Defines the passed node as the parent of the current node.
  95268. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95269. * @see https://doc.babylonjs.com/how_to/parenting
  95270. * @param node the node ot set as the parent
  95271. * @returns this TransformNode.
  95272. */
  95273. setParent(node: Nullable<Node>): TransformNode;
  95274. private _nonUniformScaling;
  95275. /**
  95276. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95277. */
  95278. get nonUniformScaling(): boolean;
  95279. /** @hidden */
  95280. _updateNonUniformScalingState(value: boolean): boolean;
  95281. /**
  95282. * Attach the current TransformNode to another TransformNode associated with a bone
  95283. * @param bone Bone affecting the TransformNode
  95284. * @param affectedTransformNode TransformNode associated with the bone
  95285. * @returns this object
  95286. */
  95287. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95288. /**
  95289. * Detach the transform node if its associated with a bone
  95290. * @returns this object
  95291. */
  95292. detachFromBone(): TransformNode;
  95293. private static _rotationAxisCache;
  95294. /**
  95295. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95296. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95298. * The passed axis is also normalized.
  95299. * @param axis the axis to rotate around
  95300. * @param amount the amount to rotate in radians
  95301. * @param space Space to rotate in (Default: local)
  95302. * @returns the TransformNode.
  95303. */
  95304. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95305. /**
  95306. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95307. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95308. * The passed axis is also normalized. .
  95309. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95310. * @param point the point to rotate around
  95311. * @param axis the axis to rotate around
  95312. * @param amount the amount to rotate in radians
  95313. * @returns the TransformNode
  95314. */
  95315. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95316. /**
  95317. * Translates the mesh along the axis vector for the passed distance in the given space.
  95318. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95319. * @param axis the axis to translate in
  95320. * @param distance the distance to translate
  95321. * @param space Space to rotate in (Default: local)
  95322. * @returns the TransformNode.
  95323. */
  95324. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95325. /**
  95326. * Adds a rotation step to the mesh current rotation.
  95327. * x, y, z are Euler angles expressed in radians.
  95328. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95329. * This means this rotation is made in the mesh local space only.
  95330. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95331. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95332. * ```javascript
  95333. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95334. * ```
  95335. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95336. * 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.
  95337. * @param x Rotation to add
  95338. * @param y Rotation to add
  95339. * @param z Rotation to add
  95340. * @returns the TransformNode.
  95341. */
  95342. addRotation(x: number, y: number, z: number): TransformNode;
  95343. /**
  95344. * @hidden
  95345. */
  95346. protected _getEffectiveParent(): Nullable<Node>;
  95347. /**
  95348. * Computes the world matrix of the node
  95349. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95350. * @returns the world matrix
  95351. */
  95352. computeWorldMatrix(force?: boolean): Matrix;
  95353. /**
  95354. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95355. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95356. */
  95357. resetLocalMatrix(independentOfChildren?: boolean): void;
  95358. protected _afterComputeWorldMatrix(): void;
  95359. /**
  95360. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95361. * @param func callback function to add
  95362. *
  95363. * @returns the TransformNode.
  95364. */
  95365. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95366. /**
  95367. * Removes a registered callback function.
  95368. * @param func callback function to remove
  95369. * @returns the TransformNode.
  95370. */
  95371. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95372. /**
  95373. * Gets the position of the current mesh in camera space
  95374. * @param camera defines the camera to use
  95375. * @returns a position
  95376. */
  95377. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95378. /**
  95379. * Returns the distance from the mesh to the active camera
  95380. * @param camera defines the camera to use
  95381. * @returns the distance
  95382. */
  95383. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95384. /**
  95385. * Clone the current transform node
  95386. * @param name Name of the new clone
  95387. * @param newParent New parent for the clone
  95388. * @param doNotCloneChildren Do not clone children hierarchy
  95389. * @returns the new transform node
  95390. */
  95391. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95392. /**
  95393. * Serializes the objects information.
  95394. * @param currentSerializationObject defines the object to serialize in
  95395. * @returns the serialized object
  95396. */
  95397. serialize(currentSerializationObject?: any): any;
  95398. /**
  95399. * Returns a new TransformNode object parsed from the source provided.
  95400. * @param parsedTransformNode is the source.
  95401. * @param scene the scne the object belongs to
  95402. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95403. * @returns a new TransformNode object parsed from the source provided.
  95404. */
  95405. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95406. /**
  95407. * Get all child-transformNodes of this node
  95408. * @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
  95409. * @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
  95410. * @returns an array of TransformNode
  95411. */
  95412. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95413. /**
  95414. * Releases resources associated with this transform node.
  95415. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95416. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95417. */
  95418. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95419. /**
  95420. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95421. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95422. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95423. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95424. * @returns the current mesh
  95425. */
  95426. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95427. private _syncAbsoluteScalingAndRotation;
  95428. }
  95429. }
  95430. declare module BABYLON {
  95431. /**
  95432. * Class used to override all child animations of a given target
  95433. */
  95434. export class AnimationPropertiesOverride {
  95435. /**
  95436. * Gets or sets a value indicating if animation blending must be used
  95437. */
  95438. enableBlending: boolean;
  95439. /**
  95440. * Gets or sets the blending speed to use when enableBlending is true
  95441. */
  95442. blendingSpeed: number;
  95443. /**
  95444. * Gets or sets the default loop mode to use
  95445. */
  95446. loopMode: number;
  95447. }
  95448. }
  95449. declare module BABYLON {
  95450. /**
  95451. * Class used to store bone information
  95452. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95453. */
  95454. export class Bone extends Node {
  95455. /**
  95456. * defines the bone name
  95457. */
  95458. name: string;
  95459. private static _tmpVecs;
  95460. private static _tmpQuat;
  95461. private static _tmpMats;
  95462. /**
  95463. * Gets the list of child bones
  95464. */
  95465. children: Bone[];
  95466. /** Gets the animations associated with this bone */
  95467. animations: Animation[];
  95468. /**
  95469. * Gets or sets bone length
  95470. */
  95471. length: number;
  95472. /**
  95473. * @hidden Internal only
  95474. * Set this value to map this bone to a different index in the transform matrices
  95475. * Set this value to -1 to exclude the bone from the transform matrices
  95476. */
  95477. _index: Nullable<number>;
  95478. private _skeleton;
  95479. private _localMatrix;
  95480. private _restPose;
  95481. private _bindPose;
  95482. private _baseMatrix;
  95483. private _absoluteTransform;
  95484. private _invertedAbsoluteTransform;
  95485. private _parent;
  95486. private _scalingDeterminant;
  95487. private _worldTransform;
  95488. private _localScaling;
  95489. private _localRotation;
  95490. private _localPosition;
  95491. private _needToDecompose;
  95492. private _needToCompose;
  95493. /** @hidden */
  95494. _linkedTransformNode: Nullable<TransformNode>;
  95495. /** @hidden */
  95496. _waitingTransformNodeId: Nullable<string>;
  95497. /** @hidden */
  95498. get _matrix(): Matrix;
  95499. /** @hidden */
  95500. set _matrix(value: Matrix);
  95501. /**
  95502. * Create a new bone
  95503. * @param name defines the bone name
  95504. * @param skeleton defines the parent skeleton
  95505. * @param parentBone defines the parent (can be null if the bone is the root)
  95506. * @param localMatrix defines the local matrix
  95507. * @param restPose defines the rest pose matrix
  95508. * @param baseMatrix defines the base matrix
  95509. * @param index defines index of the bone in the hiearchy
  95510. */
  95511. constructor(
  95512. /**
  95513. * defines the bone name
  95514. */
  95515. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95516. /**
  95517. * Gets the current object class name.
  95518. * @return the class name
  95519. */
  95520. getClassName(): string;
  95521. /**
  95522. * Gets the parent skeleton
  95523. * @returns a skeleton
  95524. */
  95525. getSkeleton(): Skeleton;
  95526. /**
  95527. * Gets parent bone
  95528. * @returns a bone or null if the bone is the root of the bone hierarchy
  95529. */
  95530. getParent(): Nullable<Bone>;
  95531. /**
  95532. * Returns an array containing the root bones
  95533. * @returns an array containing the root bones
  95534. */
  95535. getChildren(): Array<Bone>;
  95536. /**
  95537. * Gets the node index in matrix array generated for rendering
  95538. * @returns the node index
  95539. */
  95540. getIndex(): number;
  95541. /**
  95542. * Sets the parent bone
  95543. * @param parent defines the parent (can be null if the bone is the root)
  95544. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95545. */
  95546. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95547. /**
  95548. * Gets the local matrix
  95549. * @returns a matrix
  95550. */
  95551. getLocalMatrix(): Matrix;
  95552. /**
  95553. * Gets the base matrix (initial matrix which remains unchanged)
  95554. * @returns a matrix
  95555. */
  95556. getBaseMatrix(): Matrix;
  95557. /**
  95558. * Gets the rest pose matrix
  95559. * @returns a matrix
  95560. */
  95561. getRestPose(): Matrix;
  95562. /**
  95563. * Sets the rest pose matrix
  95564. * @param matrix the local-space rest pose to set for this bone
  95565. */
  95566. setRestPose(matrix: Matrix): void;
  95567. /**
  95568. * Gets the bind pose matrix
  95569. * @returns the bind pose matrix
  95570. */
  95571. getBindPose(): Matrix;
  95572. /**
  95573. * Sets the bind pose matrix
  95574. * @param matrix the local-space bind pose to set for this bone
  95575. */
  95576. setBindPose(matrix: Matrix): void;
  95577. /**
  95578. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95579. */
  95580. getWorldMatrix(): Matrix;
  95581. /**
  95582. * Sets the local matrix to rest pose matrix
  95583. */
  95584. returnToRest(): void;
  95585. /**
  95586. * Gets the inverse of the absolute transform matrix.
  95587. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95588. * @returns a matrix
  95589. */
  95590. getInvertedAbsoluteTransform(): Matrix;
  95591. /**
  95592. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95593. * @returns a matrix
  95594. */
  95595. getAbsoluteTransform(): Matrix;
  95596. /**
  95597. * Links with the given transform node.
  95598. * The local matrix of this bone is copied from the transform node every frame.
  95599. * @param transformNode defines the transform node to link to
  95600. */
  95601. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95602. /**
  95603. * Gets the node used to drive the bone's transformation
  95604. * @returns a transform node or null
  95605. */
  95606. getTransformNode(): Nullable<TransformNode>;
  95607. /** Gets or sets current position (in local space) */
  95608. get position(): Vector3;
  95609. set position(newPosition: Vector3);
  95610. /** Gets or sets current rotation (in local space) */
  95611. get rotation(): Vector3;
  95612. set rotation(newRotation: Vector3);
  95613. /** Gets or sets current rotation quaternion (in local space) */
  95614. get rotationQuaternion(): Quaternion;
  95615. set rotationQuaternion(newRotation: Quaternion);
  95616. /** Gets or sets current scaling (in local space) */
  95617. get scaling(): Vector3;
  95618. set scaling(newScaling: Vector3);
  95619. /**
  95620. * Gets the animation properties override
  95621. */
  95622. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95623. private _decompose;
  95624. private _compose;
  95625. /**
  95626. * Update the base and local matrices
  95627. * @param matrix defines the new base or local matrix
  95628. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95629. * @param updateLocalMatrix defines if the local matrix should be updated
  95630. */
  95631. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95632. /** @hidden */
  95633. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95634. /**
  95635. * Flag the bone as dirty (Forcing it to update everything)
  95636. */
  95637. markAsDirty(): void;
  95638. /** @hidden */
  95639. _markAsDirtyAndCompose(): void;
  95640. private _markAsDirtyAndDecompose;
  95641. /**
  95642. * Translate the bone in local or world space
  95643. * @param vec The amount to translate the bone
  95644. * @param space The space that the translation is in
  95645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95646. */
  95647. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95648. /**
  95649. * Set the postion of the bone in local or world space
  95650. * @param position The position to set the bone
  95651. * @param space The space that the position is in
  95652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95653. */
  95654. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95655. /**
  95656. * Set the absolute position of the bone (world space)
  95657. * @param position The position to set the bone
  95658. * @param mesh The mesh that this bone is attached to
  95659. */
  95660. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95661. /**
  95662. * Scale the bone on the x, y and z axes (in local space)
  95663. * @param x The amount to scale the bone on the x axis
  95664. * @param y The amount to scale the bone on the y axis
  95665. * @param z The amount to scale the bone on the z axis
  95666. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95667. */
  95668. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95669. /**
  95670. * Set the bone scaling in local space
  95671. * @param scale defines the scaling vector
  95672. */
  95673. setScale(scale: Vector3): void;
  95674. /**
  95675. * Gets the current scaling in local space
  95676. * @returns the current scaling vector
  95677. */
  95678. getScale(): Vector3;
  95679. /**
  95680. * Gets the current scaling in local space and stores it in a target vector
  95681. * @param result defines the target vector
  95682. */
  95683. getScaleToRef(result: Vector3): void;
  95684. /**
  95685. * Set the yaw, pitch, and roll of the bone in local or world space
  95686. * @param yaw The rotation of the bone on the y axis
  95687. * @param pitch The rotation of the bone on the x axis
  95688. * @param roll The rotation of the bone on the z axis
  95689. * @param space The space that the axes of rotation are in
  95690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95691. */
  95692. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95693. /**
  95694. * Add a rotation to the bone on an axis in local or world space
  95695. * @param axis The axis to rotate the bone on
  95696. * @param amount The amount to rotate the bone
  95697. * @param space The space that the axis is in
  95698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95699. */
  95700. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95701. /**
  95702. * Set the rotation of the bone to a particular axis angle in local or world space
  95703. * @param axis The axis to rotate the bone on
  95704. * @param angle The angle that the bone should be rotated to
  95705. * @param space The space that the axis is in
  95706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95707. */
  95708. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95709. /**
  95710. * Set the euler rotation of the bone in local or world space
  95711. * @param rotation The euler rotation that the bone should be set to
  95712. * @param space The space that the rotation is in
  95713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95714. */
  95715. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95716. /**
  95717. * Set the quaternion rotation of the bone in local or world space
  95718. * @param quat The quaternion rotation that the bone should be set to
  95719. * @param space The space that the rotation is in
  95720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95721. */
  95722. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95723. /**
  95724. * Set the rotation matrix of the bone in local or world space
  95725. * @param rotMat The rotation matrix that the bone should be set to
  95726. * @param space The space that the rotation is in
  95727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95728. */
  95729. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95730. private _rotateWithMatrix;
  95731. private _getNegativeRotationToRef;
  95732. /**
  95733. * Get the position of the bone in local or world space
  95734. * @param space The space that the returned position is in
  95735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95736. * @returns The position of the bone
  95737. */
  95738. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95739. /**
  95740. * Copy the position of the bone to a vector3 in local or world space
  95741. * @param space The space that the returned position is in
  95742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95743. * @param result The vector3 to copy the position to
  95744. */
  95745. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95746. /**
  95747. * Get the absolute position of the bone (world space)
  95748. * @param mesh The mesh that this bone is attached to
  95749. * @returns The absolute position of the bone
  95750. */
  95751. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95752. /**
  95753. * Copy the absolute position of the bone (world space) to the result param
  95754. * @param mesh The mesh that this bone is attached to
  95755. * @param result The vector3 to copy the absolute position to
  95756. */
  95757. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95758. /**
  95759. * Compute the absolute transforms of this bone and its children
  95760. */
  95761. computeAbsoluteTransforms(): void;
  95762. /**
  95763. * Get the world direction from an axis that is in the local space of the bone
  95764. * @param localAxis The local direction that is used to compute the world direction
  95765. * @param mesh The mesh that this bone is attached to
  95766. * @returns The world direction
  95767. */
  95768. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95769. /**
  95770. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95771. * @param localAxis The local direction that is used to compute the world direction
  95772. * @param mesh The mesh that this bone is attached to
  95773. * @param result The vector3 that the world direction will be copied to
  95774. */
  95775. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95776. /**
  95777. * Get the euler rotation of the bone in local or world space
  95778. * @param space The space that the rotation should be in
  95779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95780. * @returns The euler rotation
  95781. */
  95782. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95783. /**
  95784. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95785. * @param space The space that the rotation should be in
  95786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95787. * @param result The vector3 that the rotation should be copied to
  95788. */
  95789. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95790. /**
  95791. * Get the quaternion rotation of the bone in either local or world space
  95792. * @param space The space that the rotation should be in
  95793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95794. * @returns The quaternion rotation
  95795. */
  95796. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95797. /**
  95798. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95799. * @param space The space that the rotation should be in
  95800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95801. * @param result The quaternion that the rotation should be copied to
  95802. */
  95803. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95804. /**
  95805. * Get the rotation matrix of the bone in local or world space
  95806. * @param space The space that the rotation should be in
  95807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95808. * @returns The rotation matrix
  95809. */
  95810. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95811. /**
  95812. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95813. * @param space The space that the rotation should be in
  95814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95815. * @param result The quaternion that the rotation should be copied to
  95816. */
  95817. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95818. /**
  95819. * Get the world position of a point that is in the local space of the bone
  95820. * @param position The local position
  95821. * @param mesh The mesh that this bone is attached to
  95822. * @returns The world position
  95823. */
  95824. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95825. /**
  95826. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95827. * @param position The local position
  95828. * @param mesh The mesh that this bone is attached to
  95829. * @param result The vector3 that the world position should be copied to
  95830. */
  95831. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95832. /**
  95833. * Get the local position of a point that is in world space
  95834. * @param position The world position
  95835. * @param mesh The mesh that this bone is attached to
  95836. * @returns The local position
  95837. */
  95838. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95839. /**
  95840. * Get the local position of a point that is in world space and copy it to the result param
  95841. * @param position The world position
  95842. * @param mesh The mesh that this bone is attached to
  95843. * @param result The vector3 that the local position should be copied to
  95844. */
  95845. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95846. /**
  95847. * Set the current local matrix as the restPose for this bone.
  95848. */
  95849. setCurrentPoseAsRest(): void;
  95850. }
  95851. }
  95852. declare module BABYLON {
  95853. /**
  95854. * Defines a runtime animation
  95855. */
  95856. export class RuntimeAnimation {
  95857. private _events;
  95858. /**
  95859. * The current frame of the runtime animation
  95860. */
  95861. private _currentFrame;
  95862. /**
  95863. * The animation used by the runtime animation
  95864. */
  95865. private _animation;
  95866. /**
  95867. * The target of the runtime animation
  95868. */
  95869. private _target;
  95870. /**
  95871. * The initiating animatable
  95872. */
  95873. private _host;
  95874. /**
  95875. * The original value of the runtime animation
  95876. */
  95877. private _originalValue;
  95878. /**
  95879. * The original blend value of the runtime animation
  95880. */
  95881. private _originalBlendValue;
  95882. /**
  95883. * The offsets cache of the runtime animation
  95884. */
  95885. private _offsetsCache;
  95886. /**
  95887. * The high limits cache of the runtime animation
  95888. */
  95889. private _highLimitsCache;
  95890. /**
  95891. * Specifies if the runtime animation has been stopped
  95892. */
  95893. private _stopped;
  95894. /**
  95895. * The blending factor of the runtime animation
  95896. */
  95897. private _blendingFactor;
  95898. /**
  95899. * The BabylonJS scene
  95900. */
  95901. private _scene;
  95902. /**
  95903. * The current value of the runtime animation
  95904. */
  95905. private _currentValue;
  95906. /** @hidden */
  95907. _animationState: _IAnimationState;
  95908. /**
  95909. * The active target of the runtime animation
  95910. */
  95911. private _activeTargets;
  95912. private _currentActiveTarget;
  95913. private _directTarget;
  95914. /**
  95915. * The target path of the runtime animation
  95916. */
  95917. private _targetPath;
  95918. /**
  95919. * The weight of the runtime animation
  95920. */
  95921. private _weight;
  95922. /**
  95923. * The ratio offset of the runtime animation
  95924. */
  95925. private _ratioOffset;
  95926. /**
  95927. * The previous delay of the runtime animation
  95928. */
  95929. private _previousDelay;
  95930. /**
  95931. * The previous ratio of the runtime animation
  95932. */
  95933. private _previousRatio;
  95934. private _enableBlending;
  95935. private _keys;
  95936. private _minFrame;
  95937. private _maxFrame;
  95938. private _minValue;
  95939. private _maxValue;
  95940. private _targetIsArray;
  95941. /**
  95942. * Gets the current frame of the runtime animation
  95943. */
  95944. get currentFrame(): number;
  95945. /**
  95946. * Gets the weight of the runtime animation
  95947. */
  95948. get weight(): number;
  95949. /**
  95950. * Gets the current value of the runtime animation
  95951. */
  95952. get currentValue(): any;
  95953. /**
  95954. * Gets the target path of the runtime animation
  95955. */
  95956. get targetPath(): string;
  95957. /**
  95958. * Gets the actual target of the runtime animation
  95959. */
  95960. get target(): any;
  95961. /**
  95962. * Gets the additive state of the runtime animation
  95963. */
  95964. get isAdditive(): boolean;
  95965. /** @hidden */
  95966. _onLoop: () => void;
  95967. /**
  95968. * Create a new RuntimeAnimation object
  95969. * @param target defines the target of the animation
  95970. * @param animation defines the source animation object
  95971. * @param scene defines the hosting scene
  95972. * @param host defines the initiating Animatable
  95973. */
  95974. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95975. private _preparePath;
  95976. /**
  95977. * Gets the animation from the runtime animation
  95978. */
  95979. get animation(): Animation;
  95980. /**
  95981. * Resets the runtime animation to the beginning
  95982. * @param restoreOriginal defines whether to restore the target property to the original value
  95983. */
  95984. reset(restoreOriginal?: boolean): void;
  95985. /**
  95986. * Specifies if the runtime animation is stopped
  95987. * @returns Boolean specifying if the runtime animation is stopped
  95988. */
  95989. isStopped(): boolean;
  95990. /**
  95991. * Disposes of the runtime animation
  95992. */
  95993. dispose(): void;
  95994. /**
  95995. * Apply the interpolated value to the target
  95996. * @param currentValue defines the value computed by the animation
  95997. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95998. */
  95999. setValue(currentValue: any, weight: number): void;
  96000. private _getOriginalValues;
  96001. private _setValue;
  96002. /**
  96003. * Gets the loop pmode of the runtime animation
  96004. * @returns Loop Mode
  96005. */
  96006. private _getCorrectLoopMode;
  96007. /**
  96008. * Move the current animation to a given frame
  96009. * @param frame defines the frame to move to
  96010. */
  96011. goToFrame(frame: number): void;
  96012. /**
  96013. * @hidden Internal use only
  96014. */
  96015. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96016. /**
  96017. * Execute the current animation
  96018. * @param delay defines the delay to add to the current frame
  96019. * @param from defines the lower bound of the animation range
  96020. * @param to defines the upper bound of the animation range
  96021. * @param loop defines if the current animation must loop
  96022. * @param speedRatio defines the current speed ratio
  96023. * @param weight defines the weight of the animation (default is -1 so no weight)
  96024. * @param onLoop optional callback called when animation loops
  96025. * @returns a boolean indicating if the animation is running
  96026. */
  96027. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96028. }
  96029. }
  96030. declare module BABYLON {
  96031. /**
  96032. * Class used to store an actual running animation
  96033. */
  96034. export class Animatable {
  96035. /** defines the target object */
  96036. target: any;
  96037. /** defines the starting frame number (default is 0) */
  96038. fromFrame: number;
  96039. /** defines the ending frame number (default is 100) */
  96040. toFrame: number;
  96041. /** defines if the animation must loop (default is false) */
  96042. loopAnimation: boolean;
  96043. /** defines a callback to call when animation ends if it is not looping */
  96044. onAnimationEnd?: (() => void) | null | undefined;
  96045. /** defines a callback to call when animation loops */
  96046. onAnimationLoop?: (() => void) | null | undefined;
  96047. /** defines whether the animation should be evaluated additively */
  96048. isAdditive: boolean;
  96049. private _localDelayOffset;
  96050. private _pausedDelay;
  96051. private _runtimeAnimations;
  96052. private _paused;
  96053. private _scene;
  96054. private _speedRatio;
  96055. private _weight;
  96056. private _syncRoot;
  96057. /**
  96058. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96059. * This will only apply for non looping animation (default is true)
  96060. */
  96061. disposeOnEnd: boolean;
  96062. /**
  96063. * Gets a boolean indicating if the animation has started
  96064. */
  96065. animationStarted: boolean;
  96066. /**
  96067. * Observer raised when the animation ends
  96068. */
  96069. onAnimationEndObservable: Observable<Animatable>;
  96070. /**
  96071. * Observer raised when the animation loops
  96072. */
  96073. onAnimationLoopObservable: Observable<Animatable>;
  96074. /**
  96075. * Gets the root Animatable used to synchronize and normalize animations
  96076. */
  96077. get syncRoot(): Nullable<Animatable>;
  96078. /**
  96079. * Gets the current frame of the first RuntimeAnimation
  96080. * Used to synchronize Animatables
  96081. */
  96082. get masterFrame(): number;
  96083. /**
  96084. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96085. */
  96086. get weight(): number;
  96087. set weight(value: number);
  96088. /**
  96089. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96090. */
  96091. get speedRatio(): number;
  96092. set speedRatio(value: number);
  96093. /**
  96094. * Creates a new Animatable
  96095. * @param scene defines the hosting scene
  96096. * @param target defines the target object
  96097. * @param fromFrame defines the starting frame number (default is 0)
  96098. * @param toFrame defines the ending frame number (default is 100)
  96099. * @param loopAnimation defines if the animation must loop (default is false)
  96100. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96101. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96102. * @param animations defines a group of animation to add to the new Animatable
  96103. * @param onAnimationLoop defines a callback to call when animation loops
  96104. * @param isAdditive defines whether the animation should be evaluated additively
  96105. */
  96106. constructor(scene: Scene,
  96107. /** defines the target object */
  96108. target: any,
  96109. /** defines the starting frame number (default is 0) */
  96110. fromFrame?: number,
  96111. /** defines the ending frame number (default is 100) */
  96112. toFrame?: number,
  96113. /** defines if the animation must loop (default is false) */
  96114. loopAnimation?: boolean, speedRatio?: number,
  96115. /** defines a callback to call when animation ends if it is not looping */
  96116. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96117. /** defines a callback to call when animation loops */
  96118. onAnimationLoop?: (() => void) | null | undefined,
  96119. /** defines whether the animation should be evaluated additively */
  96120. isAdditive?: boolean);
  96121. /**
  96122. * Synchronize and normalize current Animatable with a source Animatable
  96123. * This is useful when using animation weights and when animations are not of the same length
  96124. * @param root defines the root Animatable to synchronize with
  96125. * @returns the current Animatable
  96126. */
  96127. syncWith(root: Animatable): Animatable;
  96128. /**
  96129. * Gets the list of runtime animations
  96130. * @returns an array of RuntimeAnimation
  96131. */
  96132. getAnimations(): RuntimeAnimation[];
  96133. /**
  96134. * Adds more animations to the current animatable
  96135. * @param target defines the target of the animations
  96136. * @param animations defines the new animations to add
  96137. */
  96138. appendAnimations(target: any, animations: Animation[]): void;
  96139. /**
  96140. * Gets the source animation for a specific property
  96141. * @param property defines the propertyu to look for
  96142. * @returns null or the source animation for the given property
  96143. */
  96144. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96145. /**
  96146. * Gets the runtime animation for a specific property
  96147. * @param property defines the propertyu to look for
  96148. * @returns null or the runtime animation for the given property
  96149. */
  96150. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96151. /**
  96152. * Resets the animatable to its original state
  96153. */
  96154. reset(): void;
  96155. /**
  96156. * Allows the animatable to blend with current running animations
  96157. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96158. * @param blendingSpeed defines the blending speed to use
  96159. */
  96160. enableBlending(blendingSpeed: number): void;
  96161. /**
  96162. * Disable animation blending
  96163. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96164. */
  96165. disableBlending(): void;
  96166. /**
  96167. * Jump directly to a given frame
  96168. * @param frame defines the frame to jump to
  96169. */
  96170. goToFrame(frame: number): void;
  96171. /**
  96172. * Pause the animation
  96173. */
  96174. pause(): void;
  96175. /**
  96176. * Restart the animation
  96177. */
  96178. restart(): void;
  96179. private _raiseOnAnimationEnd;
  96180. /**
  96181. * Stop and delete the current animation
  96182. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96183. * @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)
  96184. */
  96185. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96186. /**
  96187. * Wait asynchronously for the animation to end
  96188. * @returns a promise which will be fullfilled when the animation ends
  96189. */
  96190. waitAsync(): Promise<Animatable>;
  96191. /** @hidden */
  96192. _animate(delay: number): boolean;
  96193. }
  96194. interface Scene {
  96195. /** @hidden */
  96196. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96197. /** @hidden */
  96198. _processLateAnimationBindingsForMatrices(holder: {
  96199. totalWeight: number;
  96200. totalAdditiveWeight: number;
  96201. animations: RuntimeAnimation[];
  96202. additiveAnimations: RuntimeAnimation[];
  96203. originalValue: Matrix;
  96204. }): any;
  96205. /** @hidden */
  96206. _processLateAnimationBindingsForQuaternions(holder: {
  96207. totalWeight: number;
  96208. totalAdditiveWeight: number;
  96209. animations: RuntimeAnimation[];
  96210. additiveAnimations: RuntimeAnimation[];
  96211. originalValue: Quaternion;
  96212. }, refQuaternion: Quaternion): Quaternion;
  96213. /** @hidden */
  96214. _processLateAnimationBindings(): void;
  96215. /**
  96216. * Will start the animation sequence of a given target
  96217. * @param target defines the target
  96218. * @param from defines from which frame should animation start
  96219. * @param to defines until which frame should animation run.
  96220. * @param weight defines the weight to apply to the animation (1.0 by default)
  96221. * @param loop defines if the animation loops
  96222. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96223. * @param onAnimationEnd defines the function to be executed when the animation ends
  96224. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96225. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96226. * @param onAnimationLoop defines the callback to call when an animation loops
  96227. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96228. * @returns the animatable object created for this animation
  96229. */
  96230. 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;
  96231. /**
  96232. * Will start the animation sequence of a given target
  96233. * @param target defines the target
  96234. * @param from defines from which frame should animation start
  96235. * @param to defines until which frame should animation run.
  96236. * @param loop defines if the animation loops
  96237. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96238. * @param onAnimationEnd defines the function to be executed when the animation ends
  96239. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96240. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96241. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96242. * @param onAnimationLoop defines the callback to call when an animation loops
  96243. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96244. * @returns the animatable object created for this animation
  96245. */
  96246. 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;
  96247. /**
  96248. * Will start the animation sequence of a given target and its hierarchy
  96249. * @param target defines the target
  96250. * @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.
  96251. * @param from defines from which frame should animation start
  96252. * @param to defines until which frame should animation run.
  96253. * @param loop defines if the animation loops
  96254. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96255. * @param onAnimationEnd defines the function to be executed when the animation ends
  96256. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96257. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96258. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96259. * @param onAnimationLoop defines the callback to call when an animation loops
  96260. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96261. * @returns the list of created animatables
  96262. */
  96263. 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[];
  96264. /**
  96265. * Begin a new animation on a given node
  96266. * @param target defines the target where the animation will take place
  96267. * @param animations defines the list of animations to start
  96268. * @param from defines the initial value
  96269. * @param to defines the final value
  96270. * @param loop defines if you want animation to loop (off by default)
  96271. * @param speedRatio defines the speed ratio to apply to all animations
  96272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96273. * @param onAnimationLoop defines the callback to call when an animation loops
  96274. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96275. * @returns the list of created animatables
  96276. */
  96277. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96278. /**
  96279. * Begin a new animation on a given node and its hierarchy
  96280. * @param target defines the root node where the animation will take place
  96281. * @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.
  96282. * @param animations defines the list of animations to start
  96283. * @param from defines the initial value
  96284. * @param to defines the final value
  96285. * @param loop defines if you want animation to loop (off by default)
  96286. * @param speedRatio defines the speed ratio to apply to all animations
  96287. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96288. * @param onAnimationLoop defines the callback to call when an animation loops
  96289. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96290. * @returns the list of animatables created for all nodes
  96291. */
  96292. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96293. /**
  96294. * Gets the animatable associated with a specific target
  96295. * @param target defines the target of the animatable
  96296. * @returns the required animatable if found
  96297. */
  96298. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96299. /**
  96300. * Gets all animatables associated with a given target
  96301. * @param target defines the target to look animatables for
  96302. * @returns an array of Animatables
  96303. */
  96304. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96305. /**
  96306. * Stops and removes all animations that have been applied to the scene
  96307. */
  96308. stopAllAnimations(): void;
  96309. /**
  96310. * Gets the current delta time used by animation engine
  96311. */
  96312. deltaTime: number;
  96313. }
  96314. interface Bone {
  96315. /**
  96316. * Copy an animation range from another bone
  96317. * @param source defines the source bone
  96318. * @param rangeName defines the range name to copy
  96319. * @param frameOffset defines the frame offset
  96320. * @param rescaleAsRequired defines if rescaling must be applied if required
  96321. * @param skelDimensionsRatio defines the scaling ratio
  96322. * @returns true if operation was successful
  96323. */
  96324. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96325. }
  96326. }
  96327. declare module BABYLON {
  96328. /**
  96329. * Class used to handle skinning animations
  96330. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96331. */
  96332. export class Skeleton implements IAnimatable {
  96333. /** defines the skeleton name */
  96334. name: string;
  96335. /** defines the skeleton Id */
  96336. id: string;
  96337. /**
  96338. * Defines the list of child bones
  96339. */
  96340. bones: Bone[];
  96341. /**
  96342. * Defines an estimate of the dimension of the skeleton at rest
  96343. */
  96344. dimensionsAtRest: Vector3;
  96345. /**
  96346. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96347. */
  96348. needInitialSkinMatrix: boolean;
  96349. /**
  96350. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96351. */
  96352. overrideMesh: Nullable<AbstractMesh>;
  96353. /**
  96354. * Gets the list of animations attached to this skeleton
  96355. */
  96356. animations: Array<Animation>;
  96357. private _scene;
  96358. private _isDirty;
  96359. private _transformMatrices;
  96360. private _transformMatrixTexture;
  96361. private _meshesWithPoseMatrix;
  96362. private _animatables;
  96363. private _identity;
  96364. private _synchronizedWithMesh;
  96365. private _ranges;
  96366. private _lastAbsoluteTransformsUpdateId;
  96367. private _canUseTextureForBones;
  96368. private _uniqueId;
  96369. /** @hidden */
  96370. _numBonesWithLinkedTransformNode: number;
  96371. /** @hidden */
  96372. _hasWaitingData: Nullable<boolean>;
  96373. /** @hidden */
  96374. _waitingOverrideMeshId: Nullable<string>;
  96375. /**
  96376. * Specifies if the skeleton should be serialized
  96377. */
  96378. doNotSerialize: boolean;
  96379. private _useTextureToStoreBoneMatrices;
  96380. /**
  96381. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96382. * Please note that this option is not available if the hardware does not support it
  96383. */
  96384. get useTextureToStoreBoneMatrices(): boolean;
  96385. set useTextureToStoreBoneMatrices(value: boolean);
  96386. private _animationPropertiesOverride;
  96387. /**
  96388. * Gets or sets the animation properties override
  96389. */
  96390. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96391. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96392. /**
  96393. * List of inspectable custom properties (used by the Inspector)
  96394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96395. */
  96396. inspectableCustomProperties: IInspectable[];
  96397. /**
  96398. * An observable triggered before computing the skeleton's matrices
  96399. */
  96400. onBeforeComputeObservable: Observable<Skeleton>;
  96401. /**
  96402. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96403. */
  96404. get isUsingTextureForMatrices(): boolean;
  96405. /**
  96406. * Gets the unique ID of this skeleton
  96407. */
  96408. get uniqueId(): number;
  96409. /**
  96410. * Creates a new skeleton
  96411. * @param name defines the skeleton name
  96412. * @param id defines the skeleton Id
  96413. * @param scene defines the hosting scene
  96414. */
  96415. constructor(
  96416. /** defines the skeleton name */
  96417. name: string,
  96418. /** defines the skeleton Id */
  96419. id: string, scene: Scene);
  96420. /**
  96421. * Gets the current object class name.
  96422. * @return the class name
  96423. */
  96424. getClassName(): string;
  96425. /**
  96426. * Returns an array containing the root bones
  96427. * @returns an array containing the root bones
  96428. */
  96429. getChildren(): Array<Bone>;
  96430. /**
  96431. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96432. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96433. * @returns a Float32Array containing matrices data
  96434. */
  96435. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96436. /**
  96437. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96438. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96439. * @returns a raw texture containing the data
  96440. */
  96441. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96442. /**
  96443. * Gets the current hosting scene
  96444. * @returns a scene object
  96445. */
  96446. getScene(): Scene;
  96447. /**
  96448. * Gets a string representing the current skeleton data
  96449. * @param fullDetails defines a boolean indicating if we want a verbose version
  96450. * @returns a string representing the current skeleton data
  96451. */
  96452. toString(fullDetails?: boolean): string;
  96453. /**
  96454. * Get bone's index searching by name
  96455. * @param name defines bone's name to search for
  96456. * @return the indice of the bone. Returns -1 if not found
  96457. */
  96458. getBoneIndexByName(name: string): number;
  96459. /**
  96460. * Creater a new animation range
  96461. * @param name defines the name of the range
  96462. * @param from defines the start key
  96463. * @param to defines the end key
  96464. */
  96465. createAnimationRange(name: string, from: number, to: number): void;
  96466. /**
  96467. * Delete a specific animation range
  96468. * @param name defines the name of the range
  96469. * @param deleteFrames defines if frames must be removed as well
  96470. */
  96471. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96472. /**
  96473. * Gets a specific animation range
  96474. * @param name defines the name of the range to look for
  96475. * @returns the requested animation range or null if not found
  96476. */
  96477. getAnimationRange(name: string): Nullable<AnimationRange>;
  96478. /**
  96479. * Gets the list of all animation ranges defined on this skeleton
  96480. * @returns an array
  96481. */
  96482. getAnimationRanges(): Nullable<AnimationRange>[];
  96483. /**
  96484. * Copy animation range from a source skeleton.
  96485. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96486. * @param source defines the source skeleton
  96487. * @param name defines the name of the range to copy
  96488. * @param rescaleAsRequired defines if rescaling must be applied if required
  96489. * @returns true if operation was successful
  96490. */
  96491. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96492. /**
  96493. * Forces the skeleton to go to rest pose
  96494. */
  96495. returnToRest(): void;
  96496. private _getHighestAnimationFrame;
  96497. /**
  96498. * Begin a specific animation range
  96499. * @param name defines the name of the range to start
  96500. * @param loop defines if looping must be turned on (false by default)
  96501. * @param speedRatio defines the speed ratio to apply (1 by default)
  96502. * @param onAnimationEnd defines a callback which will be called when animation will end
  96503. * @returns a new animatable
  96504. */
  96505. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96506. /**
  96507. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96508. * @param skeleton defines the Skeleton containing the animation range to convert
  96509. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96510. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96511. * @returns the original skeleton
  96512. */
  96513. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96514. /** @hidden */
  96515. _markAsDirty(): void;
  96516. /** @hidden */
  96517. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96518. /** @hidden */
  96519. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96520. private _computeTransformMatrices;
  96521. /**
  96522. * Build all resources required to render a skeleton
  96523. */
  96524. prepare(): void;
  96525. /**
  96526. * Gets the list of animatables currently running for this skeleton
  96527. * @returns an array of animatables
  96528. */
  96529. getAnimatables(): IAnimatable[];
  96530. /**
  96531. * Clone the current skeleton
  96532. * @param name defines the name of the new skeleton
  96533. * @param id defines the id of the new skeleton
  96534. * @returns the new skeleton
  96535. */
  96536. clone(name: string, id?: string): Skeleton;
  96537. /**
  96538. * Enable animation blending for this skeleton
  96539. * @param blendingSpeed defines the blending speed to apply
  96540. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96541. */
  96542. enableBlending(blendingSpeed?: number): void;
  96543. /**
  96544. * Releases all resources associated with the current skeleton
  96545. */
  96546. dispose(): void;
  96547. /**
  96548. * Serialize the skeleton in a JSON object
  96549. * @returns a JSON object
  96550. */
  96551. serialize(): any;
  96552. /**
  96553. * Creates a new skeleton from serialized data
  96554. * @param parsedSkeleton defines the serialized data
  96555. * @param scene defines the hosting scene
  96556. * @returns a new skeleton
  96557. */
  96558. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96559. /**
  96560. * Compute all node absolute transforms
  96561. * @param forceUpdate defines if computation must be done even if cache is up to date
  96562. */
  96563. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96564. /**
  96565. * Gets the root pose matrix
  96566. * @returns a matrix
  96567. */
  96568. getPoseMatrix(): Nullable<Matrix>;
  96569. /**
  96570. * Sorts bones per internal index
  96571. */
  96572. sortBones(): void;
  96573. private _sortBones;
  96574. /**
  96575. * Set the current local matrix as the restPose for all bones in the skeleton.
  96576. */
  96577. setCurrentPoseAsRest(): void;
  96578. }
  96579. }
  96580. declare module BABYLON {
  96581. /**
  96582. * Creates an instance based on a source mesh.
  96583. */
  96584. export class InstancedMesh extends AbstractMesh {
  96585. private _sourceMesh;
  96586. private _currentLOD;
  96587. /** @hidden */
  96588. _indexInSourceMeshInstanceArray: number;
  96589. constructor(name: string, source: Mesh);
  96590. /**
  96591. * Returns the string "InstancedMesh".
  96592. */
  96593. getClassName(): string;
  96594. /** Gets the list of lights affecting that mesh */
  96595. get lightSources(): Light[];
  96596. _resyncLightSources(): void;
  96597. _resyncLightSource(light: Light): void;
  96598. _removeLightSource(light: Light, dispose: boolean): void;
  96599. /**
  96600. * If the source mesh receives shadows
  96601. */
  96602. get receiveShadows(): boolean;
  96603. /**
  96604. * The material of the source mesh
  96605. */
  96606. get material(): Nullable<Material>;
  96607. /**
  96608. * Visibility of the source mesh
  96609. */
  96610. get visibility(): number;
  96611. /**
  96612. * Skeleton of the source mesh
  96613. */
  96614. get skeleton(): Nullable<Skeleton>;
  96615. /**
  96616. * Rendering ground id of the source mesh
  96617. */
  96618. get renderingGroupId(): number;
  96619. set renderingGroupId(value: number);
  96620. /**
  96621. * Returns the total number of vertices (integer).
  96622. */
  96623. getTotalVertices(): number;
  96624. /**
  96625. * Returns a positive integer : the total number of indices in this mesh geometry.
  96626. * @returns the numner of indices or zero if the mesh has no geometry.
  96627. */
  96628. getTotalIndices(): number;
  96629. /**
  96630. * The source mesh of the instance
  96631. */
  96632. get sourceMesh(): Mesh;
  96633. /**
  96634. * Creates a new InstancedMesh object from the mesh model.
  96635. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96636. * @param name defines the name of the new instance
  96637. * @returns a new InstancedMesh
  96638. */
  96639. createInstance(name: string): InstancedMesh;
  96640. /**
  96641. * Is this node ready to be used/rendered
  96642. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96643. * @return {boolean} is it ready
  96644. */
  96645. isReady(completeCheck?: boolean): boolean;
  96646. /**
  96647. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96648. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96649. * @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.
  96650. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96651. */
  96652. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96653. /**
  96654. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96655. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96656. * The `data` are either a numeric array either a Float32Array.
  96657. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96658. * 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).
  96659. * Note that a new underlying VertexBuffer object is created each call.
  96660. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96661. *
  96662. * Possible `kind` values :
  96663. * - VertexBuffer.PositionKind
  96664. * - VertexBuffer.UVKind
  96665. * - VertexBuffer.UV2Kind
  96666. * - VertexBuffer.UV3Kind
  96667. * - VertexBuffer.UV4Kind
  96668. * - VertexBuffer.UV5Kind
  96669. * - VertexBuffer.UV6Kind
  96670. * - VertexBuffer.ColorKind
  96671. * - VertexBuffer.MatricesIndicesKind
  96672. * - VertexBuffer.MatricesIndicesExtraKind
  96673. * - VertexBuffer.MatricesWeightsKind
  96674. * - VertexBuffer.MatricesWeightsExtraKind
  96675. *
  96676. * Returns the Mesh.
  96677. */
  96678. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96679. /**
  96680. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96681. * If the mesh has no geometry, it is simply returned as it is.
  96682. * The `data` are either a numeric array either a Float32Array.
  96683. * No new underlying VertexBuffer object is created.
  96684. * 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.
  96685. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96686. *
  96687. * Possible `kind` values :
  96688. * - VertexBuffer.PositionKind
  96689. * - VertexBuffer.UVKind
  96690. * - VertexBuffer.UV2Kind
  96691. * - VertexBuffer.UV3Kind
  96692. * - VertexBuffer.UV4Kind
  96693. * - VertexBuffer.UV5Kind
  96694. * - VertexBuffer.UV6Kind
  96695. * - VertexBuffer.ColorKind
  96696. * - VertexBuffer.MatricesIndicesKind
  96697. * - VertexBuffer.MatricesIndicesExtraKind
  96698. * - VertexBuffer.MatricesWeightsKind
  96699. * - VertexBuffer.MatricesWeightsExtraKind
  96700. *
  96701. * Returns the Mesh.
  96702. */
  96703. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96704. /**
  96705. * Sets the mesh indices.
  96706. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96707. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96708. * This method creates a new index buffer each call.
  96709. * Returns the Mesh.
  96710. */
  96711. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96712. /**
  96713. * Boolean : True if the mesh owns the requested kind of data.
  96714. */
  96715. isVerticesDataPresent(kind: string): boolean;
  96716. /**
  96717. * Returns an array of indices (IndicesArray).
  96718. */
  96719. getIndices(): Nullable<IndicesArray>;
  96720. get _positions(): Nullable<Vector3[]>;
  96721. /**
  96722. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96723. * This means the mesh underlying bounding box and sphere are recomputed.
  96724. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96725. * @returns the current mesh
  96726. */
  96727. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96728. /** @hidden */
  96729. _preActivate(): InstancedMesh;
  96730. /** @hidden */
  96731. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96732. /** @hidden */
  96733. _postActivate(): void;
  96734. getWorldMatrix(): Matrix;
  96735. get isAnInstance(): boolean;
  96736. /**
  96737. * Returns the current associated LOD AbstractMesh.
  96738. */
  96739. getLOD(camera: Camera): AbstractMesh;
  96740. /** @hidden */
  96741. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96742. /** @hidden */
  96743. _syncSubMeshes(): InstancedMesh;
  96744. /** @hidden */
  96745. _generatePointsArray(): boolean;
  96746. /** @hidden */
  96747. _updateBoundingInfo(): AbstractMesh;
  96748. /**
  96749. * Creates a new InstancedMesh from the current mesh.
  96750. * - name (string) : the cloned mesh name
  96751. * - newParent (optional Node) : the optional Node to parent the clone to.
  96752. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96753. *
  96754. * Returns the clone.
  96755. */
  96756. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96757. /**
  96758. * Disposes the InstancedMesh.
  96759. * Returns nothing.
  96760. */
  96761. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96762. }
  96763. interface Mesh {
  96764. /**
  96765. * Register a custom buffer that will be instanced
  96766. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96767. * @param kind defines the buffer kind
  96768. * @param stride defines the stride in floats
  96769. */
  96770. registerInstancedBuffer(kind: string, stride: number): void;
  96771. /**
  96772. * true to use the edge renderer for all instances of this mesh
  96773. */
  96774. edgesShareWithInstances: boolean;
  96775. /** @hidden */
  96776. _userInstancedBuffersStorage: {
  96777. data: {
  96778. [key: string]: Float32Array;
  96779. };
  96780. sizes: {
  96781. [key: string]: number;
  96782. };
  96783. vertexBuffers: {
  96784. [key: string]: Nullable<VertexBuffer>;
  96785. };
  96786. strides: {
  96787. [key: string]: number;
  96788. };
  96789. };
  96790. }
  96791. interface AbstractMesh {
  96792. /**
  96793. * Object used to store instanced buffers defined by user
  96794. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96795. */
  96796. instancedBuffers: {
  96797. [key: string]: any;
  96798. };
  96799. }
  96800. }
  96801. declare module BABYLON {
  96802. /**
  96803. * Defines the options associated with the creation of a shader material.
  96804. */
  96805. export interface IShaderMaterialOptions {
  96806. /**
  96807. * Does the material work in alpha blend mode
  96808. */
  96809. needAlphaBlending: boolean;
  96810. /**
  96811. * Does the material work in alpha test mode
  96812. */
  96813. needAlphaTesting: boolean;
  96814. /**
  96815. * The list of attribute names used in the shader
  96816. */
  96817. attributes: string[];
  96818. /**
  96819. * The list of unifrom names used in the shader
  96820. */
  96821. uniforms: string[];
  96822. /**
  96823. * The list of UBO names used in the shader
  96824. */
  96825. uniformBuffers: string[];
  96826. /**
  96827. * The list of sampler names used in the shader
  96828. */
  96829. samplers: string[];
  96830. /**
  96831. * The list of defines used in the shader
  96832. */
  96833. defines: string[];
  96834. }
  96835. /**
  96836. * 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.
  96837. *
  96838. * This returned material effects how the mesh will look based on the code in the shaders.
  96839. *
  96840. * @see https://doc.babylonjs.com/how_to/shader_material
  96841. */
  96842. export class ShaderMaterial extends Material {
  96843. private _shaderPath;
  96844. private _options;
  96845. private _textures;
  96846. private _textureArrays;
  96847. private _floats;
  96848. private _ints;
  96849. private _floatsArrays;
  96850. private _colors3;
  96851. private _colors3Arrays;
  96852. private _colors4;
  96853. private _colors4Arrays;
  96854. private _vectors2;
  96855. private _vectors3;
  96856. private _vectors4;
  96857. private _matrices;
  96858. private _matrixArrays;
  96859. private _matrices3x3;
  96860. private _matrices2x2;
  96861. private _vectors2Arrays;
  96862. private _vectors3Arrays;
  96863. private _vectors4Arrays;
  96864. private _cachedWorldViewMatrix;
  96865. private _cachedWorldViewProjectionMatrix;
  96866. private _renderId;
  96867. private _multiview;
  96868. private _cachedDefines;
  96869. /** Define the Url to load snippets */
  96870. static SnippetUrl: string;
  96871. /** Snippet ID if the material was created from the snippet server */
  96872. snippetId: string;
  96873. /**
  96874. * Instantiate a new shader material.
  96875. * 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.
  96876. * This returned material effects how the mesh will look based on the code in the shaders.
  96877. * @see https://doc.babylonjs.com/how_to/shader_material
  96878. * @param name Define the name of the material in the scene
  96879. * @param scene Define the scene the material belongs to
  96880. * @param shaderPath Defines the route to the shader code in one of three ways:
  96881. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96882. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96883. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96884. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96885. * @param options Define the options used to create the shader
  96886. */
  96887. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96888. /**
  96889. * Gets the shader path used to define the shader code
  96890. * It can be modified to trigger a new compilation
  96891. */
  96892. get shaderPath(): any;
  96893. /**
  96894. * Sets the shader path used to define the shader code
  96895. * It can be modified to trigger a new compilation
  96896. */
  96897. set shaderPath(shaderPath: any);
  96898. /**
  96899. * Gets the options used to compile the shader.
  96900. * They can be modified to trigger a new compilation
  96901. */
  96902. get options(): IShaderMaterialOptions;
  96903. /**
  96904. * Gets the current class name of the material e.g. "ShaderMaterial"
  96905. * Mainly use in serialization.
  96906. * @returns the class name
  96907. */
  96908. getClassName(): string;
  96909. /**
  96910. * Specifies if the material will require alpha blending
  96911. * @returns a boolean specifying if alpha blending is needed
  96912. */
  96913. needAlphaBlending(): boolean;
  96914. /**
  96915. * Specifies if this material should be rendered in alpha test mode
  96916. * @returns a boolean specifying if an alpha test is needed.
  96917. */
  96918. needAlphaTesting(): boolean;
  96919. private _checkUniform;
  96920. /**
  96921. * Set a texture in the shader.
  96922. * @param name Define the name of the uniform samplers as defined in the shader
  96923. * @param texture Define the texture to bind to this sampler
  96924. * @return the material itself allowing "fluent" like uniform updates
  96925. */
  96926. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96927. /**
  96928. * Set a texture array in the shader.
  96929. * @param name Define the name of the uniform sampler array as defined in the shader
  96930. * @param textures Define the list of textures to bind to this sampler
  96931. * @return the material itself allowing "fluent" like uniform updates
  96932. */
  96933. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96934. /**
  96935. * Set a float in the shader.
  96936. * @param name Define the name of the uniform as defined in the shader
  96937. * @param value Define the value to give to the uniform
  96938. * @return the material itself allowing "fluent" like uniform updates
  96939. */
  96940. setFloat(name: string, value: number): ShaderMaterial;
  96941. /**
  96942. * Set a int in the shader.
  96943. * @param name Define the name of the uniform as defined in the shader
  96944. * @param value Define the value to give to the uniform
  96945. * @return the material itself allowing "fluent" like uniform updates
  96946. */
  96947. setInt(name: string, value: number): ShaderMaterial;
  96948. /**
  96949. * Set an array of floats in the shader.
  96950. * @param name Define the name of the uniform as defined in the shader
  96951. * @param value Define the value to give to the uniform
  96952. * @return the material itself allowing "fluent" like uniform updates
  96953. */
  96954. setFloats(name: string, value: number[]): ShaderMaterial;
  96955. /**
  96956. * Set a vec3 in the shader from a Color3.
  96957. * @param name Define the name of the uniform as defined in the shader
  96958. * @param value Define the value to give to the uniform
  96959. * @return the material itself allowing "fluent" like uniform updates
  96960. */
  96961. setColor3(name: string, value: Color3): ShaderMaterial;
  96962. /**
  96963. * Set a vec3 array in the shader from a Color3 array.
  96964. * @param name Define the name of the uniform as defined in the shader
  96965. * @param value Define the value to give to the uniform
  96966. * @return the material itself allowing "fluent" like uniform updates
  96967. */
  96968. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96969. /**
  96970. * Set a vec4 in the shader from a Color4.
  96971. * @param name Define the name of the uniform as defined in the shader
  96972. * @param value Define the value to give to the uniform
  96973. * @return the material itself allowing "fluent" like uniform updates
  96974. */
  96975. setColor4(name: string, value: Color4): ShaderMaterial;
  96976. /**
  96977. * Set a vec4 array in the shader from a Color4 array.
  96978. * @param name Define the name of the uniform as defined in the shader
  96979. * @param value Define the value to give to the uniform
  96980. * @return the material itself allowing "fluent" like uniform updates
  96981. */
  96982. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96983. /**
  96984. * Set a vec2 in the shader from a Vector2.
  96985. * @param name Define the name of the uniform as defined in the shader
  96986. * @param value Define the value to give to the uniform
  96987. * @return the material itself allowing "fluent" like uniform updates
  96988. */
  96989. setVector2(name: string, value: Vector2): ShaderMaterial;
  96990. /**
  96991. * Set a vec3 in the shader from a Vector3.
  96992. * @param name Define the name of the uniform as defined in the shader
  96993. * @param value Define the value to give to the uniform
  96994. * @return the material itself allowing "fluent" like uniform updates
  96995. */
  96996. setVector3(name: string, value: Vector3): ShaderMaterial;
  96997. /**
  96998. * Set a vec4 in the shader from a Vector4.
  96999. * @param name Define the name of the uniform as defined in the shader
  97000. * @param value Define the value to give to the uniform
  97001. * @return the material itself allowing "fluent" like uniform updates
  97002. */
  97003. setVector4(name: string, value: Vector4): ShaderMaterial;
  97004. /**
  97005. * Set a mat4 in the shader from a Matrix.
  97006. * @param name Define the name of the uniform as defined in the shader
  97007. * @param value Define the value to give to the uniform
  97008. * @return the material itself allowing "fluent" like uniform updates
  97009. */
  97010. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97011. /**
  97012. * Set a float32Array in the shader from a matrix array.
  97013. * @param name Define the name of the uniform as defined in the shader
  97014. * @param value Define the value to give to the uniform
  97015. * @return the material itself allowing "fluent" like uniform updates
  97016. */
  97017. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97018. /**
  97019. * Set a mat3 in the shader from a Float32Array.
  97020. * @param name Define the name of the uniform as defined in the shader
  97021. * @param value Define the value to give to the uniform
  97022. * @return the material itself allowing "fluent" like uniform updates
  97023. */
  97024. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97025. /**
  97026. * Set a mat2 in the shader from a Float32Array.
  97027. * @param name Define the name of the uniform as defined in the shader
  97028. * @param value Define the value to give to the uniform
  97029. * @return the material itself allowing "fluent" like uniform updates
  97030. */
  97031. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97032. /**
  97033. * Set a vec2 array in the shader from a number array.
  97034. * @param name Define the name of the uniform as defined in the shader
  97035. * @param value Define the value to give to the uniform
  97036. * @return the material itself allowing "fluent" like uniform updates
  97037. */
  97038. setArray2(name: string, value: number[]): ShaderMaterial;
  97039. /**
  97040. * Set a vec3 array in the shader from a number array.
  97041. * @param name Define the name of the uniform as defined in the shader
  97042. * @param value Define the value to give to the uniform
  97043. * @return the material itself allowing "fluent" like uniform updates
  97044. */
  97045. setArray3(name: string, value: number[]): ShaderMaterial;
  97046. /**
  97047. * Set a vec4 array in the shader from a number array.
  97048. * @param name Define the name of the uniform as defined in the shader
  97049. * @param value Define the value to give to the uniform
  97050. * @return the material itself allowing "fluent" like uniform updates
  97051. */
  97052. setArray4(name: string, value: number[]): ShaderMaterial;
  97053. private _checkCache;
  97054. /**
  97055. * Specifies that the submesh is ready to be used
  97056. * @param mesh defines the mesh to check
  97057. * @param subMesh defines which submesh to check
  97058. * @param useInstances specifies that instances should be used
  97059. * @returns a boolean indicating that the submesh is ready or not
  97060. */
  97061. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97062. /**
  97063. * Checks if the material is ready to render the requested mesh
  97064. * @param mesh Define the mesh to render
  97065. * @param useInstances Define whether or not the material is used with instances
  97066. * @returns true if ready, otherwise false
  97067. */
  97068. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97069. /**
  97070. * Binds the world matrix to the material
  97071. * @param world defines the world transformation matrix
  97072. * @param effectOverride - If provided, use this effect instead of internal effect
  97073. */
  97074. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97075. /**
  97076. * Binds the submesh to this material by preparing the effect and shader to draw
  97077. * @param world defines the world transformation matrix
  97078. * @param mesh defines the mesh containing the submesh
  97079. * @param subMesh defines the submesh to bind the material to
  97080. */
  97081. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97082. /**
  97083. * Binds the material to the mesh
  97084. * @param world defines the world transformation matrix
  97085. * @param mesh defines the mesh to bind the material to
  97086. * @param effectOverride - If provided, use this effect instead of internal effect
  97087. */
  97088. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97089. protected _afterBind(mesh?: Mesh): void;
  97090. /**
  97091. * Gets the active textures from the material
  97092. * @returns an array of textures
  97093. */
  97094. getActiveTextures(): BaseTexture[];
  97095. /**
  97096. * Specifies if the material uses a texture
  97097. * @param texture defines the texture to check against the material
  97098. * @returns a boolean specifying if the material uses the texture
  97099. */
  97100. hasTexture(texture: BaseTexture): boolean;
  97101. /**
  97102. * Makes a duplicate of the material, and gives it a new name
  97103. * @param name defines the new name for the duplicated material
  97104. * @returns the cloned material
  97105. */
  97106. clone(name: string): ShaderMaterial;
  97107. /**
  97108. * Disposes the material
  97109. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97110. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97111. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97112. */
  97113. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97114. /**
  97115. * Serializes this material in a JSON representation
  97116. * @returns the serialized material object
  97117. */
  97118. serialize(): any;
  97119. /**
  97120. * Creates a shader material from parsed shader material data
  97121. * @param source defines the JSON represnetation of the material
  97122. * @param scene defines the hosting scene
  97123. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97124. * @returns a new material
  97125. */
  97126. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97127. /**
  97128. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97129. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97130. * @param url defines the url to load from
  97131. * @param scene defines the hosting scene
  97132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97133. * @returns a promise that will resolve to the new ShaderMaterial
  97134. */
  97135. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97136. /**
  97137. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97138. * @param snippetId defines the snippet to load
  97139. * @param scene defines the hosting scene
  97140. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97141. * @returns a promise that will resolve to the new ShaderMaterial
  97142. */
  97143. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97144. }
  97145. }
  97146. declare module BABYLON {
  97147. /** @hidden */
  97148. export var colorPixelShader: {
  97149. name: string;
  97150. shader: string;
  97151. };
  97152. }
  97153. declare module BABYLON {
  97154. /** @hidden */
  97155. export var colorVertexShader: {
  97156. name: string;
  97157. shader: string;
  97158. };
  97159. }
  97160. declare module BABYLON {
  97161. /**
  97162. * Line mesh
  97163. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97164. */
  97165. export class LinesMesh extends Mesh {
  97166. /**
  97167. * If vertex color should be applied to the mesh
  97168. */
  97169. readonly useVertexColor?: boolean | undefined;
  97170. /**
  97171. * If vertex alpha should be applied to the mesh
  97172. */
  97173. readonly useVertexAlpha?: boolean | undefined;
  97174. /**
  97175. * Color of the line (Default: White)
  97176. */
  97177. color: Color3;
  97178. /**
  97179. * Alpha of the line (Default: 1)
  97180. */
  97181. alpha: number;
  97182. /**
  97183. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97184. * This margin is expressed in world space coordinates, so its value may vary.
  97185. * Default value is 0.1
  97186. */
  97187. intersectionThreshold: number;
  97188. private _colorShader;
  97189. private color4;
  97190. /**
  97191. * Creates a new LinesMesh
  97192. * @param name defines the name
  97193. * @param scene defines the hosting scene
  97194. * @param parent defines the parent mesh if any
  97195. * @param source defines the optional source LinesMesh used to clone data from
  97196. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97197. * When false, achieved by calling a clone(), also passing False.
  97198. * This will make creation of children, recursive.
  97199. * @param useVertexColor defines if this LinesMesh supports vertex color
  97200. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97201. */
  97202. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97203. /**
  97204. * If vertex color should be applied to the mesh
  97205. */
  97206. useVertexColor?: boolean | undefined,
  97207. /**
  97208. * If vertex alpha should be applied to the mesh
  97209. */
  97210. useVertexAlpha?: boolean | undefined);
  97211. private _addClipPlaneDefine;
  97212. private _removeClipPlaneDefine;
  97213. isReady(): boolean;
  97214. /**
  97215. * Returns the string "LineMesh"
  97216. */
  97217. getClassName(): string;
  97218. /**
  97219. * @hidden
  97220. */
  97221. get material(): Material;
  97222. /**
  97223. * @hidden
  97224. */
  97225. set material(value: Material);
  97226. /**
  97227. * @hidden
  97228. */
  97229. get checkCollisions(): boolean;
  97230. /** @hidden */
  97231. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97232. /** @hidden */
  97233. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97234. /**
  97235. * Disposes of the line mesh
  97236. * @param doNotRecurse If children should be disposed
  97237. */
  97238. dispose(doNotRecurse?: boolean): void;
  97239. /**
  97240. * Returns a new LineMesh object cloned from the current one.
  97241. */
  97242. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97243. /**
  97244. * Creates a new InstancedLinesMesh object from the mesh model.
  97245. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97246. * @param name defines the name of the new instance
  97247. * @returns a new InstancedLinesMesh
  97248. */
  97249. createInstance(name: string): InstancedLinesMesh;
  97250. }
  97251. /**
  97252. * Creates an instance based on a source LinesMesh
  97253. */
  97254. export class InstancedLinesMesh extends InstancedMesh {
  97255. /**
  97256. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97257. * This margin is expressed in world space coordinates, so its value may vary.
  97258. * Initilized with the intersectionThreshold value of the source LinesMesh
  97259. */
  97260. intersectionThreshold: number;
  97261. constructor(name: string, source: LinesMesh);
  97262. /**
  97263. * Returns the string "InstancedLinesMesh".
  97264. */
  97265. getClassName(): string;
  97266. }
  97267. }
  97268. declare module BABYLON {
  97269. /** @hidden */
  97270. export var linePixelShader: {
  97271. name: string;
  97272. shader: string;
  97273. };
  97274. }
  97275. declare module BABYLON {
  97276. /** @hidden */
  97277. export var lineVertexShader: {
  97278. name: string;
  97279. shader: string;
  97280. };
  97281. }
  97282. declare module BABYLON {
  97283. interface Scene {
  97284. /** @hidden */
  97285. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97286. }
  97287. interface AbstractMesh {
  97288. /**
  97289. * Gets the edgesRenderer associated with the mesh
  97290. */
  97291. edgesRenderer: Nullable<EdgesRenderer>;
  97292. }
  97293. interface LinesMesh {
  97294. /**
  97295. * Enables the edge rendering mode on the mesh.
  97296. * This mode makes the mesh edges visible
  97297. * @param epsilon defines the maximal distance between two angles to detect a face
  97298. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97299. * @returns the currentAbstractMesh
  97300. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97301. */
  97302. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97303. }
  97304. interface InstancedLinesMesh {
  97305. /**
  97306. * Enables the edge rendering mode on the mesh.
  97307. * This mode makes the mesh edges visible
  97308. * @param epsilon defines the maximal distance between two angles to detect a face
  97309. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97310. * @returns the current InstancedLinesMesh
  97311. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97312. */
  97313. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97314. }
  97315. /**
  97316. * Defines the minimum contract an Edges renderer should follow.
  97317. */
  97318. export interface IEdgesRenderer extends IDisposable {
  97319. /**
  97320. * Gets or sets a boolean indicating if the edgesRenderer is active
  97321. */
  97322. isEnabled: boolean;
  97323. /**
  97324. * Renders the edges of the attached mesh,
  97325. */
  97326. render(): void;
  97327. /**
  97328. * Checks wether or not the edges renderer is ready to render.
  97329. * @return true if ready, otherwise false.
  97330. */
  97331. isReady(): boolean;
  97332. /**
  97333. * List of instances to render in case the source mesh has instances
  97334. */
  97335. customInstances: SmartArray<Matrix>;
  97336. }
  97337. /**
  97338. * Defines the additional options of the edges renderer
  97339. */
  97340. export interface IEdgesRendererOptions {
  97341. /**
  97342. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97343. * If not defined, the default value is true
  97344. */
  97345. useAlternateEdgeFinder?: boolean;
  97346. /**
  97347. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97348. * If not defined, the default value is true.
  97349. * 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)
  97350. * This option is used only if useAlternateEdgeFinder = true
  97351. */
  97352. useFastVertexMerger?: boolean;
  97353. /**
  97354. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97355. * The default value is 1e-6
  97356. * This option is used only if useAlternateEdgeFinder = true
  97357. */
  97358. epsilonVertexMerge?: number;
  97359. /**
  97360. * 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
  97361. * 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.
  97362. * This option is used only if useAlternateEdgeFinder = true
  97363. */
  97364. applyTessellation?: boolean;
  97365. /**
  97366. * 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
  97367. * The default value is 1e-6
  97368. * This option is used only if useAlternateEdgeFinder = true
  97369. */
  97370. epsilonVertexAligned?: number;
  97371. }
  97372. /**
  97373. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97374. */
  97375. export class EdgesRenderer implements IEdgesRenderer {
  97376. /**
  97377. * Define the size of the edges with an orthographic camera
  97378. */
  97379. edgesWidthScalerForOrthographic: number;
  97380. /**
  97381. * Define the size of the edges with a perspective camera
  97382. */
  97383. edgesWidthScalerForPerspective: number;
  97384. protected _source: AbstractMesh;
  97385. protected _linesPositions: number[];
  97386. protected _linesNormals: number[];
  97387. protected _linesIndices: number[];
  97388. protected _epsilon: number;
  97389. protected _indicesCount: number;
  97390. protected _lineShader: ShaderMaterial;
  97391. protected _ib: DataBuffer;
  97392. protected _buffers: {
  97393. [key: string]: Nullable<VertexBuffer>;
  97394. };
  97395. protected _buffersForInstances: {
  97396. [key: string]: Nullable<VertexBuffer>;
  97397. };
  97398. protected _checkVerticesInsteadOfIndices: boolean;
  97399. protected _options: Nullable<IEdgesRendererOptions>;
  97400. private _meshRebuildObserver;
  97401. private _meshDisposeObserver;
  97402. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97403. isEnabled: boolean;
  97404. /**
  97405. * List of instances to render in case the source mesh has instances
  97406. */
  97407. customInstances: SmartArray<Matrix>;
  97408. private static GetShader;
  97409. /**
  97410. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97411. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97412. * @param source Mesh used to create edges
  97413. * @param epsilon sum of angles in adjacency to check for edge
  97414. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97415. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97416. * @param options The options to apply when generating the edges
  97417. */
  97418. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97419. protected _prepareRessources(): void;
  97420. /** @hidden */
  97421. _rebuild(): void;
  97422. /**
  97423. * Releases the required resources for the edges renderer
  97424. */
  97425. dispose(): void;
  97426. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97427. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97428. /**
  97429. * Checks if the pair of p0 and p1 is en edge
  97430. * @param faceIndex
  97431. * @param edge
  97432. * @param faceNormals
  97433. * @param p0
  97434. * @param p1
  97435. * @private
  97436. */
  97437. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97438. /**
  97439. * push line into the position, normal and index buffer
  97440. * @protected
  97441. */
  97442. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97443. /**
  97444. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97445. */
  97446. private _tessellateTriangle;
  97447. private _generateEdgesLinesAlternate;
  97448. /**
  97449. * Generates lines edges from adjacencjes
  97450. * @private
  97451. */
  97452. _generateEdgesLines(): void;
  97453. /**
  97454. * Checks wether or not the edges renderer is ready to render.
  97455. * @return true if ready, otherwise false.
  97456. */
  97457. isReady(): boolean;
  97458. /**
  97459. * Renders the edges of the attached mesh,
  97460. */
  97461. render(): void;
  97462. }
  97463. /**
  97464. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97465. */
  97466. export class LineEdgesRenderer extends EdgesRenderer {
  97467. /**
  97468. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97469. * @param source LineMesh used to generate edges
  97470. * @param epsilon not important (specified angle for edge detection)
  97471. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97472. */
  97473. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97474. /**
  97475. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97476. */
  97477. _generateEdgesLines(): void;
  97478. }
  97479. }
  97480. declare module BABYLON {
  97481. /**
  97482. * This represents the object necessary to create a rendering group.
  97483. * This is exclusively used and created by the rendering manager.
  97484. * To modify the behavior, you use the available helpers in your scene or meshes.
  97485. * @hidden
  97486. */
  97487. export class RenderingGroup {
  97488. index: number;
  97489. private static _zeroVector;
  97490. private _scene;
  97491. private _opaqueSubMeshes;
  97492. private _transparentSubMeshes;
  97493. private _alphaTestSubMeshes;
  97494. private _depthOnlySubMeshes;
  97495. private _particleSystems;
  97496. private _spriteManagers;
  97497. private _opaqueSortCompareFn;
  97498. private _alphaTestSortCompareFn;
  97499. private _transparentSortCompareFn;
  97500. private _renderOpaque;
  97501. private _renderAlphaTest;
  97502. private _renderTransparent;
  97503. /** @hidden */
  97504. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97505. onBeforeTransparentRendering: () => void;
  97506. /**
  97507. * Set the opaque sort comparison function.
  97508. * If null the sub meshes will be render in the order they were created
  97509. */
  97510. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97511. /**
  97512. * Set the alpha test sort comparison function.
  97513. * If null the sub meshes will be render in the order they were created
  97514. */
  97515. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97516. /**
  97517. * Set the transparent sort comparison function.
  97518. * If null the sub meshes will be render in the order they were created
  97519. */
  97520. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97521. /**
  97522. * Creates a new rendering group.
  97523. * @param index The rendering group index
  97524. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97525. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97526. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97527. */
  97528. 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>);
  97529. /**
  97530. * Render all the sub meshes contained in the group.
  97531. * @param customRenderFunction Used to override the default render behaviour of the group.
  97532. * @returns true if rendered some submeshes.
  97533. */
  97534. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97535. /**
  97536. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97537. * @param subMeshes The submeshes to render
  97538. */
  97539. private renderOpaqueSorted;
  97540. /**
  97541. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97542. * @param subMeshes The submeshes to render
  97543. */
  97544. private renderAlphaTestSorted;
  97545. /**
  97546. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97547. * @param subMeshes The submeshes to render
  97548. */
  97549. private renderTransparentSorted;
  97550. /**
  97551. * Renders the submeshes in a specified order.
  97552. * @param subMeshes The submeshes to sort before render
  97553. * @param sortCompareFn The comparison function use to sort
  97554. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97555. * @param transparent Specifies to activate blending if true
  97556. */
  97557. private static renderSorted;
  97558. /**
  97559. * Renders the submeshes in the order they were dispatched (no sort applied).
  97560. * @param subMeshes The submeshes to render
  97561. */
  97562. private static renderUnsorted;
  97563. /**
  97564. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97565. * are rendered back to front if in the same alpha index.
  97566. *
  97567. * @param a The first submesh
  97568. * @param b The second submesh
  97569. * @returns The result of the comparison
  97570. */
  97571. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97572. /**
  97573. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97574. * are rendered back to front.
  97575. *
  97576. * @param a The first submesh
  97577. * @param b The second submesh
  97578. * @returns The result of the comparison
  97579. */
  97580. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97581. /**
  97582. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97583. * are rendered front to back (prevent overdraw).
  97584. *
  97585. * @param a The first submesh
  97586. * @param b The second submesh
  97587. * @returns The result of the comparison
  97588. */
  97589. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97590. /**
  97591. * Resets the different lists of submeshes to prepare a new frame.
  97592. */
  97593. prepare(): void;
  97594. dispose(): void;
  97595. /**
  97596. * Inserts the submesh in its correct queue depending on its material.
  97597. * @param subMesh The submesh to dispatch
  97598. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97599. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97600. */
  97601. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97602. dispatchSprites(spriteManager: ISpriteManager): void;
  97603. dispatchParticles(particleSystem: IParticleSystem): void;
  97604. private _renderParticles;
  97605. private _renderSprites;
  97606. }
  97607. }
  97608. declare module BABYLON {
  97609. /**
  97610. * Interface describing the different options available in the rendering manager
  97611. * regarding Auto Clear between groups.
  97612. */
  97613. export interface IRenderingManagerAutoClearSetup {
  97614. /**
  97615. * Defines whether or not autoclear is enable.
  97616. */
  97617. autoClear: boolean;
  97618. /**
  97619. * Defines whether or not to autoclear the depth buffer.
  97620. */
  97621. depth: boolean;
  97622. /**
  97623. * Defines whether or not to autoclear the stencil buffer.
  97624. */
  97625. stencil: boolean;
  97626. }
  97627. /**
  97628. * This class is used by the onRenderingGroupObservable
  97629. */
  97630. export class RenderingGroupInfo {
  97631. /**
  97632. * The Scene that being rendered
  97633. */
  97634. scene: Scene;
  97635. /**
  97636. * The camera currently used for the rendering pass
  97637. */
  97638. camera: Nullable<Camera>;
  97639. /**
  97640. * The ID of the renderingGroup being processed
  97641. */
  97642. renderingGroupId: number;
  97643. }
  97644. /**
  97645. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97646. * It is enable to manage the different groups as well as the different necessary sort functions.
  97647. * This should not be used directly aside of the few static configurations
  97648. */
  97649. export class RenderingManager {
  97650. /**
  97651. * The max id used for rendering groups (not included)
  97652. */
  97653. static MAX_RENDERINGGROUPS: number;
  97654. /**
  97655. * The min id used for rendering groups (included)
  97656. */
  97657. static MIN_RENDERINGGROUPS: number;
  97658. /**
  97659. * Used to globally prevent autoclearing scenes.
  97660. */
  97661. static AUTOCLEAR: boolean;
  97662. /**
  97663. * @hidden
  97664. */
  97665. _useSceneAutoClearSetup: boolean;
  97666. private _scene;
  97667. private _renderingGroups;
  97668. private _depthStencilBufferAlreadyCleaned;
  97669. private _autoClearDepthStencil;
  97670. private _customOpaqueSortCompareFn;
  97671. private _customAlphaTestSortCompareFn;
  97672. private _customTransparentSortCompareFn;
  97673. private _renderingGroupInfo;
  97674. /**
  97675. * Instantiates a new rendering group for a particular scene
  97676. * @param scene Defines the scene the groups belongs to
  97677. */
  97678. constructor(scene: Scene);
  97679. private _clearDepthStencilBuffer;
  97680. /**
  97681. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97682. * @hidden
  97683. */
  97684. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97685. /**
  97686. * Resets the different information of the group to prepare a new frame
  97687. * @hidden
  97688. */
  97689. reset(): void;
  97690. /**
  97691. * Dispose and release the group and its associated resources.
  97692. * @hidden
  97693. */
  97694. dispose(): void;
  97695. /**
  97696. * Clear the info related to rendering groups preventing retention points during dispose.
  97697. */
  97698. freeRenderingGroups(): void;
  97699. private _prepareRenderingGroup;
  97700. /**
  97701. * Add a sprite manager to the rendering manager in order to render it this frame.
  97702. * @param spriteManager Define the sprite manager to render
  97703. */
  97704. dispatchSprites(spriteManager: ISpriteManager): void;
  97705. /**
  97706. * Add a particle system to the rendering manager in order to render it this frame.
  97707. * @param particleSystem Define the particle system to render
  97708. */
  97709. dispatchParticles(particleSystem: IParticleSystem): void;
  97710. /**
  97711. * Add a submesh to the manager in order to render it this frame
  97712. * @param subMesh The submesh to dispatch
  97713. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97714. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97715. */
  97716. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97717. /**
  97718. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97719. * This allowed control for front to back rendering or reversly depending of the special needs.
  97720. *
  97721. * @param renderingGroupId The rendering group id corresponding to its index
  97722. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97723. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97724. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97725. */
  97726. 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;
  97727. /**
  97728. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97729. *
  97730. * @param renderingGroupId The rendering group id corresponding to its index
  97731. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97732. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97733. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97734. */
  97735. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97736. /**
  97737. * Gets the current auto clear configuration for one rendering group of the rendering
  97738. * manager.
  97739. * @param index the rendering group index to get the information for
  97740. * @returns The auto clear setup for the requested rendering group
  97741. */
  97742. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97743. }
  97744. }
  97745. declare module BABYLON {
  97746. /**
  97747. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97748. */
  97749. export interface ICustomShaderOptions {
  97750. /**
  97751. * Gets or sets the custom shader name to use
  97752. */
  97753. shaderName: string;
  97754. /**
  97755. * The list of attribute names used in the shader
  97756. */
  97757. attributes?: string[];
  97758. /**
  97759. * The list of unifrom names used in the shader
  97760. */
  97761. uniforms?: string[];
  97762. /**
  97763. * The list of sampler names used in the shader
  97764. */
  97765. samplers?: string[];
  97766. /**
  97767. * The list of defines used in the shader
  97768. */
  97769. defines?: string[];
  97770. }
  97771. /**
  97772. * Interface to implement to create a shadow generator compatible with BJS.
  97773. */
  97774. export interface IShadowGenerator {
  97775. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97776. id: string;
  97777. /**
  97778. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97779. * @returns The render target texture if present otherwise, null
  97780. */
  97781. getShadowMap(): Nullable<RenderTargetTexture>;
  97782. /**
  97783. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97784. * @param subMesh The submesh we want to render in the shadow map
  97785. * @param useInstances Defines wether will draw in the map using instances
  97786. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97787. * @returns true if ready otherwise, false
  97788. */
  97789. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97790. /**
  97791. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97792. * @param defines Defines of the material we want to update
  97793. * @param lightIndex Index of the light in the enabled light list of the material
  97794. */
  97795. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97796. /**
  97797. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97798. * defined in the generator but impacting the effect).
  97799. * It implies the unifroms available on the materials are the standard BJS ones.
  97800. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97801. * @param effect The effect we are binfing the information for
  97802. */
  97803. bindShadowLight(lightIndex: string, effect: Effect): void;
  97804. /**
  97805. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97806. * (eq to shadow prjection matrix * light transform matrix)
  97807. * @returns The transform matrix used to create the shadow map
  97808. */
  97809. getTransformMatrix(): Matrix;
  97810. /**
  97811. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97812. * Cube and 2D textures for instance.
  97813. */
  97814. recreateShadowMap(): void;
  97815. /**
  97816. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97817. * @param onCompiled Callback triggered at the and of the effects compilation
  97818. * @param options Sets of optional options forcing the compilation with different modes
  97819. */
  97820. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97821. useInstances: boolean;
  97822. }>): void;
  97823. /**
  97824. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97825. * @param options Sets of optional options forcing the compilation with different modes
  97826. * @returns A promise that resolves when the compilation completes
  97827. */
  97828. forceCompilationAsync(options?: Partial<{
  97829. useInstances: boolean;
  97830. }>): Promise<void>;
  97831. /**
  97832. * Serializes the shadow generator setup to a json object.
  97833. * @returns The serialized JSON object
  97834. */
  97835. serialize(): any;
  97836. /**
  97837. * Disposes the Shadow map and related Textures and effects.
  97838. */
  97839. dispose(): void;
  97840. }
  97841. /**
  97842. * Default implementation IShadowGenerator.
  97843. * This is the main object responsible of generating shadows in the framework.
  97844. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97845. */
  97846. export class ShadowGenerator implements IShadowGenerator {
  97847. /**
  97848. * Name of the shadow generator class
  97849. */
  97850. static CLASSNAME: string;
  97851. /**
  97852. * Shadow generator mode None: no filtering applied.
  97853. */
  97854. static readonly FILTER_NONE: number;
  97855. /**
  97856. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97857. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97858. */
  97859. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97860. /**
  97861. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97862. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97863. */
  97864. static readonly FILTER_POISSONSAMPLING: number;
  97865. /**
  97866. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97867. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97868. */
  97869. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97870. /**
  97871. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97872. * edge artifacts on steep falloff.
  97873. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97874. */
  97875. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97876. /**
  97877. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97878. * edge artifacts on steep falloff.
  97879. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97880. */
  97881. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97882. /**
  97883. * Shadow generator mode PCF: Percentage Closer Filtering
  97884. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97885. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97886. */
  97887. static readonly FILTER_PCF: number;
  97888. /**
  97889. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97890. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97891. * Contact Hardening
  97892. */
  97893. static readonly FILTER_PCSS: number;
  97894. /**
  97895. * Reserved for PCF and PCSS
  97896. * Highest Quality.
  97897. *
  97898. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97899. *
  97900. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97901. */
  97902. static readonly QUALITY_HIGH: number;
  97903. /**
  97904. * Reserved for PCF and PCSS
  97905. * Good tradeoff for quality/perf cross devices
  97906. *
  97907. * Execute PCF on a 3*3 kernel.
  97908. *
  97909. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97910. */
  97911. static readonly QUALITY_MEDIUM: number;
  97912. /**
  97913. * Reserved for PCF and PCSS
  97914. * The lowest quality but the fastest.
  97915. *
  97916. * Execute PCF on a 1*1 kernel.
  97917. *
  97918. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97919. */
  97920. static readonly QUALITY_LOW: number;
  97921. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97922. id: string;
  97923. /** Gets or sets the custom shader name to use */
  97924. customShaderOptions: ICustomShaderOptions;
  97925. /**
  97926. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97927. */
  97928. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97929. /**
  97930. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97931. */
  97932. onAfterShadowMapRenderObservable: Observable<Effect>;
  97933. /**
  97934. * Observable triggered before a mesh is rendered in the shadow map.
  97935. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97936. */
  97937. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97938. /**
  97939. * Observable triggered after a mesh is rendered in the shadow map.
  97940. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97941. */
  97942. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97943. protected _bias: number;
  97944. /**
  97945. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97946. */
  97947. get bias(): number;
  97948. /**
  97949. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97950. */
  97951. set bias(bias: number);
  97952. protected _normalBias: number;
  97953. /**
  97954. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97955. */
  97956. get normalBias(): number;
  97957. /**
  97958. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97959. */
  97960. set normalBias(normalBias: number);
  97961. protected _blurBoxOffset: number;
  97962. /**
  97963. * Gets the blur box offset: offset applied during the blur pass.
  97964. * Only useful if useKernelBlur = false
  97965. */
  97966. get blurBoxOffset(): number;
  97967. /**
  97968. * Sets the blur box offset: offset applied during the blur pass.
  97969. * Only useful if useKernelBlur = false
  97970. */
  97971. set blurBoxOffset(value: number);
  97972. protected _blurScale: number;
  97973. /**
  97974. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97975. * 2 means half of the size.
  97976. */
  97977. get blurScale(): number;
  97978. /**
  97979. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97980. * 2 means half of the size.
  97981. */
  97982. set blurScale(value: number);
  97983. protected _blurKernel: number;
  97984. /**
  97985. * Gets the blur kernel: kernel size of the blur pass.
  97986. * Only useful if useKernelBlur = true
  97987. */
  97988. get blurKernel(): number;
  97989. /**
  97990. * Sets the blur kernel: kernel size of the blur pass.
  97991. * Only useful if useKernelBlur = true
  97992. */
  97993. set blurKernel(value: number);
  97994. protected _useKernelBlur: boolean;
  97995. /**
  97996. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97997. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97998. */
  97999. get useKernelBlur(): boolean;
  98000. /**
  98001. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98002. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98003. */
  98004. set useKernelBlur(value: boolean);
  98005. protected _depthScale: number;
  98006. /**
  98007. * Gets the depth scale used in ESM mode.
  98008. */
  98009. get depthScale(): number;
  98010. /**
  98011. * Sets the depth scale used in ESM mode.
  98012. * This can override the scale stored on the light.
  98013. */
  98014. set depthScale(value: number);
  98015. protected _validateFilter(filter: number): number;
  98016. protected _filter: number;
  98017. /**
  98018. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98019. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98020. */
  98021. get filter(): number;
  98022. /**
  98023. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98024. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98025. */
  98026. set filter(value: number);
  98027. /**
  98028. * Gets if the current filter is set to Poisson Sampling.
  98029. */
  98030. get usePoissonSampling(): boolean;
  98031. /**
  98032. * Sets the current filter to Poisson Sampling.
  98033. */
  98034. set usePoissonSampling(value: boolean);
  98035. /**
  98036. * Gets if the current filter is set to ESM.
  98037. */
  98038. get useExponentialShadowMap(): boolean;
  98039. /**
  98040. * Sets the current filter is to ESM.
  98041. */
  98042. set useExponentialShadowMap(value: boolean);
  98043. /**
  98044. * Gets if the current filter is set to filtered ESM.
  98045. */
  98046. get useBlurExponentialShadowMap(): boolean;
  98047. /**
  98048. * Gets if the current filter is set to filtered ESM.
  98049. */
  98050. set useBlurExponentialShadowMap(value: boolean);
  98051. /**
  98052. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98053. * exponential to prevent steep falloff artifacts).
  98054. */
  98055. get useCloseExponentialShadowMap(): boolean;
  98056. /**
  98057. * Sets the current filter to "close ESM" (using the inverse of the
  98058. * exponential to prevent steep falloff artifacts).
  98059. */
  98060. set useCloseExponentialShadowMap(value: boolean);
  98061. /**
  98062. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98063. * exponential to prevent steep falloff artifacts).
  98064. */
  98065. get useBlurCloseExponentialShadowMap(): boolean;
  98066. /**
  98067. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98068. * exponential to prevent steep falloff artifacts).
  98069. */
  98070. set useBlurCloseExponentialShadowMap(value: boolean);
  98071. /**
  98072. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98073. */
  98074. get usePercentageCloserFiltering(): boolean;
  98075. /**
  98076. * Sets the current filter to "PCF" (percentage closer filtering).
  98077. */
  98078. set usePercentageCloserFiltering(value: boolean);
  98079. protected _filteringQuality: number;
  98080. /**
  98081. * Gets the PCF or PCSS Quality.
  98082. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98083. */
  98084. get filteringQuality(): number;
  98085. /**
  98086. * Sets the PCF or PCSS Quality.
  98087. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98088. */
  98089. set filteringQuality(filteringQuality: number);
  98090. /**
  98091. * Gets if the current filter is set to "PCSS" (contact hardening).
  98092. */
  98093. get useContactHardeningShadow(): boolean;
  98094. /**
  98095. * Sets the current filter to "PCSS" (contact hardening).
  98096. */
  98097. set useContactHardeningShadow(value: boolean);
  98098. protected _contactHardeningLightSizeUVRatio: number;
  98099. /**
  98100. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98101. * Using a ratio helps keeping shape stability independently of the map size.
  98102. *
  98103. * It does not account for the light projection as it was having too much
  98104. * instability during the light setup or during light position changes.
  98105. *
  98106. * Only valid if useContactHardeningShadow is true.
  98107. */
  98108. get contactHardeningLightSizeUVRatio(): number;
  98109. /**
  98110. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98111. * Using a ratio helps keeping shape stability independently of the map size.
  98112. *
  98113. * It does not account for the light projection as it was having too much
  98114. * instability during the light setup or during light position changes.
  98115. *
  98116. * Only valid if useContactHardeningShadow is true.
  98117. */
  98118. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98119. protected _darkness: number;
  98120. /** Gets or sets the actual darkness of a shadow */
  98121. get darkness(): number;
  98122. set darkness(value: number);
  98123. /**
  98124. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98125. * 0 means strongest and 1 would means no shadow.
  98126. * @returns the darkness.
  98127. */
  98128. getDarkness(): number;
  98129. /**
  98130. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98131. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98132. * @returns the shadow generator allowing fluent coding.
  98133. */
  98134. setDarkness(darkness: number): ShadowGenerator;
  98135. protected _transparencyShadow: boolean;
  98136. /** Gets or sets the ability to have transparent shadow */
  98137. get transparencyShadow(): boolean;
  98138. set transparencyShadow(value: boolean);
  98139. /**
  98140. * Sets the ability to have transparent shadow (boolean).
  98141. * @param transparent True if transparent else False
  98142. * @returns the shadow generator allowing fluent coding
  98143. */
  98144. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98145. /**
  98146. * Enables or disables shadows with varying strength based on the transparency
  98147. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98148. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98149. * mesh.visibility * alphaTexture.a
  98150. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98151. */
  98152. enableSoftTransparentShadow: boolean;
  98153. protected _shadowMap: Nullable<RenderTargetTexture>;
  98154. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98155. /**
  98156. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98157. * @returns The render target texture if present otherwise, null
  98158. */
  98159. getShadowMap(): Nullable<RenderTargetTexture>;
  98160. /**
  98161. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98162. * @returns The render target texture if the shadow map is present otherwise, null
  98163. */
  98164. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98165. /**
  98166. * Gets the class name of that object
  98167. * @returns "ShadowGenerator"
  98168. */
  98169. getClassName(): string;
  98170. /**
  98171. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98172. * @param mesh Mesh to add
  98173. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98174. * @returns the Shadow Generator itself
  98175. */
  98176. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98177. /**
  98178. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98179. * @param mesh Mesh to remove
  98180. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98181. * @returns the Shadow Generator itself
  98182. */
  98183. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98184. /**
  98185. * Controls the extent to which the shadows fade out at the edge of the frustum
  98186. */
  98187. frustumEdgeFalloff: number;
  98188. protected _light: IShadowLight;
  98189. /**
  98190. * Returns the associated light object.
  98191. * @returns the light generating the shadow
  98192. */
  98193. getLight(): IShadowLight;
  98194. /**
  98195. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98196. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98197. * It might on the other hand introduce peter panning.
  98198. */
  98199. forceBackFacesOnly: boolean;
  98200. protected _scene: Scene;
  98201. protected _lightDirection: Vector3;
  98202. protected _effect: Effect;
  98203. protected _viewMatrix: Matrix;
  98204. protected _projectionMatrix: Matrix;
  98205. protected _transformMatrix: Matrix;
  98206. protected _cachedPosition: Vector3;
  98207. protected _cachedDirection: Vector3;
  98208. protected _cachedDefines: string;
  98209. protected _currentRenderID: number;
  98210. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98211. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98212. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98213. protected _blurPostProcesses: PostProcess[];
  98214. protected _mapSize: number;
  98215. protected _currentFaceIndex: number;
  98216. protected _currentFaceIndexCache: number;
  98217. protected _textureType: number;
  98218. protected _defaultTextureMatrix: Matrix;
  98219. protected _storedUniqueId: Nullable<number>;
  98220. /** @hidden */
  98221. static _SceneComponentInitialization: (scene: Scene) => void;
  98222. /**
  98223. * Creates a ShadowGenerator object.
  98224. * A ShadowGenerator is the required tool to use the shadows.
  98225. * Each light casting shadows needs to use its own ShadowGenerator.
  98226. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98227. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98228. * @param light The light object generating the shadows.
  98229. * @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.
  98230. */
  98231. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98232. protected _initializeGenerator(): void;
  98233. protected _createTargetRenderTexture(): void;
  98234. protected _initializeShadowMap(): void;
  98235. protected _initializeBlurRTTAndPostProcesses(): void;
  98236. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98237. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98238. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98239. protected _applyFilterValues(): void;
  98240. /**
  98241. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98242. * @param onCompiled Callback triggered at the and of the effects compilation
  98243. * @param options Sets of optional options forcing the compilation with different modes
  98244. */
  98245. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98246. useInstances: boolean;
  98247. }>): void;
  98248. /**
  98249. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98250. * @param options Sets of optional options forcing the compilation with different modes
  98251. * @returns A promise that resolves when the compilation completes
  98252. */
  98253. forceCompilationAsync(options?: Partial<{
  98254. useInstances: boolean;
  98255. }>): Promise<void>;
  98256. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98257. private _prepareShadowDefines;
  98258. /**
  98259. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98260. * @param subMesh The submesh we want to render in the shadow map
  98261. * @param useInstances Defines wether will draw in the map using instances
  98262. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98263. * @returns true if ready otherwise, false
  98264. */
  98265. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98266. /**
  98267. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98268. * @param defines Defines of the material we want to update
  98269. * @param lightIndex Index of the light in the enabled light list of the material
  98270. */
  98271. prepareDefines(defines: any, lightIndex: number): void;
  98272. /**
  98273. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98274. * defined in the generator but impacting the effect).
  98275. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98276. * @param effect The effect we are binfing the information for
  98277. */
  98278. bindShadowLight(lightIndex: string, effect: Effect): void;
  98279. /**
  98280. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98281. * (eq to shadow prjection matrix * light transform matrix)
  98282. * @returns The transform matrix used to create the shadow map
  98283. */
  98284. getTransformMatrix(): Matrix;
  98285. /**
  98286. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98287. * Cube and 2D textures for instance.
  98288. */
  98289. recreateShadowMap(): void;
  98290. protected _disposeBlurPostProcesses(): void;
  98291. protected _disposeRTTandPostProcesses(): void;
  98292. /**
  98293. * Disposes the ShadowGenerator.
  98294. * Returns nothing.
  98295. */
  98296. dispose(): void;
  98297. /**
  98298. * Serializes the shadow generator setup to a json object.
  98299. * @returns The serialized JSON object
  98300. */
  98301. serialize(): any;
  98302. /**
  98303. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98304. * @param parsedShadowGenerator The JSON object to parse
  98305. * @param scene The scene to create the shadow map for
  98306. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98307. * @returns The parsed shadow generator
  98308. */
  98309. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98310. }
  98311. }
  98312. declare module BABYLON {
  98313. /**
  98314. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98315. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98316. * 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.
  98317. */
  98318. export abstract class Light extends Node {
  98319. /**
  98320. * Falloff Default: light is falling off following the material specification:
  98321. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98322. */
  98323. static readonly FALLOFF_DEFAULT: number;
  98324. /**
  98325. * Falloff Physical: light is falling off following the inverse squared distance law.
  98326. */
  98327. static readonly FALLOFF_PHYSICAL: number;
  98328. /**
  98329. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98330. * to enhance interoperability with other engines.
  98331. */
  98332. static readonly FALLOFF_GLTF: number;
  98333. /**
  98334. * Falloff Standard: light is falling off like in the standard material
  98335. * to enhance interoperability with other materials.
  98336. */
  98337. static readonly FALLOFF_STANDARD: number;
  98338. /**
  98339. * If every light affecting the material is in this lightmapMode,
  98340. * material.lightmapTexture adds or multiplies
  98341. * (depends on material.useLightmapAsShadowmap)
  98342. * after every other light calculations.
  98343. */
  98344. static readonly LIGHTMAP_DEFAULT: number;
  98345. /**
  98346. * material.lightmapTexture as only diffuse lighting from this light
  98347. * adds only specular lighting from this light
  98348. * adds dynamic shadows
  98349. */
  98350. static readonly LIGHTMAP_SPECULAR: number;
  98351. /**
  98352. * material.lightmapTexture as only lighting
  98353. * no light calculation from this light
  98354. * only adds dynamic shadows from this light
  98355. */
  98356. static readonly LIGHTMAP_SHADOWSONLY: number;
  98357. /**
  98358. * Each light type uses the default quantity according to its type:
  98359. * point/spot lights use luminous intensity
  98360. * directional lights use illuminance
  98361. */
  98362. static readonly INTENSITYMODE_AUTOMATIC: number;
  98363. /**
  98364. * lumen (lm)
  98365. */
  98366. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98367. /**
  98368. * candela (lm/sr)
  98369. */
  98370. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98371. /**
  98372. * lux (lm/m^2)
  98373. */
  98374. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98375. /**
  98376. * nit (cd/m^2)
  98377. */
  98378. static readonly INTENSITYMODE_LUMINANCE: number;
  98379. /**
  98380. * Light type const id of the point light.
  98381. */
  98382. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98383. /**
  98384. * Light type const id of the directional light.
  98385. */
  98386. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98387. /**
  98388. * Light type const id of the spot light.
  98389. */
  98390. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98391. /**
  98392. * Light type const id of the hemispheric light.
  98393. */
  98394. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98395. /**
  98396. * Diffuse gives the basic color to an object.
  98397. */
  98398. diffuse: Color3;
  98399. /**
  98400. * Specular produces a highlight color on an object.
  98401. * Note: This is note affecting PBR materials.
  98402. */
  98403. specular: Color3;
  98404. /**
  98405. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98406. * falling off base on range or angle.
  98407. * This can be set to any values in Light.FALLOFF_x.
  98408. *
  98409. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98410. * other types of materials.
  98411. */
  98412. falloffType: number;
  98413. /**
  98414. * Strength of the light.
  98415. * Note: By default it is define in the framework own unit.
  98416. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98417. */
  98418. intensity: number;
  98419. private _range;
  98420. protected _inverseSquaredRange: number;
  98421. /**
  98422. * Defines how far from the source the light is impacting in scene units.
  98423. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98424. */
  98425. get range(): number;
  98426. /**
  98427. * Defines how far from the source the light is impacting in scene units.
  98428. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98429. */
  98430. set range(value: number);
  98431. /**
  98432. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98433. * of light.
  98434. */
  98435. private _photometricScale;
  98436. private _intensityMode;
  98437. /**
  98438. * Gets the photometric scale used to interpret the intensity.
  98439. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98440. */
  98441. get intensityMode(): number;
  98442. /**
  98443. * Sets the photometric scale used to interpret the intensity.
  98444. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98445. */
  98446. set intensityMode(value: number);
  98447. private _radius;
  98448. /**
  98449. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98450. */
  98451. get radius(): number;
  98452. /**
  98453. * sets the light radius used by PBR Materials to simulate soft area lights.
  98454. */
  98455. set radius(value: number);
  98456. private _renderPriority;
  98457. /**
  98458. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98459. * exceeding the number allowed of the materials.
  98460. */
  98461. renderPriority: number;
  98462. private _shadowEnabled;
  98463. /**
  98464. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98465. * the current shadow generator.
  98466. */
  98467. get shadowEnabled(): boolean;
  98468. /**
  98469. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98470. * the current shadow generator.
  98471. */
  98472. set shadowEnabled(value: boolean);
  98473. private _includedOnlyMeshes;
  98474. /**
  98475. * Gets the only meshes impacted by this light.
  98476. */
  98477. get includedOnlyMeshes(): AbstractMesh[];
  98478. /**
  98479. * Sets the only meshes impacted by this light.
  98480. */
  98481. set includedOnlyMeshes(value: AbstractMesh[]);
  98482. private _excludedMeshes;
  98483. /**
  98484. * Gets the meshes not impacted by this light.
  98485. */
  98486. get excludedMeshes(): AbstractMesh[];
  98487. /**
  98488. * Sets the meshes not impacted by this light.
  98489. */
  98490. set excludedMeshes(value: AbstractMesh[]);
  98491. private _excludeWithLayerMask;
  98492. /**
  98493. * Gets the layer id use to find what meshes are not impacted by the light.
  98494. * Inactive if 0
  98495. */
  98496. get excludeWithLayerMask(): number;
  98497. /**
  98498. * Sets the layer id use to find what meshes are not impacted by the light.
  98499. * Inactive if 0
  98500. */
  98501. set excludeWithLayerMask(value: number);
  98502. private _includeOnlyWithLayerMask;
  98503. /**
  98504. * Gets the layer id use to find what meshes are impacted by the light.
  98505. * Inactive if 0
  98506. */
  98507. get includeOnlyWithLayerMask(): number;
  98508. /**
  98509. * Sets the layer id use to find what meshes are impacted by the light.
  98510. * Inactive if 0
  98511. */
  98512. set includeOnlyWithLayerMask(value: number);
  98513. private _lightmapMode;
  98514. /**
  98515. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98516. */
  98517. get lightmapMode(): number;
  98518. /**
  98519. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98520. */
  98521. set lightmapMode(value: number);
  98522. /**
  98523. * Shadow generator associted to the light.
  98524. * @hidden Internal use only.
  98525. */
  98526. _shadowGenerator: Nullable<IShadowGenerator>;
  98527. /**
  98528. * @hidden Internal use only.
  98529. */
  98530. _excludedMeshesIds: string[];
  98531. /**
  98532. * @hidden Internal use only.
  98533. */
  98534. _includedOnlyMeshesIds: string[];
  98535. /**
  98536. * The current light unifom buffer.
  98537. * @hidden Internal use only.
  98538. */
  98539. _uniformBuffer: UniformBuffer;
  98540. /** @hidden */
  98541. _renderId: number;
  98542. /**
  98543. * Creates a Light object in the scene.
  98544. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98545. * @param name The firendly name of the light
  98546. * @param scene The scene the light belongs too
  98547. */
  98548. constructor(name: string, scene: Scene);
  98549. protected abstract _buildUniformLayout(): void;
  98550. /**
  98551. * Sets the passed Effect "effect" with the Light information.
  98552. * @param effect The effect to update
  98553. * @param lightIndex The index of the light in the effect to update
  98554. * @returns The light
  98555. */
  98556. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98557. /**
  98558. * Sets the passed Effect "effect" with the Light textures.
  98559. * @param effect The effect to update
  98560. * @param lightIndex The index of the light in the effect to update
  98561. * @returns The light
  98562. */
  98563. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98564. /**
  98565. * Binds the lights information from the scene to the effect for the given mesh.
  98566. * @param lightIndex Light index
  98567. * @param scene The scene where the light belongs to
  98568. * @param effect The effect we are binding the data to
  98569. * @param useSpecular Defines if specular is supported
  98570. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98571. */
  98572. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98573. /**
  98574. * Sets the passed Effect "effect" with the Light information.
  98575. * @param effect The effect to update
  98576. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98577. * @returns The light
  98578. */
  98579. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98580. /**
  98581. * Returns the string "Light".
  98582. * @returns the class name
  98583. */
  98584. getClassName(): string;
  98585. /** @hidden */
  98586. readonly _isLight: boolean;
  98587. /**
  98588. * Converts the light information to a readable string for debug purpose.
  98589. * @param fullDetails Supports for multiple levels of logging within scene loading
  98590. * @returns the human readable light info
  98591. */
  98592. toString(fullDetails?: boolean): string;
  98593. /** @hidden */
  98594. protected _syncParentEnabledState(): void;
  98595. /**
  98596. * Set the enabled state of this node.
  98597. * @param value - the new enabled state
  98598. */
  98599. setEnabled(value: boolean): void;
  98600. /**
  98601. * Returns the Light associated shadow generator if any.
  98602. * @return the associated shadow generator.
  98603. */
  98604. getShadowGenerator(): Nullable<IShadowGenerator>;
  98605. /**
  98606. * Returns a Vector3, the absolute light position in the World.
  98607. * @returns the world space position of the light
  98608. */
  98609. getAbsolutePosition(): Vector3;
  98610. /**
  98611. * Specifies if the light will affect the passed mesh.
  98612. * @param mesh The mesh to test against the light
  98613. * @return true the mesh is affected otherwise, false.
  98614. */
  98615. canAffectMesh(mesh: AbstractMesh): boolean;
  98616. /**
  98617. * Sort function to order lights for rendering.
  98618. * @param a First Light object to compare to second.
  98619. * @param b Second Light object to compare first.
  98620. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98621. */
  98622. static CompareLightsPriority(a: Light, b: Light): number;
  98623. /**
  98624. * Releases resources associated with this node.
  98625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98627. */
  98628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98629. /**
  98630. * Returns the light type ID (integer).
  98631. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98632. */
  98633. getTypeID(): number;
  98634. /**
  98635. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98636. * @returns the scaled intensity in intensity mode unit
  98637. */
  98638. getScaledIntensity(): number;
  98639. /**
  98640. * Returns a new Light object, named "name", from the current one.
  98641. * @param name The name of the cloned light
  98642. * @param newParent The parent of this light, if it has one
  98643. * @returns the new created light
  98644. */
  98645. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98646. /**
  98647. * Serializes the current light into a Serialization object.
  98648. * @returns the serialized object.
  98649. */
  98650. serialize(): any;
  98651. /**
  98652. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98653. * This new light is named "name" and added to the passed scene.
  98654. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98655. * @param name The friendly name of the light
  98656. * @param scene The scene the new light will belong to
  98657. * @returns the constructor function
  98658. */
  98659. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98660. /**
  98661. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98662. * @param parsedLight The JSON representation of the light
  98663. * @param scene The scene to create the parsed light in
  98664. * @returns the created light after parsing
  98665. */
  98666. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98667. private _hookArrayForExcluded;
  98668. private _hookArrayForIncludedOnly;
  98669. private _resyncMeshes;
  98670. /**
  98671. * Forces the meshes to update their light related information in their rendering used effects
  98672. * @hidden Internal Use Only
  98673. */
  98674. _markMeshesAsLightDirty(): void;
  98675. /**
  98676. * Recomputes the cached photometric scale if needed.
  98677. */
  98678. private _computePhotometricScale;
  98679. /**
  98680. * Returns the Photometric Scale according to the light type and intensity mode.
  98681. */
  98682. private _getPhotometricScale;
  98683. /**
  98684. * Reorder the light in the scene according to their defined priority.
  98685. * @hidden Internal Use Only
  98686. */
  98687. _reorderLightsInScene(): void;
  98688. /**
  98689. * Prepares the list of defines specific to the light type.
  98690. * @param defines the list of defines
  98691. * @param lightIndex defines the index of the light for the effect
  98692. */
  98693. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98694. }
  98695. }
  98696. declare module BABYLON {
  98697. /**
  98698. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98699. * This is the base of the follow, arc rotate cameras and Free camera
  98700. * @see https://doc.babylonjs.com/features/cameras
  98701. */
  98702. export class TargetCamera extends Camera {
  98703. private static _RigCamTransformMatrix;
  98704. private static _TargetTransformMatrix;
  98705. private static _TargetFocalPoint;
  98706. private _tmpUpVector;
  98707. private _tmpTargetVector;
  98708. /**
  98709. * Define the current direction the camera is moving to
  98710. */
  98711. cameraDirection: Vector3;
  98712. /**
  98713. * Define the current rotation the camera is rotating to
  98714. */
  98715. cameraRotation: Vector2;
  98716. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98717. ignoreParentScaling: boolean;
  98718. /**
  98719. * When set, the up vector of the camera will be updated by the rotation of the camera
  98720. */
  98721. updateUpVectorFromRotation: boolean;
  98722. private _tmpQuaternion;
  98723. /**
  98724. * Define the current rotation of the camera
  98725. */
  98726. rotation: Vector3;
  98727. /**
  98728. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98729. */
  98730. rotationQuaternion: Quaternion;
  98731. /**
  98732. * Define the current speed of the camera
  98733. */
  98734. speed: number;
  98735. /**
  98736. * Add constraint to the camera to prevent it to move freely in all directions and
  98737. * around all axis.
  98738. */
  98739. noRotationConstraint: boolean;
  98740. /**
  98741. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98742. * panning
  98743. */
  98744. invertRotation: boolean;
  98745. /**
  98746. * Speed multiplier for inverse camera panning
  98747. */
  98748. inverseRotationSpeed: number;
  98749. /**
  98750. * Define the current target of the camera as an object or a position.
  98751. */
  98752. lockedTarget: any;
  98753. /** @hidden */
  98754. _currentTarget: Vector3;
  98755. /** @hidden */
  98756. _initialFocalDistance: number;
  98757. /** @hidden */
  98758. _viewMatrix: Matrix;
  98759. /** @hidden */
  98760. _camMatrix: Matrix;
  98761. /** @hidden */
  98762. _cameraTransformMatrix: Matrix;
  98763. /** @hidden */
  98764. _cameraRotationMatrix: Matrix;
  98765. /** @hidden */
  98766. _referencePoint: Vector3;
  98767. /** @hidden */
  98768. _transformedReferencePoint: Vector3;
  98769. /** @hidden */
  98770. _reset: () => void;
  98771. private _defaultUp;
  98772. /**
  98773. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98774. * This is the base of the follow, arc rotate cameras and Free camera
  98775. * @see https://doc.babylonjs.com/features/cameras
  98776. * @param name Defines the name of the camera in the scene
  98777. * @param position Defines the start position of the camera in the scene
  98778. * @param scene Defines the scene the camera belongs to
  98779. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98780. */
  98781. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98782. /**
  98783. * Gets the position in front of the camera at a given distance.
  98784. * @param distance The distance from the camera we want the position to be
  98785. * @returns the position
  98786. */
  98787. getFrontPosition(distance: number): Vector3;
  98788. /** @hidden */
  98789. _getLockedTargetPosition(): Nullable<Vector3>;
  98790. private _storedPosition;
  98791. private _storedRotation;
  98792. private _storedRotationQuaternion;
  98793. /**
  98794. * Store current camera state of the camera (fov, position, rotation, etc..)
  98795. * @returns the camera
  98796. */
  98797. storeState(): Camera;
  98798. /**
  98799. * Restored camera state. You must call storeState() first
  98800. * @returns whether it was successful or not
  98801. * @hidden
  98802. */
  98803. _restoreStateValues(): boolean;
  98804. /** @hidden */
  98805. _initCache(): void;
  98806. /** @hidden */
  98807. _updateCache(ignoreParentClass?: boolean): void;
  98808. /** @hidden */
  98809. _isSynchronizedViewMatrix(): boolean;
  98810. /** @hidden */
  98811. _computeLocalCameraSpeed(): number;
  98812. /**
  98813. * Defines the target the camera should look at.
  98814. * @param target Defines the new target as a Vector or a mesh
  98815. */
  98816. setTarget(target: Vector3): void;
  98817. /**
  98818. * Defines the target point of the camera.
  98819. * The camera looks towards it form the radius distance.
  98820. */
  98821. get target(): Vector3;
  98822. set target(value: Vector3);
  98823. /**
  98824. * Return the current target position of the camera. This value is expressed in local space.
  98825. * @returns the target position
  98826. */
  98827. getTarget(): Vector3;
  98828. /** @hidden */
  98829. _decideIfNeedsToMove(): boolean;
  98830. /** @hidden */
  98831. _updatePosition(): void;
  98832. /** @hidden */
  98833. _checkInputs(): void;
  98834. protected _updateCameraRotationMatrix(): void;
  98835. /**
  98836. * 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)
  98837. * @returns the current camera
  98838. */
  98839. private _rotateUpVectorWithCameraRotationMatrix;
  98840. private _cachedRotationZ;
  98841. private _cachedQuaternionRotationZ;
  98842. /** @hidden */
  98843. _getViewMatrix(): Matrix;
  98844. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98845. /**
  98846. * @hidden
  98847. */
  98848. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98849. /**
  98850. * @hidden
  98851. */
  98852. _updateRigCameras(): void;
  98853. private _getRigCamPositionAndTarget;
  98854. /**
  98855. * Gets the current object class name.
  98856. * @return the class name
  98857. */
  98858. getClassName(): string;
  98859. }
  98860. }
  98861. declare module BABYLON {
  98862. /**
  98863. * Gather the list of keyboard event types as constants.
  98864. */
  98865. export class KeyboardEventTypes {
  98866. /**
  98867. * The keydown event is fired when a key becomes active (pressed).
  98868. */
  98869. static readonly KEYDOWN: number;
  98870. /**
  98871. * The keyup event is fired when a key has been released.
  98872. */
  98873. static readonly KEYUP: number;
  98874. }
  98875. /**
  98876. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98877. */
  98878. export class KeyboardInfo {
  98879. /**
  98880. * Defines the type of event (KeyboardEventTypes)
  98881. */
  98882. type: number;
  98883. /**
  98884. * Defines the related dom event
  98885. */
  98886. event: KeyboardEvent;
  98887. /**
  98888. * Instantiates a new keyboard info.
  98889. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98890. * @param type Defines the type of event (KeyboardEventTypes)
  98891. * @param event Defines the related dom event
  98892. */
  98893. constructor(
  98894. /**
  98895. * Defines the type of event (KeyboardEventTypes)
  98896. */
  98897. type: number,
  98898. /**
  98899. * Defines the related dom event
  98900. */
  98901. event: KeyboardEvent);
  98902. }
  98903. /**
  98904. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98905. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98906. */
  98907. export class KeyboardInfoPre extends KeyboardInfo {
  98908. /**
  98909. * Defines the type of event (KeyboardEventTypes)
  98910. */
  98911. type: number;
  98912. /**
  98913. * Defines the related dom event
  98914. */
  98915. event: KeyboardEvent;
  98916. /**
  98917. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98918. */
  98919. skipOnPointerObservable: boolean;
  98920. /**
  98921. * Instantiates a new keyboard pre info.
  98922. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98923. * @param type Defines the type of event (KeyboardEventTypes)
  98924. * @param event Defines the related dom event
  98925. */
  98926. constructor(
  98927. /**
  98928. * Defines the type of event (KeyboardEventTypes)
  98929. */
  98930. type: number,
  98931. /**
  98932. * Defines the related dom event
  98933. */
  98934. event: KeyboardEvent);
  98935. }
  98936. }
  98937. declare module BABYLON {
  98938. /**
  98939. * Manage the keyboard inputs to control the movement of a free camera.
  98940. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98941. */
  98942. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98943. /**
  98944. * Defines the camera the input is attached to.
  98945. */
  98946. camera: FreeCamera;
  98947. /**
  98948. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98949. */
  98950. keysUp: number[];
  98951. /**
  98952. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98953. */
  98954. keysUpward: number[];
  98955. /**
  98956. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98957. */
  98958. keysDown: number[];
  98959. /**
  98960. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98961. */
  98962. keysDownward: number[];
  98963. /**
  98964. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98965. */
  98966. keysLeft: number[];
  98967. /**
  98968. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98969. */
  98970. keysRight: number[];
  98971. private _keys;
  98972. private _onCanvasBlurObserver;
  98973. private _onKeyboardObserver;
  98974. private _engine;
  98975. private _scene;
  98976. /**
  98977. * Attach the input controls to a specific dom element to get the input from.
  98978. * @param element Defines the element the controls should be listened from
  98979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98980. */
  98981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98982. /**
  98983. * Detach the current controls from the specified dom element.
  98984. * @param element Defines the element to stop listening the inputs from
  98985. */
  98986. detachControl(element: Nullable<HTMLElement>): void;
  98987. /**
  98988. * Update the current camera state depending on the inputs that have been used this frame.
  98989. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98990. */
  98991. checkInputs(): void;
  98992. /**
  98993. * Gets the class name of the current intput.
  98994. * @returns the class name
  98995. */
  98996. getClassName(): string;
  98997. /** @hidden */
  98998. _onLostFocus(): void;
  98999. /**
  99000. * Get the friendly name associated with the input class.
  99001. * @returns the input friendly name
  99002. */
  99003. getSimpleName(): string;
  99004. }
  99005. }
  99006. declare module BABYLON {
  99007. /**
  99008. * Gather the list of pointer event types as constants.
  99009. */
  99010. export class PointerEventTypes {
  99011. /**
  99012. * 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.
  99013. */
  99014. static readonly POINTERDOWN: number;
  99015. /**
  99016. * The pointerup event is fired when a pointer is no longer active.
  99017. */
  99018. static readonly POINTERUP: number;
  99019. /**
  99020. * The pointermove event is fired when a pointer changes coordinates.
  99021. */
  99022. static readonly POINTERMOVE: number;
  99023. /**
  99024. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99025. */
  99026. static readonly POINTERWHEEL: number;
  99027. /**
  99028. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99029. */
  99030. static readonly POINTERPICK: number;
  99031. /**
  99032. * The pointertap event is fired when a the object has been touched and released without drag.
  99033. */
  99034. static readonly POINTERTAP: number;
  99035. /**
  99036. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99037. */
  99038. static readonly POINTERDOUBLETAP: number;
  99039. }
  99040. /**
  99041. * Base class of pointer info types.
  99042. */
  99043. export class PointerInfoBase {
  99044. /**
  99045. * Defines the type of event (PointerEventTypes)
  99046. */
  99047. type: number;
  99048. /**
  99049. * Defines the related dom event
  99050. */
  99051. event: PointerEvent | MouseWheelEvent;
  99052. /**
  99053. * Instantiates the base class of pointers info.
  99054. * @param type Defines the type of event (PointerEventTypes)
  99055. * @param event Defines the related dom event
  99056. */
  99057. constructor(
  99058. /**
  99059. * Defines the type of event (PointerEventTypes)
  99060. */
  99061. type: number,
  99062. /**
  99063. * Defines the related dom event
  99064. */
  99065. event: PointerEvent | MouseWheelEvent);
  99066. }
  99067. /**
  99068. * This class is used to store pointer related info for the onPrePointerObservable event.
  99069. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99070. */
  99071. export class PointerInfoPre extends PointerInfoBase {
  99072. /**
  99073. * Ray from a pointer if availible (eg. 6dof controller)
  99074. */
  99075. ray: Nullable<Ray>;
  99076. /**
  99077. * Defines the local position of the pointer on the canvas.
  99078. */
  99079. localPosition: Vector2;
  99080. /**
  99081. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99082. */
  99083. skipOnPointerObservable: boolean;
  99084. /**
  99085. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99086. * @param type Defines the type of event (PointerEventTypes)
  99087. * @param event Defines the related dom event
  99088. * @param localX Defines the local x coordinates of the pointer when the event occured
  99089. * @param localY Defines the local y coordinates of the pointer when the event occured
  99090. */
  99091. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99092. }
  99093. /**
  99094. * This type contains all the data related to a pointer event in Babylon.js.
  99095. * 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.
  99096. */
  99097. export class PointerInfo extends PointerInfoBase {
  99098. /**
  99099. * Defines the picking info associated to the info (if any)\
  99100. */
  99101. pickInfo: Nullable<PickingInfo>;
  99102. /**
  99103. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99104. * @param type Defines the type of event (PointerEventTypes)
  99105. * @param event Defines the related dom event
  99106. * @param pickInfo Defines the picking info associated to the info (if any)\
  99107. */
  99108. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99109. /**
  99110. * Defines the picking info associated to the info (if any)\
  99111. */
  99112. pickInfo: Nullable<PickingInfo>);
  99113. }
  99114. /**
  99115. * Data relating to a touch event on the screen.
  99116. */
  99117. export interface PointerTouch {
  99118. /**
  99119. * X coordinate of touch.
  99120. */
  99121. x: number;
  99122. /**
  99123. * Y coordinate of touch.
  99124. */
  99125. y: number;
  99126. /**
  99127. * Id of touch. Unique for each finger.
  99128. */
  99129. pointerId: number;
  99130. /**
  99131. * Event type passed from DOM.
  99132. */
  99133. type: any;
  99134. }
  99135. }
  99136. declare module BABYLON {
  99137. /**
  99138. * Manage the mouse inputs to control the movement of a free camera.
  99139. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99140. */
  99141. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99142. /**
  99143. * Define if touch is enabled in the mouse input
  99144. */
  99145. touchEnabled: boolean;
  99146. /**
  99147. * Defines the camera the input is attached to.
  99148. */
  99149. camera: FreeCamera;
  99150. /**
  99151. * Defines the buttons associated with the input to handle camera move.
  99152. */
  99153. buttons: number[];
  99154. /**
  99155. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99156. */
  99157. angularSensibility: number;
  99158. private _pointerInput;
  99159. private _onMouseMove;
  99160. private _observer;
  99161. private previousPosition;
  99162. /**
  99163. * Observable for when a pointer move event occurs containing the move offset
  99164. */
  99165. onPointerMovedObservable: Observable<{
  99166. offsetX: number;
  99167. offsetY: number;
  99168. }>;
  99169. /**
  99170. * @hidden
  99171. * If the camera should be rotated automatically based on pointer movement
  99172. */
  99173. _allowCameraRotation: boolean;
  99174. /**
  99175. * Manage the mouse inputs to control the movement of a free camera.
  99176. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99177. * @param touchEnabled Defines if touch is enabled or not
  99178. */
  99179. constructor(
  99180. /**
  99181. * Define if touch is enabled in the mouse input
  99182. */
  99183. touchEnabled?: boolean);
  99184. /**
  99185. * Attach the input controls to a specific dom element to get the input from.
  99186. * @param element Defines the element the controls should be listened from
  99187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99188. */
  99189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99190. /**
  99191. * Called on JS contextmenu event.
  99192. * Override this method to provide functionality.
  99193. */
  99194. protected onContextMenu(evt: PointerEvent): void;
  99195. /**
  99196. * Detach the current controls from the specified dom element.
  99197. * @param element Defines the element to stop listening the inputs from
  99198. */
  99199. detachControl(element: Nullable<HTMLElement>): void;
  99200. /**
  99201. * Gets the class name of the current intput.
  99202. * @returns the class name
  99203. */
  99204. getClassName(): string;
  99205. /**
  99206. * Get the friendly name associated with the input class.
  99207. * @returns the input friendly name
  99208. */
  99209. getSimpleName(): string;
  99210. }
  99211. }
  99212. declare module BABYLON {
  99213. /**
  99214. * Manage the touch inputs to control the movement of a free camera.
  99215. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99216. */
  99217. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99218. /**
  99219. * Define if mouse events can be treated as touch events
  99220. */
  99221. allowMouse: boolean;
  99222. /**
  99223. * Defines the camera the input is attached to.
  99224. */
  99225. camera: FreeCamera;
  99226. /**
  99227. * Defines the touch sensibility for rotation.
  99228. * The higher the faster.
  99229. */
  99230. touchAngularSensibility: number;
  99231. /**
  99232. * Defines the touch sensibility for move.
  99233. * The higher the faster.
  99234. */
  99235. touchMoveSensibility: number;
  99236. private _offsetX;
  99237. private _offsetY;
  99238. private _pointerPressed;
  99239. private _pointerInput;
  99240. private _observer;
  99241. private _onLostFocus;
  99242. /**
  99243. * Manage the touch inputs to control the movement of a free camera.
  99244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99245. * @param allowMouse Defines if mouse events can be treated as touch events
  99246. */
  99247. constructor(
  99248. /**
  99249. * Define if mouse events can be treated as touch events
  99250. */
  99251. allowMouse?: boolean);
  99252. /**
  99253. * Attach the input controls to a specific dom element to get the input from.
  99254. * @param element Defines the element the controls should be listened from
  99255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99256. */
  99257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99258. /**
  99259. * Detach the current controls from the specified dom element.
  99260. * @param element Defines the element to stop listening the inputs from
  99261. */
  99262. detachControl(element: Nullable<HTMLElement>): void;
  99263. /**
  99264. * Update the current camera state depending on the inputs that have been used this frame.
  99265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99266. */
  99267. checkInputs(): void;
  99268. /**
  99269. * Gets the class name of the current intput.
  99270. * @returns the class name
  99271. */
  99272. getClassName(): string;
  99273. /**
  99274. * Get the friendly name associated with the input class.
  99275. * @returns the input friendly name
  99276. */
  99277. getSimpleName(): string;
  99278. }
  99279. }
  99280. declare module BABYLON {
  99281. /**
  99282. * Default Inputs manager for the FreeCamera.
  99283. * It groups all the default supported inputs for ease of use.
  99284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99285. */
  99286. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99287. /**
  99288. * @hidden
  99289. */
  99290. _mouseInput: Nullable<FreeCameraMouseInput>;
  99291. /**
  99292. * Instantiates a new FreeCameraInputsManager.
  99293. * @param camera Defines the camera the inputs belong to
  99294. */
  99295. constructor(camera: FreeCamera);
  99296. /**
  99297. * Add keyboard input support to the input manager.
  99298. * @returns the current input manager
  99299. */
  99300. addKeyboard(): FreeCameraInputsManager;
  99301. /**
  99302. * Add mouse input support to the input manager.
  99303. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99304. * @returns the current input manager
  99305. */
  99306. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99307. /**
  99308. * Removes the mouse input support from the manager
  99309. * @returns the current input manager
  99310. */
  99311. removeMouse(): FreeCameraInputsManager;
  99312. /**
  99313. * Add touch input support to the input manager.
  99314. * @returns the current input manager
  99315. */
  99316. addTouch(): FreeCameraInputsManager;
  99317. /**
  99318. * Remove all attached input methods from a camera
  99319. */
  99320. clear(): void;
  99321. }
  99322. }
  99323. declare module BABYLON {
  99324. /**
  99325. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99326. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99327. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99328. */
  99329. export class FreeCamera extends TargetCamera {
  99330. /**
  99331. * Define the collision ellipsoid of the camera.
  99332. * This is helpful to simulate a camera body like the player body around the camera
  99333. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99334. */
  99335. ellipsoid: Vector3;
  99336. /**
  99337. * Define an offset for the position of the ellipsoid around the camera.
  99338. * This can be helpful to determine the center of the body near the gravity center of the body
  99339. * instead of its head.
  99340. */
  99341. ellipsoidOffset: Vector3;
  99342. /**
  99343. * Enable or disable collisions of the camera with the rest of the scene objects.
  99344. */
  99345. checkCollisions: boolean;
  99346. /**
  99347. * Enable or disable gravity on the camera.
  99348. */
  99349. applyGravity: boolean;
  99350. /**
  99351. * Define the input manager associated to the camera.
  99352. */
  99353. inputs: FreeCameraInputsManager;
  99354. /**
  99355. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99356. * Higher values reduce sensitivity.
  99357. */
  99358. get angularSensibility(): number;
  99359. /**
  99360. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99361. * Higher values reduce sensitivity.
  99362. */
  99363. set angularSensibility(value: number);
  99364. /**
  99365. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99366. */
  99367. get keysUp(): number[];
  99368. set keysUp(value: number[]);
  99369. /**
  99370. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99371. */
  99372. get keysUpward(): number[];
  99373. set keysUpward(value: number[]);
  99374. /**
  99375. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99376. */
  99377. get keysDown(): number[];
  99378. set keysDown(value: number[]);
  99379. /**
  99380. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99381. */
  99382. get keysDownward(): number[];
  99383. set keysDownward(value: number[]);
  99384. /**
  99385. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99386. */
  99387. get keysLeft(): number[];
  99388. set keysLeft(value: number[]);
  99389. /**
  99390. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99391. */
  99392. get keysRight(): number[];
  99393. set keysRight(value: number[]);
  99394. /**
  99395. * Event raised when the camera collide with a mesh in the scene.
  99396. */
  99397. onCollide: (collidedMesh: AbstractMesh) => void;
  99398. private _collider;
  99399. private _needMoveForGravity;
  99400. private _oldPosition;
  99401. private _diffPosition;
  99402. private _newPosition;
  99403. /** @hidden */
  99404. _localDirection: Vector3;
  99405. /** @hidden */
  99406. _transformedDirection: Vector3;
  99407. /**
  99408. * Instantiates a Free Camera.
  99409. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99410. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99411. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99412. * @param name Define the name of the camera in the scene
  99413. * @param position Define the start position of the camera in the scene
  99414. * @param scene Define the scene the camera belongs to
  99415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99416. */
  99417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99418. /**
  99419. * Attached controls to the current camera.
  99420. * @param element Defines the element the controls should be listened from
  99421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99422. */
  99423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99424. /**
  99425. * Detach the current controls from the camera.
  99426. * The camera will stop reacting to inputs.
  99427. * @param element Defines the element to stop listening the inputs from
  99428. */
  99429. detachControl(element: HTMLElement): void;
  99430. private _collisionMask;
  99431. /**
  99432. * Define a collision mask to limit the list of object the camera can collide with
  99433. */
  99434. get collisionMask(): number;
  99435. set collisionMask(mask: number);
  99436. /** @hidden */
  99437. _collideWithWorld(displacement: Vector3): void;
  99438. private _onCollisionPositionChange;
  99439. /** @hidden */
  99440. _checkInputs(): void;
  99441. /** @hidden */
  99442. _decideIfNeedsToMove(): boolean;
  99443. /** @hidden */
  99444. _updatePosition(): void;
  99445. /**
  99446. * Destroy the camera and release the current resources hold by it.
  99447. */
  99448. dispose(): void;
  99449. /**
  99450. * Gets the current object class name.
  99451. * @return the class name
  99452. */
  99453. getClassName(): string;
  99454. }
  99455. }
  99456. declare module BABYLON {
  99457. /**
  99458. * Represents a gamepad control stick position
  99459. */
  99460. export class StickValues {
  99461. /**
  99462. * The x component of the control stick
  99463. */
  99464. x: number;
  99465. /**
  99466. * The y component of the control stick
  99467. */
  99468. y: number;
  99469. /**
  99470. * Initializes the gamepad x and y control stick values
  99471. * @param x The x component of the gamepad control stick value
  99472. * @param y The y component of the gamepad control stick value
  99473. */
  99474. constructor(
  99475. /**
  99476. * The x component of the control stick
  99477. */
  99478. x: number,
  99479. /**
  99480. * The y component of the control stick
  99481. */
  99482. y: number);
  99483. }
  99484. /**
  99485. * An interface which manages callbacks for gamepad button changes
  99486. */
  99487. export interface GamepadButtonChanges {
  99488. /**
  99489. * Called when a gamepad has been changed
  99490. */
  99491. changed: boolean;
  99492. /**
  99493. * Called when a gamepad press event has been triggered
  99494. */
  99495. pressChanged: boolean;
  99496. /**
  99497. * Called when a touch event has been triggered
  99498. */
  99499. touchChanged: boolean;
  99500. /**
  99501. * Called when a value has changed
  99502. */
  99503. valueChanged: boolean;
  99504. }
  99505. /**
  99506. * Represents a gamepad
  99507. */
  99508. export class Gamepad {
  99509. /**
  99510. * The id of the gamepad
  99511. */
  99512. id: string;
  99513. /**
  99514. * The index of the gamepad
  99515. */
  99516. index: number;
  99517. /**
  99518. * The browser gamepad
  99519. */
  99520. browserGamepad: any;
  99521. /**
  99522. * Specifies what type of gamepad this represents
  99523. */
  99524. type: number;
  99525. private _leftStick;
  99526. private _rightStick;
  99527. /** @hidden */
  99528. _isConnected: boolean;
  99529. private _leftStickAxisX;
  99530. private _leftStickAxisY;
  99531. private _rightStickAxisX;
  99532. private _rightStickAxisY;
  99533. /**
  99534. * Triggered when the left control stick has been changed
  99535. */
  99536. private _onleftstickchanged;
  99537. /**
  99538. * Triggered when the right control stick has been changed
  99539. */
  99540. private _onrightstickchanged;
  99541. /**
  99542. * Represents a gamepad controller
  99543. */
  99544. static GAMEPAD: number;
  99545. /**
  99546. * Represents a generic controller
  99547. */
  99548. static GENERIC: number;
  99549. /**
  99550. * Represents an XBox controller
  99551. */
  99552. static XBOX: number;
  99553. /**
  99554. * Represents a pose-enabled controller
  99555. */
  99556. static POSE_ENABLED: number;
  99557. /**
  99558. * Represents an Dual Shock controller
  99559. */
  99560. static DUALSHOCK: number;
  99561. /**
  99562. * Specifies whether the left control stick should be Y-inverted
  99563. */
  99564. protected _invertLeftStickY: boolean;
  99565. /**
  99566. * Specifies if the gamepad has been connected
  99567. */
  99568. get isConnected(): boolean;
  99569. /**
  99570. * Initializes the gamepad
  99571. * @param id The id of the gamepad
  99572. * @param index The index of the gamepad
  99573. * @param browserGamepad The browser gamepad
  99574. * @param leftStickX The x component of the left joystick
  99575. * @param leftStickY The y component of the left joystick
  99576. * @param rightStickX The x component of the right joystick
  99577. * @param rightStickY The y component of the right joystick
  99578. */
  99579. constructor(
  99580. /**
  99581. * The id of the gamepad
  99582. */
  99583. id: string,
  99584. /**
  99585. * The index of the gamepad
  99586. */
  99587. index: number,
  99588. /**
  99589. * The browser gamepad
  99590. */
  99591. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99592. /**
  99593. * Callback triggered when the left joystick has changed
  99594. * @param callback
  99595. */
  99596. onleftstickchanged(callback: (values: StickValues) => void): void;
  99597. /**
  99598. * Callback triggered when the right joystick has changed
  99599. * @param callback
  99600. */
  99601. onrightstickchanged(callback: (values: StickValues) => void): void;
  99602. /**
  99603. * Gets the left joystick
  99604. */
  99605. get leftStick(): StickValues;
  99606. /**
  99607. * Sets the left joystick values
  99608. */
  99609. set leftStick(newValues: StickValues);
  99610. /**
  99611. * Gets the right joystick
  99612. */
  99613. get rightStick(): StickValues;
  99614. /**
  99615. * Sets the right joystick value
  99616. */
  99617. set rightStick(newValues: StickValues);
  99618. /**
  99619. * Updates the gamepad joystick positions
  99620. */
  99621. update(): void;
  99622. /**
  99623. * Disposes the gamepad
  99624. */
  99625. dispose(): void;
  99626. }
  99627. /**
  99628. * Represents a generic gamepad
  99629. */
  99630. export class GenericPad extends Gamepad {
  99631. private _buttons;
  99632. private _onbuttondown;
  99633. private _onbuttonup;
  99634. /**
  99635. * Observable triggered when a button has been pressed
  99636. */
  99637. onButtonDownObservable: Observable<number>;
  99638. /**
  99639. * Observable triggered when a button has been released
  99640. */
  99641. onButtonUpObservable: Observable<number>;
  99642. /**
  99643. * Callback triggered when a button has been pressed
  99644. * @param callback Called when a button has been pressed
  99645. */
  99646. onbuttondown(callback: (buttonPressed: number) => void): void;
  99647. /**
  99648. * Callback triggered when a button has been released
  99649. * @param callback Called when a button has been released
  99650. */
  99651. onbuttonup(callback: (buttonReleased: number) => void): void;
  99652. /**
  99653. * Initializes the generic gamepad
  99654. * @param id The id of the generic gamepad
  99655. * @param index The index of the generic gamepad
  99656. * @param browserGamepad The browser gamepad
  99657. */
  99658. constructor(id: string, index: number, browserGamepad: any);
  99659. private _setButtonValue;
  99660. /**
  99661. * Updates the generic gamepad
  99662. */
  99663. update(): void;
  99664. /**
  99665. * Disposes the generic gamepad
  99666. */
  99667. dispose(): void;
  99668. }
  99669. }
  99670. declare module BABYLON {
  99671. /**
  99672. * Defines the types of pose enabled controllers that are supported
  99673. */
  99674. export enum PoseEnabledControllerType {
  99675. /**
  99676. * HTC Vive
  99677. */
  99678. VIVE = 0,
  99679. /**
  99680. * Oculus Rift
  99681. */
  99682. OCULUS = 1,
  99683. /**
  99684. * Windows mixed reality
  99685. */
  99686. WINDOWS = 2,
  99687. /**
  99688. * Samsung gear VR
  99689. */
  99690. GEAR_VR = 3,
  99691. /**
  99692. * Google Daydream
  99693. */
  99694. DAYDREAM = 4,
  99695. /**
  99696. * Generic
  99697. */
  99698. GENERIC = 5
  99699. }
  99700. /**
  99701. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99702. */
  99703. export interface MutableGamepadButton {
  99704. /**
  99705. * Value of the button/trigger
  99706. */
  99707. value: number;
  99708. /**
  99709. * If the button/trigger is currently touched
  99710. */
  99711. touched: boolean;
  99712. /**
  99713. * If the button/trigger is currently pressed
  99714. */
  99715. pressed: boolean;
  99716. }
  99717. /**
  99718. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99719. * @hidden
  99720. */
  99721. export interface ExtendedGamepadButton extends GamepadButton {
  99722. /**
  99723. * If the button/trigger is currently pressed
  99724. */
  99725. readonly pressed: boolean;
  99726. /**
  99727. * If the button/trigger is currently touched
  99728. */
  99729. readonly touched: boolean;
  99730. /**
  99731. * Value of the button/trigger
  99732. */
  99733. readonly value: number;
  99734. }
  99735. /** @hidden */
  99736. export interface _GamePadFactory {
  99737. /**
  99738. * Returns whether or not the current gamepad can be created for this type of controller.
  99739. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99740. * @returns true if it can be created, otherwise false
  99741. */
  99742. canCreate(gamepadInfo: any): boolean;
  99743. /**
  99744. * Creates a new instance of the Gamepad.
  99745. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99746. * @returns the new gamepad instance
  99747. */
  99748. create(gamepadInfo: any): Gamepad;
  99749. }
  99750. /**
  99751. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99752. */
  99753. export class PoseEnabledControllerHelper {
  99754. /** @hidden */
  99755. static _ControllerFactories: _GamePadFactory[];
  99756. /** @hidden */
  99757. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99758. /**
  99759. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99760. * @param vrGamepad the gamepad to initialized
  99761. * @returns a vr controller of the type the gamepad identified as
  99762. */
  99763. static InitiateController(vrGamepad: any): Gamepad;
  99764. }
  99765. /**
  99766. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99767. */
  99768. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99769. /**
  99770. * If the controller is used in a webXR session
  99771. */
  99772. isXR: boolean;
  99773. private _deviceRoomPosition;
  99774. private _deviceRoomRotationQuaternion;
  99775. /**
  99776. * The device position in babylon space
  99777. */
  99778. devicePosition: Vector3;
  99779. /**
  99780. * The device rotation in babylon space
  99781. */
  99782. deviceRotationQuaternion: Quaternion;
  99783. /**
  99784. * The scale factor of the device in babylon space
  99785. */
  99786. deviceScaleFactor: number;
  99787. /**
  99788. * (Likely devicePosition should be used instead) The device position in its room space
  99789. */
  99790. position: Vector3;
  99791. /**
  99792. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99793. */
  99794. rotationQuaternion: Quaternion;
  99795. /**
  99796. * The type of controller (Eg. Windows mixed reality)
  99797. */
  99798. controllerType: PoseEnabledControllerType;
  99799. protected _calculatedPosition: Vector3;
  99800. private _calculatedRotation;
  99801. /**
  99802. * The raw pose from the device
  99803. */
  99804. rawPose: DevicePose;
  99805. private _trackPosition;
  99806. private _maxRotationDistFromHeadset;
  99807. private _draggedRoomRotation;
  99808. /**
  99809. * @hidden
  99810. */
  99811. _disableTrackPosition(fixedPosition: Vector3): void;
  99812. /**
  99813. * Internal, the mesh attached to the controller
  99814. * @hidden
  99815. */
  99816. _mesh: Nullable<AbstractMesh>;
  99817. private _poseControlledCamera;
  99818. private _leftHandSystemQuaternion;
  99819. /**
  99820. * Internal, matrix used to convert room space to babylon space
  99821. * @hidden
  99822. */
  99823. _deviceToWorld: Matrix;
  99824. /**
  99825. * Node to be used when casting a ray from the controller
  99826. * @hidden
  99827. */
  99828. _pointingPoseNode: Nullable<TransformNode>;
  99829. /**
  99830. * Name of the child mesh that can be used to cast a ray from the controller
  99831. */
  99832. static readonly POINTING_POSE: string;
  99833. /**
  99834. * Creates a new PoseEnabledController from a gamepad
  99835. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99836. */
  99837. constructor(browserGamepad: any);
  99838. private _workingMatrix;
  99839. /**
  99840. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99841. */
  99842. update(): void;
  99843. /**
  99844. * Updates only the pose device and mesh without doing any button event checking
  99845. */
  99846. protected _updatePoseAndMesh(): void;
  99847. /**
  99848. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99849. * @param poseData raw pose fromthe device
  99850. */
  99851. updateFromDevice(poseData: DevicePose): void;
  99852. /**
  99853. * @hidden
  99854. */
  99855. _meshAttachedObservable: Observable<AbstractMesh>;
  99856. /**
  99857. * Attaches a mesh to the controller
  99858. * @param mesh the mesh to be attached
  99859. */
  99860. attachToMesh(mesh: AbstractMesh): void;
  99861. /**
  99862. * Attaches the controllers mesh to a camera
  99863. * @param camera the camera the mesh should be attached to
  99864. */
  99865. attachToPoseControlledCamera(camera: TargetCamera): void;
  99866. /**
  99867. * Disposes of the controller
  99868. */
  99869. dispose(): void;
  99870. /**
  99871. * The mesh that is attached to the controller
  99872. */
  99873. get mesh(): Nullable<AbstractMesh>;
  99874. /**
  99875. * Gets the ray of the controller in the direction the controller is pointing
  99876. * @param length the length the resulting ray should be
  99877. * @returns a ray in the direction the controller is pointing
  99878. */
  99879. getForwardRay(length?: number): Ray;
  99880. }
  99881. }
  99882. declare module BABYLON {
  99883. /**
  99884. * Defines the WebVRController object that represents controllers tracked in 3D space
  99885. */
  99886. export abstract class WebVRController extends PoseEnabledController {
  99887. /**
  99888. * Internal, the default controller model for the controller
  99889. */
  99890. protected _defaultModel: Nullable<AbstractMesh>;
  99891. /**
  99892. * Fired when the trigger state has changed
  99893. */
  99894. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99895. /**
  99896. * Fired when the main button state has changed
  99897. */
  99898. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99899. /**
  99900. * Fired when the secondary button state has changed
  99901. */
  99902. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99903. /**
  99904. * Fired when the pad state has changed
  99905. */
  99906. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99907. /**
  99908. * Fired when controllers stick values have changed
  99909. */
  99910. onPadValuesChangedObservable: Observable<StickValues>;
  99911. /**
  99912. * Array of button availible on the controller
  99913. */
  99914. protected _buttons: Array<MutableGamepadButton>;
  99915. private _onButtonStateChange;
  99916. /**
  99917. * Fired when a controller button's state has changed
  99918. * @param callback the callback containing the button that was modified
  99919. */
  99920. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99921. /**
  99922. * X and Y axis corresponding to the controllers joystick
  99923. */
  99924. pad: StickValues;
  99925. /**
  99926. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99927. */
  99928. hand: string;
  99929. /**
  99930. * The default controller model for the controller
  99931. */
  99932. get defaultModel(): Nullable<AbstractMesh>;
  99933. /**
  99934. * Creates a new WebVRController from a gamepad
  99935. * @param vrGamepad the gamepad that the WebVRController should be created from
  99936. */
  99937. constructor(vrGamepad: any);
  99938. /**
  99939. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99940. */
  99941. update(): void;
  99942. /**
  99943. * Function to be called when a button is modified
  99944. */
  99945. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99946. /**
  99947. * Loads a mesh and attaches it to the controller
  99948. * @param scene the scene the mesh should be added to
  99949. * @param meshLoaded callback for when the mesh has been loaded
  99950. */
  99951. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99952. private _setButtonValue;
  99953. private _changes;
  99954. private _checkChanges;
  99955. /**
  99956. * Disposes of th webVRCOntroller
  99957. */
  99958. dispose(): void;
  99959. }
  99960. }
  99961. declare module BABYLON {
  99962. /**
  99963. * The HemisphericLight simulates the ambient environment light,
  99964. * so the passed direction is the light reflection direction, not the incoming direction.
  99965. */
  99966. export class HemisphericLight extends Light {
  99967. /**
  99968. * The groundColor is the light in the opposite direction to the one specified during creation.
  99969. * 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.
  99970. */
  99971. groundColor: Color3;
  99972. /**
  99973. * The light reflection direction, not the incoming direction.
  99974. */
  99975. direction: Vector3;
  99976. /**
  99977. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99978. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99979. * The HemisphericLight can't cast shadows.
  99980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99981. * @param name The friendly name of the light
  99982. * @param direction The direction of the light reflection
  99983. * @param scene The scene the light belongs to
  99984. */
  99985. constructor(name: string, direction: Vector3, scene: Scene);
  99986. protected _buildUniformLayout(): void;
  99987. /**
  99988. * Returns the string "HemisphericLight".
  99989. * @return The class name
  99990. */
  99991. getClassName(): string;
  99992. /**
  99993. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99994. * Returns the updated direction.
  99995. * @param target The target the direction should point to
  99996. * @return The computed direction
  99997. */
  99998. setDirectionToTarget(target: Vector3): Vector3;
  99999. /**
  100000. * Returns the shadow generator associated to the light.
  100001. * @returns Always null for hemispheric lights because it does not support shadows.
  100002. */
  100003. getShadowGenerator(): Nullable<IShadowGenerator>;
  100004. /**
  100005. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100006. * @param effect The effect to update
  100007. * @param lightIndex The index of the light in the effect to update
  100008. * @returns The hemispheric light
  100009. */
  100010. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100011. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100012. /**
  100013. * Computes the world matrix of the node
  100014. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100015. * @param useWasUpdatedFlag defines a reserved property
  100016. * @returns the world matrix
  100017. */
  100018. computeWorldMatrix(): Matrix;
  100019. /**
  100020. * Returns the integer 3.
  100021. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100022. */
  100023. getTypeID(): number;
  100024. /**
  100025. * Prepares the list of defines specific to the light type.
  100026. * @param defines the list of defines
  100027. * @param lightIndex defines the index of the light for the effect
  100028. */
  100029. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100030. }
  100031. }
  100032. declare module BABYLON {
  100033. /** @hidden */
  100034. export var vrMultiviewToSingleviewPixelShader: {
  100035. name: string;
  100036. shader: string;
  100037. };
  100038. }
  100039. declare module BABYLON {
  100040. /**
  100041. * Renders to multiple views with a single draw call
  100042. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100043. */
  100044. export class MultiviewRenderTarget extends RenderTargetTexture {
  100045. /**
  100046. * Creates a multiview render target
  100047. * @param scene scene used with the render target
  100048. * @param size the size of the render target (used for each view)
  100049. */
  100050. constructor(scene: Scene, size?: number | {
  100051. width: number;
  100052. height: number;
  100053. } | {
  100054. ratio: number;
  100055. });
  100056. /**
  100057. * @hidden
  100058. * @param faceIndex the face index, if its a cube texture
  100059. */
  100060. _bindFrameBuffer(faceIndex?: number): void;
  100061. /**
  100062. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100063. * @returns the view count
  100064. */
  100065. getViewCount(): number;
  100066. }
  100067. }
  100068. declare module BABYLON {
  100069. interface Engine {
  100070. /**
  100071. * Creates a new multiview render target
  100072. * @param width defines the width of the texture
  100073. * @param height defines the height of the texture
  100074. * @returns the created multiview texture
  100075. */
  100076. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100077. /**
  100078. * Binds a multiview framebuffer to be drawn to
  100079. * @param multiviewTexture texture to bind
  100080. */
  100081. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100082. }
  100083. interface Camera {
  100084. /**
  100085. * @hidden
  100086. * 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)
  100087. */
  100088. _useMultiviewToSingleView: boolean;
  100089. /**
  100090. * @hidden
  100091. * 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)
  100092. */
  100093. _multiviewTexture: Nullable<RenderTargetTexture>;
  100094. /**
  100095. * @hidden
  100096. * ensures the multiview texture of the camera exists and has the specified width/height
  100097. * @param width height to set on the multiview texture
  100098. * @param height width to set on the multiview texture
  100099. */
  100100. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100101. }
  100102. interface Scene {
  100103. /** @hidden */
  100104. _transformMatrixR: Matrix;
  100105. /** @hidden */
  100106. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100107. /** @hidden */
  100108. _createMultiviewUbo(): void;
  100109. /** @hidden */
  100110. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100111. /** @hidden */
  100112. _renderMultiviewToSingleView(camera: Camera): void;
  100113. }
  100114. }
  100115. declare module BABYLON {
  100116. /**
  100117. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100118. * This will not be used for webXR as it supports displaying texture arrays directly
  100119. */
  100120. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100121. /**
  100122. * Gets a string identifying the name of the class
  100123. * @returns "VRMultiviewToSingleviewPostProcess" string
  100124. */
  100125. getClassName(): string;
  100126. /**
  100127. * Initializes a VRMultiviewToSingleview
  100128. * @param name name of the post process
  100129. * @param camera camera to be applied to
  100130. * @param scaleFactor scaling factor to the size of the output texture
  100131. */
  100132. constructor(name: string, camera: Camera, scaleFactor: number);
  100133. }
  100134. }
  100135. declare module BABYLON {
  100136. /**
  100137. * Interface used to define additional presentation attributes
  100138. */
  100139. export interface IVRPresentationAttributes {
  100140. /**
  100141. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100142. */
  100143. highRefreshRate: boolean;
  100144. /**
  100145. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100146. */
  100147. foveationLevel: number;
  100148. }
  100149. interface Engine {
  100150. /** @hidden */
  100151. _vrDisplay: any;
  100152. /** @hidden */
  100153. _vrSupported: boolean;
  100154. /** @hidden */
  100155. _oldSize: Size;
  100156. /** @hidden */
  100157. _oldHardwareScaleFactor: number;
  100158. /** @hidden */
  100159. _vrExclusivePointerMode: boolean;
  100160. /** @hidden */
  100161. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100162. /** @hidden */
  100163. _onVRDisplayPointerRestricted: () => void;
  100164. /** @hidden */
  100165. _onVRDisplayPointerUnrestricted: () => void;
  100166. /** @hidden */
  100167. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100168. /** @hidden */
  100169. _onVrDisplayDisconnect: Nullable<() => void>;
  100170. /** @hidden */
  100171. _onVrDisplayPresentChange: Nullable<() => void>;
  100172. /**
  100173. * Observable signaled when VR display mode changes
  100174. */
  100175. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100176. /**
  100177. * Observable signaled when VR request present is complete
  100178. */
  100179. onVRRequestPresentComplete: Observable<boolean>;
  100180. /**
  100181. * Observable signaled when VR request present starts
  100182. */
  100183. onVRRequestPresentStart: Observable<Engine>;
  100184. /**
  100185. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100186. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100187. */
  100188. isInVRExclusivePointerMode: boolean;
  100189. /**
  100190. * Gets a boolean indicating if a webVR device was detected
  100191. * @returns true if a webVR device was detected
  100192. */
  100193. isVRDevicePresent(): boolean;
  100194. /**
  100195. * Gets the current webVR device
  100196. * @returns the current webVR device (or null)
  100197. */
  100198. getVRDevice(): any;
  100199. /**
  100200. * Initializes a webVR display and starts listening to display change events
  100201. * The onVRDisplayChangedObservable will be notified upon these changes
  100202. * @returns A promise containing a VRDisplay and if vr is supported
  100203. */
  100204. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100205. /** @hidden */
  100206. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100207. /**
  100208. * Gets or sets the presentation attributes used to configure VR rendering
  100209. */
  100210. vrPresentationAttributes?: IVRPresentationAttributes;
  100211. /**
  100212. * Call this function to switch to webVR mode
  100213. * Will do nothing if webVR is not supported or if there is no webVR device
  100214. * @param options the webvr options provided to the camera. mainly used for multiview
  100215. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100216. */
  100217. enableVR(options: WebVROptions): void;
  100218. /** @hidden */
  100219. _onVRFullScreenTriggered(): void;
  100220. }
  100221. }
  100222. declare module BABYLON {
  100223. /**
  100224. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100225. * IMPORTANT!! The data is right-hand data.
  100226. * @export
  100227. * @interface DevicePose
  100228. */
  100229. export interface DevicePose {
  100230. /**
  100231. * The position of the device, values in array are [x,y,z].
  100232. */
  100233. readonly position: Nullable<Float32Array>;
  100234. /**
  100235. * The linearVelocity of the device, values in array are [x,y,z].
  100236. */
  100237. readonly linearVelocity: Nullable<Float32Array>;
  100238. /**
  100239. * The linearAcceleration of the device, values in array are [x,y,z].
  100240. */
  100241. readonly linearAcceleration: Nullable<Float32Array>;
  100242. /**
  100243. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100244. */
  100245. readonly orientation: Nullable<Float32Array>;
  100246. /**
  100247. * The angularVelocity of the device, values in array are [x,y,z].
  100248. */
  100249. readonly angularVelocity: Nullable<Float32Array>;
  100250. /**
  100251. * The angularAcceleration of the device, values in array are [x,y,z].
  100252. */
  100253. readonly angularAcceleration: Nullable<Float32Array>;
  100254. }
  100255. /**
  100256. * Interface representing a pose controlled object in Babylon.
  100257. * A pose controlled object has both regular pose values as well as pose values
  100258. * from an external device such as a VR head mounted display
  100259. */
  100260. export interface PoseControlled {
  100261. /**
  100262. * The position of the object in babylon space.
  100263. */
  100264. position: Vector3;
  100265. /**
  100266. * The rotation quaternion of the object in babylon space.
  100267. */
  100268. rotationQuaternion: Quaternion;
  100269. /**
  100270. * The position of the device in babylon space.
  100271. */
  100272. devicePosition?: Vector3;
  100273. /**
  100274. * The rotation quaternion of the device in babylon space.
  100275. */
  100276. deviceRotationQuaternion: Quaternion;
  100277. /**
  100278. * The raw pose coming from the device.
  100279. */
  100280. rawPose: Nullable<DevicePose>;
  100281. /**
  100282. * The scale of the device to be used when translating from device space to babylon space.
  100283. */
  100284. deviceScaleFactor: number;
  100285. /**
  100286. * Updates the poseControlled values based on the input device pose.
  100287. * @param poseData the pose data to update the object with
  100288. */
  100289. updateFromDevice(poseData: DevicePose): void;
  100290. }
  100291. /**
  100292. * Set of options to customize the webVRCamera
  100293. */
  100294. export interface WebVROptions {
  100295. /**
  100296. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100297. */
  100298. trackPosition?: boolean;
  100299. /**
  100300. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100301. */
  100302. positionScale?: number;
  100303. /**
  100304. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100305. */
  100306. displayName?: string;
  100307. /**
  100308. * Should the native controller meshes be initialized. (default: true)
  100309. */
  100310. controllerMeshes?: boolean;
  100311. /**
  100312. * Creating a default HemiLight only on controllers. (default: true)
  100313. */
  100314. defaultLightingOnControllers?: boolean;
  100315. /**
  100316. * If you don't want to use the default VR button of the helper. (default: false)
  100317. */
  100318. useCustomVRButton?: boolean;
  100319. /**
  100320. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100321. */
  100322. customVRButton?: HTMLButtonElement;
  100323. /**
  100324. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100325. */
  100326. rayLength?: number;
  100327. /**
  100328. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100329. */
  100330. defaultHeight?: number;
  100331. /**
  100332. * If multiview should be used if availible (default: false)
  100333. */
  100334. useMultiview?: boolean;
  100335. }
  100336. /**
  100337. * This represents a WebVR camera.
  100338. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100339. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100340. */
  100341. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100342. private webVROptions;
  100343. /**
  100344. * @hidden
  100345. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100346. */
  100347. _vrDevice: any;
  100348. /**
  100349. * The rawPose of the vrDevice.
  100350. */
  100351. rawPose: Nullable<DevicePose>;
  100352. private _onVREnabled;
  100353. private _specsVersion;
  100354. private _attached;
  100355. private _frameData;
  100356. protected _descendants: Array<Node>;
  100357. private _deviceRoomPosition;
  100358. /** @hidden */
  100359. _deviceRoomRotationQuaternion: Quaternion;
  100360. private _standingMatrix;
  100361. /**
  100362. * Represents device position in babylon space.
  100363. */
  100364. devicePosition: Vector3;
  100365. /**
  100366. * Represents device rotation in babylon space.
  100367. */
  100368. deviceRotationQuaternion: Quaternion;
  100369. /**
  100370. * The scale of the device to be used when translating from device space to babylon space.
  100371. */
  100372. deviceScaleFactor: number;
  100373. private _deviceToWorld;
  100374. private _worldToDevice;
  100375. /**
  100376. * References to the webVR controllers for the vrDevice.
  100377. */
  100378. controllers: Array<WebVRController>;
  100379. /**
  100380. * Emits an event when a controller is attached.
  100381. */
  100382. onControllersAttachedObservable: Observable<WebVRController[]>;
  100383. /**
  100384. * Emits an event when a controller's mesh has been loaded;
  100385. */
  100386. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100387. /**
  100388. * Emits an event when the HMD's pose has been updated.
  100389. */
  100390. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100391. private _poseSet;
  100392. /**
  100393. * If the rig cameras be used as parent instead of this camera.
  100394. */
  100395. rigParenting: boolean;
  100396. private _lightOnControllers;
  100397. private _defaultHeight?;
  100398. /**
  100399. * Instantiates a WebVRFreeCamera.
  100400. * @param name The name of the WebVRFreeCamera
  100401. * @param position The starting anchor position for the camera
  100402. * @param scene The scene the camera belongs to
  100403. * @param webVROptions a set of customizable options for the webVRCamera
  100404. */
  100405. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100406. /**
  100407. * Gets the device distance from the ground in meters.
  100408. * @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.
  100409. */
  100410. deviceDistanceToRoomGround(): number;
  100411. /**
  100412. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100413. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100414. */
  100415. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100416. /**
  100417. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100418. * @returns A promise with a boolean set to if the standing matrix is supported.
  100419. */
  100420. useStandingMatrixAsync(): Promise<boolean>;
  100421. /**
  100422. * Disposes the camera
  100423. */
  100424. dispose(): void;
  100425. /**
  100426. * Gets a vrController by name.
  100427. * @param name The name of the controller to retreive
  100428. * @returns the controller matching the name specified or null if not found
  100429. */
  100430. getControllerByName(name: string): Nullable<WebVRController>;
  100431. private _leftController;
  100432. /**
  100433. * The controller corresponding to the users left hand.
  100434. */
  100435. get leftController(): Nullable<WebVRController>;
  100436. private _rightController;
  100437. /**
  100438. * The controller corresponding to the users right hand.
  100439. */
  100440. get rightController(): Nullable<WebVRController>;
  100441. /**
  100442. * Casts a ray forward from the vrCamera's gaze.
  100443. * @param length Length of the ray (default: 100)
  100444. * @returns the ray corresponding to the gaze
  100445. */
  100446. getForwardRay(length?: number): Ray;
  100447. /**
  100448. * @hidden
  100449. * Updates the camera based on device's frame data
  100450. */
  100451. _checkInputs(): void;
  100452. /**
  100453. * Updates the poseControlled values based on the input device pose.
  100454. * @param poseData Pose coming from the device
  100455. */
  100456. updateFromDevice(poseData: DevicePose): void;
  100457. private _htmlElementAttached;
  100458. private _detachIfAttached;
  100459. /**
  100460. * WebVR's attach control will start broadcasting frames to the device.
  100461. * Note that in certain browsers (chrome for example) this function must be called
  100462. * within a user-interaction callback. Example:
  100463. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100464. *
  100465. * @param element html element to attach the vrDevice to
  100466. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100467. */
  100468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100469. /**
  100470. * Detaches the camera from the html element and disables VR
  100471. *
  100472. * @param element html element to detach from
  100473. */
  100474. detachControl(element: HTMLElement): void;
  100475. /**
  100476. * @returns the name of this class
  100477. */
  100478. getClassName(): string;
  100479. /**
  100480. * Calls resetPose on the vrDisplay
  100481. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100482. */
  100483. resetToCurrentRotation(): void;
  100484. /**
  100485. * @hidden
  100486. * Updates the rig cameras (left and right eye)
  100487. */
  100488. _updateRigCameras(): void;
  100489. private _workingVector;
  100490. private _oneVector;
  100491. private _workingMatrix;
  100492. private updateCacheCalled;
  100493. private _correctPositionIfNotTrackPosition;
  100494. /**
  100495. * @hidden
  100496. * Updates the cached values of the camera
  100497. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100498. */
  100499. _updateCache(ignoreParentClass?: boolean): void;
  100500. /**
  100501. * @hidden
  100502. * Get current device position in babylon world
  100503. */
  100504. _computeDevicePosition(): void;
  100505. /**
  100506. * Updates the current device position and rotation in the babylon world
  100507. */
  100508. update(): void;
  100509. /**
  100510. * @hidden
  100511. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100512. * @returns an identity matrix
  100513. */
  100514. _getViewMatrix(): Matrix;
  100515. private _tmpMatrix;
  100516. /**
  100517. * This function is called by the two RIG cameras.
  100518. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100519. * @hidden
  100520. */
  100521. _getWebVRViewMatrix(): Matrix;
  100522. /** @hidden */
  100523. _getWebVRProjectionMatrix(): Matrix;
  100524. private _onGamepadConnectedObserver;
  100525. private _onGamepadDisconnectedObserver;
  100526. private _updateCacheWhenTrackingDisabledObserver;
  100527. /**
  100528. * Initializes the controllers and their meshes
  100529. */
  100530. initControllers(): void;
  100531. }
  100532. }
  100533. declare module BABYLON {
  100534. /**
  100535. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100536. *
  100537. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100538. *
  100539. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100540. */
  100541. export class MaterialHelper {
  100542. /**
  100543. * Bind the current view position to an effect.
  100544. * @param effect The effect to be bound
  100545. * @param scene The scene the eyes position is used from
  100546. * @param variableName name of the shader variable that will hold the eye position
  100547. */
  100548. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100549. /**
  100550. * Helps preparing the defines values about the UVs in used in the effect.
  100551. * UVs are shared as much as we can accross channels in the shaders.
  100552. * @param texture The texture we are preparing the UVs for
  100553. * @param defines The defines to update
  100554. * @param key The channel key "diffuse", "specular"... used in the shader
  100555. */
  100556. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100557. /**
  100558. * Binds a texture matrix value to its corrsponding uniform
  100559. * @param texture The texture to bind the matrix for
  100560. * @param uniformBuffer The uniform buffer receivin the data
  100561. * @param key The channel key "diffuse", "specular"... used in the shader
  100562. */
  100563. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100564. /**
  100565. * Gets the current status of the fog (should it be enabled?)
  100566. * @param mesh defines the mesh to evaluate for fog support
  100567. * @param scene defines the hosting scene
  100568. * @returns true if fog must be enabled
  100569. */
  100570. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100571. /**
  100572. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100573. * @param mesh defines the current mesh
  100574. * @param scene defines the current scene
  100575. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100576. * @param pointsCloud defines if point cloud rendering has to be turned on
  100577. * @param fogEnabled defines if fog has to be turned on
  100578. * @param alphaTest defines if alpha testing has to be turned on
  100579. * @param defines defines the current list of defines
  100580. */
  100581. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100582. /**
  100583. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100584. * @param scene defines the current scene
  100585. * @param engine defines the current engine
  100586. * @param defines specifies the list of active defines
  100587. * @param useInstances defines if instances have to be turned on
  100588. * @param useClipPlane defines if clip plane have to be turned on
  100589. * @param useInstances defines if instances have to be turned on
  100590. * @param useThinInstances defines if thin instances have to be turned on
  100591. */
  100592. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100593. /**
  100594. * Prepares the defines for bones
  100595. * @param mesh The mesh containing the geometry data we will draw
  100596. * @param defines The defines to update
  100597. */
  100598. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100599. /**
  100600. * Prepares the defines for morph targets
  100601. * @param mesh The mesh containing the geometry data we will draw
  100602. * @param defines The defines to update
  100603. */
  100604. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100605. /**
  100606. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100607. * @param mesh The mesh containing the geometry data we will draw
  100608. * @param defines The defines to update
  100609. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100610. * @param useBones Precise whether bones should be used or not (override mesh info)
  100611. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100612. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100613. * @returns false if defines are considered not dirty and have not been checked
  100614. */
  100615. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100616. /**
  100617. * Prepares the defines related to multiview
  100618. * @param scene The scene we are intending to draw
  100619. * @param defines The defines to update
  100620. */
  100621. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100622. /**
  100623. * Prepares the defines related to the prepass
  100624. * @param scene The scene we are intending to draw
  100625. * @param defines The defines to update
  100626. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100627. */
  100628. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100629. /**
  100630. * Prepares the defines related to the light information passed in parameter
  100631. * @param scene The scene we are intending to draw
  100632. * @param mesh The mesh the effect is compiling for
  100633. * @param light The light the effect is compiling for
  100634. * @param lightIndex The index of the light
  100635. * @param defines The defines to update
  100636. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100637. * @param state Defines the current state regarding what is needed (normals, etc...)
  100638. */
  100639. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100640. needNormals: boolean;
  100641. needRebuild: boolean;
  100642. shadowEnabled: boolean;
  100643. specularEnabled: boolean;
  100644. lightmapMode: boolean;
  100645. }): void;
  100646. /**
  100647. * Prepares the defines related to the light information passed in parameter
  100648. * @param scene The scene we are intending to draw
  100649. * @param mesh The mesh the effect is compiling for
  100650. * @param defines The defines to update
  100651. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100652. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100653. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100654. * @returns true if normals will be required for the rest of the effect
  100655. */
  100656. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100657. /**
  100658. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100659. * @param lightIndex defines the light index
  100660. * @param uniformsList The uniform list
  100661. * @param samplersList The sampler list
  100662. * @param projectedLightTexture defines if projected texture must be used
  100663. * @param uniformBuffersList defines an optional list of uniform buffers
  100664. */
  100665. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100666. /**
  100667. * Prepares the uniforms and samplers list to be used in the effect
  100668. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100669. * @param samplersList The sampler list
  100670. * @param defines The defines helping in the list generation
  100671. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100672. */
  100673. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100674. /**
  100675. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100676. * @param defines The defines to update while falling back
  100677. * @param fallbacks The authorized effect fallbacks
  100678. * @param maxSimultaneousLights The maximum number of lights allowed
  100679. * @param rank the current rank of the Effect
  100680. * @returns The newly affected rank
  100681. */
  100682. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100683. private static _TmpMorphInfluencers;
  100684. /**
  100685. * Prepares the list of attributes required for morph targets according to the effect defines.
  100686. * @param attribs The current list of supported attribs
  100687. * @param mesh The mesh to prepare the morph targets attributes for
  100688. * @param influencers The number of influencers
  100689. */
  100690. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100691. /**
  100692. * Prepares the list of attributes required for morph targets according to the effect defines.
  100693. * @param attribs The current list of supported attribs
  100694. * @param mesh The mesh to prepare the morph targets attributes for
  100695. * @param defines The current Defines of the effect
  100696. */
  100697. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100698. /**
  100699. * Prepares the list of attributes required for bones according to the effect defines.
  100700. * @param attribs The current list of supported attribs
  100701. * @param mesh The mesh to prepare the bones attributes for
  100702. * @param defines The current Defines of the effect
  100703. * @param fallbacks The current efffect fallback strategy
  100704. */
  100705. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100706. /**
  100707. * Check and prepare the list of attributes required for instances according to the effect defines.
  100708. * @param attribs The current list of supported attribs
  100709. * @param defines The current MaterialDefines of the effect
  100710. */
  100711. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100712. /**
  100713. * Add the list of attributes required for instances to the attribs array.
  100714. * @param attribs The current list of supported attribs
  100715. */
  100716. static PushAttributesForInstances(attribs: string[]): void;
  100717. /**
  100718. * Binds the light information to the effect.
  100719. * @param light The light containing the generator
  100720. * @param effect The effect we are binding the data to
  100721. * @param lightIndex The light index in the effect used to render
  100722. */
  100723. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100724. /**
  100725. * Binds the lights information from the scene to the effect for the given mesh.
  100726. * @param light Light to bind
  100727. * @param lightIndex Light index
  100728. * @param scene The scene where the light belongs to
  100729. * @param effect The effect we are binding the data to
  100730. * @param useSpecular Defines if specular is supported
  100731. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100732. */
  100733. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100734. /**
  100735. * Binds the lights information from the scene to the effect for the given mesh.
  100736. * @param scene The scene the lights belongs to
  100737. * @param mesh The mesh we are binding the information to render
  100738. * @param effect The effect we are binding the data to
  100739. * @param defines The generated defines for the effect
  100740. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100741. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100742. */
  100743. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100744. private static _tempFogColor;
  100745. /**
  100746. * Binds the fog information from the scene to the effect for the given mesh.
  100747. * @param scene The scene the lights belongs to
  100748. * @param mesh The mesh we are binding the information to render
  100749. * @param effect The effect we are binding the data to
  100750. * @param linearSpace Defines if the fog effect is applied in linear space
  100751. */
  100752. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100753. /**
  100754. * Binds the bones information from the mesh to the effect.
  100755. * @param mesh The mesh we are binding the information to render
  100756. * @param effect The effect we are binding the data to
  100757. */
  100758. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100759. /**
  100760. * Binds the morph targets information from the mesh to the effect.
  100761. * @param abstractMesh The mesh we are binding the information to render
  100762. * @param effect The effect we are binding the data to
  100763. */
  100764. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100765. /**
  100766. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100767. * @param defines The generated defines used in the effect
  100768. * @param effect The effect we are binding the data to
  100769. * @param scene The scene we are willing to render with logarithmic scale for
  100770. */
  100771. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100772. /**
  100773. * Binds the clip plane information from the scene to the effect.
  100774. * @param scene The scene the clip plane information are extracted from
  100775. * @param effect The effect we are binding the data to
  100776. */
  100777. static BindClipPlane(effect: Effect, scene: Scene): void;
  100778. }
  100779. }
  100780. declare module BABYLON {
  100781. /**
  100782. * Block used to expose an input value
  100783. */
  100784. export class InputBlock extends NodeMaterialBlock {
  100785. private _mode;
  100786. private _associatedVariableName;
  100787. private _storedValue;
  100788. private _valueCallback;
  100789. private _type;
  100790. private _animationType;
  100791. /** Gets or set a value used to limit the range of float values */
  100792. min: number;
  100793. /** Gets or set a value used to limit the range of float values */
  100794. max: number;
  100795. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100796. isBoolean: boolean;
  100797. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100798. matrixMode: number;
  100799. /** @hidden */
  100800. _systemValue: Nullable<NodeMaterialSystemValues>;
  100801. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100802. isConstant: boolean;
  100803. /** Gets or sets the group to use to display this block in the Inspector */
  100804. groupInInspector: string;
  100805. /** Gets an observable raised when the value is changed */
  100806. onValueChangedObservable: Observable<InputBlock>;
  100807. /**
  100808. * Gets or sets the connection point type (default is float)
  100809. */
  100810. get type(): NodeMaterialBlockConnectionPointTypes;
  100811. /**
  100812. * Creates a new InputBlock
  100813. * @param name defines the block name
  100814. * @param target defines the target of that block (Vertex by default)
  100815. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100816. */
  100817. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100818. /**
  100819. * Validates if a name is a reserve word.
  100820. * @param newName the new name to be given to the node.
  100821. * @returns false if the name is a reserve word, else true.
  100822. */
  100823. validateBlockName(newName: string): boolean;
  100824. /**
  100825. * Gets the output component
  100826. */
  100827. get output(): NodeMaterialConnectionPoint;
  100828. /**
  100829. * Set the source of this connection point to a vertex attribute
  100830. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100831. * @returns the current connection point
  100832. */
  100833. setAsAttribute(attributeName?: string): InputBlock;
  100834. /**
  100835. * Set the source of this connection point to a system value
  100836. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100837. * @returns the current connection point
  100838. */
  100839. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100840. /**
  100841. * Gets or sets the value of that point.
  100842. * Please note that this value will be ignored if valueCallback is defined
  100843. */
  100844. get value(): any;
  100845. set value(value: any);
  100846. /**
  100847. * Gets or sets a callback used to get the value of that point.
  100848. * Please note that setting this value will force the connection point to ignore the value property
  100849. */
  100850. get valueCallback(): () => any;
  100851. set valueCallback(value: () => any);
  100852. /**
  100853. * Gets or sets the associated variable name in the shader
  100854. */
  100855. get associatedVariableName(): string;
  100856. set associatedVariableName(value: string);
  100857. /** Gets or sets the type of animation applied to the input */
  100858. get animationType(): AnimatedInputBlockTypes;
  100859. set animationType(value: AnimatedInputBlockTypes);
  100860. /**
  100861. * Gets a boolean indicating that this connection point not defined yet
  100862. */
  100863. get isUndefined(): boolean;
  100864. /**
  100865. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100866. * In this case the connection point name must be the name of the uniform to use.
  100867. * Can only be set on inputs
  100868. */
  100869. get isUniform(): boolean;
  100870. set isUniform(value: boolean);
  100871. /**
  100872. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100873. * In this case the connection point name must be the name of the attribute to use
  100874. * Can only be set on inputs
  100875. */
  100876. get isAttribute(): boolean;
  100877. set isAttribute(value: boolean);
  100878. /**
  100879. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100880. * Can only be set on exit points
  100881. */
  100882. get isVarying(): boolean;
  100883. set isVarying(value: boolean);
  100884. /**
  100885. * Gets a boolean indicating that the current connection point is a system value
  100886. */
  100887. get isSystemValue(): boolean;
  100888. /**
  100889. * Gets or sets the current well known value or null if not defined as a system value
  100890. */
  100891. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100892. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100893. /**
  100894. * Gets the current class name
  100895. * @returns the class name
  100896. */
  100897. getClassName(): string;
  100898. /**
  100899. * Animate the input if animationType !== None
  100900. * @param scene defines the rendering scene
  100901. */
  100902. animate(scene: Scene): void;
  100903. private _emitDefine;
  100904. initialize(state: NodeMaterialBuildState): void;
  100905. /**
  100906. * Set the input block to its default value (based on its type)
  100907. */
  100908. setDefaultValue(): void;
  100909. private _emitConstant;
  100910. /** @hidden */
  100911. get _noContextSwitch(): boolean;
  100912. private _emit;
  100913. /** @hidden */
  100914. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100915. /** @hidden */
  100916. _transmit(effect: Effect, scene: Scene): void;
  100917. protected _buildBlock(state: NodeMaterialBuildState): void;
  100918. protected _dumpPropertiesCode(): string;
  100919. dispose(): void;
  100920. serialize(): any;
  100921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100922. }
  100923. }
  100924. declare module BABYLON {
  100925. /**
  100926. * Enum used to define the compatibility state between two connection points
  100927. */
  100928. export enum NodeMaterialConnectionPointCompatibilityStates {
  100929. /** Points are compatibles */
  100930. Compatible = 0,
  100931. /** Points are incompatible because of their types */
  100932. TypeIncompatible = 1,
  100933. /** Points are incompatible because of their targets (vertex vs fragment) */
  100934. TargetIncompatible = 2
  100935. }
  100936. /**
  100937. * Defines the direction of a connection point
  100938. */
  100939. export enum NodeMaterialConnectionPointDirection {
  100940. /** Input */
  100941. Input = 0,
  100942. /** Output */
  100943. Output = 1
  100944. }
  100945. /**
  100946. * Defines a connection point for a block
  100947. */
  100948. export class NodeMaterialConnectionPoint {
  100949. /** @hidden */
  100950. _ownerBlock: NodeMaterialBlock;
  100951. /** @hidden */
  100952. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100953. private _endpoints;
  100954. private _associatedVariableName;
  100955. private _direction;
  100956. /** @hidden */
  100957. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100958. /** @hidden */
  100959. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100960. private _type;
  100961. /** @hidden */
  100962. _enforceAssociatedVariableName: boolean;
  100963. /** Gets the direction of the point */
  100964. get direction(): NodeMaterialConnectionPointDirection;
  100965. /** Indicates that this connection point needs dual validation before being connected to another point */
  100966. needDualDirectionValidation: boolean;
  100967. /**
  100968. * Gets or sets the additional types supported by this connection point
  100969. */
  100970. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100971. /**
  100972. * Gets or sets the additional types excluded by this connection point
  100973. */
  100974. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100975. /**
  100976. * Observable triggered when this point is connected
  100977. */
  100978. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100979. /**
  100980. * Gets or sets the associated variable name in the shader
  100981. */
  100982. get associatedVariableName(): string;
  100983. set associatedVariableName(value: string);
  100984. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100985. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100986. /**
  100987. * Gets or sets the connection point type (default is float)
  100988. */
  100989. get type(): NodeMaterialBlockConnectionPointTypes;
  100990. set type(value: NodeMaterialBlockConnectionPointTypes);
  100991. /**
  100992. * Gets or sets the connection point name
  100993. */
  100994. name: string;
  100995. /**
  100996. * Gets or sets the connection point name
  100997. */
  100998. displayName: string;
  100999. /**
  101000. * Gets or sets a boolean indicating that this connection point can be omitted
  101001. */
  101002. isOptional: boolean;
  101003. /**
  101004. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101005. */
  101006. isExposedOnFrame: boolean;
  101007. /**
  101008. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101009. */
  101010. define: string;
  101011. /** @hidden */
  101012. _prioritizeVertex: boolean;
  101013. private _target;
  101014. /** Gets or sets the target of that connection point */
  101015. get target(): NodeMaterialBlockTargets;
  101016. set target(value: NodeMaterialBlockTargets);
  101017. /**
  101018. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101019. */
  101020. get isConnected(): boolean;
  101021. /**
  101022. * Gets a boolean indicating that the current point is connected to an input block
  101023. */
  101024. get isConnectedToInputBlock(): boolean;
  101025. /**
  101026. * Gets a the connected input block (if any)
  101027. */
  101028. get connectInputBlock(): Nullable<InputBlock>;
  101029. /** Get the other side of the connection (if any) */
  101030. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101031. /** Get the block that owns this connection point */
  101032. get ownerBlock(): NodeMaterialBlock;
  101033. /** Get the block connected on the other side of this connection (if any) */
  101034. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101035. /** Get the block connected on the endpoints of this connection (if any) */
  101036. get connectedBlocks(): Array<NodeMaterialBlock>;
  101037. /** Gets the list of connected endpoints */
  101038. get endpoints(): NodeMaterialConnectionPoint[];
  101039. /** Gets a boolean indicating if that output point is connected to at least one input */
  101040. get hasEndpoints(): boolean;
  101041. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101042. get isConnectedInVertexShader(): boolean;
  101043. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101044. get isConnectedInFragmentShader(): boolean;
  101045. /**
  101046. * Creates a block suitable to be used as an input for this input point.
  101047. * If null is returned, a block based on the point type will be created.
  101048. * @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
  101049. */
  101050. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101051. /**
  101052. * Creates a new connection point
  101053. * @param name defines the connection point name
  101054. * @param ownerBlock defines the block hosting this connection point
  101055. * @param direction defines the direction of the connection point
  101056. */
  101057. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101058. /**
  101059. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101060. * @returns the class name
  101061. */
  101062. getClassName(): string;
  101063. /**
  101064. * Gets a boolean indicating if the current point can be connected to another point
  101065. * @param connectionPoint defines the other connection point
  101066. * @returns a boolean
  101067. */
  101068. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101069. /**
  101070. * Gets a number indicating if the current point can be connected to another point
  101071. * @param connectionPoint defines the other connection point
  101072. * @returns a number defining the compatibility state
  101073. */
  101074. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101075. /**
  101076. * Connect this point to another connection point
  101077. * @param connectionPoint defines the other connection point
  101078. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101079. * @returns the current connection point
  101080. */
  101081. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101082. /**
  101083. * Disconnect this point from one of his endpoint
  101084. * @param endpoint defines the other connection point
  101085. * @returns the current connection point
  101086. */
  101087. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101088. /**
  101089. * Serializes this point in a JSON representation
  101090. * @param isInput defines if the connection point is an input (default is true)
  101091. * @returns the serialized point object
  101092. */
  101093. serialize(isInput?: boolean): any;
  101094. /**
  101095. * Release resources
  101096. */
  101097. dispose(): void;
  101098. }
  101099. }
  101100. declare module BABYLON {
  101101. /**
  101102. * Enum used to define the material modes
  101103. */
  101104. export enum NodeMaterialModes {
  101105. /** Regular material */
  101106. Material = 0,
  101107. /** For post process */
  101108. PostProcess = 1,
  101109. /** For particle system */
  101110. Particle = 2,
  101111. /** For procedural texture */
  101112. ProceduralTexture = 3
  101113. }
  101114. }
  101115. declare module BABYLON {
  101116. /**
  101117. * Block used to read a texture from a sampler
  101118. */
  101119. export class TextureBlock extends NodeMaterialBlock {
  101120. private _defineName;
  101121. private _linearDefineName;
  101122. private _gammaDefineName;
  101123. private _tempTextureRead;
  101124. private _samplerName;
  101125. private _transformedUVName;
  101126. private _textureTransformName;
  101127. private _textureInfoName;
  101128. private _mainUVName;
  101129. private _mainUVDefineName;
  101130. private _fragmentOnly;
  101131. /**
  101132. * Gets or sets the texture associated with the node
  101133. */
  101134. texture: Nullable<Texture>;
  101135. /**
  101136. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101137. */
  101138. convertToGammaSpace: boolean;
  101139. /**
  101140. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101141. */
  101142. convertToLinearSpace: boolean;
  101143. /**
  101144. * Create a new TextureBlock
  101145. * @param name defines the block name
  101146. */
  101147. constructor(name: string, fragmentOnly?: boolean);
  101148. /**
  101149. * Gets the current class name
  101150. * @returns the class name
  101151. */
  101152. getClassName(): string;
  101153. /**
  101154. * Gets the uv input component
  101155. */
  101156. get uv(): NodeMaterialConnectionPoint;
  101157. /**
  101158. * Gets the rgba output component
  101159. */
  101160. get rgba(): NodeMaterialConnectionPoint;
  101161. /**
  101162. * Gets the rgb output component
  101163. */
  101164. get rgb(): NodeMaterialConnectionPoint;
  101165. /**
  101166. * Gets the r output component
  101167. */
  101168. get r(): NodeMaterialConnectionPoint;
  101169. /**
  101170. * Gets the g output component
  101171. */
  101172. get g(): NodeMaterialConnectionPoint;
  101173. /**
  101174. * Gets the b output component
  101175. */
  101176. get b(): NodeMaterialConnectionPoint;
  101177. /**
  101178. * Gets the a output component
  101179. */
  101180. get a(): NodeMaterialConnectionPoint;
  101181. get target(): NodeMaterialBlockTargets;
  101182. autoConfigure(material: NodeMaterial): void;
  101183. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101184. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101185. isReady(): boolean;
  101186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101187. private get _isMixed();
  101188. private _injectVertexCode;
  101189. private _writeTextureRead;
  101190. private _writeOutput;
  101191. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101192. protected _dumpPropertiesCode(): string;
  101193. serialize(): any;
  101194. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101195. }
  101196. }
  101197. declare module BABYLON {
  101198. /** @hidden */
  101199. export var reflectionFunction: {
  101200. name: string;
  101201. shader: string;
  101202. };
  101203. }
  101204. declare module BABYLON {
  101205. /**
  101206. * Base block used to read a reflection texture from a sampler
  101207. */
  101208. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101209. /** @hidden */
  101210. _define3DName: string;
  101211. /** @hidden */
  101212. _defineCubicName: string;
  101213. /** @hidden */
  101214. _defineExplicitName: string;
  101215. /** @hidden */
  101216. _defineProjectionName: string;
  101217. /** @hidden */
  101218. _defineLocalCubicName: string;
  101219. /** @hidden */
  101220. _defineSphericalName: string;
  101221. /** @hidden */
  101222. _definePlanarName: string;
  101223. /** @hidden */
  101224. _defineEquirectangularName: string;
  101225. /** @hidden */
  101226. _defineMirroredEquirectangularFixedName: string;
  101227. /** @hidden */
  101228. _defineEquirectangularFixedName: string;
  101229. /** @hidden */
  101230. _defineSkyboxName: string;
  101231. /** @hidden */
  101232. _defineOppositeZ: string;
  101233. /** @hidden */
  101234. _cubeSamplerName: string;
  101235. /** @hidden */
  101236. _2DSamplerName: string;
  101237. protected _positionUVWName: string;
  101238. protected _directionWName: string;
  101239. protected _reflectionVectorName: string;
  101240. /** @hidden */
  101241. _reflectionCoordsName: string;
  101242. /** @hidden */
  101243. _reflectionMatrixName: string;
  101244. protected _reflectionColorName: string;
  101245. /**
  101246. * Gets or sets the texture associated with the node
  101247. */
  101248. texture: Nullable<BaseTexture>;
  101249. /**
  101250. * Create a new ReflectionTextureBaseBlock
  101251. * @param name defines the block name
  101252. */
  101253. constructor(name: string);
  101254. /**
  101255. * Gets the current class name
  101256. * @returns the class name
  101257. */
  101258. getClassName(): string;
  101259. /**
  101260. * Gets the world position input component
  101261. */
  101262. abstract get position(): NodeMaterialConnectionPoint;
  101263. /**
  101264. * Gets the world position input component
  101265. */
  101266. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101267. /**
  101268. * Gets the world normal input component
  101269. */
  101270. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101271. /**
  101272. * Gets the world input component
  101273. */
  101274. abstract get world(): NodeMaterialConnectionPoint;
  101275. /**
  101276. * Gets the camera (or eye) position component
  101277. */
  101278. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101279. /**
  101280. * Gets the view input component
  101281. */
  101282. abstract get view(): NodeMaterialConnectionPoint;
  101283. protected _getTexture(): Nullable<BaseTexture>;
  101284. autoConfigure(material: NodeMaterial): void;
  101285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101286. isReady(): boolean;
  101287. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101288. /**
  101289. * Gets the code to inject in the vertex shader
  101290. * @param state current state of the node material building
  101291. * @returns the shader code
  101292. */
  101293. handleVertexSide(state: NodeMaterialBuildState): string;
  101294. /**
  101295. * Handles the inits for the fragment code path
  101296. * @param state node material build state
  101297. */
  101298. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101299. /**
  101300. * Generates the reflection coords code for the fragment code path
  101301. * @param worldNormalVarName name of the world normal variable
  101302. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101303. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101304. * @returns the shader code
  101305. */
  101306. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101307. /**
  101308. * Generates the reflection color code for the fragment code path
  101309. * @param lodVarName name of the lod variable
  101310. * @param swizzleLookupTexture swizzle to use for the final color variable
  101311. * @returns the shader code
  101312. */
  101313. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101314. /**
  101315. * Generates the code corresponding to the connected output points
  101316. * @param state node material build state
  101317. * @param varName name of the variable to output
  101318. * @returns the shader code
  101319. */
  101320. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101321. protected _buildBlock(state: NodeMaterialBuildState): this;
  101322. protected _dumpPropertiesCode(): string;
  101323. serialize(): any;
  101324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101325. }
  101326. }
  101327. declare module BABYLON {
  101328. /**
  101329. * Defines a connection point to be used for points with a custom object type
  101330. */
  101331. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101332. private _blockType;
  101333. private _blockName;
  101334. private _nameForCheking?;
  101335. /**
  101336. * Creates a new connection point
  101337. * @param name defines the connection point name
  101338. * @param ownerBlock defines the block hosting this connection point
  101339. * @param direction defines the direction of the connection point
  101340. */
  101341. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101342. /**
  101343. * Gets a number indicating if the current point can be connected to another point
  101344. * @param connectionPoint defines the other connection point
  101345. * @returns a number defining the compatibility state
  101346. */
  101347. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101348. /**
  101349. * Creates a block suitable to be used as an input for this input point.
  101350. * If null is returned, a block based on the point type will be created.
  101351. * @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
  101352. */
  101353. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101354. }
  101355. }
  101356. declare module BABYLON {
  101357. /**
  101358. * Enum defining the type of properties that can be edited in the property pages in the NME
  101359. */
  101360. export enum PropertyTypeForEdition {
  101361. /** property is a boolean */
  101362. Boolean = 0,
  101363. /** property is a float */
  101364. Float = 1,
  101365. /** property is a Vector2 */
  101366. Vector2 = 2,
  101367. /** property is a list of values */
  101368. List = 3
  101369. }
  101370. /**
  101371. * Interface that defines an option in a variable of type list
  101372. */
  101373. export interface IEditablePropertyListOption {
  101374. /** label of the option */
  101375. "label": string;
  101376. /** value of the option */
  101377. "value": number;
  101378. }
  101379. /**
  101380. * Interface that defines the options available for an editable property
  101381. */
  101382. export interface IEditablePropertyOption {
  101383. /** min value */
  101384. "min"?: number;
  101385. /** max value */
  101386. "max"?: number;
  101387. /** notifiers: indicates which actions to take when the property is changed */
  101388. "notifiers"?: {
  101389. /** the material should be rebuilt */
  101390. "rebuild"?: boolean;
  101391. /** the preview should be updated */
  101392. "update"?: boolean;
  101393. };
  101394. /** list of the options for a variable of type list */
  101395. "options"?: IEditablePropertyListOption[];
  101396. }
  101397. /**
  101398. * Interface that describes an editable property
  101399. */
  101400. export interface IPropertyDescriptionForEdition {
  101401. /** name of the property */
  101402. "propertyName": string;
  101403. /** display name of the property */
  101404. "displayName": string;
  101405. /** type of the property */
  101406. "type": PropertyTypeForEdition;
  101407. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101408. "groupName": string;
  101409. /** options for the property */
  101410. "options": IEditablePropertyOption;
  101411. }
  101412. /**
  101413. * Decorator that flags a property in a node material block as being editable
  101414. */
  101415. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101416. }
  101417. declare module BABYLON {
  101418. /**
  101419. * Block used to implement the refraction part of the sub surface module of the PBR material
  101420. */
  101421. export class RefractionBlock extends NodeMaterialBlock {
  101422. /** @hidden */
  101423. _define3DName: string;
  101424. /** @hidden */
  101425. _refractionMatrixName: string;
  101426. /** @hidden */
  101427. _defineLODRefractionAlpha: string;
  101428. /** @hidden */
  101429. _defineLinearSpecularRefraction: string;
  101430. /** @hidden */
  101431. _defineOppositeZ: string;
  101432. /** @hidden */
  101433. _cubeSamplerName: string;
  101434. /** @hidden */
  101435. _2DSamplerName: string;
  101436. /** @hidden */
  101437. _vRefractionMicrosurfaceInfosName: string;
  101438. /** @hidden */
  101439. _vRefractionInfosName: string;
  101440. private _scene;
  101441. /**
  101442. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101443. * Materials half opaque for instance using refraction could benefit from this control.
  101444. */
  101445. linkRefractionWithTransparency: boolean;
  101446. /**
  101447. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101448. */
  101449. invertRefractionY: boolean;
  101450. /**
  101451. * Gets or sets the texture associated with the node
  101452. */
  101453. texture: Nullable<BaseTexture>;
  101454. /**
  101455. * Create a new RefractionBlock
  101456. * @param name defines the block name
  101457. */
  101458. constructor(name: string);
  101459. /**
  101460. * Gets the current class name
  101461. * @returns the class name
  101462. */
  101463. getClassName(): string;
  101464. /**
  101465. * Gets the intensity input component
  101466. */
  101467. get intensity(): NodeMaterialConnectionPoint;
  101468. /**
  101469. * Gets the index of refraction input component
  101470. */
  101471. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101472. /**
  101473. * Gets the tint at distance input component
  101474. */
  101475. get tintAtDistance(): NodeMaterialConnectionPoint;
  101476. /**
  101477. * Gets the view input component
  101478. */
  101479. get view(): NodeMaterialConnectionPoint;
  101480. /**
  101481. * Gets the refraction object output component
  101482. */
  101483. get refraction(): NodeMaterialConnectionPoint;
  101484. /**
  101485. * Returns true if the block has a texture
  101486. */
  101487. get hasTexture(): boolean;
  101488. protected _getTexture(): Nullable<BaseTexture>;
  101489. autoConfigure(material: NodeMaterial): void;
  101490. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101491. isReady(): boolean;
  101492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101493. /**
  101494. * Gets the main code of the block (fragment side)
  101495. * @param state current state of the node material building
  101496. * @returns the shader code
  101497. */
  101498. getCode(state: NodeMaterialBuildState): string;
  101499. protected _buildBlock(state: NodeMaterialBuildState): this;
  101500. protected _dumpPropertiesCode(): string;
  101501. serialize(): any;
  101502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101503. }
  101504. }
  101505. declare module BABYLON {
  101506. /**
  101507. * Base block used as input for post process
  101508. */
  101509. export class CurrentScreenBlock extends NodeMaterialBlock {
  101510. private _samplerName;
  101511. private _linearDefineName;
  101512. private _gammaDefineName;
  101513. private _mainUVName;
  101514. private _tempTextureRead;
  101515. /**
  101516. * Gets or sets the texture associated with the node
  101517. */
  101518. texture: Nullable<BaseTexture>;
  101519. /**
  101520. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101521. */
  101522. convertToGammaSpace: boolean;
  101523. /**
  101524. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101525. */
  101526. convertToLinearSpace: boolean;
  101527. /**
  101528. * Create a new CurrentScreenBlock
  101529. * @param name defines the block name
  101530. */
  101531. constructor(name: string);
  101532. /**
  101533. * Gets the current class name
  101534. * @returns the class name
  101535. */
  101536. getClassName(): string;
  101537. /**
  101538. * Gets the uv input component
  101539. */
  101540. get uv(): NodeMaterialConnectionPoint;
  101541. /**
  101542. * Gets the rgba output component
  101543. */
  101544. get rgba(): NodeMaterialConnectionPoint;
  101545. /**
  101546. * Gets the rgb output component
  101547. */
  101548. get rgb(): NodeMaterialConnectionPoint;
  101549. /**
  101550. * Gets the r output component
  101551. */
  101552. get r(): NodeMaterialConnectionPoint;
  101553. /**
  101554. * Gets the g output component
  101555. */
  101556. get g(): NodeMaterialConnectionPoint;
  101557. /**
  101558. * Gets the b output component
  101559. */
  101560. get b(): NodeMaterialConnectionPoint;
  101561. /**
  101562. * Gets the a output component
  101563. */
  101564. get a(): NodeMaterialConnectionPoint;
  101565. /**
  101566. * Initialize the block and prepare the context for build
  101567. * @param state defines the state that will be used for the build
  101568. */
  101569. initialize(state: NodeMaterialBuildState): void;
  101570. get target(): NodeMaterialBlockTargets;
  101571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101572. isReady(): boolean;
  101573. private _injectVertexCode;
  101574. private _writeTextureRead;
  101575. private _writeOutput;
  101576. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101577. serialize(): any;
  101578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101579. }
  101580. }
  101581. declare module BABYLON {
  101582. /**
  101583. * Base block used for the particle texture
  101584. */
  101585. export class ParticleTextureBlock extends NodeMaterialBlock {
  101586. private _samplerName;
  101587. private _linearDefineName;
  101588. private _gammaDefineName;
  101589. private _tempTextureRead;
  101590. /**
  101591. * Gets or sets the texture associated with the node
  101592. */
  101593. texture: Nullable<BaseTexture>;
  101594. /**
  101595. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101596. */
  101597. convertToGammaSpace: boolean;
  101598. /**
  101599. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101600. */
  101601. convertToLinearSpace: boolean;
  101602. /**
  101603. * Create a new ParticleTextureBlock
  101604. * @param name defines the block name
  101605. */
  101606. constructor(name: string);
  101607. /**
  101608. * Gets the current class name
  101609. * @returns the class name
  101610. */
  101611. getClassName(): string;
  101612. /**
  101613. * Gets the uv input component
  101614. */
  101615. get uv(): NodeMaterialConnectionPoint;
  101616. /**
  101617. * Gets the rgba output component
  101618. */
  101619. get rgba(): NodeMaterialConnectionPoint;
  101620. /**
  101621. * Gets the rgb output component
  101622. */
  101623. get rgb(): NodeMaterialConnectionPoint;
  101624. /**
  101625. * Gets the r output component
  101626. */
  101627. get r(): NodeMaterialConnectionPoint;
  101628. /**
  101629. * Gets the g output component
  101630. */
  101631. get g(): NodeMaterialConnectionPoint;
  101632. /**
  101633. * Gets the b output component
  101634. */
  101635. get b(): NodeMaterialConnectionPoint;
  101636. /**
  101637. * Gets the a output component
  101638. */
  101639. get a(): NodeMaterialConnectionPoint;
  101640. /**
  101641. * Initialize the block and prepare the context for build
  101642. * @param state defines the state that will be used for the build
  101643. */
  101644. initialize(state: NodeMaterialBuildState): void;
  101645. autoConfigure(material: NodeMaterial): void;
  101646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101647. isReady(): boolean;
  101648. private _writeOutput;
  101649. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101650. serialize(): any;
  101651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101652. }
  101653. }
  101654. declare module BABYLON {
  101655. /**
  101656. * Class used to store shared data between 2 NodeMaterialBuildState
  101657. */
  101658. export class NodeMaterialBuildStateSharedData {
  101659. /**
  101660. * Gets the list of emitted varyings
  101661. */
  101662. temps: string[];
  101663. /**
  101664. * Gets the list of emitted varyings
  101665. */
  101666. varyings: string[];
  101667. /**
  101668. * Gets the varying declaration string
  101669. */
  101670. varyingDeclaration: string;
  101671. /**
  101672. * Input blocks
  101673. */
  101674. inputBlocks: InputBlock[];
  101675. /**
  101676. * Input blocks
  101677. */
  101678. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101679. /**
  101680. * Bindable blocks (Blocks that need to set data to the effect)
  101681. */
  101682. bindableBlocks: NodeMaterialBlock[];
  101683. /**
  101684. * List of blocks that can provide a compilation fallback
  101685. */
  101686. blocksWithFallbacks: NodeMaterialBlock[];
  101687. /**
  101688. * List of blocks that can provide a define update
  101689. */
  101690. blocksWithDefines: NodeMaterialBlock[];
  101691. /**
  101692. * List of blocks that can provide a repeatable content
  101693. */
  101694. repeatableContentBlocks: NodeMaterialBlock[];
  101695. /**
  101696. * List of blocks that can provide a dynamic list of uniforms
  101697. */
  101698. dynamicUniformBlocks: NodeMaterialBlock[];
  101699. /**
  101700. * List of blocks that can block the isReady function for the material
  101701. */
  101702. blockingBlocks: NodeMaterialBlock[];
  101703. /**
  101704. * Gets the list of animated inputs
  101705. */
  101706. animatedInputs: InputBlock[];
  101707. /**
  101708. * Build Id used to avoid multiple recompilations
  101709. */
  101710. buildId: number;
  101711. /** List of emitted variables */
  101712. variableNames: {
  101713. [key: string]: number;
  101714. };
  101715. /** List of emitted defines */
  101716. defineNames: {
  101717. [key: string]: number;
  101718. };
  101719. /** Should emit comments? */
  101720. emitComments: boolean;
  101721. /** Emit build activity */
  101722. verbose: boolean;
  101723. /** Gets or sets the hosting scene */
  101724. scene: Scene;
  101725. /**
  101726. * Gets the compilation hints emitted at compilation time
  101727. */
  101728. hints: {
  101729. needWorldViewMatrix: boolean;
  101730. needWorldViewProjectionMatrix: boolean;
  101731. needAlphaBlending: boolean;
  101732. needAlphaTesting: boolean;
  101733. };
  101734. /**
  101735. * List of compilation checks
  101736. */
  101737. checks: {
  101738. emitVertex: boolean;
  101739. emitFragment: boolean;
  101740. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101741. };
  101742. /**
  101743. * Is vertex program allowed to be empty?
  101744. */
  101745. allowEmptyVertexProgram: boolean;
  101746. /** Creates a new shared data */
  101747. constructor();
  101748. /**
  101749. * Emits console errors and exceptions if there is a failing check
  101750. */
  101751. emitErrors(): void;
  101752. }
  101753. }
  101754. declare module BABYLON {
  101755. /**
  101756. * Class used to store node based material build state
  101757. */
  101758. export class NodeMaterialBuildState {
  101759. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101760. supportUniformBuffers: boolean;
  101761. /**
  101762. * Gets the list of emitted attributes
  101763. */
  101764. attributes: string[];
  101765. /**
  101766. * Gets the list of emitted uniforms
  101767. */
  101768. uniforms: string[];
  101769. /**
  101770. * Gets the list of emitted constants
  101771. */
  101772. constants: string[];
  101773. /**
  101774. * Gets the list of emitted samplers
  101775. */
  101776. samplers: string[];
  101777. /**
  101778. * Gets the list of emitted functions
  101779. */
  101780. functions: {
  101781. [key: string]: string;
  101782. };
  101783. /**
  101784. * Gets the list of emitted extensions
  101785. */
  101786. extensions: {
  101787. [key: string]: string;
  101788. };
  101789. /**
  101790. * Gets the target of the compilation state
  101791. */
  101792. target: NodeMaterialBlockTargets;
  101793. /**
  101794. * Gets the list of emitted counters
  101795. */
  101796. counters: {
  101797. [key: string]: number;
  101798. };
  101799. /**
  101800. * Shared data between multiple NodeMaterialBuildState instances
  101801. */
  101802. sharedData: NodeMaterialBuildStateSharedData;
  101803. /** @hidden */
  101804. _vertexState: NodeMaterialBuildState;
  101805. /** @hidden */
  101806. _attributeDeclaration: string;
  101807. /** @hidden */
  101808. _uniformDeclaration: string;
  101809. /** @hidden */
  101810. _constantDeclaration: string;
  101811. /** @hidden */
  101812. _samplerDeclaration: string;
  101813. /** @hidden */
  101814. _varyingTransfer: string;
  101815. /** @hidden */
  101816. _injectAtEnd: string;
  101817. private _repeatableContentAnchorIndex;
  101818. /** @hidden */
  101819. _builtCompilationString: string;
  101820. /**
  101821. * Gets the emitted compilation strings
  101822. */
  101823. compilationString: string;
  101824. /**
  101825. * Finalize the compilation strings
  101826. * @param state defines the current compilation state
  101827. */
  101828. finalize(state: NodeMaterialBuildState): void;
  101829. /** @hidden */
  101830. get _repeatableContentAnchor(): string;
  101831. /** @hidden */
  101832. _getFreeVariableName(prefix: string): string;
  101833. /** @hidden */
  101834. _getFreeDefineName(prefix: string): string;
  101835. /** @hidden */
  101836. _excludeVariableName(name: string): void;
  101837. /** @hidden */
  101838. _emit2DSampler(name: string): void;
  101839. /** @hidden */
  101840. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101841. /** @hidden */
  101842. _emitExtension(name: string, extension: string, define?: string): void;
  101843. /** @hidden */
  101844. _emitFunction(name: string, code: string, comments: string): void;
  101845. /** @hidden */
  101846. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101847. replaceStrings?: {
  101848. search: RegExp;
  101849. replace: string;
  101850. }[];
  101851. repeatKey?: string;
  101852. }): string;
  101853. /** @hidden */
  101854. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101855. repeatKey?: string;
  101856. removeAttributes?: boolean;
  101857. removeUniforms?: boolean;
  101858. removeVaryings?: boolean;
  101859. removeIfDef?: boolean;
  101860. replaceStrings?: {
  101861. search: RegExp;
  101862. replace: string;
  101863. }[];
  101864. }, storeKey?: string): void;
  101865. /** @hidden */
  101866. _registerTempVariable(name: string): boolean;
  101867. /** @hidden */
  101868. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101869. /** @hidden */
  101870. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101871. /** @hidden */
  101872. _emitFloat(value: number): string;
  101873. }
  101874. }
  101875. declare module BABYLON {
  101876. /**
  101877. * Helper class used to generate session unique ID
  101878. */
  101879. export class UniqueIdGenerator {
  101880. private static _UniqueIdCounter;
  101881. /**
  101882. * Gets an unique (relatively to the current scene) Id
  101883. */
  101884. static get UniqueId(): number;
  101885. }
  101886. }
  101887. declare module BABYLON {
  101888. /**
  101889. * Defines a block that can be used inside a node based material
  101890. */
  101891. export class NodeMaterialBlock {
  101892. private _buildId;
  101893. private _buildTarget;
  101894. private _target;
  101895. private _isFinalMerger;
  101896. private _isInput;
  101897. private _name;
  101898. protected _isUnique: boolean;
  101899. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101900. inputsAreExclusive: boolean;
  101901. /** @hidden */
  101902. _codeVariableName: string;
  101903. /** @hidden */
  101904. _inputs: NodeMaterialConnectionPoint[];
  101905. /** @hidden */
  101906. _outputs: NodeMaterialConnectionPoint[];
  101907. /** @hidden */
  101908. _preparationId: number;
  101909. /**
  101910. * Gets the name of the block
  101911. */
  101912. get name(): string;
  101913. /**
  101914. * Sets the name of the block. Will check if the name is valid.
  101915. */
  101916. set name(newName: string);
  101917. /**
  101918. * Gets or sets the unique id of the node
  101919. */
  101920. uniqueId: number;
  101921. /**
  101922. * Gets or sets the comments associated with this block
  101923. */
  101924. comments: string;
  101925. /**
  101926. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101927. */
  101928. get isUnique(): boolean;
  101929. /**
  101930. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101931. */
  101932. get isFinalMerger(): boolean;
  101933. /**
  101934. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101935. */
  101936. get isInput(): boolean;
  101937. /**
  101938. * Gets or sets the build Id
  101939. */
  101940. get buildId(): number;
  101941. set buildId(value: number);
  101942. /**
  101943. * Gets or sets the target of the block
  101944. */
  101945. get target(): NodeMaterialBlockTargets;
  101946. set target(value: NodeMaterialBlockTargets);
  101947. /**
  101948. * Gets the list of input points
  101949. */
  101950. get inputs(): NodeMaterialConnectionPoint[];
  101951. /** Gets the list of output points */
  101952. get outputs(): NodeMaterialConnectionPoint[];
  101953. /**
  101954. * Find an input by its name
  101955. * @param name defines the name of the input to look for
  101956. * @returns the input or null if not found
  101957. */
  101958. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101959. /**
  101960. * Find an output by its name
  101961. * @param name defines the name of the outputto look for
  101962. * @returns the output or null if not found
  101963. */
  101964. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101965. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101966. visibleInInspector: boolean;
  101967. /**
  101968. * Creates a new NodeMaterialBlock
  101969. * @param name defines the block name
  101970. * @param target defines the target of that block (Vertex by default)
  101971. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101972. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101973. */
  101974. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101975. /**
  101976. * Initialize the block and prepare the context for build
  101977. * @param state defines the state that will be used for the build
  101978. */
  101979. initialize(state: NodeMaterialBuildState): void;
  101980. /**
  101981. * Bind data to effect. Will only be called for blocks with isBindable === true
  101982. * @param effect defines the effect to bind data to
  101983. * @param nodeMaterial defines the hosting NodeMaterial
  101984. * @param mesh defines the mesh that will be rendered
  101985. * @param subMesh defines the submesh that will be rendered
  101986. */
  101987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101988. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101989. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101990. protected _writeFloat(value: number): string;
  101991. /**
  101992. * Gets the current class name e.g. "NodeMaterialBlock"
  101993. * @returns the class name
  101994. */
  101995. getClassName(): string;
  101996. /**
  101997. * Register a new input. Must be called inside a block constructor
  101998. * @param name defines the connection point name
  101999. * @param type defines the connection point type
  102000. * @param isOptional defines a boolean indicating that this input can be omitted
  102001. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102002. * @param point an already created connection point. If not provided, create a new one
  102003. * @returns the current block
  102004. */
  102005. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102006. /**
  102007. * Register a new output. Must be called inside a block constructor
  102008. * @param name defines the connection point name
  102009. * @param type defines the connection point type
  102010. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102011. * @param point an already created connection point. If not provided, create a new one
  102012. * @returns the current block
  102013. */
  102014. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102015. /**
  102016. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102017. * @param forOutput defines an optional connection point to check compatibility with
  102018. * @returns the first available input or null
  102019. */
  102020. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102021. /**
  102022. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102023. * @param forBlock defines an optional block to check compatibility with
  102024. * @returns the first available input or null
  102025. */
  102026. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102027. /**
  102028. * Gets the sibling of the given output
  102029. * @param current defines the current output
  102030. * @returns the next output in the list or null
  102031. */
  102032. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102033. /**
  102034. * Connect current block with another block
  102035. * @param other defines the block to connect with
  102036. * @param options define the various options to help pick the right connections
  102037. * @returns the current block
  102038. */
  102039. connectTo(other: NodeMaterialBlock, options?: {
  102040. input?: string;
  102041. output?: string;
  102042. outputSwizzle?: string;
  102043. }): this | undefined;
  102044. protected _buildBlock(state: NodeMaterialBuildState): void;
  102045. /**
  102046. * Add uniforms, samplers and uniform buffers at compilation time
  102047. * @param state defines the state to update
  102048. * @param nodeMaterial defines the node material requesting the update
  102049. * @param defines defines the material defines to update
  102050. * @param uniformBuffers defines the list of uniform buffer names
  102051. */
  102052. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102053. /**
  102054. * Add potential fallbacks if shader compilation fails
  102055. * @param mesh defines the mesh to be rendered
  102056. * @param fallbacks defines the current prioritized list of fallbacks
  102057. */
  102058. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102059. /**
  102060. * Initialize defines for shader compilation
  102061. * @param mesh defines the mesh to be rendered
  102062. * @param nodeMaterial defines the node material requesting the update
  102063. * @param defines defines the material defines to update
  102064. * @param useInstances specifies that instances should be used
  102065. */
  102066. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102067. /**
  102068. * Update defines for shader compilation
  102069. * @param mesh defines the mesh to be rendered
  102070. * @param nodeMaterial defines the node material requesting the update
  102071. * @param defines defines the material defines to update
  102072. * @param useInstances specifies that instances should be used
  102073. * @param subMesh defines which submesh to render
  102074. */
  102075. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102076. /**
  102077. * Lets the block try to connect some inputs automatically
  102078. * @param material defines the hosting NodeMaterial
  102079. */
  102080. autoConfigure(material: NodeMaterial): void;
  102081. /**
  102082. * Function called when a block is declared as repeatable content generator
  102083. * @param vertexShaderState defines the current compilation state for the vertex shader
  102084. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102085. * @param mesh defines the mesh to be rendered
  102086. * @param defines defines the material defines to update
  102087. */
  102088. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102089. /**
  102090. * Checks if the block is ready
  102091. * @param mesh defines the mesh to be rendered
  102092. * @param nodeMaterial defines the node material requesting the update
  102093. * @param defines defines the material defines to update
  102094. * @param useInstances specifies that instances should be used
  102095. * @returns true if the block is ready
  102096. */
  102097. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102098. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102099. private _processBuild;
  102100. /**
  102101. * Validates the new name for the block node.
  102102. * @param newName the new name to be given to the node.
  102103. * @returns false if the name is a reserve word, else true.
  102104. */
  102105. validateBlockName(newName: string): boolean;
  102106. /**
  102107. * Compile the current node and generate the shader code
  102108. * @param state defines the current compilation state (uniforms, samplers, current string)
  102109. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102110. * @returns true if already built
  102111. */
  102112. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102113. protected _inputRename(name: string): string;
  102114. protected _outputRename(name: string): string;
  102115. protected _dumpPropertiesCode(): string;
  102116. /** @hidden */
  102117. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102118. /** @hidden */
  102119. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102120. /**
  102121. * Clone the current block to a new identical block
  102122. * @param scene defines the hosting scene
  102123. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102124. * @returns a copy of the current block
  102125. */
  102126. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102127. /**
  102128. * Serializes this block in a JSON representation
  102129. * @returns the serialized block object
  102130. */
  102131. serialize(): any;
  102132. /** @hidden */
  102133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102134. private _deserializePortDisplayNamesAndExposedOnFrame;
  102135. /**
  102136. * Release resources
  102137. */
  102138. dispose(): void;
  102139. }
  102140. }
  102141. declare module BABYLON {
  102142. /**
  102143. * Base class of materials working in push mode in babylon JS
  102144. * @hidden
  102145. */
  102146. export class PushMaterial extends Material {
  102147. protected _activeEffect: Effect;
  102148. protected _normalMatrix: Matrix;
  102149. constructor(name: string, scene: Scene);
  102150. getEffect(): Effect;
  102151. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102152. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102153. /**
  102154. * Binds the given world matrix to the active effect
  102155. *
  102156. * @param world the matrix to bind
  102157. */
  102158. bindOnlyWorldMatrix(world: Matrix): void;
  102159. /**
  102160. * Binds the given normal matrix to the active effect
  102161. *
  102162. * @param normalMatrix the matrix to bind
  102163. */
  102164. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102165. bind(world: Matrix, mesh?: Mesh): void;
  102166. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102167. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102168. }
  102169. }
  102170. declare module BABYLON {
  102171. /**
  102172. * Root class for all node material optimizers
  102173. */
  102174. export class NodeMaterialOptimizer {
  102175. /**
  102176. * Function used to optimize a NodeMaterial graph
  102177. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102178. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102179. */
  102180. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102181. }
  102182. }
  102183. declare module BABYLON {
  102184. /**
  102185. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102186. */
  102187. export class TransformBlock extends NodeMaterialBlock {
  102188. /**
  102189. * Defines the value to use to complement W value to transform it to a Vector4
  102190. */
  102191. complementW: number;
  102192. /**
  102193. * Defines the value to use to complement z value to transform it to a Vector4
  102194. */
  102195. complementZ: number;
  102196. /**
  102197. * Creates a new TransformBlock
  102198. * @param name defines the block name
  102199. */
  102200. constructor(name: string);
  102201. /**
  102202. * Gets the current class name
  102203. * @returns the class name
  102204. */
  102205. getClassName(): string;
  102206. /**
  102207. * Gets the vector input
  102208. */
  102209. get vector(): NodeMaterialConnectionPoint;
  102210. /**
  102211. * Gets the output component
  102212. */
  102213. get output(): NodeMaterialConnectionPoint;
  102214. /**
  102215. * Gets the xyz output component
  102216. */
  102217. get xyz(): NodeMaterialConnectionPoint;
  102218. /**
  102219. * Gets the matrix transform input
  102220. */
  102221. get transform(): NodeMaterialConnectionPoint;
  102222. protected _buildBlock(state: NodeMaterialBuildState): this;
  102223. /**
  102224. * Update defines for shader compilation
  102225. * @param mesh defines the mesh to be rendered
  102226. * @param nodeMaterial defines the node material requesting the update
  102227. * @param defines defines the material defines to update
  102228. * @param useInstances specifies that instances should be used
  102229. * @param subMesh defines which submesh to render
  102230. */
  102231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102232. serialize(): any;
  102233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102234. protected _dumpPropertiesCode(): string;
  102235. }
  102236. }
  102237. declare module BABYLON {
  102238. /**
  102239. * Block used to output the vertex position
  102240. */
  102241. export class VertexOutputBlock extends NodeMaterialBlock {
  102242. /**
  102243. * Creates a new VertexOutputBlock
  102244. * @param name defines the block name
  102245. */
  102246. constructor(name: string);
  102247. /**
  102248. * Gets the current class name
  102249. * @returns the class name
  102250. */
  102251. getClassName(): string;
  102252. /**
  102253. * Gets the vector input component
  102254. */
  102255. get vector(): NodeMaterialConnectionPoint;
  102256. protected _buildBlock(state: NodeMaterialBuildState): this;
  102257. }
  102258. }
  102259. declare module BABYLON {
  102260. /**
  102261. * Block used to output the final color
  102262. */
  102263. export class FragmentOutputBlock extends NodeMaterialBlock {
  102264. /**
  102265. * Create a new FragmentOutputBlock
  102266. * @param name defines the block name
  102267. */
  102268. constructor(name: string);
  102269. /**
  102270. * Gets the current class name
  102271. * @returns the class name
  102272. */
  102273. getClassName(): string;
  102274. /**
  102275. * Gets the rgba input component
  102276. */
  102277. get rgba(): NodeMaterialConnectionPoint;
  102278. /**
  102279. * Gets the rgb input component
  102280. */
  102281. get rgb(): NodeMaterialConnectionPoint;
  102282. /**
  102283. * Gets the a input component
  102284. */
  102285. get a(): NodeMaterialConnectionPoint;
  102286. protected _buildBlock(state: NodeMaterialBuildState): this;
  102287. }
  102288. }
  102289. declare module BABYLON {
  102290. /**
  102291. * Block used for the particle ramp gradient section
  102292. */
  102293. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102294. /**
  102295. * Create a new ParticleRampGradientBlock
  102296. * @param name defines the block name
  102297. */
  102298. constructor(name: string);
  102299. /**
  102300. * Gets the current class name
  102301. * @returns the class name
  102302. */
  102303. getClassName(): string;
  102304. /**
  102305. * Gets the color input component
  102306. */
  102307. get color(): NodeMaterialConnectionPoint;
  102308. /**
  102309. * Gets the rampColor output component
  102310. */
  102311. get rampColor(): NodeMaterialConnectionPoint;
  102312. /**
  102313. * Initialize the block and prepare the context for build
  102314. * @param state defines the state that will be used for the build
  102315. */
  102316. initialize(state: NodeMaterialBuildState): void;
  102317. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102318. }
  102319. }
  102320. declare module BABYLON {
  102321. /**
  102322. * Block used for the particle blend multiply section
  102323. */
  102324. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102325. /**
  102326. * Create a new ParticleBlendMultiplyBlock
  102327. * @param name defines the block name
  102328. */
  102329. constructor(name: string);
  102330. /**
  102331. * Gets the current class name
  102332. * @returns the class name
  102333. */
  102334. getClassName(): string;
  102335. /**
  102336. * Gets the color input component
  102337. */
  102338. get color(): NodeMaterialConnectionPoint;
  102339. /**
  102340. * Gets the alphaTexture input component
  102341. */
  102342. get alphaTexture(): NodeMaterialConnectionPoint;
  102343. /**
  102344. * Gets the alphaColor input component
  102345. */
  102346. get alphaColor(): NodeMaterialConnectionPoint;
  102347. /**
  102348. * Gets the blendColor output component
  102349. */
  102350. get blendColor(): NodeMaterialConnectionPoint;
  102351. /**
  102352. * Initialize the block and prepare the context for build
  102353. * @param state defines the state that will be used for the build
  102354. */
  102355. initialize(state: NodeMaterialBuildState): void;
  102356. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102357. }
  102358. }
  102359. declare module BABYLON {
  102360. /**
  102361. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102362. */
  102363. export class VectorMergerBlock extends NodeMaterialBlock {
  102364. /**
  102365. * Create a new VectorMergerBlock
  102366. * @param name defines the block name
  102367. */
  102368. constructor(name: string);
  102369. /**
  102370. * Gets the current class name
  102371. * @returns the class name
  102372. */
  102373. getClassName(): string;
  102374. /**
  102375. * Gets the xyz component (input)
  102376. */
  102377. get xyzIn(): NodeMaterialConnectionPoint;
  102378. /**
  102379. * Gets the xy component (input)
  102380. */
  102381. get xyIn(): NodeMaterialConnectionPoint;
  102382. /**
  102383. * Gets the x component (input)
  102384. */
  102385. get x(): NodeMaterialConnectionPoint;
  102386. /**
  102387. * Gets the y component (input)
  102388. */
  102389. get y(): NodeMaterialConnectionPoint;
  102390. /**
  102391. * Gets the z component (input)
  102392. */
  102393. get z(): NodeMaterialConnectionPoint;
  102394. /**
  102395. * Gets the w component (input)
  102396. */
  102397. get w(): NodeMaterialConnectionPoint;
  102398. /**
  102399. * Gets the xyzw component (output)
  102400. */
  102401. get xyzw(): NodeMaterialConnectionPoint;
  102402. /**
  102403. * Gets the xyz component (output)
  102404. */
  102405. get xyzOut(): NodeMaterialConnectionPoint;
  102406. /**
  102407. * Gets the xy component (output)
  102408. */
  102409. get xyOut(): NodeMaterialConnectionPoint;
  102410. /**
  102411. * Gets the xy component (output)
  102412. * @deprecated Please use xyOut instead.
  102413. */
  102414. get xy(): NodeMaterialConnectionPoint;
  102415. /**
  102416. * Gets the xyz component (output)
  102417. * @deprecated Please use xyzOut instead.
  102418. */
  102419. get xyz(): NodeMaterialConnectionPoint;
  102420. protected _buildBlock(state: NodeMaterialBuildState): this;
  102421. }
  102422. }
  102423. declare module BABYLON {
  102424. /**
  102425. * Block used to remap a float from a range to a new one
  102426. */
  102427. export class RemapBlock extends NodeMaterialBlock {
  102428. /**
  102429. * Gets or sets the source range
  102430. */
  102431. sourceRange: Vector2;
  102432. /**
  102433. * Gets or sets the target range
  102434. */
  102435. targetRange: Vector2;
  102436. /**
  102437. * Creates a new RemapBlock
  102438. * @param name defines the block name
  102439. */
  102440. constructor(name: string);
  102441. /**
  102442. * Gets the current class name
  102443. * @returns the class name
  102444. */
  102445. getClassName(): string;
  102446. /**
  102447. * Gets the input component
  102448. */
  102449. get input(): NodeMaterialConnectionPoint;
  102450. /**
  102451. * Gets the source min input component
  102452. */
  102453. get sourceMin(): NodeMaterialConnectionPoint;
  102454. /**
  102455. * Gets the source max input component
  102456. */
  102457. get sourceMax(): NodeMaterialConnectionPoint;
  102458. /**
  102459. * Gets the target min input component
  102460. */
  102461. get targetMin(): NodeMaterialConnectionPoint;
  102462. /**
  102463. * Gets the target max input component
  102464. */
  102465. get targetMax(): NodeMaterialConnectionPoint;
  102466. /**
  102467. * Gets the output component
  102468. */
  102469. get output(): NodeMaterialConnectionPoint;
  102470. protected _buildBlock(state: NodeMaterialBuildState): this;
  102471. protected _dumpPropertiesCode(): string;
  102472. serialize(): any;
  102473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102474. }
  102475. }
  102476. declare module BABYLON {
  102477. /**
  102478. * Block used to multiply 2 values
  102479. */
  102480. export class MultiplyBlock extends NodeMaterialBlock {
  102481. /**
  102482. * Creates a new MultiplyBlock
  102483. * @param name defines the block name
  102484. */
  102485. constructor(name: string);
  102486. /**
  102487. * Gets the current class name
  102488. * @returns the class name
  102489. */
  102490. getClassName(): string;
  102491. /**
  102492. * Gets the left operand input component
  102493. */
  102494. get left(): NodeMaterialConnectionPoint;
  102495. /**
  102496. * Gets the right operand input component
  102497. */
  102498. get right(): NodeMaterialConnectionPoint;
  102499. /**
  102500. * Gets the output component
  102501. */
  102502. get output(): NodeMaterialConnectionPoint;
  102503. protected _buildBlock(state: NodeMaterialBuildState): this;
  102504. }
  102505. }
  102506. declare module BABYLON {
  102507. /**
  102508. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102509. */
  102510. export class ColorSplitterBlock extends NodeMaterialBlock {
  102511. /**
  102512. * Create a new ColorSplitterBlock
  102513. * @param name defines the block name
  102514. */
  102515. constructor(name: string);
  102516. /**
  102517. * Gets the current class name
  102518. * @returns the class name
  102519. */
  102520. getClassName(): string;
  102521. /**
  102522. * Gets the rgba component (input)
  102523. */
  102524. get rgba(): NodeMaterialConnectionPoint;
  102525. /**
  102526. * Gets the rgb component (input)
  102527. */
  102528. get rgbIn(): NodeMaterialConnectionPoint;
  102529. /**
  102530. * Gets the rgb component (output)
  102531. */
  102532. get rgbOut(): NodeMaterialConnectionPoint;
  102533. /**
  102534. * Gets the r component (output)
  102535. */
  102536. get r(): NodeMaterialConnectionPoint;
  102537. /**
  102538. * Gets the g component (output)
  102539. */
  102540. get g(): NodeMaterialConnectionPoint;
  102541. /**
  102542. * Gets the b component (output)
  102543. */
  102544. get b(): NodeMaterialConnectionPoint;
  102545. /**
  102546. * Gets the a component (output)
  102547. */
  102548. get a(): NodeMaterialConnectionPoint;
  102549. protected _inputRename(name: string): string;
  102550. protected _outputRename(name: string): string;
  102551. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102552. }
  102553. }
  102554. declare module BABYLON {
  102555. /**
  102556. * Operations supported by the Trigonometry block
  102557. */
  102558. export enum TrigonometryBlockOperations {
  102559. /** Cos */
  102560. Cos = 0,
  102561. /** Sin */
  102562. Sin = 1,
  102563. /** Abs */
  102564. Abs = 2,
  102565. /** Exp */
  102566. Exp = 3,
  102567. /** Exp2 */
  102568. Exp2 = 4,
  102569. /** Round */
  102570. Round = 5,
  102571. /** Floor */
  102572. Floor = 6,
  102573. /** Ceiling */
  102574. Ceiling = 7,
  102575. /** Square root */
  102576. Sqrt = 8,
  102577. /** Log */
  102578. Log = 9,
  102579. /** Tangent */
  102580. Tan = 10,
  102581. /** Arc tangent */
  102582. ArcTan = 11,
  102583. /** Arc cosinus */
  102584. ArcCos = 12,
  102585. /** Arc sinus */
  102586. ArcSin = 13,
  102587. /** Fraction */
  102588. Fract = 14,
  102589. /** Sign */
  102590. Sign = 15,
  102591. /** To radians (from degrees) */
  102592. Radians = 16,
  102593. /** To degrees (from radians) */
  102594. Degrees = 17
  102595. }
  102596. /**
  102597. * Block used to apply trigonometry operation to floats
  102598. */
  102599. export class TrigonometryBlock extends NodeMaterialBlock {
  102600. /**
  102601. * Gets or sets the operation applied by the block
  102602. */
  102603. operation: TrigonometryBlockOperations;
  102604. /**
  102605. * Creates a new TrigonometryBlock
  102606. * @param name defines the block name
  102607. */
  102608. constructor(name: string);
  102609. /**
  102610. * Gets the current class name
  102611. * @returns the class name
  102612. */
  102613. getClassName(): string;
  102614. /**
  102615. * Gets the input component
  102616. */
  102617. get input(): NodeMaterialConnectionPoint;
  102618. /**
  102619. * Gets the output component
  102620. */
  102621. get output(): NodeMaterialConnectionPoint;
  102622. protected _buildBlock(state: NodeMaterialBuildState): this;
  102623. serialize(): any;
  102624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102625. protected _dumpPropertiesCode(): string;
  102626. }
  102627. }
  102628. declare module BABYLON {
  102629. /**
  102630. * Interface used to configure the node material editor
  102631. */
  102632. export interface INodeMaterialEditorOptions {
  102633. /** Define the URl to load node editor script */
  102634. editorURL?: string;
  102635. }
  102636. /** @hidden */
  102637. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102638. NORMAL: boolean;
  102639. TANGENT: boolean;
  102640. UV1: boolean;
  102641. /** BONES */
  102642. NUM_BONE_INFLUENCERS: number;
  102643. BonesPerMesh: number;
  102644. BONETEXTURE: boolean;
  102645. /** MORPH TARGETS */
  102646. MORPHTARGETS: boolean;
  102647. MORPHTARGETS_NORMAL: boolean;
  102648. MORPHTARGETS_TANGENT: boolean;
  102649. MORPHTARGETS_UV: boolean;
  102650. NUM_MORPH_INFLUENCERS: number;
  102651. /** IMAGE PROCESSING */
  102652. IMAGEPROCESSING: boolean;
  102653. VIGNETTE: boolean;
  102654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102655. VIGNETTEBLENDMODEOPAQUE: boolean;
  102656. TONEMAPPING: boolean;
  102657. TONEMAPPING_ACES: boolean;
  102658. CONTRAST: boolean;
  102659. EXPOSURE: boolean;
  102660. COLORCURVES: boolean;
  102661. COLORGRADING: boolean;
  102662. COLORGRADING3D: boolean;
  102663. SAMPLER3DGREENDEPTH: boolean;
  102664. SAMPLER3DBGRMAP: boolean;
  102665. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102666. /** MISC. */
  102667. BUMPDIRECTUV: number;
  102668. constructor();
  102669. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102670. }
  102671. /**
  102672. * Class used to configure NodeMaterial
  102673. */
  102674. export interface INodeMaterialOptions {
  102675. /**
  102676. * Defines if blocks should emit comments
  102677. */
  102678. emitComments: boolean;
  102679. }
  102680. /**
  102681. * Class used to create a node based material built by assembling shader blocks
  102682. */
  102683. export class NodeMaterial extends PushMaterial {
  102684. private static _BuildIdGenerator;
  102685. private _options;
  102686. private _vertexCompilationState;
  102687. private _fragmentCompilationState;
  102688. private _sharedData;
  102689. private _buildId;
  102690. private _buildWasSuccessful;
  102691. private _cachedWorldViewMatrix;
  102692. private _cachedWorldViewProjectionMatrix;
  102693. private _optimizers;
  102694. private _animationFrame;
  102695. /** Define the Url to load node editor script */
  102696. static EditorURL: string;
  102697. /** Define the Url to load snippets */
  102698. static SnippetUrl: string;
  102699. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102700. static IgnoreTexturesAtLoadTime: boolean;
  102701. private BJSNODEMATERIALEDITOR;
  102702. /** Get the inspector from bundle or global */
  102703. private _getGlobalNodeMaterialEditor;
  102704. /**
  102705. * Snippet ID if the material was created from the snippet server
  102706. */
  102707. snippetId: string;
  102708. /**
  102709. * Gets or sets data used by visual editor
  102710. * @see https://nme.babylonjs.com
  102711. */
  102712. editorData: any;
  102713. /**
  102714. * 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)
  102715. */
  102716. ignoreAlpha: boolean;
  102717. /**
  102718. * Defines the maximum number of lights that can be used in the material
  102719. */
  102720. maxSimultaneousLights: number;
  102721. /**
  102722. * Observable raised when the material is built
  102723. */
  102724. onBuildObservable: Observable<NodeMaterial>;
  102725. /**
  102726. * Gets or sets the root nodes of the material vertex shader
  102727. */
  102728. _vertexOutputNodes: NodeMaterialBlock[];
  102729. /**
  102730. * Gets or sets the root nodes of the material fragment (pixel) shader
  102731. */
  102732. _fragmentOutputNodes: NodeMaterialBlock[];
  102733. /** Gets or sets options to control the node material overall behavior */
  102734. get options(): INodeMaterialOptions;
  102735. set options(options: INodeMaterialOptions);
  102736. /**
  102737. * Default configuration related to image processing available in the standard Material.
  102738. */
  102739. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102740. /**
  102741. * Gets the image processing configuration used either in this material.
  102742. */
  102743. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102744. /**
  102745. * Sets the Default image processing configuration used either in the this material.
  102746. *
  102747. * If sets to null, the scene one is in use.
  102748. */
  102749. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102750. /**
  102751. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102752. */
  102753. attachedBlocks: NodeMaterialBlock[];
  102754. /**
  102755. * Specifies the mode of the node material
  102756. * @hidden
  102757. */
  102758. _mode: NodeMaterialModes;
  102759. /**
  102760. * Gets the mode property
  102761. */
  102762. get mode(): NodeMaterialModes;
  102763. /**
  102764. * Create a new node based material
  102765. * @param name defines the material name
  102766. * @param scene defines the hosting scene
  102767. * @param options defines creation option
  102768. */
  102769. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102770. /**
  102771. * Gets the current class name of the material e.g. "NodeMaterial"
  102772. * @returns the class name
  102773. */
  102774. getClassName(): string;
  102775. /**
  102776. * Keep track of the image processing observer to allow dispose and replace.
  102777. */
  102778. private _imageProcessingObserver;
  102779. /**
  102780. * Attaches a new image processing configuration to the Standard Material.
  102781. * @param configuration
  102782. */
  102783. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102784. /**
  102785. * Get a block by its name
  102786. * @param name defines the name of the block to retrieve
  102787. * @returns the required block or null if not found
  102788. */
  102789. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102790. /**
  102791. * Get a block by its name
  102792. * @param predicate defines the predicate used to find the good candidate
  102793. * @returns the required block or null if not found
  102794. */
  102795. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102796. /**
  102797. * Get an input block by its name
  102798. * @param predicate defines the predicate used to find the good candidate
  102799. * @returns the required input block or null if not found
  102800. */
  102801. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102802. /**
  102803. * Gets the list of input blocks attached to this material
  102804. * @returns an array of InputBlocks
  102805. */
  102806. getInputBlocks(): InputBlock[];
  102807. /**
  102808. * Adds a new optimizer to the list of optimizers
  102809. * @param optimizer defines the optimizers to add
  102810. * @returns the current material
  102811. */
  102812. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102813. /**
  102814. * Remove an optimizer from the list of optimizers
  102815. * @param optimizer defines the optimizers to remove
  102816. * @returns the current material
  102817. */
  102818. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102819. /**
  102820. * Add a new block to the list of output nodes
  102821. * @param node defines the node to add
  102822. * @returns the current material
  102823. */
  102824. addOutputNode(node: NodeMaterialBlock): this;
  102825. /**
  102826. * Remove a block from the list of root nodes
  102827. * @param node defines the node to remove
  102828. * @returns the current material
  102829. */
  102830. removeOutputNode(node: NodeMaterialBlock): this;
  102831. private _addVertexOutputNode;
  102832. private _removeVertexOutputNode;
  102833. private _addFragmentOutputNode;
  102834. private _removeFragmentOutputNode;
  102835. /**
  102836. * Specifies if the material will require alpha blending
  102837. * @returns a boolean specifying if alpha blending is needed
  102838. */
  102839. needAlphaBlending(): boolean;
  102840. /**
  102841. * Specifies if this material should be rendered in alpha test mode
  102842. * @returns a boolean specifying if an alpha test is needed.
  102843. */
  102844. needAlphaTesting(): boolean;
  102845. private _initializeBlock;
  102846. private _resetDualBlocks;
  102847. /**
  102848. * Remove a block from the current node material
  102849. * @param block defines the block to remove
  102850. */
  102851. removeBlock(block: NodeMaterialBlock): void;
  102852. /**
  102853. * Build the material and generates the inner effect
  102854. * @param verbose defines if the build should log activity
  102855. */
  102856. build(verbose?: boolean): void;
  102857. /**
  102858. * Runs an otpimization phase to try to improve the shader code
  102859. */
  102860. optimize(): void;
  102861. private _prepareDefinesForAttributes;
  102862. /**
  102863. * Create a post process from the material
  102864. * @param camera The camera to apply the render pass to.
  102865. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102867. * @param engine The engine which the post process will be applied. (default: current engine)
  102868. * @param reusable If the post process can be reused on the same frame. (default: false)
  102869. * @param textureType Type of textures used when performing the post process. (default: 0)
  102870. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102871. * @returns the post process created
  102872. */
  102873. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102874. /**
  102875. * Create the post process effect from the material
  102876. * @param postProcess The post process to create the effect for
  102877. */
  102878. createEffectForPostProcess(postProcess: PostProcess): void;
  102879. private _createEffectForPostProcess;
  102880. /**
  102881. * Create a new procedural texture based on this node material
  102882. * @param size defines the size of the texture
  102883. * @param scene defines the hosting scene
  102884. * @returns the new procedural texture attached to this node material
  102885. */
  102886. createProceduralTexture(size: number | {
  102887. width: number;
  102888. height: number;
  102889. layers?: number;
  102890. }, scene: Scene): Nullable<ProceduralTexture>;
  102891. private _createEffectForParticles;
  102892. private _checkInternals;
  102893. /**
  102894. * Create the effect to be used as the custom effect for a particle system
  102895. * @param particleSystem Particle system to create the effect for
  102896. * @param onCompiled defines a function to call when the effect creation is successful
  102897. * @param onError defines a function to call when the effect creation has failed
  102898. */
  102899. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102900. private _processDefines;
  102901. /**
  102902. * Get if the submesh is ready to be used and all its information available.
  102903. * Child classes can use it to update shaders
  102904. * @param mesh defines the mesh to check
  102905. * @param subMesh defines which submesh to check
  102906. * @param useInstances specifies that instances should be used
  102907. * @returns a boolean indicating that the submesh is ready or not
  102908. */
  102909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102910. /**
  102911. * Get a string representing the shaders built by the current node graph
  102912. */
  102913. get compiledShaders(): string;
  102914. /**
  102915. * Binds the world matrix to the material
  102916. * @param world defines the world transformation matrix
  102917. */
  102918. bindOnlyWorldMatrix(world: Matrix): void;
  102919. /**
  102920. * Binds the submesh to this material by preparing the effect and shader to draw
  102921. * @param world defines the world transformation matrix
  102922. * @param mesh defines the mesh containing the submesh
  102923. * @param subMesh defines the submesh to bind the material to
  102924. */
  102925. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102926. /**
  102927. * Gets the active textures from the material
  102928. * @returns an array of textures
  102929. */
  102930. getActiveTextures(): BaseTexture[];
  102931. /**
  102932. * Gets the list of texture blocks
  102933. * @returns an array of texture blocks
  102934. */
  102935. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102936. /**
  102937. * Specifies if the material uses a texture
  102938. * @param texture defines the texture to check against the material
  102939. * @returns a boolean specifying if the material uses the texture
  102940. */
  102941. hasTexture(texture: BaseTexture): boolean;
  102942. /**
  102943. * Disposes the material
  102944. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102945. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102946. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102947. */
  102948. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102949. /** Creates the node editor window. */
  102950. private _createNodeEditor;
  102951. /**
  102952. * Launch the node material editor
  102953. * @param config Define the configuration of the editor
  102954. * @return a promise fulfilled when the node editor is visible
  102955. */
  102956. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102957. /**
  102958. * Clear the current material
  102959. */
  102960. clear(): void;
  102961. /**
  102962. * Clear the current material and set it to a default state
  102963. */
  102964. setToDefault(): void;
  102965. /**
  102966. * Clear the current material and set it to a default state for post process
  102967. */
  102968. setToDefaultPostProcess(): void;
  102969. /**
  102970. * Clear the current material and set it to a default state for procedural texture
  102971. */
  102972. setToDefaultProceduralTexture(): void;
  102973. /**
  102974. * Clear the current material and set it to a default state for particle
  102975. */
  102976. setToDefaultParticle(): void;
  102977. /**
  102978. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102979. * @param url defines the url to load from
  102980. * @returns a promise that will fullfil when the material is fully loaded
  102981. */
  102982. loadAsync(url: string): Promise<void>;
  102983. private _gatherBlocks;
  102984. /**
  102985. * Generate a string containing the code declaration required to create an equivalent of this material
  102986. * @returns a string
  102987. */
  102988. generateCode(): string;
  102989. /**
  102990. * Serializes this material in a JSON representation
  102991. * @returns the serialized material object
  102992. */
  102993. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102994. private _restoreConnections;
  102995. /**
  102996. * Clear the current graph and load a new one from a serialization object
  102997. * @param source defines the JSON representation of the material
  102998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102999. * @param merge defines whether or not the source must be merged or replace the current content
  103000. */
  103001. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103002. /**
  103003. * Makes a duplicate of the current material.
  103004. * @param name - name to use for the new material.
  103005. */
  103006. clone(name: string): NodeMaterial;
  103007. /**
  103008. * Creates a node material from parsed material data
  103009. * @param source defines the JSON representation of the material
  103010. * @param scene defines the hosting scene
  103011. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103012. * @returns a new node material
  103013. */
  103014. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103015. /**
  103016. * Creates a node material from a snippet saved in a remote file
  103017. * @param name defines the name of the material to create
  103018. * @param url defines the url to load from
  103019. * @param scene defines the hosting scene
  103020. * @returns a promise that will resolve to the new node material
  103021. */
  103022. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103023. /**
  103024. * Creates a node material from a snippet saved by the node material editor
  103025. * @param snippetId defines the snippet to load
  103026. * @param scene defines the hosting scene
  103027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103028. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103029. * @returns a promise that will resolve to the new node material
  103030. */
  103031. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103032. /**
  103033. * Creates a new node material set to default basic configuration
  103034. * @param name defines the name of the material
  103035. * @param scene defines the hosting scene
  103036. * @returns a new NodeMaterial
  103037. */
  103038. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103039. }
  103040. }
  103041. declare module BABYLON {
  103042. /**
  103043. * Size options for a post process
  103044. */
  103045. export type PostProcessOptions = {
  103046. width: number;
  103047. height: number;
  103048. };
  103049. /**
  103050. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103051. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103052. */
  103053. export class PostProcess {
  103054. /**
  103055. * Gets or sets the unique id of the post process
  103056. */
  103057. uniqueId: number;
  103058. /** Name of the PostProcess. */
  103059. name: string;
  103060. /**
  103061. * Width of the texture to apply the post process on
  103062. */
  103063. width: number;
  103064. /**
  103065. * Height of the texture to apply the post process on
  103066. */
  103067. height: number;
  103068. /**
  103069. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103070. */
  103071. nodeMaterialSource: Nullable<NodeMaterial>;
  103072. /**
  103073. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103074. * @hidden
  103075. */
  103076. _outputTexture: Nullable<InternalTexture>;
  103077. /**
  103078. * Sampling mode used by the shader
  103079. * See https://doc.babylonjs.com/classes/3.1/texture
  103080. */
  103081. renderTargetSamplingMode: number;
  103082. /**
  103083. * Clear color to use when screen clearing
  103084. */
  103085. clearColor: Color4;
  103086. /**
  103087. * If the buffer needs to be cleared before applying the post process. (default: true)
  103088. * Should be set to false if shader will overwrite all previous pixels.
  103089. */
  103090. autoClear: boolean;
  103091. /**
  103092. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103093. */
  103094. alphaMode: number;
  103095. /**
  103096. * Sets the setAlphaBlendConstants of the babylon engine
  103097. */
  103098. alphaConstants: Color4;
  103099. /**
  103100. * Animations to be used for the post processing
  103101. */
  103102. animations: Animation[];
  103103. /**
  103104. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103105. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103106. */
  103107. enablePixelPerfectMode: boolean;
  103108. /**
  103109. * Force the postprocess to be applied without taking in account viewport
  103110. */
  103111. forceFullscreenViewport: boolean;
  103112. /**
  103113. * List of inspectable custom properties (used by the Inspector)
  103114. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103115. */
  103116. inspectableCustomProperties: IInspectable[];
  103117. /**
  103118. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103119. *
  103120. * | Value | Type | Description |
  103121. * | ----- | ----------------------------------- | ----------- |
  103122. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103123. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103124. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103125. *
  103126. */
  103127. scaleMode: number;
  103128. /**
  103129. * Force textures to be a power of two (default: false)
  103130. */
  103131. alwaysForcePOT: boolean;
  103132. private _samples;
  103133. /**
  103134. * Number of sample textures (default: 1)
  103135. */
  103136. get samples(): number;
  103137. set samples(n: number);
  103138. /**
  103139. * Modify the scale of the post process to be the same as the viewport (default: false)
  103140. */
  103141. adaptScaleToCurrentViewport: boolean;
  103142. private _camera;
  103143. protected _scene: Scene;
  103144. private _engine;
  103145. private _options;
  103146. private _reusable;
  103147. private _textureType;
  103148. private _textureFormat;
  103149. /**
  103150. * Smart array of input and output textures for the post process.
  103151. * @hidden
  103152. */
  103153. _textures: SmartArray<InternalTexture>;
  103154. /**
  103155. * The index in _textures that corresponds to the output texture.
  103156. * @hidden
  103157. */
  103158. _currentRenderTextureInd: number;
  103159. private _effect;
  103160. private _samplers;
  103161. private _fragmentUrl;
  103162. private _vertexUrl;
  103163. private _parameters;
  103164. private _scaleRatio;
  103165. protected _indexParameters: any;
  103166. private _shareOutputWithPostProcess;
  103167. private _texelSize;
  103168. private _forcedOutputTexture;
  103169. /**
  103170. * Returns the fragment url or shader name used in the post process.
  103171. * @returns the fragment url or name in the shader store.
  103172. */
  103173. getEffectName(): string;
  103174. /**
  103175. * An event triggered when the postprocess is activated.
  103176. */
  103177. onActivateObservable: Observable<Camera>;
  103178. private _onActivateObserver;
  103179. /**
  103180. * A function that is added to the onActivateObservable
  103181. */
  103182. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103183. /**
  103184. * An event triggered when the postprocess changes its size.
  103185. */
  103186. onSizeChangedObservable: Observable<PostProcess>;
  103187. private _onSizeChangedObserver;
  103188. /**
  103189. * A function that is added to the onSizeChangedObservable
  103190. */
  103191. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103192. /**
  103193. * An event triggered when the postprocess applies its effect.
  103194. */
  103195. onApplyObservable: Observable<Effect>;
  103196. private _onApplyObserver;
  103197. /**
  103198. * A function that is added to the onApplyObservable
  103199. */
  103200. set onApply(callback: (effect: Effect) => void);
  103201. /**
  103202. * An event triggered before rendering the postprocess
  103203. */
  103204. onBeforeRenderObservable: Observable<Effect>;
  103205. private _onBeforeRenderObserver;
  103206. /**
  103207. * A function that is added to the onBeforeRenderObservable
  103208. */
  103209. set onBeforeRender(callback: (effect: Effect) => void);
  103210. /**
  103211. * An event triggered after rendering the postprocess
  103212. */
  103213. onAfterRenderObservable: Observable<Effect>;
  103214. private _onAfterRenderObserver;
  103215. /**
  103216. * A function that is added to the onAfterRenderObservable
  103217. */
  103218. set onAfterRender(callback: (efect: Effect) => void);
  103219. /**
  103220. * 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
  103221. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103222. */
  103223. get inputTexture(): InternalTexture;
  103224. set inputTexture(value: InternalTexture);
  103225. /**
  103226. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103227. * the only way to unset it is to use this function to restore its internal state
  103228. */
  103229. restoreDefaultInputTexture(): void;
  103230. /**
  103231. * Gets the camera which post process is applied to.
  103232. * @returns The camera the post process is applied to.
  103233. */
  103234. getCamera(): Camera;
  103235. /**
  103236. * Gets the texel size of the postprocess.
  103237. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103238. */
  103239. get texelSize(): Vector2;
  103240. /**
  103241. * Creates a new instance PostProcess
  103242. * @param name The name of the PostProcess.
  103243. * @param fragmentUrl The url of the fragment shader to be used.
  103244. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103245. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103246. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103247. * @param camera The camera to apply the render pass to.
  103248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103249. * @param engine The engine which the post process will be applied. (default: current engine)
  103250. * @param reusable If the post process can be reused on the same frame. (default: false)
  103251. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103252. * @param textureType Type of textures used when performing the post process. (default: 0)
  103253. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103254. * @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
  103255. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103256. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103257. */
  103258. 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);
  103259. /**
  103260. * Gets a string identifying the name of the class
  103261. * @returns "PostProcess" string
  103262. */
  103263. getClassName(): string;
  103264. /**
  103265. * Gets the engine which this post process belongs to.
  103266. * @returns The engine the post process was enabled with.
  103267. */
  103268. getEngine(): Engine;
  103269. /**
  103270. * The effect that is created when initializing the post process.
  103271. * @returns The created effect corresponding the the postprocess.
  103272. */
  103273. getEffect(): Effect;
  103274. /**
  103275. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103276. * @param postProcess The post process to share the output with.
  103277. * @returns This post process.
  103278. */
  103279. shareOutputWith(postProcess: PostProcess): PostProcess;
  103280. /**
  103281. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103282. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103283. */
  103284. useOwnOutput(): void;
  103285. /**
  103286. * Updates the effect with the current post process compile time values and recompiles the shader.
  103287. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103288. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103289. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103290. * @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
  103291. * @param onCompiled Called when the shader has been compiled.
  103292. * @param onError Called if there is an error when compiling a shader.
  103293. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103294. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103295. */
  103296. 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;
  103297. /**
  103298. * The post process is reusable if it can be used multiple times within one frame.
  103299. * @returns If the post process is reusable
  103300. */
  103301. isReusable(): boolean;
  103302. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103303. markTextureDirty(): void;
  103304. /**
  103305. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103306. * 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.
  103307. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103308. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103309. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103310. * @returns The target texture that was bound to be written to.
  103311. */
  103312. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103313. /**
  103314. * If the post process is supported.
  103315. */
  103316. get isSupported(): boolean;
  103317. /**
  103318. * The aspect ratio of the output texture.
  103319. */
  103320. get aspectRatio(): number;
  103321. /**
  103322. * Get a value indicating if the post-process is ready to be used
  103323. * @returns true if the post-process is ready (shader is compiled)
  103324. */
  103325. isReady(): boolean;
  103326. /**
  103327. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103328. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103329. */
  103330. apply(): Nullable<Effect>;
  103331. private _disposeTextures;
  103332. /**
  103333. * Disposes the post process.
  103334. * @param camera The camera to dispose the post process on.
  103335. */
  103336. dispose(camera?: Camera): void;
  103337. /**
  103338. * Serializes the particle system to a JSON object
  103339. * @returns the JSON object
  103340. */
  103341. serialize(): any;
  103342. /**
  103343. * Creates a material from parsed material data
  103344. * @param parsedPostProcess defines parsed post process data
  103345. * @param scene defines the hosting scene
  103346. * @param rootUrl defines the root URL to use to load textures
  103347. * @returns a new post process
  103348. */
  103349. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  103350. }
  103351. }
  103352. declare module BABYLON {
  103353. /** @hidden */
  103354. export var kernelBlurVaryingDeclaration: {
  103355. name: string;
  103356. shader: string;
  103357. };
  103358. }
  103359. declare module BABYLON {
  103360. /** @hidden */
  103361. export var kernelBlurFragment: {
  103362. name: string;
  103363. shader: string;
  103364. };
  103365. }
  103366. declare module BABYLON {
  103367. /** @hidden */
  103368. export var kernelBlurFragment2: {
  103369. name: string;
  103370. shader: string;
  103371. };
  103372. }
  103373. declare module BABYLON {
  103374. /** @hidden */
  103375. export var kernelBlurPixelShader: {
  103376. name: string;
  103377. shader: string;
  103378. };
  103379. }
  103380. declare module BABYLON {
  103381. /** @hidden */
  103382. export var kernelBlurVertex: {
  103383. name: string;
  103384. shader: string;
  103385. };
  103386. }
  103387. declare module BABYLON {
  103388. /** @hidden */
  103389. export var kernelBlurVertexShader: {
  103390. name: string;
  103391. shader: string;
  103392. };
  103393. }
  103394. declare module BABYLON {
  103395. /**
  103396. * The Blur Post Process which blurs an image based on a kernel and direction.
  103397. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  103398. */
  103399. export class BlurPostProcess extends PostProcess {
  103400. private blockCompilation;
  103401. protected _kernel: number;
  103402. protected _idealKernel: number;
  103403. protected _packedFloat: boolean;
  103404. private _staticDefines;
  103405. /** The direction in which to blur the image. */
  103406. direction: Vector2;
  103407. /**
  103408. * Sets the length in pixels of the blur sample region
  103409. */
  103410. set kernel(v: number);
  103411. /**
  103412. * Gets the length in pixels of the blur sample region
  103413. */
  103414. get kernel(): number;
  103415. /**
  103416. * Sets wether or not the blur needs to unpack/repack floats
  103417. */
  103418. set packedFloat(v: boolean);
  103419. /**
  103420. * Gets wether or not the blur is unpacking/repacking floats
  103421. */
  103422. get packedFloat(): boolean;
  103423. /**
  103424. * Gets a string identifying the name of the class
  103425. * @returns "BlurPostProcess" string
  103426. */
  103427. getClassName(): string;
  103428. /**
  103429. * Creates a new instance BlurPostProcess
  103430. * @param name The name of the effect.
  103431. * @param direction The direction in which to blur the image.
  103432. * @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.
  103433. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103434. * @param camera The camera to apply the render pass to.
  103435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103436. * @param engine The engine which the post process will be applied. (default: current engine)
  103437. * @param reusable If the post process can be reused on the same frame. (default: false)
  103438. * @param textureType Type of textures used when performing the post process. (default: 0)
  103439. * @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)
  103440. */
  103441. 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);
  103442. /**
  103443. * Updates the effect with the current post process compile time values and recompiles the shader.
  103444. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103445. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103446. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103447. * @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
  103448. * @param onCompiled Called when the shader has been compiled.
  103449. * @param onError Called if there is an error when compiling a shader.
  103450. */
  103451. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103452. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103453. /**
  103454. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103455. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103456. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103457. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103458. * The gaps between physical kernels are compensated for in the weighting of the samples
  103459. * @param idealKernel Ideal blur kernel.
  103460. * @return Nearest best kernel.
  103461. */
  103462. protected _nearestBestKernel(idealKernel: number): number;
  103463. /**
  103464. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103465. * @param x The point on the Gaussian distribution to sample.
  103466. * @return the value of the Gaussian function at x.
  103467. */
  103468. protected _gaussianWeight(x: number): number;
  103469. /**
  103470. * Generates a string that can be used as a floating point number in GLSL.
  103471. * @param x Value to print.
  103472. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103473. * @return GLSL float string.
  103474. */
  103475. protected _glslFloat(x: number, decimalFigures?: number): string;
  103476. /** @hidden */
  103477. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103478. }
  103479. }
  103480. declare module BABYLON {
  103481. /**
  103482. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103483. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103484. * You can then easily use it as a reflectionTexture on a flat surface.
  103485. * In case the surface is not a plane, please consider relying on reflection probes.
  103486. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103487. */
  103488. export class MirrorTexture extends RenderTargetTexture {
  103489. private scene;
  103490. /**
  103491. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103492. * 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.
  103493. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103494. */
  103495. mirrorPlane: Plane;
  103496. /**
  103497. * Define the blur ratio used to blur the reflection if needed.
  103498. */
  103499. set blurRatio(value: number);
  103500. get blurRatio(): number;
  103501. /**
  103502. * Define the adaptive blur kernel used to blur the reflection if needed.
  103503. * This will autocompute the closest best match for the `blurKernel`
  103504. */
  103505. set adaptiveBlurKernel(value: number);
  103506. /**
  103507. * Define the blur kernel used to blur the reflection if needed.
  103508. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103509. */
  103510. set blurKernel(value: number);
  103511. /**
  103512. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103513. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103514. */
  103515. set blurKernelX(value: number);
  103516. get blurKernelX(): number;
  103517. /**
  103518. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103519. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103520. */
  103521. set blurKernelY(value: number);
  103522. get blurKernelY(): number;
  103523. private _autoComputeBlurKernel;
  103524. protected _onRatioRescale(): void;
  103525. private _updateGammaSpace;
  103526. private _imageProcessingConfigChangeObserver;
  103527. private _transformMatrix;
  103528. private _mirrorMatrix;
  103529. private _savedViewMatrix;
  103530. private _blurX;
  103531. private _blurY;
  103532. private _adaptiveBlurKernel;
  103533. private _blurKernelX;
  103534. private _blurKernelY;
  103535. private _blurRatio;
  103536. /**
  103537. * Instantiates a Mirror Texture.
  103538. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103539. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103540. * You can then easily use it as a reflectionTexture on a flat surface.
  103541. * In case the surface is not a plane, please consider relying on reflection probes.
  103542. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103543. * @param name
  103544. * @param size
  103545. * @param scene
  103546. * @param generateMipMaps
  103547. * @param type
  103548. * @param samplingMode
  103549. * @param generateDepthBuffer
  103550. */
  103551. constructor(name: string, size: number | {
  103552. width: number;
  103553. height: number;
  103554. } | {
  103555. ratio: number;
  103556. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103557. private _preparePostProcesses;
  103558. /**
  103559. * Clone the mirror texture.
  103560. * @returns the cloned texture
  103561. */
  103562. clone(): MirrorTexture;
  103563. /**
  103564. * Serialize the texture to a JSON representation you could use in Parse later on
  103565. * @returns the serialized JSON representation
  103566. */
  103567. serialize(): any;
  103568. /**
  103569. * Dispose the texture and release its associated resources.
  103570. */
  103571. dispose(): void;
  103572. }
  103573. }
  103574. declare module BABYLON {
  103575. /**
  103576. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103577. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103578. */
  103579. export class Texture extends BaseTexture {
  103580. /**
  103581. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103582. */
  103583. static SerializeBuffers: boolean;
  103584. /** @hidden */
  103585. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103586. /** @hidden */
  103587. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103588. /** @hidden */
  103589. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103590. /** nearest is mag = nearest and min = nearest and mip = linear */
  103591. static readonly NEAREST_SAMPLINGMODE: number;
  103592. /** nearest is mag = nearest and min = nearest and mip = linear */
  103593. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103594. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103595. static readonly BILINEAR_SAMPLINGMODE: number;
  103596. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103597. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103598. /** Trilinear is mag = linear and min = linear and mip = linear */
  103599. static readonly TRILINEAR_SAMPLINGMODE: number;
  103600. /** Trilinear is mag = linear and min = linear and mip = linear */
  103601. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103602. /** mag = nearest and min = nearest and mip = nearest */
  103603. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103604. /** mag = nearest and min = linear and mip = nearest */
  103605. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103606. /** mag = nearest and min = linear and mip = linear */
  103607. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103608. /** mag = nearest and min = linear and mip = none */
  103609. static readonly NEAREST_LINEAR: number;
  103610. /** mag = nearest and min = nearest and mip = none */
  103611. static readonly NEAREST_NEAREST: number;
  103612. /** mag = linear and min = nearest and mip = nearest */
  103613. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103614. /** mag = linear and min = nearest and mip = linear */
  103615. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103616. /** mag = linear and min = linear and mip = none */
  103617. static readonly LINEAR_LINEAR: number;
  103618. /** mag = linear and min = nearest and mip = none */
  103619. static readonly LINEAR_NEAREST: number;
  103620. /** Explicit coordinates mode */
  103621. static readonly EXPLICIT_MODE: number;
  103622. /** Spherical coordinates mode */
  103623. static readonly SPHERICAL_MODE: number;
  103624. /** Planar coordinates mode */
  103625. static readonly PLANAR_MODE: number;
  103626. /** Cubic coordinates mode */
  103627. static readonly CUBIC_MODE: number;
  103628. /** Projection coordinates mode */
  103629. static readonly PROJECTION_MODE: number;
  103630. /** Inverse Cubic coordinates mode */
  103631. static readonly SKYBOX_MODE: number;
  103632. /** Inverse Cubic coordinates mode */
  103633. static readonly INVCUBIC_MODE: number;
  103634. /** Equirectangular coordinates mode */
  103635. static readonly EQUIRECTANGULAR_MODE: number;
  103636. /** Equirectangular Fixed coordinates mode */
  103637. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103638. /** Equirectangular Fixed Mirrored coordinates mode */
  103639. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103640. /** Texture is not repeating outside of 0..1 UVs */
  103641. static readonly CLAMP_ADDRESSMODE: number;
  103642. /** Texture is repeating outside of 0..1 UVs */
  103643. static readonly WRAP_ADDRESSMODE: number;
  103644. /** Texture is repeating and mirrored */
  103645. static readonly MIRROR_ADDRESSMODE: number;
  103646. /**
  103647. * 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
  103648. */
  103649. static UseSerializedUrlIfAny: boolean;
  103650. /**
  103651. * Define the url of the texture.
  103652. */
  103653. url: Nullable<string>;
  103654. /**
  103655. * Define an offset on the texture to offset the u coordinates of the UVs
  103656. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103657. */
  103658. uOffset: number;
  103659. /**
  103660. * Define an offset on the texture to offset the v coordinates of the UVs
  103661. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103662. */
  103663. vOffset: number;
  103664. /**
  103665. * Define an offset on the texture to scale the u coordinates of the UVs
  103666. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103667. */
  103668. uScale: number;
  103669. /**
  103670. * Define an offset on the texture to scale the v coordinates of the UVs
  103671. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103672. */
  103673. vScale: number;
  103674. /**
  103675. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103676. * @see https://doc.babylonjs.com/how_to/more_materials
  103677. */
  103678. uAng: number;
  103679. /**
  103680. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103681. * @see https://doc.babylonjs.com/how_to/more_materials
  103682. */
  103683. vAng: number;
  103684. /**
  103685. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103686. * @see https://doc.babylonjs.com/how_to/more_materials
  103687. */
  103688. wAng: number;
  103689. /**
  103690. * Defines the center of rotation (U)
  103691. */
  103692. uRotationCenter: number;
  103693. /**
  103694. * Defines the center of rotation (V)
  103695. */
  103696. vRotationCenter: number;
  103697. /**
  103698. * Defines the center of rotation (W)
  103699. */
  103700. wRotationCenter: number;
  103701. /**
  103702. * Are mip maps generated for this texture or not.
  103703. */
  103704. get noMipmap(): boolean;
  103705. /**
  103706. * List of inspectable custom properties (used by the Inspector)
  103707. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103708. */
  103709. inspectableCustomProperties: Nullable<IInspectable[]>;
  103710. private _noMipmap;
  103711. /** @hidden */
  103712. _invertY: boolean;
  103713. private _rowGenerationMatrix;
  103714. private _cachedTextureMatrix;
  103715. private _projectionModeMatrix;
  103716. private _t0;
  103717. private _t1;
  103718. private _t2;
  103719. private _cachedUOffset;
  103720. private _cachedVOffset;
  103721. private _cachedUScale;
  103722. private _cachedVScale;
  103723. private _cachedUAng;
  103724. private _cachedVAng;
  103725. private _cachedWAng;
  103726. private _cachedProjectionMatrixId;
  103727. private _cachedCoordinatesMode;
  103728. /** @hidden */
  103729. protected _initialSamplingMode: number;
  103730. /** @hidden */
  103731. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103732. private _deleteBuffer;
  103733. protected _format: Nullable<number>;
  103734. private _delayedOnLoad;
  103735. private _delayedOnError;
  103736. private _mimeType?;
  103737. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103738. get mimeType(): string | undefined;
  103739. /**
  103740. * Observable triggered once the texture has been loaded.
  103741. */
  103742. onLoadObservable: Observable<Texture>;
  103743. protected _isBlocking: boolean;
  103744. /**
  103745. * Is the texture preventing material to render while loading.
  103746. * If false, a default texture will be used instead of the loading one during the preparation step.
  103747. */
  103748. set isBlocking(value: boolean);
  103749. get isBlocking(): boolean;
  103750. /**
  103751. * Get the current sampling mode associated with the texture.
  103752. */
  103753. get samplingMode(): number;
  103754. /**
  103755. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103756. */
  103757. get invertY(): boolean;
  103758. /**
  103759. * Instantiates a new texture.
  103760. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103761. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103762. * @param url defines the url of the picture to load as a texture
  103763. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103764. * @param noMipmap defines if the texture will require mip maps or not
  103765. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103766. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103767. * @param onLoad defines a callback triggered when the texture has been loaded
  103768. * @param onError defines a callback triggered when an error occurred during the loading session
  103769. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103770. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103771. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103772. * @param mimeType defines an optional mime type information
  103773. */
  103774. 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);
  103775. /**
  103776. * Update the url (and optional buffer) of this texture if url was null during construction.
  103777. * @param url the url of the texture
  103778. * @param buffer the buffer of the texture (defaults to null)
  103779. * @param onLoad callback called when the texture is loaded (defaults to null)
  103780. */
  103781. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103782. /**
  103783. * Finish the loading sequence of a texture flagged as delayed load.
  103784. * @hidden
  103785. */
  103786. delayLoad(): void;
  103787. private _prepareRowForTextureGeneration;
  103788. /**
  103789. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103790. * @returns the transform matrix of the texture.
  103791. */
  103792. getTextureMatrix(uBase?: number): Matrix;
  103793. /**
  103794. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103795. * @returns The reflection texture transform
  103796. */
  103797. getReflectionTextureMatrix(): Matrix;
  103798. /**
  103799. * Clones the texture.
  103800. * @returns the cloned texture
  103801. */
  103802. clone(): Texture;
  103803. /**
  103804. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103805. * @returns The JSON representation of the texture
  103806. */
  103807. serialize(): any;
  103808. /**
  103809. * Get the current class name of the texture useful for serialization or dynamic coding.
  103810. * @returns "Texture"
  103811. */
  103812. getClassName(): string;
  103813. /**
  103814. * Dispose the texture and release its associated resources.
  103815. */
  103816. dispose(): void;
  103817. /**
  103818. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103819. * @param parsedTexture Define the JSON representation of the texture
  103820. * @param scene Define the scene the parsed texture should be instantiated in
  103821. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103822. * @returns The parsed texture if successful
  103823. */
  103824. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103825. /**
  103826. * Creates a texture from its base 64 representation.
  103827. * @param data Define the base64 payload without the data: prefix
  103828. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103829. * @param scene Define the scene the texture should belong to
  103830. * @param noMipmap Forces the texture to not create mip map information if true
  103831. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103832. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103833. * @param onLoad define a callback triggered when the texture has been loaded
  103834. * @param onError define a callback triggered when an error occurred during the loading session
  103835. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103836. * @returns the created texture
  103837. */
  103838. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103839. /**
  103840. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103841. * @param data Define the base64 payload without the data: prefix
  103842. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103843. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103844. * @param scene Define the scene the texture should belong to
  103845. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103846. * @param noMipmap Forces the texture to not create mip map information if true
  103847. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103848. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103849. * @param onLoad define a callback triggered when the texture has been loaded
  103850. * @param onError define a callback triggered when an error occurred during the loading session
  103851. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103852. * @returns the created texture
  103853. */
  103854. 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;
  103855. }
  103856. }
  103857. declare module BABYLON {
  103858. /**
  103859. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103860. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103861. */
  103862. export class PostProcessManager {
  103863. private _scene;
  103864. private _indexBuffer;
  103865. private _vertexBuffers;
  103866. /**
  103867. * Creates a new instance PostProcess
  103868. * @param scene The scene that the post process is associated with.
  103869. */
  103870. constructor(scene: Scene);
  103871. private _prepareBuffers;
  103872. private _buildIndexBuffer;
  103873. /**
  103874. * Rebuilds the vertex buffers of the manager.
  103875. * @hidden
  103876. */
  103877. _rebuild(): void;
  103878. /**
  103879. * Prepares a frame to be run through a post process.
  103880. * @param sourceTexture The input texture to the post procesess. (default: null)
  103881. * @param postProcesses An array of post processes to be run. (default: null)
  103882. * @returns True if the post processes were able to be run.
  103883. * @hidden
  103884. */
  103885. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103886. /**
  103887. * Manually render a set of post processes to a texture.
  103888. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103889. * @param postProcesses An array of post processes to be run.
  103890. * @param targetTexture The target texture to render to.
  103891. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103892. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103893. * @param lodLevel defines which lod of the texture to render to
  103894. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103895. */
  103896. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103897. /**
  103898. * Finalize the result of the output of the postprocesses.
  103899. * @param doNotPresent If true the result will not be displayed to the screen.
  103900. * @param targetTexture The target texture to render to.
  103901. * @param faceIndex The index of the face to bind the target texture to.
  103902. * @param postProcesses The array of post processes to render.
  103903. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103904. * @hidden
  103905. */
  103906. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103907. /**
  103908. * Disposes of the post process manager.
  103909. */
  103910. dispose(): void;
  103911. }
  103912. }
  103913. declare module BABYLON {
  103914. /**
  103915. * This Helps creating a texture that will be created from a camera in your scene.
  103916. * It is basically a dynamic texture that could be used to create special effects for instance.
  103917. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103918. */
  103919. export class RenderTargetTexture extends Texture {
  103920. /**
  103921. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103922. */
  103923. static readonly REFRESHRATE_RENDER_ONCE: number;
  103924. /**
  103925. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103926. */
  103927. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103928. /**
  103929. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103930. * the central point of your effect and can save a lot of performances.
  103931. */
  103932. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103933. /**
  103934. * Use this predicate to dynamically define the list of mesh you want to render.
  103935. * If set, the renderList property will be overwritten.
  103936. */
  103937. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103938. private _renderList;
  103939. /**
  103940. * Use this list to define the list of mesh you want to render.
  103941. */
  103942. get renderList(): Nullable<Array<AbstractMesh>>;
  103943. set renderList(value: Nullable<Array<AbstractMesh>>);
  103944. /**
  103945. * Use this function to overload the renderList array at rendering time.
  103946. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103947. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103948. * the cube (if the RTT is a cube, else layerOrFace=0).
  103949. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103950. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103951. * hold dummy elements!
  103952. */
  103953. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103954. private _hookArray;
  103955. /**
  103956. * Define if particles should be rendered in your texture.
  103957. */
  103958. renderParticles: boolean;
  103959. /**
  103960. * Define if sprites should be rendered in your texture.
  103961. */
  103962. renderSprites: boolean;
  103963. /**
  103964. * Define the camera used to render the texture.
  103965. */
  103966. activeCamera: Nullable<Camera>;
  103967. /**
  103968. * Override the mesh isReady function with your own one.
  103969. */
  103970. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103971. /**
  103972. * Override the render function of the texture with your own one.
  103973. */
  103974. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103975. /**
  103976. * Define if camera post processes should be use while rendering the texture.
  103977. */
  103978. useCameraPostProcesses: boolean;
  103979. /**
  103980. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103981. */
  103982. ignoreCameraViewport: boolean;
  103983. private _postProcessManager;
  103984. private _postProcesses;
  103985. private _resizeObserver;
  103986. /**
  103987. * An event triggered when the texture is unbind.
  103988. */
  103989. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103990. /**
  103991. * An event triggered when the texture is unbind.
  103992. */
  103993. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103994. private _onAfterUnbindObserver;
  103995. /**
  103996. * Set a after unbind callback in the texture.
  103997. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103998. */
  103999. set onAfterUnbind(callback: () => void);
  104000. /**
  104001. * An event triggered before rendering the texture
  104002. */
  104003. onBeforeRenderObservable: Observable<number>;
  104004. private _onBeforeRenderObserver;
  104005. /**
  104006. * Set a before render callback in the texture.
  104007. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104008. */
  104009. set onBeforeRender(callback: (faceIndex: number) => void);
  104010. /**
  104011. * An event triggered after rendering the texture
  104012. */
  104013. onAfterRenderObservable: Observable<number>;
  104014. private _onAfterRenderObserver;
  104015. /**
  104016. * Set a after render callback in the texture.
  104017. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104018. */
  104019. set onAfterRender(callback: (faceIndex: number) => void);
  104020. /**
  104021. * An event triggered after the texture clear
  104022. */
  104023. onClearObservable: Observable<Engine>;
  104024. private _onClearObserver;
  104025. /**
  104026. * Set a clear callback in the texture.
  104027. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104028. */
  104029. set onClear(callback: (Engine: Engine) => void);
  104030. /**
  104031. * An event triggered when the texture is resized.
  104032. */
  104033. onResizeObservable: Observable<RenderTargetTexture>;
  104034. /**
  104035. * Define the clear color of the Render Target if it should be different from the scene.
  104036. */
  104037. clearColor: Color4;
  104038. protected _size: number | {
  104039. width: number;
  104040. height: number;
  104041. layers?: number;
  104042. };
  104043. protected _initialSizeParameter: number | {
  104044. width: number;
  104045. height: number;
  104046. } | {
  104047. ratio: number;
  104048. };
  104049. protected _sizeRatio: Nullable<number>;
  104050. /** @hidden */
  104051. _generateMipMaps: boolean;
  104052. protected _renderingManager: RenderingManager;
  104053. /** @hidden */
  104054. _waitingRenderList?: string[];
  104055. protected _doNotChangeAspectRatio: boolean;
  104056. protected _currentRefreshId: number;
  104057. protected _refreshRate: number;
  104058. protected _textureMatrix: Matrix;
  104059. protected _samples: number;
  104060. protected _renderTargetOptions: RenderTargetCreationOptions;
  104061. /**
  104062. * Gets render target creation options that were used.
  104063. */
  104064. get renderTargetOptions(): RenderTargetCreationOptions;
  104065. protected _onRatioRescale(): void;
  104066. /**
  104067. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104068. * It must define where the camera used to render the texture is set
  104069. */
  104070. boundingBoxPosition: Vector3;
  104071. private _boundingBoxSize;
  104072. /**
  104073. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104074. * When defined, the cubemap will switch to local mode
  104075. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104076. * @example https://www.babylonjs-playground.com/#RNASML
  104077. */
  104078. set boundingBoxSize(value: Vector3);
  104079. get boundingBoxSize(): Vector3;
  104080. /**
  104081. * In case the RTT has been created with a depth texture, get the associated
  104082. * depth texture.
  104083. * Otherwise, return null.
  104084. */
  104085. get depthStencilTexture(): Nullable<InternalTexture>;
  104086. /**
  104087. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104088. * or used a shadow, depth texture...
  104089. * @param name The friendly name of the texture
  104090. * @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)
  104091. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104092. * @param generateMipMaps True if mip maps need to be generated after render.
  104093. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104094. * @param type The type of the buffer in the RTT (int, half float, float...)
  104095. * @param isCube True if a cube texture needs to be created
  104096. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104097. * @param generateDepthBuffer True to generate a depth buffer
  104098. * @param generateStencilBuffer True to generate a stencil buffer
  104099. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104100. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104101. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104102. */
  104103. constructor(name: string, size: number | {
  104104. width: number;
  104105. height: number;
  104106. layers?: number;
  104107. } | {
  104108. ratio: number;
  104109. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104110. /**
  104111. * Creates a depth stencil texture.
  104112. * This is only available in WebGL 2 or with the depth texture extension available.
  104113. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104114. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104115. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104116. */
  104117. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104118. private _processSizeParameter;
  104119. /**
  104120. * Define the number of samples to use in case of MSAA.
  104121. * It defaults to one meaning no MSAA has been enabled.
  104122. */
  104123. get samples(): number;
  104124. set samples(value: number);
  104125. /**
  104126. * Resets the refresh counter of the texture and start bak from scratch.
  104127. * Could be useful to regenerate the texture if it is setup to render only once.
  104128. */
  104129. resetRefreshCounter(): void;
  104130. /**
  104131. * Define the refresh rate of the texture or the rendering frequency.
  104132. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104133. */
  104134. get refreshRate(): number;
  104135. set refreshRate(value: number);
  104136. /**
  104137. * Adds a post process to the render target rendering passes.
  104138. * @param postProcess define the post process to add
  104139. */
  104140. addPostProcess(postProcess: PostProcess): void;
  104141. /**
  104142. * Clear all the post processes attached to the render target
  104143. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104144. */
  104145. clearPostProcesses(dispose?: boolean): void;
  104146. /**
  104147. * Remove one of the post process from the list of attached post processes to the texture
  104148. * @param postProcess define the post process to remove from the list
  104149. */
  104150. removePostProcess(postProcess: PostProcess): void;
  104151. /** @hidden */
  104152. _shouldRender(): boolean;
  104153. /**
  104154. * Gets the actual render size of the texture.
  104155. * @returns the width of the render size
  104156. */
  104157. getRenderSize(): number;
  104158. /**
  104159. * Gets the actual render width of the texture.
  104160. * @returns the width of the render size
  104161. */
  104162. getRenderWidth(): number;
  104163. /**
  104164. * Gets the actual render height of the texture.
  104165. * @returns the height of the render size
  104166. */
  104167. getRenderHeight(): number;
  104168. /**
  104169. * Gets the actual number of layers of the texture.
  104170. * @returns the number of layers
  104171. */
  104172. getRenderLayers(): number;
  104173. /**
  104174. * Get if the texture can be rescaled or not.
  104175. */
  104176. get canRescale(): boolean;
  104177. /**
  104178. * Resize the texture using a ratio.
  104179. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104180. */
  104181. scale(ratio: number): void;
  104182. /**
  104183. * Get the texture reflection matrix used to rotate/transform the reflection.
  104184. * @returns the reflection matrix
  104185. */
  104186. getReflectionTextureMatrix(): Matrix;
  104187. /**
  104188. * Resize the texture to a new desired size.
  104189. * Be carrefull as it will recreate all the data in the new texture.
  104190. * @param size Define the new size. It can be:
  104191. * - a number for squared texture,
  104192. * - an object containing { width: number, height: number }
  104193. * - or an object containing a ratio { ratio: number }
  104194. */
  104195. resize(size: number | {
  104196. width: number;
  104197. height: number;
  104198. } | {
  104199. ratio: number;
  104200. }): void;
  104201. private _defaultRenderListPrepared;
  104202. /**
  104203. * Renders all the objects from the render list into the texture.
  104204. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104205. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104206. */
  104207. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104208. private _bestReflectionRenderTargetDimension;
  104209. private _prepareRenderingManager;
  104210. /**
  104211. * @hidden
  104212. * @param faceIndex face index to bind to if this is a cubetexture
  104213. * @param layer defines the index of the texture to bind in the array
  104214. */
  104215. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104216. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104217. private renderToTarget;
  104218. /**
  104219. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104220. * This allowed control for front to back rendering or reversly depending of the special needs.
  104221. *
  104222. * @param renderingGroupId The rendering group id corresponding to its index
  104223. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104224. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104225. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  104226. */
  104227. 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;
  104228. /**
  104229. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  104230. *
  104231. * @param renderingGroupId The rendering group id corresponding to its index
  104232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104233. */
  104234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104235. /**
  104236. * Clones the texture.
  104237. * @returns the cloned texture
  104238. */
  104239. clone(): RenderTargetTexture;
  104240. /**
  104241. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104242. * @returns The JSON representation of the texture
  104243. */
  104244. serialize(): any;
  104245. /**
  104246. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  104247. */
  104248. disposeFramebufferObjects(): void;
  104249. /**
  104250. * Dispose the texture and release its associated resources.
  104251. */
  104252. dispose(): void;
  104253. /** @hidden */
  104254. _rebuild(): void;
  104255. /**
  104256. * Clear the info related to rendering groups preventing retention point in material dispose.
  104257. */
  104258. freeRenderingGroups(): void;
  104259. /**
  104260. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  104261. * @returns the view count
  104262. */
  104263. getViewCount(): number;
  104264. }
  104265. }
  104266. declare module BABYLON {
  104267. /**
  104268. * Class used to manipulate GUIDs
  104269. */
  104270. export class GUID {
  104271. /**
  104272. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104273. * Be aware Math.random() could cause collisions, but:
  104274. * "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"
  104275. * @returns a pseudo random id
  104276. */
  104277. static RandomId(): string;
  104278. }
  104279. }
  104280. declare module BABYLON {
  104281. /**
  104282. * Options to be used when creating a shadow depth material
  104283. */
  104284. export interface IIOptionShadowDepthMaterial {
  104285. /** Variables in the vertex shader code that need to have their names remapped.
  104286. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  104287. * "var_name" should be either: worldPos or vNormalW
  104288. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  104289. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  104290. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  104291. */
  104292. remappedVariables?: string[];
  104293. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  104294. standalone?: boolean;
  104295. }
  104296. /**
  104297. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  104298. */
  104299. export class ShadowDepthWrapper {
  104300. private _scene;
  104301. private _options?;
  104302. private _baseMaterial;
  104303. private _onEffectCreatedObserver;
  104304. private _subMeshToEffect;
  104305. private _subMeshToDepthEffect;
  104306. private _meshes;
  104307. /** @hidden */
  104308. _matriceNames: any;
  104309. /** Gets the standalone status of the wrapper */
  104310. get standalone(): boolean;
  104311. /** Gets the base material the wrapper is built upon */
  104312. get baseMaterial(): Material;
  104313. /**
  104314. * Instantiate a new shadow depth wrapper.
  104315. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  104316. * generate the shadow depth map. For more information, please refer to the documentation:
  104317. * https://doc.babylonjs.com/babylon101/shadows
  104318. * @param baseMaterial Material to wrap
  104319. * @param scene Define the scene the material belongs to
  104320. * @param options Options used to create the wrapper
  104321. */
  104322. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  104323. /**
  104324. * Gets the effect to use to generate the depth map
  104325. * @param subMesh subMesh to get the effect for
  104326. * @param shadowGenerator shadow generator to get the effect for
  104327. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  104328. */
  104329. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  104330. /**
  104331. * Specifies that the submesh is ready to be used for depth rendering
  104332. * @param subMesh submesh to check
  104333. * @param defines the list of defines to take into account when checking the effect
  104334. * @param shadowGenerator combined with subMesh, it defines the effect to check
  104335. * @param useInstances specifies that instances should be used
  104336. * @returns a boolean indicating that the submesh is ready or not
  104337. */
  104338. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  104339. /**
  104340. * Disposes the resources
  104341. */
  104342. dispose(): void;
  104343. private _makeEffect;
  104344. }
  104345. }
  104346. declare module BABYLON {
  104347. interface ThinEngine {
  104348. /**
  104349. * Unbind a list of render target textures from the webGL context
  104350. * This is used only when drawBuffer extension or webGL2 are active
  104351. * @param textures defines the render target textures to unbind
  104352. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104353. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104354. */
  104355. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104356. /**
  104357. * Create a multi render target texture
  104358. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104359. * @param size defines the size of the texture
  104360. * @param options defines the creation options
  104361. * @returns the cube texture as an InternalTexture
  104362. */
  104363. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104364. /**
  104365. * Update the sample count for a given multiple render target texture
  104366. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104367. * @param textures defines the textures to update
  104368. * @param samples defines the sample count to set
  104369. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104370. */
  104371. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104372. /**
  104373. * Select a subsets of attachments to draw to.
  104374. * @param attachments gl attachments
  104375. */
  104376. bindAttachments(attachments: number[]): void;
  104377. }
  104378. }
  104379. declare module BABYLON {
  104380. /**
  104381. * Creation options of the multi render target texture.
  104382. */
  104383. export interface IMultiRenderTargetOptions {
  104384. /**
  104385. * Define if the texture needs to create mip maps after render.
  104386. */
  104387. generateMipMaps?: boolean;
  104388. /**
  104389. * Define the types of all the draw buffers we want to create
  104390. */
  104391. types?: number[];
  104392. /**
  104393. * Define the sampling modes of all the draw buffers we want to create
  104394. */
  104395. samplingModes?: number[];
  104396. /**
  104397. * Define if a depth buffer is required
  104398. */
  104399. generateDepthBuffer?: boolean;
  104400. /**
  104401. * Define if a stencil buffer is required
  104402. */
  104403. generateStencilBuffer?: boolean;
  104404. /**
  104405. * Define if a depth texture is required instead of a depth buffer
  104406. */
  104407. generateDepthTexture?: boolean;
  104408. /**
  104409. * Define the number of desired draw buffers
  104410. */
  104411. textureCount?: number;
  104412. /**
  104413. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104414. */
  104415. doNotChangeAspectRatio?: boolean;
  104416. /**
  104417. * Define the default type of the buffers we are creating
  104418. */
  104419. defaultType?: number;
  104420. }
  104421. /**
  104422. * A multi render target, like a render target provides the ability to render to a texture.
  104423. * Unlike the render target, it can render to several draw buffers in one draw.
  104424. * This is specially interesting in deferred rendering or for any effects requiring more than
  104425. * just one color from a single pass.
  104426. */
  104427. export class MultiRenderTarget extends RenderTargetTexture {
  104428. private _internalTextures;
  104429. private _textures;
  104430. private _multiRenderTargetOptions;
  104431. private _count;
  104432. /**
  104433. * Get if draw buffers are currently supported by the used hardware and browser.
  104434. */
  104435. get isSupported(): boolean;
  104436. /**
  104437. * Get the list of textures generated by the multi render target.
  104438. */
  104439. get textures(): Texture[];
  104440. /**
  104441. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104442. */
  104443. get count(): number;
  104444. /**
  104445. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104446. */
  104447. get depthTexture(): Texture;
  104448. /**
  104449. * Set the wrapping mode on U of all the textures we are rendering to.
  104450. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104451. */
  104452. set wrapU(wrap: number);
  104453. /**
  104454. * Set the wrapping mode on V of all the textures we are rendering to.
  104455. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104456. */
  104457. set wrapV(wrap: number);
  104458. /**
  104459. * Instantiate a new multi render target texture.
  104460. * A multi render target, like a render target provides the ability to render to a texture.
  104461. * Unlike the render target, it can render to several draw buffers in one draw.
  104462. * This is specially interesting in deferred rendering or for any effects requiring more than
  104463. * just one color from a single pass.
  104464. * @param name Define the name of the texture
  104465. * @param size Define the size of the buffers to render to
  104466. * @param count Define the number of target we are rendering into
  104467. * @param scene Define the scene the texture belongs to
  104468. * @param options Define the options used to create the multi render target
  104469. */
  104470. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104471. private _initTypes;
  104472. /** @hidden */
  104473. _rebuild(forceFullRebuild?: boolean): void;
  104474. private _createInternalTextures;
  104475. private _createTextures;
  104476. /**
  104477. * Define the number of samples used if MSAA is enabled.
  104478. */
  104479. get samples(): number;
  104480. set samples(value: number);
  104481. /**
  104482. * Resize all the textures in the multi render target.
  104483. * Be careful as it will recreate all the data in the new texture.
  104484. * @param size Define the new size
  104485. */
  104486. resize(size: any): void;
  104487. /**
  104488. * Changes the number of render targets in this MRT
  104489. * Be careful as it will recreate all the data in the new texture.
  104490. * @param count new texture count
  104491. * @param options Specifies texture types and sampling modes for new textures
  104492. */
  104493. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104494. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104495. /**
  104496. * Dispose the render targets and their associated resources
  104497. */
  104498. dispose(): void;
  104499. /**
  104500. * Release all the underlying texture used as draw buffers.
  104501. */
  104502. releaseInternalTextures(): void;
  104503. }
  104504. }
  104505. declare module BABYLON {
  104506. /** @hidden */
  104507. export var imageProcessingPixelShader: {
  104508. name: string;
  104509. shader: string;
  104510. };
  104511. }
  104512. declare module BABYLON {
  104513. /**
  104514. * ImageProcessingPostProcess
  104515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104516. */
  104517. export class ImageProcessingPostProcess extends PostProcess {
  104518. /**
  104519. * Default configuration related to image processing available in the PBR Material.
  104520. */
  104521. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104522. /**
  104523. * Gets the image processing configuration used either in this material.
  104524. */
  104525. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104526. /**
  104527. * Sets the Default image processing configuration used either in the this material.
  104528. *
  104529. * If sets to null, the scene one is in use.
  104530. */
  104531. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104532. /**
  104533. * Keep track of the image processing observer to allow dispose and replace.
  104534. */
  104535. private _imageProcessingObserver;
  104536. /**
  104537. * Attaches a new image processing configuration to the PBR Material.
  104538. * @param configuration
  104539. */
  104540. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104541. /**
  104542. * If the post process is supported.
  104543. */
  104544. get isSupported(): boolean;
  104545. /**
  104546. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104547. */
  104548. get colorCurves(): Nullable<ColorCurves>;
  104549. /**
  104550. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104551. */
  104552. set colorCurves(value: Nullable<ColorCurves>);
  104553. /**
  104554. * Gets wether the color curves effect is enabled.
  104555. */
  104556. get colorCurvesEnabled(): boolean;
  104557. /**
  104558. * Sets wether the color curves effect is enabled.
  104559. */
  104560. set colorCurvesEnabled(value: boolean);
  104561. /**
  104562. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104563. */
  104564. get colorGradingTexture(): Nullable<BaseTexture>;
  104565. /**
  104566. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104567. */
  104568. set colorGradingTexture(value: Nullable<BaseTexture>);
  104569. /**
  104570. * Gets wether the color grading effect is enabled.
  104571. */
  104572. get colorGradingEnabled(): boolean;
  104573. /**
  104574. * Gets wether the color grading effect is enabled.
  104575. */
  104576. set colorGradingEnabled(value: boolean);
  104577. /**
  104578. * Gets exposure used in the effect.
  104579. */
  104580. get exposure(): number;
  104581. /**
  104582. * Sets exposure used in the effect.
  104583. */
  104584. set exposure(value: number);
  104585. /**
  104586. * Gets wether tonemapping is enabled or not.
  104587. */
  104588. get toneMappingEnabled(): boolean;
  104589. /**
  104590. * Sets wether tonemapping is enabled or not
  104591. */
  104592. set toneMappingEnabled(value: boolean);
  104593. /**
  104594. * Gets the type of tone mapping effect.
  104595. */
  104596. get toneMappingType(): number;
  104597. /**
  104598. * Sets the type of tone mapping effect.
  104599. */
  104600. set toneMappingType(value: number);
  104601. /**
  104602. * Gets contrast used in the effect.
  104603. */
  104604. get contrast(): number;
  104605. /**
  104606. * Sets contrast used in the effect.
  104607. */
  104608. set contrast(value: number);
  104609. /**
  104610. * Gets Vignette stretch size.
  104611. */
  104612. get vignetteStretch(): number;
  104613. /**
  104614. * Sets Vignette stretch size.
  104615. */
  104616. set vignetteStretch(value: number);
  104617. /**
  104618. * Gets Vignette centre X Offset.
  104619. */
  104620. get vignetteCentreX(): number;
  104621. /**
  104622. * Sets Vignette centre X Offset.
  104623. */
  104624. set vignetteCentreX(value: number);
  104625. /**
  104626. * Gets Vignette centre Y Offset.
  104627. */
  104628. get vignetteCentreY(): number;
  104629. /**
  104630. * Sets Vignette centre Y Offset.
  104631. */
  104632. set vignetteCentreY(value: number);
  104633. /**
  104634. * Gets Vignette weight or intensity of the vignette effect.
  104635. */
  104636. get vignetteWeight(): number;
  104637. /**
  104638. * Sets Vignette weight or intensity of the vignette effect.
  104639. */
  104640. set vignetteWeight(value: number);
  104641. /**
  104642. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104643. * if vignetteEnabled is set to true.
  104644. */
  104645. get vignetteColor(): Color4;
  104646. /**
  104647. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104648. * if vignetteEnabled is set to true.
  104649. */
  104650. set vignetteColor(value: Color4);
  104651. /**
  104652. * Gets Camera field of view used by the Vignette effect.
  104653. */
  104654. get vignetteCameraFov(): number;
  104655. /**
  104656. * Sets Camera field of view used by the Vignette effect.
  104657. */
  104658. set vignetteCameraFov(value: number);
  104659. /**
  104660. * Gets the vignette blend mode allowing different kind of effect.
  104661. */
  104662. get vignetteBlendMode(): number;
  104663. /**
  104664. * Sets the vignette blend mode allowing different kind of effect.
  104665. */
  104666. set vignetteBlendMode(value: number);
  104667. /**
  104668. * Gets wether the vignette effect is enabled.
  104669. */
  104670. get vignetteEnabled(): boolean;
  104671. /**
  104672. * Sets wether the vignette effect is enabled.
  104673. */
  104674. set vignetteEnabled(value: boolean);
  104675. private _fromLinearSpace;
  104676. /**
  104677. * Gets wether the input of the processing is in Gamma or Linear Space.
  104678. */
  104679. get fromLinearSpace(): boolean;
  104680. /**
  104681. * Sets wether the input of the processing is in Gamma or Linear Space.
  104682. */
  104683. set fromLinearSpace(value: boolean);
  104684. /**
  104685. * Defines cache preventing GC.
  104686. */
  104687. private _defines;
  104688. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104689. /**
  104690. * "ImageProcessingPostProcess"
  104691. * @returns "ImageProcessingPostProcess"
  104692. */
  104693. getClassName(): string;
  104694. /**
  104695. * @hidden
  104696. */
  104697. _updateParameters(): void;
  104698. dispose(camera?: Camera): void;
  104699. }
  104700. }
  104701. declare module BABYLON {
  104702. /**
  104703. * Interface for defining prepass effects in the prepass post-process pipeline
  104704. */
  104705. export interface PrePassEffectConfiguration {
  104706. /**
  104707. * Name of the effect
  104708. */
  104709. name: string;
  104710. /**
  104711. * Post process to attach for this effect
  104712. */
  104713. postProcess?: PostProcess;
  104714. /**
  104715. * Textures required in the MRT
  104716. */
  104717. texturesRequired: number[];
  104718. /**
  104719. * Is the effect enabled
  104720. */
  104721. enabled: boolean;
  104722. /**
  104723. * Disposes the effect configuration
  104724. */
  104725. dispose(): void;
  104726. /**
  104727. * Creates the associated post process
  104728. */
  104729. createPostProcess?: () => PostProcess;
  104730. }
  104731. }
  104732. declare module BABYLON {
  104733. /**
  104734. * Renders a pre pass of the scene
  104735. * This means every mesh in the scene will be rendered to a render target texture
  104736. * And then this texture will be composited to the rendering canvas with post processes
  104737. * It is necessary for effects like subsurface scattering or deferred shading
  104738. */
  104739. export class PrePassRenderer {
  104740. /** @hidden */
  104741. static _SceneComponentInitialization: (scene: Scene) => void;
  104742. private _textureFormats;
  104743. private _textureIndices;
  104744. private _scene;
  104745. private _engine;
  104746. private _isDirty;
  104747. /**
  104748. * Number of textures in the multi render target texture where the scene is directly rendered
  104749. */
  104750. mrtCount: number;
  104751. /**
  104752. * The render target where the scene is directly rendered
  104753. */
  104754. prePassRT: MultiRenderTarget;
  104755. private _multiRenderAttachments;
  104756. private _defaultAttachments;
  104757. private _clearAttachments;
  104758. private _postProcesses;
  104759. private readonly _clearColor;
  104760. /**
  104761. * Image processing post process for composition
  104762. */
  104763. imageProcessingPostProcess: ImageProcessingPostProcess;
  104764. /**
  104765. * Configuration for prepass effects
  104766. */
  104767. private _effectConfigurations;
  104768. /**
  104769. * Should materials render their geometry on the MRT
  104770. */
  104771. materialsShouldRenderGeometry: boolean;
  104772. /**
  104773. * Should materials render the irradiance information on the MRT
  104774. */
  104775. materialsShouldRenderIrradiance: boolean;
  104776. private _mrtFormats;
  104777. private _mrtLayout;
  104778. private _enabled;
  104779. /**
  104780. * Indicates if the prepass is enabled
  104781. */
  104782. get enabled(): boolean;
  104783. /**
  104784. * How many samples are used for MSAA of the scene render target
  104785. */
  104786. get samples(): number;
  104787. set samples(n: number);
  104788. /**
  104789. * Instanciates a prepass renderer
  104790. * @param scene The scene
  104791. */
  104792. constructor(scene: Scene);
  104793. private _initializeAttachments;
  104794. private _createCompositionEffect;
  104795. /**
  104796. * Indicates if rendering a prepass is supported
  104797. */
  104798. get isSupported(): boolean;
  104799. /**
  104800. * Sets the proper output textures to draw in the engine.
  104801. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104802. */
  104803. bindAttachmentsForEffect(effect: Effect): void;
  104804. /**
  104805. * @hidden
  104806. */
  104807. _beforeCameraDraw(): void;
  104808. /**
  104809. * @hidden
  104810. */
  104811. _afterCameraDraw(): void;
  104812. private _checkRTSize;
  104813. private _bindFrameBuffer;
  104814. /**
  104815. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104816. */
  104817. clear(): void;
  104818. private _setState;
  104819. private _checkTextureType;
  104820. /**
  104821. * Adds an effect configuration to the prepass.
  104822. * If an effect has already been added, it won't add it twice and will return the configuration
  104823. * already present.
  104824. * @param cfg the effect configuration
  104825. * @return the effect configuration now used by the prepass
  104826. */
  104827. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  104828. /**
  104829. * Returns the index of a texture in the multi render target texture array.
  104830. * @param type Texture type
  104831. * @return The index
  104832. */
  104833. getIndex(type: number): number;
  104834. private _enable;
  104835. private _disable;
  104836. private _resetLayout;
  104837. private _resetPostProcessChain;
  104838. private _bindPostProcessChain;
  104839. /**
  104840. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104841. */
  104842. markAsDirty(): void;
  104843. /**
  104844. * Enables a texture on the MultiRenderTarget for prepass
  104845. */
  104846. private _enableTextures;
  104847. private _update;
  104848. /**
  104849. * Disposes the prepass renderer.
  104850. */
  104851. dispose(): void;
  104852. }
  104853. }
  104854. declare module BABYLON {
  104855. /**
  104856. * Options for compiling materials.
  104857. */
  104858. export interface IMaterialCompilationOptions {
  104859. /**
  104860. * Defines whether clip planes are enabled.
  104861. */
  104862. clipPlane: boolean;
  104863. /**
  104864. * Defines whether instances are enabled.
  104865. */
  104866. useInstances: boolean;
  104867. }
  104868. /**
  104869. * Options passed when calling customShaderNameResolve
  104870. */
  104871. export interface ICustomShaderNameResolveOptions {
  104872. /**
  104873. * 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
  104874. */
  104875. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104876. }
  104877. /**
  104878. * Base class for the main features of a material in Babylon.js
  104879. */
  104880. export class Material implements IAnimatable {
  104881. /**
  104882. * Returns the triangle fill mode
  104883. */
  104884. static readonly TriangleFillMode: number;
  104885. /**
  104886. * Returns the wireframe mode
  104887. */
  104888. static readonly WireFrameFillMode: number;
  104889. /**
  104890. * Returns the point fill mode
  104891. */
  104892. static readonly PointFillMode: number;
  104893. /**
  104894. * Returns the point list draw mode
  104895. */
  104896. static readonly PointListDrawMode: number;
  104897. /**
  104898. * Returns the line list draw mode
  104899. */
  104900. static readonly LineListDrawMode: number;
  104901. /**
  104902. * Returns the line loop draw mode
  104903. */
  104904. static readonly LineLoopDrawMode: number;
  104905. /**
  104906. * Returns the line strip draw mode
  104907. */
  104908. static readonly LineStripDrawMode: number;
  104909. /**
  104910. * Returns the triangle strip draw mode
  104911. */
  104912. static readonly TriangleStripDrawMode: number;
  104913. /**
  104914. * Returns the triangle fan draw mode
  104915. */
  104916. static readonly TriangleFanDrawMode: number;
  104917. /**
  104918. * Stores the clock-wise side orientation
  104919. */
  104920. static readonly ClockWiseSideOrientation: number;
  104921. /**
  104922. * Stores the counter clock-wise side orientation
  104923. */
  104924. static readonly CounterClockWiseSideOrientation: number;
  104925. /**
  104926. * The dirty texture flag value
  104927. */
  104928. static readonly TextureDirtyFlag: number;
  104929. /**
  104930. * The dirty light flag value
  104931. */
  104932. static readonly LightDirtyFlag: number;
  104933. /**
  104934. * The dirty fresnel flag value
  104935. */
  104936. static readonly FresnelDirtyFlag: number;
  104937. /**
  104938. * The dirty attribute flag value
  104939. */
  104940. static readonly AttributesDirtyFlag: number;
  104941. /**
  104942. * The dirty misc flag value
  104943. */
  104944. static readonly MiscDirtyFlag: number;
  104945. /**
  104946. * The all dirty flag value
  104947. */
  104948. static readonly AllDirtyFlag: number;
  104949. /**
  104950. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104951. */
  104952. static readonly MATERIAL_OPAQUE: number;
  104953. /**
  104954. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104955. */
  104956. static readonly MATERIAL_ALPHATEST: number;
  104957. /**
  104958. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104959. */
  104960. static readonly MATERIAL_ALPHABLEND: number;
  104961. /**
  104962. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104963. * They are also discarded below the alpha cutoff threshold to improve performances.
  104964. */
  104965. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104966. /**
  104967. * The Whiteout method is used to blend normals.
  104968. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104969. */
  104970. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104971. /**
  104972. * The Reoriented Normal Mapping method is used to blend normals.
  104973. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104974. */
  104975. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104976. /**
  104977. * Custom callback helping to override the default shader used in the material.
  104978. */
  104979. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104980. /**
  104981. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104982. */
  104983. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104984. /**
  104985. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104986. * This means that the material can keep using a previous shader while a new one is being compiled.
  104987. * This is mostly used when shader parallel compilation is supported (true by default)
  104988. */
  104989. allowShaderHotSwapping: boolean;
  104990. /**
  104991. * The ID of the material
  104992. */
  104993. id: string;
  104994. /**
  104995. * Gets or sets the unique id of the material
  104996. */
  104997. uniqueId: number;
  104998. /**
  104999. * The name of the material
  105000. */
  105001. name: string;
  105002. /**
  105003. * Gets or sets user defined metadata
  105004. */
  105005. metadata: any;
  105006. /**
  105007. * For internal use only. Please do not use.
  105008. */
  105009. reservedDataStore: any;
  105010. /**
  105011. * Specifies if the ready state should be checked on each call
  105012. */
  105013. checkReadyOnEveryCall: boolean;
  105014. /**
  105015. * Specifies if the ready state should be checked once
  105016. */
  105017. checkReadyOnlyOnce: boolean;
  105018. /**
  105019. * The state of the material
  105020. */
  105021. state: string;
  105022. /**
  105023. * If the material can be rendered to several textures with MRT extension
  105024. */
  105025. get canRenderToMRT(): boolean;
  105026. /**
  105027. * The alpha value of the material
  105028. */
  105029. protected _alpha: number;
  105030. /**
  105031. * List of inspectable custom properties (used by the Inspector)
  105032. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105033. */
  105034. inspectableCustomProperties: IInspectable[];
  105035. /**
  105036. * Sets the alpha value of the material
  105037. */
  105038. set alpha(value: number);
  105039. /**
  105040. * Gets the alpha value of the material
  105041. */
  105042. get alpha(): number;
  105043. /**
  105044. * Specifies if back face culling is enabled
  105045. */
  105046. protected _backFaceCulling: boolean;
  105047. /**
  105048. * Sets the back-face culling state
  105049. */
  105050. set backFaceCulling(value: boolean);
  105051. /**
  105052. * Gets the back-face culling state
  105053. */
  105054. get backFaceCulling(): boolean;
  105055. /**
  105056. * Stores the value for side orientation
  105057. */
  105058. sideOrientation: number;
  105059. /**
  105060. * Callback triggered when the material is compiled
  105061. */
  105062. onCompiled: Nullable<(effect: Effect) => void>;
  105063. /**
  105064. * Callback triggered when an error occurs
  105065. */
  105066. onError: Nullable<(effect: Effect, errors: string) => void>;
  105067. /**
  105068. * Callback triggered to get the render target textures
  105069. */
  105070. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105071. /**
  105072. * Gets a boolean indicating that current material needs to register RTT
  105073. */
  105074. get hasRenderTargetTextures(): boolean;
  105075. /**
  105076. * Specifies if the material should be serialized
  105077. */
  105078. doNotSerialize: boolean;
  105079. /**
  105080. * @hidden
  105081. */
  105082. _storeEffectOnSubMeshes: boolean;
  105083. /**
  105084. * Stores the animations for the material
  105085. */
  105086. animations: Nullable<Array<Animation>>;
  105087. /**
  105088. * An event triggered when the material is disposed
  105089. */
  105090. onDisposeObservable: Observable<Material>;
  105091. /**
  105092. * An observer which watches for dispose events
  105093. */
  105094. private _onDisposeObserver;
  105095. private _onUnBindObservable;
  105096. /**
  105097. * Called during a dispose event
  105098. */
  105099. set onDispose(callback: () => void);
  105100. private _onBindObservable;
  105101. /**
  105102. * An event triggered when the material is bound
  105103. */
  105104. get onBindObservable(): Observable<AbstractMesh>;
  105105. /**
  105106. * An observer which watches for bind events
  105107. */
  105108. private _onBindObserver;
  105109. /**
  105110. * Called during a bind event
  105111. */
  105112. set onBind(callback: (Mesh: AbstractMesh) => void);
  105113. /**
  105114. * An event triggered when the material is unbound
  105115. */
  105116. get onUnBindObservable(): Observable<Material>;
  105117. protected _onEffectCreatedObservable: Nullable<Observable<{
  105118. effect: Effect;
  105119. subMesh: Nullable<SubMesh>;
  105120. }>>;
  105121. /**
  105122. * An event triggered when the effect is (re)created
  105123. */
  105124. get onEffectCreatedObservable(): Observable<{
  105125. effect: Effect;
  105126. subMesh: Nullable<SubMesh>;
  105127. }>;
  105128. /**
  105129. * Stores the value of the alpha mode
  105130. */
  105131. private _alphaMode;
  105132. /**
  105133. * Sets the value of the alpha mode.
  105134. *
  105135. * | Value | Type | Description |
  105136. * | --- | --- | --- |
  105137. * | 0 | ALPHA_DISABLE | |
  105138. * | 1 | ALPHA_ADD | |
  105139. * | 2 | ALPHA_COMBINE | |
  105140. * | 3 | ALPHA_SUBTRACT | |
  105141. * | 4 | ALPHA_MULTIPLY | |
  105142. * | 5 | ALPHA_MAXIMIZED | |
  105143. * | 6 | ALPHA_ONEONE | |
  105144. * | 7 | ALPHA_PREMULTIPLIED | |
  105145. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105146. * | 9 | ALPHA_INTERPOLATE | |
  105147. * | 10 | ALPHA_SCREENMODE | |
  105148. *
  105149. */
  105150. set alphaMode(value: number);
  105151. /**
  105152. * Gets the value of the alpha mode
  105153. */
  105154. get alphaMode(): number;
  105155. /**
  105156. * Stores the state of the need depth pre-pass value
  105157. */
  105158. private _needDepthPrePass;
  105159. /**
  105160. * Sets the need depth pre-pass value
  105161. */
  105162. set needDepthPrePass(value: boolean);
  105163. /**
  105164. * Gets the depth pre-pass value
  105165. */
  105166. get needDepthPrePass(): boolean;
  105167. /**
  105168. * Specifies if depth writing should be disabled
  105169. */
  105170. disableDepthWrite: boolean;
  105171. /**
  105172. * Specifies if color writing should be disabled
  105173. */
  105174. disableColorWrite: boolean;
  105175. /**
  105176. * Specifies if depth writing should be forced
  105177. */
  105178. forceDepthWrite: boolean;
  105179. /**
  105180. * Specifies the depth function that should be used. 0 means the default engine function
  105181. */
  105182. depthFunction: number;
  105183. /**
  105184. * Specifies if there should be a separate pass for culling
  105185. */
  105186. separateCullingPass: boolean;
  105187. /**
  105188. * Stores the state specifing if fog should be enabled
  105189. */
  105190. private _fogEnabled;
  105191. /**
  105192. * Sets the state for enabling fog
  105193. */
  105194. set fogEnabled(value: boolean);
  105195. /**
  105196. * Gets the value of the fog enabled state
  105197. */
  105198. get fogEnabled(): boolean;
  105199. /**
  105200. * Stores the size of points
  105201. */
  105202. pointSize: number;
  105203. /**
  105204. * Stores the z offset value
  105205. */
  105206. zOffset: number;
  105207. get wireframe(): boolean;
  105208. /**
  105209. * Sets the state of wireframe mode
  105210. */
  105211. set wireframe(value: boolean);
  105212. /**
  105213. * Gets the value specifying if point clouds are enabled
  105214. */
  105215. get pointsCloud(): boolean;
  105216. /**
  105217. * Sets the state of point cloud mode
  105218. */
  105219. set pointsCloud(value: boolean);
  105220. /**
  105221. * Gets the material fill mode
  105222. */
  105223. get fillMode(): number;
  105224. /**
  105225. * Sets the material fill mode
  105226. */
  105227. set fillMode(value: number);
  105228. /**
  105229. * @hidden
  105230. * Stores the effects for the material
  105231. */
  105232. _effect: Nullable<Effect>;
  105233. /**
  105234. * Specifies if uniform buffers should be used
  105235. */
  105236. private _useUBO;
  105237. /**
  105238. * Stores a reference to the scene
  105239. */
  105240. private _scene;
  105241. /**
  105242. * Stores the fill mode state
  105243. */
  105244. private _fillMode;
  105245. /**
  105246. * Specifies if the depth write state should be cached
  105247. */
  105248. private _cachedDepthWriteState;
  105249. /**
  105250. * Specifies if the color write state should be cached
  105251. */
  105252. private _cachedColorWriteState;
  105253. /**
  105254. * Specifies if the depth function state should be cached
  105255. */
  105256. private _cachedDepthFunctionState;
  105257. /**
  105258. * Stores the uniform buffer
  105259. */
  105260. protected _uniformBuffer: UniformBuffer;
  105261. /** @hidden */
  105262. _indexInSceneMaterialArray: number;
  105263. /** @hidden */
  105264. meshMap: Nullable<{
  105265. [id: string]: AbstractMesh | undefined;
  105266. }>;
  105267. /**
  105268. * Creates a material instance
  105269. * @param name defines the name of the material
  105270. * @param scene defines the scene to reference
  105271. * @param doNotAdd specifies if the material should be added to the scene
  105272. */
  105273. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105274. /**
  105275. * Returns a string representation of the current material
  105276. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105277. * @returns a string with material information
  105278. */
  105279. toString(fullDetails?: boolean): string;
  105280. /**
  105281. * Gets the class name of the material
  105282. * @returns a string with the class name of the material
  105283. */
  105284. getClassName(): string;
  105285. /**
  105286. * Specifies if updates for the material been locked
  105287. */
  105288. get isFrozen(): boolean;
  105289. /**
  105290. * Locks updates for the material
  105291. */
  105292. freeze(): void;
  105293. /**
  105294. * Unlocks updates for the material
  105295. */
  105296. unfreeze(): void;
  105297. /**
  105298. * Specifies if the material is ready to be used
  105299. * @param mesh defines the mesh to check
  105300. * @param useInstances specifies if instances should be used
  105301. * @returns a boolean indicating if the material is ready to be used
  105302. */
  105303. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105304. /**
  105305. * Specifies that the submesh is ready to be used
  105306. * @param mesh defines the mesh to check
  105307. * @param subMesh defines which submesh to check
  105308. * @param useInstances specifies that instances should be used
  105309. * @returns a boolean indicating that the submesh is ready or not
  105310. */
  105311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105312. /**
  105313. * Returns the material effect
  105314. * @returns the effect associated with the material
  105315. */
  105316. getEffect(): Nullable<Effect>;
  105317. /**
  105318. * Returns the current scene
  105319. * @returns a Scene
  105320. */
  105321. getScene(): Scene;
  105322. /**
  105323. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105324. */
  105325. protected _forceAlphaTest: boolean;
  105326. /**
  105327. * The transparency mode of the material.
  105328. */
  105329. protected _transparencyMode: Nullable<number>;
  105330. /**
  105331. * Gets the current transparency mode.
  105332. */
  105333. get transparencyMode(): Nullable<number>;
  105334. /**
  105335. * Sets the transparency mode of the material.
  105336. *
  105337. * | Value | Type | Description |
  105338. * | ----- | ----------------------------------- | ----------- |
  105339. * | 0 | OPAQUE | |
  105340. * | 1 | ALPHATEST | |
  105341. * | 2 | ALPHABLEND | |
  105342. * | 3 | ALPHATESTANDBLEND | |
  105343. *
  105344. */
  105345. set transparencyMode(value: Nullable<number>);
  105346. /**
  105347. * Returns true if alpha blending should be disabled.
  105348. */
  105349. protected get _disableAlphaBlending(): boolean;
  105350. /**
  105351. * Specifies whether or not this material should be rendered in alpha blend mode.
  105352. * @returns a boolean specifying if alpha blending is needed
  105353. */
  105354. needAlphaBlending(): boolean;
  105355. /**
  105356. * Specifies if the mesh will require alpha blending
  105357. * @param mesh defines the mesh to check
  105358. * @returns a boolean specifying if alpha blending is needed for the mesh
  105359. */
  105360. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105361. /**
  105362. * Specifies whether or not this material should be rendered in alpha test mode.
  105363. * @returns a boolean specifying if an alpha test is needed.
  105364. */
  105365. needAlphaTesting(): boolean;
  105366. /**
  105367. * Specifies if material alpha testing should be turned on for the mesh
  105368. * @param mesh defines the mesh to check
  105369. */
  105370. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105371. /**
  105372. * Gets the texture used for the alpha test
  105373. * @returns the texture to use for alpha testing
  105374. */
  105375. getAlphaTestTexture(): Nullable<BaseTexture>;
  105376. /**
  105377. * Marks the material to indicate that it needs to be re-calculated
  105378. */
  105379. markDirty(): void;
  105380. /** @hidden */
  105381. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105382. /**
  105383. * Binds the material to the mesh
  105384. * @param world defines the world transformation matrix
  105385. * @param mesh defines the mesh to bind the material to
  105386. */
  105387. bind(world: Matrix, mesh?: Mesh): void;
  105388. /**
  105389. * Binds the submesh to the material
  105390. * @param world defines the world transformation matrix
  105391. * @param mesh defines the mesh containing the submesh
  105392. * @param subMesh defines the submesh to bind the material to
  105393. */
  105394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105395. /**
  105396. * Binds the world matrix to the material
  105397. * @param world defines the world transformation matrix
  105398. */
  105399. bindOnlyWorldMatrix(world: Matrix): void;
  105400. /**
  105401. * Binds the scene's uniform buffer to the effect.
  105402. * @param effect defines the effect to bind to the scene uniform buffer
  105403. * @param sceneUbo defines the uniform buffer storing scene data
  105404. */
  105405. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105406. /**
  105407. * Binds the view matrix to the effect
  105408. * @param effect defines the effect to bind the view matrix to
  105409. */
  105410. bindView(effect: Effect): void;
  105411. /**
  105412. * Binds the view projection matrix to the effect
  105413. * @param effect defines the effect to bind the view projection matrix to
  105414. */
  105415. bindViewProjection(effect: Effect): void;
  105416. /**
  105417. * Processes to execute after binding the material to a mesh
  105418. * @param mesh defines the rendered mesh
  105419. */
  105420. protected _afterBind(mesh?: Mesh): void;
  105421. /**
  105422. * Unbinds the material from the mesh
  105423. */
  105424. unbind(): void;
  105425. /**
  105426. * Gets the active textures from the material
  105427. * @returns an array of textures
  105428. */
  105429. getActiveTextures(): BaseTexture[];
  105430. /**
  105431. * Specifies if the material uses a texture
  105432. * @param texture defines the texture to check against the material
  105433. * @returns a boolean specifying if the material uses the texture
  105434. */
  105435. hasTexture(texture: BaseTexture): boolean;
  105436. /**
  105437. * Makes a duplicate of the material, and gives it a new name
  105438. * @param name defines the new name for the duplicated material
  105439. * @returns the cloned material
  105440. */
  105441. clone(name: string): Nullable<Material>;
  105442. /**
  105443. * Gets the meshes bound to the material
  105444. * @returns an array of meshes bound to the material
  105445. */
  105446. getBindedMeshes(): AbstractMesh[];
  105447. /**
  105448. * Force shader compilation
  105449. * @param mesh defines the mesh associated with this material
  105450. * @param onCompiled defines a function to execute once the material is compiled
  105451. * @param options defines the options to configure the compilation
  105452. * @param onError defines a function to execute if the material fails compiling
  105453. */
  105454. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105455. /**
  105456. * Force shader compilation
  105457. * @param mesh defines the mesh that will use this material
  105458. * @param options defines additional options for compiling the shaders
  105459. * @returns a promise that resolves when the compilation completes
  105460. */
  105461. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105462. private static readonly _AllDirtyCallBack;
  105463. private static readonly _ImageProcessingDirtyCallBack;
  105464. private static readonly _TextureDirtyCallBack;
  105465. private static readonly _FresnelDirtyCallBack;
  105466. private static readonly _MiscDirtyCallBack;
  105467. private static readonly _LightsDirtyCallBack;
  105468. private static readonly _AttributeDirtyCallBack;
  105469. private static _FresnelAndMiscDirtyCallBack;
  105470. private static _TextureAndMiscDirtyCallBack;
  105471. private static readonly _DirtyCallbackArray;
  105472. private static readonly _RunDirtyCallBacks;
  105473. /**
  105474. * Marks a define in the material to indicate that it needs to be re-computed
  105475. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105476. */
  105477. markAsDirty(flag: number): void;
  105478. /**
  105479. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105480. * @param func defines a function which checks material defines against the submeshes
  105481. */
  105482. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105483. /**
  105484. * Indicates that the scene should check if the rendering now needs a prepass
  105485. */
  105486. protected _markScenePrePassDirty(): void;
  105487. /**
  105488. * Indicates that we need to re-calculated for all submeshes
  105489. */
  105490. protected _markAllSubMeshesAsAllDirty(): void;
  105491. /**
  105492. * Indicates that image processing needs to be re-calculated for all submeshes
  105493. */
  105494. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105495. /**
  105496. * Indicates that textures need to be re-calculated for all submeshes
  105497. */
  105498. protected _markAllSubMeshesAsTexturesDirty(): void;
  105499. /**
  105500. * Indicates that fresnel needs to be re-calculated for all submeshes
  105501. */
  105502. protected _markAllSubMeshesAsFresnelDirty(): void;
  105503. /**
  105504. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105505. */
  105506. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105507. /**
  105508. * Indicates that lights need to be re-calculated for all submeshes
  105509. */
  105510. protected _markAllSubMeshesAsLightsDirty(): void;
  105511. /**
  105512. * Indicates that attributes need to be re-calculated for all submeshes
  105513. */
  105514. protected _markAllSubMeshesAsAttributesDirty(): void;
  105515. /**
  105516. * Indicates that misc needs to be re-calculated for all submeshes
  105517. */
  105518. protected _markAllSubMeshesAsMiscDirty(): void;
  105519. /**
  105520. * Indicates that textures and misc need to be re-calculated for all submeshes
  105521. */
  105522. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105523. /**
  105524. * Sets the required values to the prepass renderer.
  105525. * @param prePassRenderer defines the prepass renderer to setup.
  105526. * @returns true if the pre pass is needed.
  105527. */
  105528. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105529. /**
  105530. * Disposes the material
  105531. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105532. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105533. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105534. */
  105535. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105536. /** @hidden */
  105537. private releaseVertexArrayObject;
  105538. /**
  105539. * Serializes this material
  105540. * @returns the serialized material object
  105541. */
  105542. serialize(): any;
  105543. /**
  105544. * Creates a material from parsed material data
  105545. * @param parsedMaterial defines parsed material data
  105546. * @param scene defines the hosting scene
  105547. * @param rootUrl defines the root URL to use to load textures
  105548. * @returns a new material
  105549. */
  105550. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105551. }
  105552. }
  105553. declare module BABYLON {
  105554. /**
  105555. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105556. * separate meshes. This can be use to improve performances.
  105557. * @see https://doc.babylonjs.com/how_to/multi_materials
  105558. */
  105559. export class MultiMaterial extends Material {
  105560. private _subMaterials;
  105561. /**
  105562. * Gets or Sets the list of Materials used within the multi material.
  105563. * They need to be ordered according to the submeshes order in the associated mesh
  105564. */
  105565. get subMaterials(): Nullable<Material>[];
  105566. set subMaterials(value: Nullable<Material>[]);
  105567. /**
  105568. * Function used to align with Node.getChildren()
  105569. * @returns the list of Materials used within the multi material
  105570. */
  105571. getChildren(): Nullable<Material>[];
  105572. /**
  105573. * Instantiates a new Multi Material
  105574. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105575. * separate meshes. This can be use to improve performances.
  105576. * @see https://doc.babylonjs.com/how_to/multi_materials
  105577. * @param name Define the name in the scene
  105578. * @param scene Define the scene the material belongs to
  105579. */
  105580. constructor(name: string, scene: Scene);
  105581. private _hookArray;
  105582. /**
  105583. * Get one of the submaterial by its index in the submaterials array
  105584. * @param index The index to look the sub material at
  105585. * @returns The Material if the index has been defined
  105586. */
  105587. getSubMaterial(index: number): Nullable<Material>;
  105588. /**
  105589. * Get the list of active textures for the whole sub materials list.
  105590. * @returns All the textures that will be used during the rendering
  105591. */
  105592. getActiveTextures(): BaseTexture[];
  105593. /**
  105594. * Gets the current class name of the material e.g. "MultiMaterial"
  105595. * Mainly use in serialization.
  105596. * @returns the class name
  105597. */
  105598. getClassName(): string;
  105599. /**
  105600. * Checks if the material is ready to render the requested sub mesh
  105601. * @param mesh Define the mesh the submesh belongs to
  105602. * @param subMesh Define the sub mesh to look readyness for
  105603. * @param useInstances Define whether or not the material is used with instances
  105604. * @returns true if ready, otherwise false
  105605. */
  105606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105607. /**
  105608. * Clones the current material and its related sub materials
  105609. * @param name Define the name of the newly cloned material
  105610. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105611. * @returns the cloned material
  105612. */
  105613. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105614. /**
  105615. * Serializes the materials into a JSON representation.
  105616. * @returns the JSON representation
  105617. */
  105618. serialize(): any;
  105619. /**
  105620. * Dispose the material and release its associated resources
  105621. * @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)
  105622. * @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)
  105623. * @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)
  105624. */
  105625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105626. /**
  105627. * Creates a MultiMaterial from parsed MultiMaterial data.
  105628. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105629. * @param scene defines the hosting scene
  105630. * @returns a new MultiMaterial
  105631. */
  105632. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105633. }
  105634. }
  105635. declare module BABYLON {
  105636. /**
  105637. * Defines a subdivision inside a mesh
  105638. */
  105639. export class SubMesh implements ICullable {
  105640. /** the material index to use */
  105641. materialIndex: number;
  105642. /** vertex index start */
  105643. verticesStart: number;
  105644. /** vertices count */
  105645. verticesCount: number;
  105646. /** index start */
  105647. indexStart: number;
  105648. /** indices count */
  105649. indexCount: number;
  105650. /** @hidden */
  105651. _materialDefines: Nullable<MaterialDefines>;
  105652. /** @hidden */
  105653. _materialEffect: Nullable<Effect>;
  105654. /** @hidden */
  105655. _effectOverride: Nullable<Effect>;
  105656. /**
  105657. * Gets material defines used by the effect associated to the sub mesh
  105658. */
  105659. get materialDefines(): Nullable<MaterialDefines>;
  105660. /**
  105661. * Sets material defines used by the effect associated to the sub mesh
  105662. */
  105663. set materialDefines(defines: Nullable<MaterialDefines>);
  105664. /**
  105665. * Gets associated effect
  105666. */
  105667. get effect(): Nullable<Effect>;
  105668. /**
  105669. * Sets associated effect (effect used to render this submesh)
  105670. * @param effect defines the effect to associate with
  105671. * @param defines defines the set of defines used to compile this effect
  105672. */
  105673. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105674. /** @hidden */
  105675. _linesIndexCount: number;
  105676. private _mesh;
  105677. private _renderingMesh;
  105678. private _boundingInfo;
  105679. private _linesIndexBuffer;
  105680. /** @hidden */
  105681. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105682. /** @hidden */
  105683. _trianglePlanes: Plane[];
  105684. /** @hidden */
  105685. _lastColliderTransformMatrix: Nullable<Matrix>;
  105686. /** @hidden */
  105687. _renderId: number;
  105688. /** @hidden */
  105689. _alphaIndex: number;
  105690. /** @hidden */
  105691. _distanceToCamera: number;
  105692. /** @hidden */
  105693. _id: number;
  105694. private _currentMaterial;
  105695. /**
  105696. * Add a new submesh to a mesh
  105697. * @param materialIndex defines the material index to use
  105698. * @param verticesStart defines vertex index start
  105699. * @param verticesCount defines vertices count
  105700. * @param indexStart defines index start
  105701. * @param indexCount defines indices count
  105702. * @param mesh defines the parent mesh
  105703. * @param renderingMesh defines an optional rendering mesh
  105704. * @param createBoundingBox defines if bounding box should be created for this submesh
  105705. * @returns the new submesh
  105706. */
  105707. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105708. /**
  105709. * Creates a new submesh
  105710. * @param materialIndex defines the material index to use
  105711. * @param verticesStart defines vertex index start
  105712. * @param verticesCount defines vertices count
  105713. * @param indexStart defines index start
  105714. * @param indexCount defines indices count
  105715. * @param mesh defines the parent mesh
  105716. * @param renderingMesh defines an optional rendering mesh
  105717. * @param createBoundingBox defines if bounding box should be created for this submesh
  105718. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105719. */
  105720. constructor(
  105721. /** the material index to use */
  105722. materialIndex: number,
  105723. /** vertex index start */
  105724. verticesStart: number,
  105725. /** vertices count */
  105726. verticesCount: number,
  105727. /** index start */
  105728. indexStart: number,
  105729. /** indices count */
  105730. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105731. /**
  105732. * Returns true if this submesh covers the entire parent mesh
  105733. * @ignorenaming
  105734. */
  105735. get IsGlobal(): boolean;
  105736. /**
  105737. * Returns the submesh BoudingInfo object
  105738. * @returns current bounding info (or mesh's one if the submesh is global)
  105739. */
  105740. getBoundingInfo(): BoundingInfo;
  105741. /**
  105742. * Sets the submesh BoundingInfo
  105743. * @param boundingInfo defines the new bounding info to use
  105744. * @returns the SubMesh
  105745. */
  105746. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105747. /**
  105748. * Returns the mesh of the current submesh
  105749. * @return the parent mesh
  105750. */
  105751. getMesh(): AbstractMesh;
  105752. /**
  105753. * Returns the rendering mesh of the submesh
  105754. * @returns the rendering mesh (could be different from parent mesh)
  105755. */
  105756. getRenderingMesh(): Mesh;
  105757. /**
  105758. * Returns the replacement mesh of the submesh
  105759. * @returns the replacement mesh (could be different from parent mesh)
  105760. */
  105761. getReplacementMesh(): Nullable<AbstractMesh>;
  105762. /**
  105763. * Returns the effective mesh of the submesh
  105764. * @returns the effective mesh (could be different from parent mesh)
  105765. */
  105766. getEffectiveMesh(): AbstractMesh;
  105767. /**
  105768. * Returns the submesh material
  105769. * @returns null or the current material
  105770. */
  105771. getMaterial(): Nullable<Material>;
  105772. private _IsMultiMaterial;
  105773. /**
  105774. * Sets a new updated BoundingInfo object to the submesh
  105775. * @param data defines an optional position array to use to determine the bounding info
  105776. * @returns the SubMesh
  105777. */
  105778. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105779. /** @hidden */
  105780. _checkCollision(collider: Collider): boolean;
  105781. /**
  105782. * Updates the submesh BoundingInfo
  105783. * @param world defines the world matrix to use to update the bounding info
  105784. * @returns the submesh
  105785. */
  105786. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105787. /**
  105788. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105789. * @param frustumPlanes defines the frustum planes
  105790. * @returns true if the submesh is intersecting with the frustum
  105791. */
  105792. isInFrustum(frustumPlanes: Plane[]): boolean;
  105793. /**
  105794. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105795. * @param frustumPlanes defines the frustum planes
  105796. * @returns true if the submesh is inside the frustum
  105797. */
  105798. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105799. /**
  105800. * Renders the submesh
  105801. * @param enableAlphaMode defines if alpha needs to be used
  105802. * @returns the submesh
  105803. */
  105804. render(enableAlphaMode: boolean): SubMesh;
  105805. /**
  105806. * @hidden
  105807. */
  105808. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105809. /**
  105810. * Checks if the submesh intersects with a ray
  105811. * @param ray defines the ray to test
  105812. * @returns true is the passed ray intersects the submesh bounding box
  105813. */
  105814. canIntersects(ray: Ray): boolean;
  105815. /**
  105816. * Intersects current submesh with a ray
  105817. * @param ray defines the ray to test
  105818. * @param positions defines mesh's positions array
  105819. * @param indices defines mesh's indices array
  105820. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105822. * @returns intersection info or null if no intersection
  105823. */
  105824. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105825. /** @hidden */
  105826. private _intersectLines;
  105827. /** @hidden */
  105828. private _intersectUnIndexedLines;
  105829. /** @hidden */
  105830. private _intersectTriangles;
  105831. /** @hidden */
  105832. private _intersectUnIndexedTriangles;
  105833. /** @hidden */
  105834. _rebuild(): void;
  105835. /**
  105836. * Creates a new submesh from the passed mesh
  105837. * @param newMesh defines the new hosting mesh
  105838. * @param newRenderingMesh defines an optional rendering mesh
  105839. * @returns the new submesh
  105840. */
  105841. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105842. /**
  105843. * Release associated resources
  105844. */
  105845. dispose(): void;
  105846. /**
  105847. * Gets the class name
  105848. * @returns the string "SubMesh".
  105849. */
  105850. getClassName(): string;
  105851. /**
  105852. * Creates a new submesh from indices data
  105853. * @param materialIndex the index of the main mesh material
  105854. * @param startIndex the index where to start the copy in the mesh indices array
  105855. * @param indexCount the number of indices to copy then from the startIndex
  105856. * @param mesh the main mesh to create the submesh from
  105857. * @param renderingMesh the optional rendering mesh
  105858. * @returns a new submesh
  105859. */
  105860. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105861. }
  105862. }
  105863. declare module BABYLON {
  105864. /**
  105865. * Class used to represent data loading progression
  105866. */
  105867. export class SceneLoaderFlags {
  105868. private static _ForceFullSceneLoadingForIncremental;
  105869. private static _ShowLoadingScreen;
  105870. private static _CleanBoneMatrixWeights;
  105871. private static _loggingLevel;
  105872. /**
  105873. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105874. */
  105875. static get ForceFullSceneLoadingForIncremental(): boolean;
  105876. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105877. /**
  105878. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105879. */
  105880. static get ShowLoadingScreen(): boolean;
  105881. static set ShowLoadingScreen(value: boolean);
  105882. /**
  105883. * Defines the current logging level (while loading the scene)
  105884. * @ignorenaming
  105885. */
  105886. static get loggingLevel(): number;
  105887. static set loggingLevel(value: number);
  105888. /**
  105889. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105890. */
  105891. static get CleanBoneMatrixWeights(): boolean;
  105892. static set CleanBoneMatrixWeights(value: boolean);
  105893. }
  105894. }
  105895. declare module BABYLON {
  105896. /**
  105897. * Class used to store geometry data (vertex buffers + index buffer)
  105898. */
  105899. export class Geometry implements IGetSetVerticesData {
  105900. /**
  105901. * Gets or sets the ID of the geometry
  105902. */
  105903. id: string;
  105904. /**
  105905. * Gets or sets the unique ID of the geometry
  105906. */
  105907. uniqueId: number;
  105908. /**
  105909. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105910. */
  105911. delayLoadState: number;
  105912. /**
  105913. * Gets the file containing the data to load when running in delay load state
  105914. */
  105915. delayLoadingFile: Nullable<string>;
  105916. /**
  105917. * Callback called when the geometry is updated
  105918. */
  105919. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105920. private _scene;
  105921. private _engine;
  105922. private _meshes;
  105923. private _totalVertices;
  105924. /** @hidden */
  105925. _indices: IndicesArray;
  105926. /** @hidden */
  105927. _vertexBuffers: {
  105928. [key: string]: VertexBuffer;
  105929. };
  105930. private _isDisposed;
  105931. private _extend;
  105932. private _boundingBias;
  105933. /** @hidden */
  105934. _delayInfo: Array<string>;
  105935. private _indexBuffer;
  105936. private _indexBufferIsUpdatable;
  105937. /** @hidden */
  105938. _boundingInfo: Nullable<BoundingInfo>;
  105939. /** @hidden */
  105940. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105941. /** @hidden */
  105942. _softwareSkinningFrameId: number;
  105943. private _vertexArrayObjects;
  105944. private _updatable;
  105945. /** @hidden */
  105946. _positions: Nullable<Vector3[]>;
  105947. /**
  105948. * 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
  105949. */
  105950. get boundingBias(): Vector2;
  105951. /**
  105952. * 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
  105953. */
  105954. set boundingBias(value: Vector2);
  105955. /**
  105956. * Static function used to attach a new empty geometry to a mesh
  105957. * @param mesh defines the mesh to attach the geometry to
  105958. * @returns the new Geometry
  105959. */
  105960. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105961. /** Get the list of meshes using this geometry */
  105962. get meshes(): Mesh[];
  105963. /**
  105964. * 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
  105965. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105966. */
  105967. useBoundingInfoFromGeometry: boolean;
  105968. /**
  105969. * Creates a new geometry
  105970. * @param id defines the unique ID
  105971. * @param scene defines the hosting scene
  105972. * @param vertexData defines the VertexData used to get geometry data
  105973. * @param updatable defines if geometry must be updatable (false by default)
  105974. * @param mesh defines the mesh that will be associated with the geometry
  105975. */
  105976. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105977. /**
  105978. * Gets the current extend of the geometry
  105979. */
  105980. get extend(): {
  105981. minimum: Vector3;
  105982. maximum: Vector3;
  105983. };
  105984. /**
  105985. * Gets the hosting scene
  105986. * @returns the hosting Scene
  105987. */
  105988. getScene(): Scene;
  105989. /**
  105990. * Gets the hosting engine
  105991. * @returns the hosting Engine
  105992. */
  105993. getEngine(): Engine;
  105994. /**
  105995. * Defines if the geometry is ready to use
  105996. * @returns true if the geometry is ready to be used
  105997. */
  105998. isReady(): boolean;
  105999. /**
  106000. * Gets a value indicating that the geometry should not be serialized
  106001. */
  106002. get doNotSerialize(): boolean;
  106003. /** @hidden */
  106004. _rebuild(): void;
  106005. /**
  106006. * Affects all geometry data in one call
  106007. * @param vertexData defines the geometry data
  106008. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106009. */
  106010. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106011. /**
  106012. * Set specific vertex data
  106013. * @param kind defines the data kind (Position, normal, etc...)
  106014. * @param data defines the vertex data to use
  106015. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106016. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106017. */
  106018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106019. /**
  106020. * Removes a specific vertex data
  106021. * @param kind defines the data kind (Position, normal, etc...)
  106022. */
  106023. removeVerticesData(kind: string): void;
  106024. /**
  106025. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106026. * @param buffer defines the vertex buffer to use
  106027. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106028. */
  106029. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106030. /**
  106031. * Update a specific vertex buffer
  106032. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106033. * It will do nothing if the buffer is not updatable
  106034. * @param kind defines the data kind (Position, normal, etc...)
  106035. * @param data defines the data to use
  106036. * @param offset defines the offset in the target buffer where to store the data
  106037. * @param useBytes set to true if the offset is in bytes
  106038. */
  106039. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106040. /**
  106041. * Update a specific vertex buffer
  106042. * This function will create a new buffer if the current one is not updatable
  106043. * @param kind defines the data kind (Position, normal, etc...)
  106044. * @param data defines the data to use
  106045. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106046. */
  106047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106048. private _updateBoundingInfo;
  106049. /** @hidden */
  106050. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106051. /**
  106052. * Gets total number of vertices
  106053. * @returns the total number of vertices
  106054. */
  106055. getTotalVertices(): number;
  106056. /**
  106057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106058. * @param kind defines the data kind (Position, normal, etc...)
  106059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106061. * @returns a float array containing vertex data
  106062. */
  106063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106064. /**
  106065. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106066. * @param kind defines the data kind (Position, normal, etc...)
  106067. * @returns true if the vertex buffer with the specified kind is updatable
  106068. */
  106069. isVertexBufferUpdatable(kind: string): boolean;
  106070. /**
  106071. * Gets a specific vertex buffer
  106072. * @param kind defines the data kind (Position, normal, etc...)
  106073. * @returns a VertexBuffer
  106074. */
  106075. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106076. /**
  106077. * Returns all vertex buffers
  106078. * @return an object holding all vertex buffers indexed by kind
  106079. */
  106080. getVertexBuffers(): Nullable<{
  106081. [key: string]: VertexBuffer;
  106082. }>;
  106083. /**
  106084. * Gets a boolean indicating if specific vertex buffer is present
  106085. * @param kind defines the data kind (Position, normal, etc...)
  106086. * @returns true if data is present
  106087. */
  106088. isVerticesDataPresent(kind: string): boolean;
  106089. /**
  106090. * Gets a list of all attached data kinds (Position, normal, etc...)
  106091. * @returns a list of string containing all kinds
  106092. */
  106093. getVerticesDataKinds(): string[];
  106094. /**
  106095. * Update index buffer
  106096. * @param indices defines the indices to store in the index buffer
  106097. * @param offset defines the offset in the target buffer where to store the data
  106098. * @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)
  106099. */
  106100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106101. /**
  106102. * Creates a new index buffer
  106103. * @param indices defines the indices to store in the index buffer
  106104. * @param totalVertices defines the total number of vertices (could be null)
  106105. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106106. */
  106107. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106108. /**
  106109. * Return the total number of indices
  106110. * @returns the total number of indices
  106111. */
  106112. getTotalIndices(): number;
  106113. /**
  106114. * Gets the index buffer array
  106115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106117. * @returns the index buffer array
  106118. */
  106119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106120. /**
  106121. * Gets the index buffer
  106122. * @return the index buffer
  106123. */
  106124. getIndexBuffer(): Nullable<DataBuffer>;
  106125. /** @hidden */
  106126. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106127. /**
  106128. * Release the associated resources for a specific mesh
  106129. * @param mesh defines the source mesh
  106130. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106131. */
  106132. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106133. /**
  106134. * Apply current geometry to a given mesh
  106135. * @param mesh defines the mesh to apply geometry to
  106136. */
  106137. applyToMesh(mesh: Mesh): void;
  106138. private _updateExtend;
  106139. private _applyToMesh;
  106140. private notifyUpdate;
  106141. /**
  106142. * Load the geometry if it was flagged as delay loaded
  106143. * @param scene defines the hosting scene
  106144. * @param onLoaded defines a callback called when the geometry is loaded
  106145. */
  106146. load(scene: Scene, onLoaded?: () => void): void;
  106147. private _queueLoad;
  106148. /**
  106149. * Invert the geometry to move from a right handed system to a left handed one.
  106150. */
  106151. toLeftHanded(): void;
  106152. /** @hidden */
  106153. _resetPointsArrayCache(): void;
  106154. /** @hidden */
  106155. _generatePointsArray(): boolean;
  106156. /**
  106157. * Gets a value indicating if the geometry is disposed
  106158. * @returns true if the geometry was disposed
  106159. */
  106160. isDisposed(): boolean;
  106161. private _disposeVertexArrayObjects;
  106162. /**
  106163. * Free all associated resources
  106164. */
  106165. dispose(): void;
  106166. /**
  106167. * Clone the current geometry into a new geometry
  106168. * @param id defines the unique ID of the new geometry
  106169. * @returns a new geometry object
  106170. */
  106171. copy(id: string): Geometry;
  106172. /**
  106173. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106174. * @return a JSON representation of the current geometry data (without the vertices data)
  106175. */
  106176. serialize(): any;
  106177. private toNumberArray;
  106178. /**
  106179. * Serialize all vertices data into a JSON oject
  106180. * @returns a JSON representation of the current geometry data
  106181. */
  106182. serializeVerticeData(): any;
  106183. /**
  106184. * Extracts a clone of a mesh geometry
  106185. * @param mesh defines the source mesh
  106186. * @param id defines the unique ID of the new geometry object
  106187. * @returns the new geometry object
  106188. */
  106189. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106190. /**
  106191. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106192. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106193. * Be aware Math.random() could cause collisions, but:
  106194. * "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"
  106195. * @returns a string containing a new GUID
  106196. */
  106197. static RandomId(): string;
  106198. /** @hidden */
  106199. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106200. private static _CleanMatricesWeights;
  106201. /**
  106202. * Create a new geometry from persisted data (Using .babylon file format)
  106203. * @param parsedVertexData defines the persisted data
  106204. * @param scene defines the hosting scene
  106205. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106206. * @returns the new geometry object
  106207. */
  106208. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106209. }
  106210. }
  106211. declare module BABYLON {
  106212. /**
  106213. * Define an interface for all classes that will get and set the data on vertices
  106214. */
  106215. export interface IGetSetVerticesData {
  106216. /**
  106217. * Gets a boolean indicating if specific vertex data is present
  106218. * @param kind defines the vertex data kind to use
  106219. * @returns true is data kind is present
  106220. */
  106221. isVerticesDataPresent(kind: string): boolean;
  106222. /**
  106223. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106224. * @param kind defines the data kind (Position, normal, etc...)
  106225. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106226. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106227. * @returns a float array containing vertex data
  106228. */
  106229. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106230. /**
  106231. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106232. * @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.
  106233. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106234. * @returns the indices array or an empty array if the mesh has no geometry
  106235. */
  106236. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106237. /**
  106238. * Set specific vertex data
  106239. * @param kind defines the data kind (Position, normal, etc...)
  106240. * @param data defines the vertex data to use
  106241. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106242. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106243. */
  106244. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106245. /**
  106246. * Update a specific associated vertex buffer
  106247. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106248. * - VertexBuffer.PositionKind
  106249. * - VertexBuffer.UVKind
  106250. * - VertexBuffer.UV2Kind
  106251. * - VertexBuffer.UV3Kind
  106252. * - VertexBuffer.UV4Kind
  106253. * - VertexBuffer.UV5Kind
  106254. * - VertexBuffer.UV6Kind
  106255. * - VertexBuffer.ColorKind
  106256. * - VertexBuffer.MatricesIndicesKind
  106257. * - VertexBuffer.MatricesIndicesExtraKind
  106258. * - VertexBuffer.MatricesWeightsKind
  106259. * - VertexBuffer.MatricesWeightsExtraKind
  106260. * @param data defines the data source
  106261. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106262. * @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)
  106263. */
  106264. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106265. /**
  106266. * Creates a new index buffer
  106267. * @param indices defines the indices to store in the index buffer
  106268. * @param totalVertices defines the total number of vertices (could be null)
  106269. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106270. */
  106271. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106272. }
  106273. /**
  106274. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106275. */
  106276. export class VertexData {
  106277. /**
  106278. * Mesh side orientation : usually the external or front surface
  106279. */
  106280. static readonly FRONTSIDE: number;
  106281. /**
  106282. * Mesh side orientation : usually the internal or back surface
  106283. */
  106284. static readonly BACKSIDE: number;
  106285. /**
  106286. * Mesh side orientation : both internal and external or front and back surfaces
  106287. */
  106288. static readonly DOUBLESIDE: number;
  106289. /**
  106290. * Mesh side orientation : by default, `FRONTSIDE`
  106291. */
  106292. static readonly DEFAULTSIDE: number;
  106293. /**
  106294. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106295. */
  106296. positions: Nullable<FloatArray>;
  106297. /**
  106298. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106299. */
  106300. normals: Nullable<FloatArray>;
  106301. /**
  106302. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106303. */
  106304. tangents: Nullable<FloatArray>;
  106305. /**
  106306. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106307. */
  106308. uvs: Nullable<FloatArray>;
  106309. /**
  106310. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106311. */
  106312. uvs2: Nullable<FloatArray>;
  106313. /**
  106314. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106315. */
  106316. uvs3: Nullable<FloatArray>;
  106317. /**
  106318. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106319. */
  106320. uvs4: Nullable<FloatArray>;
  106321. /**
  106322. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106323. */
  106324. uvs5: Nullable<FloatArray>;
  106325. /**
  106326. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106327. */
  106328. uvs6: Nullable<FloatArray>;
  106329. /**
  106330. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106331. */
  106332. colors: Nullable<FloatArray>;
  106333. /**
  106334. * 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).
  106335. */
  106336. matricesIndices: Nullable<FloatArray>;
  106337. /**
  106338. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106339. */
  106340. matricesWeights: Nullable<FloatArray>;
  106341. /**
  106342. * An array extending the number of possible indices
  106343. */
  106344. matricesIndicesExtra: Nullable<FloatArray>;
  106345. /**
  106346. * An array extending the number of possible weights when the number of indices is extended
  106347. */
  106348. matricesWeightsExtra: Nullable<FloatArray>;
  106349. /**
  106350. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106351. */
  106352. indices: Nullable<IndicesArray>;
  106353. /**
  106354. * Uses the passed data array to set the set the values for the specified kind of data
  106355. * @param data a linear array of floating numbers
  106356. * @param kind the type of data that is being set, eg positions, colors etc
  106357. */
  106358. set(data: FloatArray, kind: string): void;
  106359. /**
  106360. * Associates the vertexData to the passed Mesh.
  106361. * Sets it as updatable or not (default `false`)
  106362. * @param mesh the mesh the vertexData is applied to
  106363. * @param updatable when used and having the value true allows new data to update the vertexData
  106364. * @returns the VertexData
  106365. */
  106366. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106367. /**
  106368. * Associates the vertexData to the passed Geometry.
  106369. * Sets it as updatable or not (default `false`)
  106370. * @param geometry the geometry the vertexData is applied to
  106371. * @param updatable when used and having the value true allows new data to update the vertexData
  106372. * @returns VertexData
  106373. */
  106374. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106375. /**
  106376. * Updates the associated mesh
  106377. * @param mesh the mesh to be updated
  106378. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106379. * @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
  106380. * @returns VertexData
  106381. */
  106382. updateMesh(mesh: Mesh): VertexData;
  106383. /**
  106384. * Updates the associated geometry
  106385. * @param geometry the geometry to be updated
  106386. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106387. * @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
  106388. * @returns VertexData.
  106389. */
  106390. updateGeometry(geometry: Geometry): VertexData;
  106391. private _applyTo;
  106392. private _update;
  106393. /**
  106394. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106395. * @param matrix the transforming matrix
  106396. * @returns the VertexData
  106397. */
  106398. transform(matrix: Matrix): VertexData;
  106399. /**
  106400. * Merges the passed VertexData into the current one
  106401. * @param other the VertexData to be merged into the current one
  106402. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106403. * @returns the modified VertexData
  106404. */
  106405. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106406. private _mergeElement;
  106407. private _validate;
  106408. /**
  106409. * Serializes the VertexData
  106410. * @returns a serialized object
  106411. */
  106412. serialize(): any;
  106413. /**
  106414. * Extracts the vertexData from a mesh
  106415. * @param mesh the mesh from which to extract the VertexData
  106416. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106417. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106418. * @returns the object VertexData associated to the passed mesh
  106419. */
  106420. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106421. /**
  106422. * Extracts the vertexData from the geometry
  106423. * @param geometry the geometry from which to extract the VertexData
  106424. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106425. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106426. * @returns the object VertexData associated to the passed mesh
  106427. */
  106428. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106429. private static _ExtractFrom;
  106430. /**
  106431. * Creates the VertexData for a Ribbon
  106432. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106433. * * pathArray array of paths, each of which an array of successive Vector3
  106434. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106435. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106436. * * 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
  106437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106438. * * 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)
  106439. * * 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)
  106440. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106441. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106442. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106443. * @returns the VertexData of the ribbon
  106444. */
  106445. static CreateRibbon(options: {
  106446. pathArray: Vector3[][];
  106447. closeArray?: boolean;
  106448. closePath?: boolean;
  106449. offset?: number;
  106450. sideOrientation?: number;
  106451. frontUVs?: Vector4;
  106452. backUVs?: Vector4;
  106453. invertUV?: boolean;
  106454. uvs?: Vector2[];
  106455. colors?: Color4[];
  106456. }): VertexData;
  106457. /**
  106458. * Creates the VertexData for a box
  106459. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106460. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106461. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106462. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106463. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106464. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106465. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106467. * * 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)
  106468. * * 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)
  106469. * @returns the VertexData of the box
  106470. */
  106471. static CreateBox(options: {
  106472. size?: number;
  106473. width?: number;
  106474. height?: number;
  106475. depth?: number;
  106476. faceUV?: Vector4[];
  106477. faceColors?: Color4[];
  106478. sideOrientation?: number;
  106479. frontUVs?: Vector4;
  106480. backUVs?: Vector4;
  106481. }): VertexData;
  106482. /**
  106483. * Creates the VertexData for a tiled box
  106484. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106485. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106486. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106487. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106489. * @returns the VertexData of the box
  106490. */
  106491. static CreateTiledBox(options: {
  106492. pattern?: number;
  106493. width?: number;
  106494. height?: number;
  106495. depth?: number;
  106496. tileSize?: number;
  106497. tileWidth?: number;
  106498. tileHeight?: number;
  106499. alignHorizontal?: number;
  106500. alignVertical?: number;
  106501. faceUV?: Vector4[];
  106502. faceColors?: Color4[];
  106503. sideOrientation?: number;
  106504. }): VertexData;
  106505. /**
  106506. * Creates the VertexData for a tiled plane
  106507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106508. * * pattern a limited pattern arrangement depending on the number
  106509. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106510. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106511. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106513. * * 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)
  106514. * * 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)
  106515. * @returns the VertexData of the tiled plane
  106516. */
  106517. static CreateTiledPlane(options: {
  106518. pattern?: number;
  106519. tileSize?: number;
  106520. tileWidth?: number;
  106521. tileHeight?: number;
  106522. size?: number;
  106523. width?: number;
  106524. height?: number;
  106525. alignHorizontal?: number;
  106526. alignVertical?: number;
  106527. sideOrientation?: number;
  106528. frontUVs?: Vector4;
  106529. backUVs?: Vector4;
  106530. }): VertexData;
  106531. /**
  106532. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106533. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106534. * * segments sets the number of horizontal strips optional, default 32
  106535. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106536. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106537. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106538. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106539. * * 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
  106540. * * 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
  106541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106542. * * 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)
  106543. * * 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)
  106544. * @returns the VertexData of the ellipsoid
  106545. */
  106546. static CreateSphere(options: {
  106547. segments?: number;
  106548. diameter?: number;
  106549. diameterX?: number;
  106550. diameterY?: number;
  106551. diameterZ?: number;
  106552. arc?: number;
  106553. slice?: number;
  106554. sideOrientation?: number;
  106555. frontUVs?: Vector4;
  106556. backUVs?: Vector4;
  106557. }): VertexData;
  106558. /**
  106559. * Creates the VertexData for a cylinder, cone or prism
  106560. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106561. * * height sets the height (y direction) of the cylinder, optional, default 2
  106562. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106563. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106564. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106565. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106566. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106567. * * 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
  106568. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106569. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106570. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106571. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106573. * * 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)
  106574. * * 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)
  106575. * @returns the VertexData of the cylinder, cone or prism
  106576. */
  106577. static CreateCylinder(options: {
  106578. height?: number;
  106579. diameterTop?: number;
  106580. diameterBottom?: number;
  106581. diameter?: number;
  106582. tessellation?: number;
  106583. subdivisions?: number;
  106584. arc?: number;
  106585. faceColors?: Color4[];
  106586. faceUV?: Vector4[];
  106587. hasRings?: boolean;
  106588. enclose?: boolean;
  106589. sideOrientation?: number;
  106590. frontUVs?: Vector4;
  106591. backUVs?: Vector4;
  106592. }): VertexData;
  106593. /**
  106594. * Creates the VertexData for a torus
  106595. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106596. * * diameter the diameter of the torus, optional default 1
  106597. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106598. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106600. * * 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)
  106601. * * 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)
  106602. * @returns the VertexData of the torus
  106603. */
  106604. static CreateTorus(options: {
  106605. diameter?: number;
  106606. thickness?: number;
  106607. tessellation?: number;
  106608. sideOrientation?: number;
  106609. frontUVs?: Vector4;
  106610. backUVs?: Vector4;
  106611. }): VertexData;
  106612. /**
  106613. * Creates the VertexData of the LineSystem
  106614. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106615. * - lines an array of lines, each line being an array of successive Vector3
  106616. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106617. * @returns the VertexData of the LineSystem
  106618. */
  106619. static CreateLineSystem(options: {
  106620. lines: Vector3[][];
  106621. colors?: Nullable<Color4[][]>;
  106622. }): VertexData;
  106623. /**
  106624. * Create the VertexData for a DashedLines
  106625. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106626. * - points an array successive Vector3
  106627. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106628. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106629. * - dashNb the intended total number of dashes, optional, default 200
  106630. * @returns the VertexData for the DashedLines
  106631. */
  106632. static CreateDashedLines(options: {
  106633. points: Vector3[];
  106634. dashSize?: number;
  106635. gapSize?: number;
  106636. dashNb?: number;
  106637. }): VertexData;
  106638. /**
  106639. * Creates the VertexData for a Ground
  106640. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106641. * - width the width (x direction) of the ground, optional, default 1
  106642. * - height the height (z direction) of the ground, optional, default 1
  106643. * - subdivisions the number of subdivisions per side, optional, default 1
  106644. * @returns the VertexData of the Ground
  106645. */
  106646. static CreateGround(options: {
  106647. width?: number;
  106648. height?: number;
  106649. subdivisions?: number;
  106650. subdivisionsX?: number;
  106651. subdivisionsY?: number;
  106652. }): VertexData;
  106653. /**
  106654. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106655. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106656. * * xmin the ground minimum X coordinate, optional, default -1
  106657. * * zmin the ground minimum Z coordinate, optional, default -1
  106658. * * xmax the ground maximum X coordinate, optional, default 1
  106659. * * zmax the ground maximum Z coordinate, optional, default 1
  106660. * * 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}
  106661. * * 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}
  106662. * @returns the VertexData of the TiledGround
  106663. */
  106664. static CreateTiledGround(options: {
  106665. xmin: number;
  106666. zmin: number;
  106667. xmax: number;
  106668. zmax: number;
  106669. subdivisions?: {
  106670. w: number;
  106671. h: number;
  106672. };
  106673. precision?: {
  106674. w: number;
  106675. h: number;
  106676. };
  106677. }): VertexData;
  106678. /**
  106679. * Creates the VertexData of the Ground designed from a heightmap
  106680. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106681. * * width the width (x direction) of the ground
  106682. * * height the height (z direction) of the ground
  106683. * * subdivisions the number of subdivisions per side
  106684. * * minHeight the minimum altitude on the ground, optional, default 0
  106685. * * maxHeight the maximum altitude on the ground, optional default 1
  106686. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106687. * * buffer the array holding the image color data
  106688. * * bufferWidth the width of image
  106689. * * bufferHeight the height of image
  106690. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106691. * @returns the VertexData of the Ground designed from a heightmap
  106692. */
  106693. static CreateGroundFromHeightMap(options: {
  106694. width: number;
  106695. height: number;
  106696. subdivisions: number;
  106697. minHeight: number;
  106698. maxHeight: number;
  106699. colorFilter: Color3;
  106700. buffer: Uint8Array;
  106701. bufferWidth: number;
  106702. bufferHeight: number;
  106703. alphaFilter: number;
  106704. }): VertexData;
  106705. /**
  106706. * Creates the VertexData for a Plane
  106707. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106708. * * size sets the width and height of the plane to the value of size, optional default 1
  106709. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106710. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106712. * * 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)
  106713. * * 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)
  106714. * @returns the VertexData of the box
  106715. */
  106716. static CreatePlane(options: {
  106717. size?: number;
  106718. width?: number;
  106719. height?: number;
  106720. sideOrientation?: number;
  106721. frontUVs?: Vector4;
  106722. backUVs?: Vector4;
  106723. }): VertexData;
  106724. /**
  106725. * Creates the VertexData of the Disc or regular Polygon
  106726. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106727. * * radius the radius of the disc, optional default 0.5
  106728. * * tessellation the number of polygon sides, optional, default 64
  106729. * * 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
  106730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106731. * * 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)
  106732. * * 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)
  106733. * @returns the VertexData of the box
  106734. */
  106735. static CreateDisc(options: {
  106736. radius?: number;
  106737. tessellation?: number;
  106738. arc?: number;
  106739. sideOrientation?: number;
  106740. frontUVs?: Vector4;
  106741. backUVs?: Vector4;
  106742. }): VertexData;
  106743. /**
  106744. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106745. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106746. * @param polygon a mesh built from polygonTriangulation.build()
  106747. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106748. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106749. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106750. * @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)
  106751. * @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)
  106752. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106753. * @returns the VertexData of the Polygon
  106754. */
  106755. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106756. /**
  106757. * Creates the VertexData of the IcoSphere
  106758. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106759. * * radius the radius of the IcoSphere, optional default 1
  106760. * * radiusX allows stretching in the x direction, optional, default radius
  106761. * * radiusY allows stretching in the y direction, optional, default radius
  106762. * * radiusZ allows stretching in the z direction, optional, default radius
  106763. * * flat when true creates a flat shaded mesh, optional, default true
  106764. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106766. * * 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)
  106767. * * 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)
  106768. * @returns the VertexData of the IcoSphere
  106769. */
  106770. static CreateIcoSphere(options: {
  106771. radius?: number;
  106772. radiusX?: number;
  106773. radiusY?: number;
  106774. radiusZ?: number;
  106775. flat?: boolean;
  106776. subdivisions?: number;
  106777. sideOrientation?: number;
  106778. frontUVs?: Vector4;
  106779. backUVs?: Vector4;
  106780. }): VertexData;
  106781. /**
  106782. * Creates the VertexData for a Polyhedron
  106783. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106784. * * type provided types are:
  106785. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106786. * * 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)
  106787. * * size the size of the IcoSphere, optional default 1
  106788. * * sizeX allows stretching in the x direction, optional, default size
  106789. * * sizeY allows stretching in the y direction, optional, default size
  106790. * * sizeZ allows stretching in the z direction, optional, default size
  106791. * * 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
  106792. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106793. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106794. * * flat when true creates a flat shaded mesh, optional, default true
  106795. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106797. * * 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)
  106798. * * 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)
  106799. * @returns the VertexData of the Polyhedron
  106800. */
  106801. static CreatePolyhedron(options: {
  106802. type?: number;
  106803. size?: number;
  106804. sizeX?: number;
  106805. sizeY?: number;
  106806. sizeZ?: number;
  106807. custom?: any;
  106808. faceUV?: Vector4[];
  106809. faceColors?: Color4[];
  106810. flat?: boolean;
  106811. sideOrientation?: number;
  106812. frontUVs?: Vector4;
  106813. backUVs?: Vector4;
  106814. }): VertexData;
  106815. /**
  106816. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106817. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106818. * @returns the VertexData of the Capsule
  106819. */
  106820. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106821. /**
  106822. * Creates the VertexData for a TorusKnot
  106823. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106824. * * radius the radius of the torus knot, optional, default 2
  106825. * * tube the thickness of the tube, optional, default 0.5
  106826. * * radialSegments the number of sides on each tube segments, optional, default 32
  106827. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106828. * * p the number of windings around the z axis, optional, default 2
  106829. * * q the number of windings around the x axis, optional, default 3
  106830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106831. * * 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)
  106832. * * 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)
  106833. * @returns the VertexData of the Torus Knot
  106834. */
  106835. static CreateTorusKnot(options: {
  106836. radius?: number;
  106837. tube?: number;
  106838. radialSegments?: number;
  106839. tubularSegments?: number;
  106840. p?: number;
  106841. q?: number;
  106842. sideOrientation?: number;
  106843. frontUVs?: Vector4;
  106844. backUVs?: Vector4;
  106845. }): VertexData;
  106846. /**
  106847. * Compute normals for given positions and indices
  106848. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106849. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106850. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106851. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106852. * * facetNormals : optional array of facet normals (vector3)
  106853. * * facetPositions : optional array of facet positions (vector3)
  106854. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106855. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106856. * * bInfo : optional bounding info, required for facetPartitioning computation
  106857. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106858. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106859. * * useRightHandedSystem: optional boolean to for right handed system computation
  106860. * * depthSort : optional boolean to enable the facet depth sort computation
  106861. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106862. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106863. */
  106864. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106865. facetNormals?: any;
  106866. facetPositions?: any;
  106867. facetPartitioning?: any;
  106868. ratio?: number;
  106869. bInfo?: any;
  106870. bbSize?: Vector3;
  106871. subDiv?: any;
  106872. useRightHandedSystem?: boolean;
  106873. depthSort?: boolean;
  106874. distanceTo?: Vector3;
  106875. depthSortedFacets?: any;
  106876. }): void;
  106877. /** @hidden */
  106878. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106879. /**
  106880. * Applies VertexData created from the imported parameters to the geometry
  106881. * @param parsedVertexData the parsed data from an imported file
  106882. * @param geometry the geometry to apply the VertexData to
  106883. */
  106884. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106885. }
  106886. }
  106887. declare module BABYLON {
  106888. /**
  106889. * Defines a target to use with MorphTargetManager
  106890. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106891. */
  106892. export class MorphTarget implements IAnimatable {
  106893. /** defines the name of the target */
  106894. name: string;
  106895. /**
  106896. * Gets or sets the list of animations
  106897. */
  106898. animations: Animation[];
  106899. private _scene;
  106900. private _positions;
  106901. private _normals;
  106902. private _tangents;
  106903. private _uvs;
  106904. private _influence;
  106905. private _uniqueId;
  106906. /**
  106907. * Observable raised when the influence changes
  106908. */
  106909. onInfluenceChanged: Observable<boolean>;
  106910. /** @hidden */
  106911. _onDataLayoutChanged: Observable<void>;
  106912. /**
  106913. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106914. */
  106915. get influence(): number;
  106916. set influence(influence: number);
  106917. /**
  106918. * Gets or sets the id of the morph Target
  106919. */
  106920. id: string;
  106921. private _animationPropertiesOverride;
  106922. /**
  106923. * Gets or sets the animation properties override
  106924. */
  106925. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106926. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106927. /**
  106928. * Creates a new MorphTarget
  106929. * @param name defines the name of the target
  106930. * @param influence defines the influence to use
  106931. * @param scene defines the scene the morphtarget belongs to
  106932. */
  106933. constructor(
  106934. /** defines the name of the target */
  106935. name: string, influence?: number, scene?: Nullable<Scene>);
  106936. /**
  106937. * Gets the unique ID of this manager
  106938. */
  106939. get uniqueId(): number;
  106940. /**
  106941. * Gets a boolean defining if the target contains position data
  106942. */
  106943. get hasPositions(): boolean;
  106944. /**
  106945. * Gets a boolean defining if the target contains normal data
  106946. */
  106947. get hasNormals(): boolean;
  106948. /**
  106949. * Gets a boolean defining if the target contains tangent data
  106950. */
  106951. get hasTangents(): boolean;
  106952. /**
  106953. * Gets a boolean defining if the target contains texture coordinates data
  106954. */
  106955. get hasUVs(): boolean;
  106956. /**
  106957. * Affects position data to this target
  106958. * @param data defines the position data to use
  106959. */
  106960. setPositions(data: Nullable<FloatArray>): void;
  106961. /**
  106962. * Gets the position data stored in this target
  106963. * @returns a FloatArray containing the position data (or null if not present)
  106964. */
  106965. getPositions(): Nullable<FloatArray>;
  106966. /**
  106967. * Affects normal data to this target
  106968. * @param data defines the normal data to use
  106969. */
  106970. setNormals(data: Nullable<FloatArray>): void;
  106971. /**
  106972. * Gets the normal data stored in this target
  106973. * @returns a FloatArray containing the normal data (or null if not present)
  106974. */
  106975. getNormals(): Nullable<FloatArray>;
  106976. /**
  106977. * Affects tangent data to this target
  106978. * @param data defines the tangent data to use
  106979. */
  106980. setTangents(data: Nullable<FloatArray>): void;
  106981. /**
  106982. * Gets the tangent data stored in this target
  106983. * @returns a FloatArray containing the tangent data (or null if not present)
  106984. */
  106985. getTangents(): Nullable<FloatArray>;
  106986. /**
  106987. * Affects texture coordinates data to this target
  106988. * @param data defines the texture coordinates data to use
  106989. */
  106990. setUVs(data: Nullable<FloatArray>): void;
  106991. /**
  106992. * Gets the texture coordinates data stored in this target
  106993. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106994. */
  106995. getUVs(): Nullable<FloatArray>;
  106996. /**
  106997. * Clone the current target
  106998. * @returns a new MorphTarget
  106999. */
  107000. clone(): MorphTarget;
  107001. /**
  107002. * Serializes the current target into a Serialization object
  107003. * @returns the serialized object
  107004. */
  107005. serialize(): any;
  107006. /**
  107007. * Returns the string "MorphTarget"
  107008. * @returns "MorphTarget"
  107009. */
  107010. getClassName(): string;
  107011. /**
  107012. * Creates a new target from serialized data
  107013. * @param serializationObject defines the serialized data to use
  107014. * @returns a new MorphTarget
  107015. */
  107016. static Parse(serializationObject: any): MorphTarget;
  107017. /**
  107018. * Creates a MorphTarget from mesh data
  107019. * @param mesh defines the source mesh
  107020. * @param name defines the name to use for the new target
  107021. * @param influence defines the influence to attach to the target
  107022. * @returns a new MorphTarget
  107023. */
  107024. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107025. }
  107026. }
  107027. declare module BABYLON {
  107028. /**
  107029. * This class is used to deform meshes using morphing between different targets
  107030. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107031. */
  107032. export class MorphTargetManager {
  107033. private _targets;
  107034. private _targetInfluenceChangedObservers;
  107035. private _targetDataLayoutChangedObservers;
  107036. private _activeTargets;
  107037. private _scene;
  107038. private _influences;
  107039. private _supportsNormals;
  107040. private _supportsTangents;
  107041. private _supportsUVs;
  107042. private _vertexCount;
  107043. private _uniqueId;
  107044. private _tempInfluences;
  107045. /**
  107046. * Gets or sets a boolean indicating if normals must be morphed
  107047. */
  107048. enableNormalMorphing: boolean;
  107049. /**
  107050. * Gets or sets a boolean indicating if tangents must be morphed
  107051. */
  107052. enableTangentMorphing: boolean;
  107053. /**
  107054. * Gets or sets a boolean indicating if UV must be morphed
  107055. */
  107056. enableUVMorphing: boolean;
  107057. /**
  107058. * Creates a new MorphTargetManager
  107059. * @param scene defines the current scene
  107060. */
  107061. constructor(scene?: Nullable<Scene>);
  107062. /**
  107063. * Gets the unique ID of this manager
  107064. */
  107065. get uniqueId(): number;
  107066. /**
  107067. * Gets the number of vertices handled by this manager
  107068. */
  107069. get vertexCount(): number;
  107070. /**
  107071. * Gets a boolean indicating if this manager supports morphing of normals
  107072. */
  107073. get supportsNormals(): boolean;
  107074. /**
  107075. * Gets a boolean indicating if this manager supports morphing of tangents
  107076. */
  107077. get supportsTangents(): boolean;
  107078. /**
  107079. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107080. */
  107081. get supportsUVs(): boolean;
  107082. /**
  107083. * Gets the number of targets stored in this manager
  107084. */
  107085. get numTargets(): number;
  107086. /**
  107087. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107088. */
  107089. get numInfluencers(): number;
  107090. /**
  107091. * Gets the list of influences (one per target)
  107092. */
  107093. get influences(): Float32Array;
  107094. /**
  107095. * Gets the active target at specified index. An active target is a target with an influence > 0
  107096. * @param index defines the index to check
  107097. * @returns the requested target
  107098. */
  107099. getActiveTarget(index: number): MorphTarget;
  107100. /**
  107101. * Gets the target at specified index
  107102. * @param index defines the index to check
  107103. * @returns the requested target
  107104. */
  107105. getTarget(index: number): MorphTarget;
  107106. /**
  107107. * Add a new target to this manager
  107108. * @param target defines the target to add
  107109. */
  107110. addTarget(target: MorphTarget): void;
  107111. /**
  107112. * Removes a target from the manager
  107113. * @param target defines the target to remove
  107114. */
  107115. removeTarget(target: MorphTarget): void;
  107116. /**
  107117. * Clone the current manager
  107118. * @returns a new MorphTargetManager
  107119. */
  107120. clone(): MorphTargetManager;
  107121. /**
  107122. * Serializes the current manager into a Serialization object
  107123. * @returns the serialized object
  107124. */
  107125. serialize(): any;
  107126. private _syncActiveTargets;
  107127. /**
  107128. * Syncrhonize the targets with all the meshes using this morph target manager
  107129. */
  107130. synchronize(): void;
  107131. /**
  107132. * Creates a new MorphTargetManager from serialized data
  107133. * @param serializationObject defines the serialized data
  107134. * @param scene defines the hosting scene
  107135. * @returns the new MorphTargetManager
  107136. */
  107137. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107138. }
  107139. }
  107140. declare module BABYLON {
  107141. /**
  107142. * Class used to represent a specific level of detail of a mesh
  107143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107144. */
  107145. export class MeshLODLevel {
  107146. /** Defines the distance where this level should start being displayed */
  107147. distance: number;
  107148. /** Defines the mesh to use to render this level */
  107149. mesh: Nullable<Mesh>;
  107150. /**
  107151. * Creates a new LOD level
  107152. * @param distance defines the distance where this level should star being displayed
  107153. * @param mesh defines the mesh to use to render this level
  107154. */
  107155. constructor(
  107156. /** Defines the distance where this level should start being displayed */
  107157. distance: number,
  107158. /** Defines the mesh to use to render this level */
  107159. mesh: Nullable<Mesh>);
  107160. }
  107161. }
  107162. declare module BABYLON {
  107163. /**
  107164. * Helper class used to generate a canvas to manipulate images
  107165. */
  107166. export class CanvasGenerator {
  107167. /**
  107168. * Create a new canvas (or offscreen canvas depending on the context)
  107169. * @param width defines the expected width
  107170. * @param height defines the expected height
  107171. * @return a new canvas or offscreen canvas
  107172. */
  107173. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107174. }
  107175. }
  107176. declare module BABYLON {
  107177. /**
  107178. * Mesh representing the gorund
  107179. */
  107180. export class GroundMesh extends Mesh {
  107181. /** If octree should be generated */
  107182. generateOctree: boolean;
  107183. private _heightQuads;
  107184. /** @hidden */
  107185. _subdivisionsX: number;
  107186. /** @hidden */
  107187. _subdivisionsY: number;
  107188. /** @hidden */
  107189. _width: number;
  107190. /** @hidden */
  107191. _height: number;
  107192. /** @hidden */
  107193. _minX: number;
  107194. /** @hidden */
  107195. _maxX: number;
  107196. /** @hidden */
  107197. _minZ: number;
  107198. /** @hidden */
  107199. _maxZ: number;
  107200. constructor(name: string, scene: Scene);
  107201. /**
  107202. * "GroundMesh"
  107203. * @returns "GroundMesh"
  107204. */
  107205. getClassName(): string;
  107206. /**
  107207. * The minimum of x and y subdivisions
  107208. */
  107209. get subdivisions(): number;
  107210. /**
  107211. * X subdivisions
  107212. */
  107213. get subdivisionsX(): number;
  107214. /**
  107215. * Y subdivisions
  107216. */
  107217. get subdivisionsY(): number;
  107218. /**
  107219. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107220. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107221. * @param chunksCount the number of subdivisions for x and y
  107222. * @param octreeBlocksSize (Default: 32)
  107223. */
  107224. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107225. /**
  107226. * Returns a height (y) value in the Worl system :
  107227. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107228. * @param x x coordinate
  107229. * @param z z coordinate
  107230. * @returns the ground y position if (x, z) are outside the ground surface.
  107231. */
  107232. getHeightAtCoordinates(x: number, z: number): number;
  107233. /**
  107234. * Returns a normalized vector (Vector3) orthogonal to the ground
  107235. * at the ground coordinates (x, z) expressed in the World system.
  107236. * @param x x coordinate
  107237. * @param z z coordinate
  107238. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107239. */
  107240. getNormalAtCoordinates(x: number, z: number): Vector3;
  107241. /**
  107242. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107243. * at the ground coordinates (x, z) expressed in the World system.
  107244. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107245. * @param x x coordinate
  107246. * @param z z coordinate
  107247. * @param ref vector to store the result
  107248. * @returns the GroundMesh.
  107249. */
  107250. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107251. /**
  107252. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107253. * if the ground has been updated.
  107254. * This can be used in the render loop.
  107255. * @returns the GroundMesh.
  107256. */
  107257. updateCoordinateHeights(): GroundMesh;
  107258. private _getFacetAt;
  107259. private _initHeightQuads;
  107260. private _computeHeightQuads;
  107261. /**
  107262. * Serializes this ground mesh
  107263. * @param serializationObject object to write serialization to
  107264. */
  107265. serialize(serializationObject: any): void;
  107266. /**
  107267. * Parses a serialized ground mesh
  107268. * @param parsedMesh the serialized mesh
  107269. * @param scene the scene to create the ground mesh in
  107270. * @returns the created ground mesh
  107271. */
  107272. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107273. }
  107274. }
  107275. declare module BABYLON {
  107276. /**
  107277. * Interface for Physics-Joint data
  107278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107279. */
  107280. export interface PhysicsJointData {
  107281. /**
  107282. * The main pivot of the joint
  107283. */
  107284. mainPivot?: Vector3;
  107285. /**
  107286. * The connected pivot of the joint
  107287. */
  107288. connectedPivot?: Vector3;
  107289. /**
  107290. * The main axis of the joint
  107291. */
  107292. mainAxis?: Vector3;
  107293. /**
  107294. * The connected axis of the joint
  107295. */
  107296. connectedAxis?: Vector3;
  107297. /**
  107298. * The collision of the joint
  107299. */
  107300. collision?: boolean;
  107301. /**
  107302. * Native Oimo/Cannon/Energy data
  107303. */
  107304. nativeParams?: any;
  107305. }
  107306. /**
  107307. * This is a holder class for the physics joint created by the physics plugin
  107308. * It holds a set of functions to control the underlying joint
  107309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107310. */
  107311. export class PhysicsJoint {
  107312. /**
  107313. * The type of the physics joint
  107314. */
  107315. type: number;
  107316. /**
  107317. * The data for the physics joint
  107318. */
  107319. jointData: PhysicsJointData;
  107320. private _physicsJoint;
  107321. protected _physicsPlugin: IPhysicsEnginePlugin;
  107322. /**
  107323. * Initializes the physics joint
  107324. * @param type The type of the physics joint
  107325. * @param jointData The data for the physics joint
  107326. */
  107327. constructor(
  107328. /**
  107329. * The type of the physics joint
  107330. */
  107331. type: number,
  107332. /**
  107333. * The data for the physics joint
  107334. */
  107335. jointData: PhysicsJointData);
  107336. /**
  107337. * Gets the physics joint
  107338. */
  107339. get physicsJoint(): any;
  107340. /**
  107341. * Sets the physics joint
  107342. */
  107343. set physicsJoint(newJoint: any);
  107344. /**
  107345. * Sets the physics plugin
  107346. */
  107347. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107348. /**
  107349. * Execute a function that is physics-plugin specific.
  107350. * @param {Function} func the function that will be executed.
  107351. * It accepts two parameters: the physics world and the physics joint
  107352. */
  107353. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107354. /**
  107355. * Distance-Joint type
  107356. */
  107357. static DistanceJoint: number;
  107358. /**
  107359. * Hinge-Joint type
  107360. */
  107361. static HingeJoint: number;
  107362. /**
  107363. * Ball-and-Socket joint type
  107364. */
  107365. static BallAndSocketJoint: number;
  107366. /**
  107367. * Wheel-Joint type
  107368. */
  107369. static WheelJoint: number;
  107370. /**
  107371. * Slider-Joint type
  107372. */
  107373. static SliderJoint: number;
  107374. /**
  107375. * Prismatic-Joint type
  107376. */
  107377. static PrismaticJoint: number;
  107378. /**
  107379. * Universal-Joint type
  107380. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107381. */
  107382. static UniversalJoint: number;
  107383. /**
  107384. * Hinge-Joint 2 type
  107385. */
  107386. static Hinge2Joint: number;
  107387. /**
  107388. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107389. */
  107390. static PointToPointJoint: number;
  107391. /**
  107392. * Spring-Joint type
  107393. */
  107394. static SpringJoint: number;
  107395. /**
  107396. * Lock-Joint type
  107397. */
  107398. static LockJoint: number;
  107399. }
  107400. /**
  107401. * A class representing a physics distance joint
  107402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107403. */
  107404. export class DistanceJoint extends PhysicsJoint {
  107405. /**
  107406. *
  107407. * @param jointData The data for the Distance-Joint
  107408. */
  107409. constructor(jointData: DistanceJointData);
  107410. /**
  107411. * Update the predefined distance.
  107412. * @param maxDistance The maximum preferred distance
  107413. * @param minDistance The minimum preferred distance
  107414. */
  107415. updateDistance(maxDistance: number, minDistance?: number): void;
  107416. }
  107417. /**
  107418. * Represents a Motor-Enabled Joint
  107419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107420. */
  107421. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107422. /**
  107423. * Initializes the Motor-Enabled Joint
  107424. * @param type The type of the joint
  107425. * @param jointData The physica joint data for the joint
  107426. */
  107427. constructor(type: number, jointData: PhysicsJointData);
  107428. /**
  107429. * Set the motor values.
  107430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107431. * @param force the force to apply
  107432. * @param maxForce max force for this motor.
  107433. */
  107434. setMotor(force?: number, maxForce?: number): void;
  107435. /**
  107436. * Set the motor's limits.
  107437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107438. * @param upperLimit The upper limit of the motor
  107439. * @param lowerLimit The lower limit of the motor
  107440. */
  107441. setLimit(upperLimit: number, lowerLimit?: number): void;
  107442. }
  107443. /**
  107444. * This class represents a single physics Hinge-Joint
  107445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107446. */
  107447. export class HingeJoint extends MotorEnabledJoint {
  107448. /**
  107449. * Initializes the Hinge-Joint
  107450. * @param jointData The joint data for the Hinge-Joint
  107451. */
  107452. constructor(jointData: PhysicsJointData);
  107453. /**
  107454. * Set the motor values.
  107455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107456. * @param {number} force the force to apply
  107457. * @param {number} maxForce max force for this motor.
  107458. */
  107459. setMotor(force?: number, maxForce?: number): void;
  107460. /**
  107461. * Set the motor's limits.
  107462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107463. * @param upperLimit The upper limit of the motor
  107464. * @param lowerLimit The lower limit of the motor
  107465. */
  107466. setLimit(upperLimit: number, lowerLimit?: number): void;
  107467. }
  107468. /**
  107469. * This class represents a dual hinge physics joint (same as wheel joint)
  107470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107471. */
  107472. export class Hinge2Joint extends MotorEnabledJoint {
  107473. /**
  107474. * Initializes the Hinge2-Joint
  107475. * @param jointData The joint data for the Hinge2-Joint
  107476. */
  107477. constructor(jointData: PhysicsJointData);
  107478. /**
  107479. * Set the motor values.
  107480. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107481. * @param {number} targetSpeed the speed the motor is to reach
  107482. * @param {number} maxForce max force for this motor.
  107483. * @param {motorIndex} the motor's index, 0 or 1.
  107484. */
  107485. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107486. /**
  107487. * Set the motor limits.
  107488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107489. * @param {number} upperLimit the upper limit
  107490. * @param {number} lowerLimit lower limit
  107491. * @param {motorIndex} the motor's index, 0 or 1.
  107492. */
  107493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107494. }
  107495. /**
  107496. * Interface for a motor enabled joint
  107497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107498. */
  107499. export interface IMotorEnabledJoint {
  107500. /**
  107501. * Physics joint
  107502. */
  107503. physicsJoint: any;
  107504. /**
  107505. * Sets the motor of the motor-enabled joint
  107506. * @param force The force of the motor
  107507. * @param maxForce The maximum force of the motor
  107508. * @param motorIndex The index of the motor
  107509. */
  107510. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107511. /**
  107512. * Sets the limit of the motor
  107513. * @param upperLimit The upper limit of the motor
  107514. * @param lowerLimit The lower limit of the motor
  107515. * @param motorIndex The index of the motor
  107516. */
  107517. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107518. }
  107519. /**
  107520. * Joint data for a Distance-Joint
  107521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107522. */
  107523. export interface DistanceJointData extends PhysicsJointData {
  107524. /**
  107525. * Max distance the 2 joint objects can be apart
  107526. */
  107527. maxDistance: number;
  107528. }
  107529. /**
  107530. * Joint data from a spring joint
  107531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107532. */
  107533. export interface SpringJointData extends PhysicsJointData {
  107534. /**
  107535. * Length of the spring
  107536. */
  107537. length: number;
  107538. /**
  107539. * Stiffness of the spring
  107540. */
  107541. stiffness: number;
  107542. /**
  107543. * Damping of the spring
  107544. */
  107545. damping: number;
  107546. /** this callback will be called when applying the force to the impostors. */
  107547. forceApplicationCallback: () => void;
  107548. }
  107549. }
  107550. declare module BABYLON {
  107551. /**
  107552. * Holds the data for the raycast result
  107553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107554. */
  107555. export class PhysicsRaycastResult {
  107556. private _hasHit;
  107557. private _hitDistance;
  107558. private _hitNormalWorld;
  107559. private _hitPointWorld;
  107560. private _rayFromWorld;
  107561. private _rayToWorld;
  107562. /**
  107563. * Gets if there was a hit
  107564. */
  107565. get hasHit(): boolean;
  107566. /**
  107567. * Gets the distance from the hit
  107568. */
  107569. get hitDistance(): number;
  107570. /**
  107571. * Gets the hit normal/direction in the world
  107572. */
  107573. get hitNormalWorld(): Vector3;
  107574. /**
  107575. * Gets the hit point in the world
  107576. */
  107577. get hitPointWorld(): Vector3;
  107578. /**
  107579. * Gets the ray "start point" of the ray in the world
  107580. */
  107581. get rayFromWorld(): Vector3;
  107582. /**
  107583. * Gets the ray "end point" of the ray in the world
  107584. */
  107585. get rayToWorld(): Vector3;
  107586. /**
  107587. * Sets the hit data (normal & point in world space)
  107588. * @param hitNormalWorld defines the normal in world space
  107589. * @param hitPointWorld defines the point in world space
  107590. */
  107591. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107592. /**
  107593. * Sets the distance from the start point to the hit point
  107594. * @param distance
  107595. */
  107596. setHitDistance(distance: number): void;
  107597. /**
  107598. * Calculates the distance manually
  107599. */
  107600. calculateHitDistance(): void;
  107601. /**
  107602. * Resets all the values to default
  107603. * @param from The from point on world space
  107604. * @param to The to point on world space
  107605. */
  107606. reset(from?: Vector3, to?: Vector3): void;
  107607. }
  107608. /**
  107609. * Interface for the size containing width and height
  107610. */
  107611. interface IXYZ {
  107612. /**
  107613. * X
  107614. */
  107615. x: number;
  107616. /**
  107617. * Y
  107618. */
  107619. y: number;
  107620. /**
  107621. * Z
  107622. */
  107623. z: number;
  107624. }
  107625. }
  107626. declare module BABYLON {
  107627. /**
  107628. * Interface used to describe a physics joint
  107629. */
  107630. export interface PhysicsImpostorJoint {
  107631. /** Defines the main impostor to which the joint is linked */
  107632. mainImpostor: PhysicsImpostor;
  107633. /** Defines the impostor that is connected to the main impostor using this joint */
  107634. connectedImpostor: PhysicsImpostor;
  107635. /** Defines the joint itself */
  107636. joint: PhysicsJoint;
  107637. }
  107638. /** @hidden */
  107639. export interface IPhysicsEnginePlugin {
  107640. world: any;
  107641. name: string;
  107642. setGravity(gravity: Vector3): void;
  107643. setTimeStep(timeStep: number): void;
  107644. getTimeStep(): number;
  107645. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107646. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107648. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107649. removePhysicsBody(impostor: PhysicsImpostor): void;
  107650. generateJoint(joint: PhysicsImpostorJoint): void;
  107651. removeJoint(joint: PhysicsImpostorJoint): void;
  107652. isSupported(): boolean;
  107653. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107654. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107655. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107656. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107657. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107658. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107659. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107660. getBodyMass(impostor: PhysicsImpostor): number;
  107661. getBodyFriction(impostor: PhysicsImpostor): number;
  107662. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107663. getBodyRestitution(impostor: PhysicsImpostor): number;
  107664. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107665. getBodyPressure?(impostor: PhysicsImpostor): number;
  107666. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107667. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107668. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107669. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107670. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107671. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107672. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107673. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107674. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107675. sleepBody(impostor: PhysicsImpostor): void;
  107676. wakeUpBody(impostor: PhysicsImpostor): void;
  107677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107678. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107679. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107680. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107681. getRadius(impostor: PhysicsImpostor): number;
  107682. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107683. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107684. dispose(): void;
  107685. }
  107686. /**
  107687. * Interface used to define a physics engine
  107688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107689. */
  107690. export interface IPhysicsEngine {
  107691. /**
  107692. * Gets the gravity vector used by the simulation
  107693. */
  107694. gravity: Vector3;
  107695. /**
  107696. * Sets the gravity vector used by the simulation
  107697. * @param gravity defines the gravity vector to use
  107698. */
  107699. setGravity(gravity: Vector3): void;
  107700. /**
  107701. * Set the time step of the physics engine.
  107702. * Default is 1/60.
  107703. * To slow it down, enter 1/600 for example.
  107704. * To speed it up, 1/30
  107705. * @param newTimeStep the new timestep to apply to this world.
  107706. */
  107707. setTimeStep(newTimeStep: number): void;
  107708. /**
  107709. * Get the time step of the physics engine.
  107710. * @returns the current time step
  107711. */
  107712. getTimeStep(): number;
  107713. /**
  107714. * Set the sub time step of the physics engine.
  107715. * Default is 0 meaning there is no sub steps
  107716. * To increase physics resolution precision, set a small value (like 1 ms)
  107717. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107718. */
  107719. setSubTimeStep(subTimeStep: number): void;
  107720. /**
  107721. * Get the sub time step of the physics engine.
  107722. * @returns the current sub time step
  107723. */
  107724. getSubTimeStep(): number;
  107725. /**
  107726. * Release all resources
  107727. */
  107728. dispose(): void;
  107729. /**
  107730. * Gets the name of the current physics plugin
  107731. * @returns the name of the plugin
  107732. */
  107733. getPhysicsPluginName(): string;
  107734. /**
  107735. * Adding a new impostor for the impostor tracking.
  107736. * This will be done by the impostor itself.
  107737. * @param impostor the impostor to add
  107738. */
  107739. addImpostor(impostor: PhysicsImpostor): void;
  107740. /**
  107741. * Remove an impostor from the engine.
  107742. * This impostor and its mesh will not longer be updated by the physics engine.
  107743. * @param impostor the impostor to remove
  107744. */
  107745. removeImpostor(impostor: PhysicsImpostor): void;
  107746. /**
  107747. * Add a joint to the physics engine
  107748. * @param mainImpostor defines the main impostor to which the joint is added.
  107749. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107750. * @param joint defines the joint that will connect both impostors.
  107751. */
  107752. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107753. /**
  107754. * Removes a joint from the simulation
  107755. * @param mainImpostor defines the impostor used with the joint
  107756. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107757. * @param joint defines the joint to remove
  107758. */
  107759. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107760. /**
  107761. * Gets the current plugin used to run the simulation
  107762. * @returns current plugin
  107763. */
  107764. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107765. /**
  107766. * Gets the list of physic impostors
  107767. * @returns an array of PhysicsImpostor
  107768. */
  107769. getImpostors(): Array<PhysicsImpostor>;
  107770. /**
  107771. * Gets the impostor for a physics enabled object
  107772. * @param object defines the object impersonated by the impostor
  107773. * @returns the PhysicsImpostor or null if not found
  107774. */
  107775. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107776. /**
  107777. * Gets the impostor for a physics body object
  107778. * @param body defines physics body used by the impostor
  107779. * @returns the PhysicsImpostor or null if not found
  107780. */
  107781. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107782. /**
  107783. * Does a raycast in the physics world
  107784. * @param from when should the ray start?
  107785. * @param to when should the ray end?
  107786. * @returns PhysicsRaycastResult
  107787. */
  107788. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107789. /**
  107790. * Called by the scene. No need to call it.
  107791. * @param delta defines the timespam between frames
  107792. */
  107793. _step(delta: number): void;
  107794. }
  107795. }
  107796. declare module BABYLON {
  107797. /**
  107798. * The interface for the physics imposter parameters
  107799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107800. */
  107801. export interface PhysicsImpostorParameters {
  107802. /**
  107803. * The mass of the physics imposter
  107804. */
  107805. mass: number;
  107806. /**
  107807. * The friction of the physics imposter
  107808. */
  107809. friction?: number;
  107810. /**
  107811. * The coefficient of restitution of the physics imposter
  107812. */
  107813. restitution?: number;
  107814. /**
  107815. * The native options of the physics imposter
  107816. */
  107817. nativeOptions?: any;
  107818. /**
  107819. * Specifies if the parent should be ignored
  107820. */
  107821. ignoreParent?: boolean;
  107822. /**
  107823. * Specifies if bi-directional transformations should be disabled
  107824. */
  107825. disableBidirectionalTransformation?: boolean;
  107826. /**
  107827. * The pressure inside the physics imposter, soft object only
  107828. */
  107829. pressure?: number;
  107830. /**
  107831. * The stiffness the physics imposter, soft object only
  107832. */
  107833. stiffness?: number;
  107834. /**
  107835. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107836. */
  107837. velocityIterations?: number;
  107838. /**
  107839. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107840. */
  107841. positionIterations?: number;
  107842. /**
  107843. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107844. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107845. * Add to fix multiple points
  107846. */
  107847. fixedPoints?: number;
  107848. /**
  107849. * The collision margin around a soft object
  107850. */
  107851. margin?: number;
  107852. /**
  107853. * The collision margin around a soft object
  107854. */
  107855. damping?: number;
  107856. /**
  107857. * The path for a rope based on an extrusion
  107858. */
  107859. path?: any;
  107860. /**
  107861. * The shape of an extrusion used for a rope based on an extrusion
  107862. */
  107863. shape?: any;
  107864. }
  107865. /**
  107866. * Interface for a physics-enabled object
  107867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107868. */
  107869. export interface IPhysicsEnabledObject {
  107870. /**
  107871. * The position of the physics-enabled object
  107872. */
  107873. position: Vector3;
  107874. /**
  107875. * The rotation of the physics-enabled object
  107876. */
  107877. rotationQuaternion: Nullable<Quaternion>;
  107878. /**
  107879. * The scale of the physics-enabled object
  107880. */
  107881. scaling: Vector3;
  107882. /**
  107883. * The rotation of the physics-enabled object
  107884. */
  107885. rotation?: Vector3;
  107886. /**
  107887. * The parent of the physics-enabled object
  107888. */
  107889. parent?: any;
  107890. /**
  107891. * The bounding info of the physics-enabled object
  107892. * @returns The bounding info of the physics-enabled object
  107893. */
  107894. getBoundingInfo(): BoundingInfo;
  107895. /**
  107896. * Computes the world matrix
  107897. * @param force Specifies if the world matrix should be computed by force
  107898. * @returns A world matrix
  107899. */
  107900. computeWorldMatrix(force: boolean): Matrix;
  107901. /**
  107902. * Gets the world matrix
  107903. * @returns A world matrix
  107904. */
  107905. getWorldMatrix?(): Matrix;
  107906. /**
  107907. * Gets the child meshes
  107908. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107909. * @returns An array of abstract meshes
  107910. */
  107911. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107912. /**
  107913. * Gets the vertex data
  107914. * @param kind The type of vertex data
  107915. * @returns A nullable array of numbers, or a float32 array
  107916. */
  107917. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107918. /**
  107919. * Gets the indices from the mesh
  107920. * @returns A nullable array of index arrays
  107921. */
  107922. getIndices?(): Nullable<IndicesArray>;
  107923. /**
  107924. * Gets the scene from the mesh
  107925. * @returns the indices array or null
  107926. */
  107927. getScene?(): Scene;
  107928. /**
  107929. * Gets the absolute position from the mesh
  107930. * @returns the absolute position
  107931. */
  107932. getAbsolutePosition(): Vector3;
  107933. /**
  107934. * Gets the absolute pivot point from the mesh
  107935. * @returns the absolute pivot point
  107936. */
  107937. getAbsolutePivotPoint(): Vector3;
  107938. /**
  107939. * Rotates the mesh
  107940. * @param axis The axis of rotation
  107941. * @param amount The amount of rotation
  107942. * @param space The space of the rotation
  107943. * @returns The rotation transform node
  107944. */
  107945. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107946. /**
  107947. * Translates the mesh
  107948. * @param axis The axis of translation
  107949. * @param distance The distance of translation
  107950. * @param space The space of the translation
  107951. * @returns The transform node
  107952. */
  107953. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107954. /**
  107955. * Sets the absolute position of the mesh
  107956. * @param absolutePosition The absolute position of the mesh
  107957. * @returns The transform node
  107958. */
  107959. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107960. /**
  107961. * Gets the class name of the mesh
  107962. * @returns The class name
  107963. */
  107964. getClassName(): string;
  107965. }
  107966. /**
  107967. * Represents a physics imposter
  107968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107969. */
  107970. export class PhysicsImpostor {
  107971. /**
  107972. * The physics-enabled object used as the physics imposter
  107973. */
  107974. object: IPhysicsEnabledObject;
  107975. /**
  107976. * The type of the physics imposter
  107977. */
  107978. type: number;
  107979. private _options;
  107980. private _scene?;
  107981. /**
  107982. * The default object size of the imposter
  107983. */
  107984. static DEFAULT_OBJECT_SIZE: Vector3;
  107985. /**
  107986. * The identity quaternion of the imposter
  107987. */
  107988. static IDENTITY_QUATERNION: Quaternion;
  107989. /** @hidden */
  107990. _pluginData: any;
  107991. private _physicsEngine;
  107992. private _physicsBody;
  107993. private _bodyUpdateRequired;
  107994. private _onBeforePhysicsStepCallbacks;
  107995. private _onAfterPhysicsStepCallbacks;
  107996. /** @hidden */
  107997. _onPhysicsCollideCallbacks: Array<{
  107998. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107999. otherImpostors: Array<PhysicsImpostor>;
  108000. }>;
  108001. private _deltaPosition;
  108002. private _deltaRotation;
  108003. private _deltaRotationConjugated;
  108004. /** @hidden */
  108005. _isFromLine: boolean;
  108006. private _parent;
  108007. private _isDisposed;
  108008. private static _tmpVecs;
  108009. private static _tmpQuat;
  108010. /**
  108011. * Specifies if the physics imposter is disposed
  108012. */
  108013. get isDisposed(): boolean;
  108014. /**
  108015. * Gets the mass of the physics imposter
  108016. */
  108017. get mass(): number;
  108018. set mass(value: number);
  108019. /**
  108020. * Gets the coefficient of friction
  108021. */
  108022. get friction(): number;
  108023. /**
  108024. * Sets the coefficient of friction
  108025. */
  108026. set friction(value: number);
  108027. /**
  108028. * Gets the coefficient of restitution
  108029. */
  108030. get restitution(): number;
  108031. /**
  108032. * Sets the coefficient of restitution
  108033. */
  108034. set restitution(value: number);
  108035. /**
  108036. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108037. */
  108038. get pressure(): number;
  108039. /**
  108040. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108041. */
  108042. set pressure(value: number);
  108043. /**
  108044. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108045. */
  108046. get stiffness(): number;
  108047. /**
  108048. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108049. */
  108050. set stiffness(value: number);
  108051. /**
  108052. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108053. */
  108054. get velocityIterations(): number;
  108055. /**
  108056. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108057. */
  108058. set velocityIterations(value: number);
  108059. /**
  108060. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108061. */
  108062. get positionIterations(): number;
  108063. /**
  108064. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108065. */
  108066. set positionIterations(value: number);
  108067. /**
  108068. * The unique id of the physics imposter
  108069. * set by the physics engine when adding this impostor to the array
  108070. */
  108071. uniqueId: number;
  108072. /**
  108073. * @hidden
  108074. */
  108075. soft: boolean;
  108076. /**
  108077. * @hidden
  108078. */
  108079. segments: number;
  108080. private _joints;
  108081. /**
  108082. * Initializes the physics imposter
  108083. * @param object The physics-enabled object used as the physics imposter
  108084. * @param type The type of the physics imposter
  108085. * @param _options The options for the physics imposter
  108086. * @param _scene The Babylon scene
  108087. */
  108088. constructor(
  108089. /**
  108090. * The physics-enabled object used as the physics imposter
  108091. */
  108092. object: IPhysicsEnabledObject,
  108093. /**
  108094. * The type of the physics imposter
  108095. */
  108096. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108097. /**
  108098. * This function will completly initialize this impostor.
  108099. * It will create a new body - but only if this mesh has no parent.
  108100. * If it has, this impostor will not be used other than to define the impostor
  108101. * of the child mesh.
  108102. * @hidden
  108103. */
  108104. _init(): void;
  108105. private _getPhysicsParent;
  108106. /**
  108107. * Should a new body be generated.
  108108. * @returns boolean specifying if body initialization is required
  108109. */
  108110. isBodyInitRequired(): boolean;
  108111. /**
  108112. * Sets the updated scaling
  108113. * @param updated Specifies if the scaling is updated
  108114. */
  108115. setScalingUpdated(): void;
  108116. /**
  108117. * Force a regeneration of this or the parent's impostor's body.
  108118. * Use under cautious - This will remove all joints already implemented.
  108119. */
  108120. forceUpdate(): void;
  108121. /**
  108122. * Gets the body that holds this impostor. Either its own, or its parent.
  108123. */
  108124. get physicsBody(): any;
  108125. /**
  108126. * Get the parent of the physics imposter
  108127. * @returns Physics imposter or null
  108128. */
  108129. get parent(): Nullable<PhysicsImpostor>;
  108130. /**
  108131. * Sets the parent of the physics imposter
  108132. */
  108133. set parent(value: Nullable<PhysicsImpostor>);
  108134. /**
  108135. * Set the physics body. Used mainly by the physics engine/plugin
  108136. */
  108137. set physicsBody(physicsBody: any);
  108138. /**
  108139. * Resets the update flags
  108140. */
  108141. resetUpdateFlags(): void;
  108142. /**
  108143. * Gets the object extend size
  108144. * @returns the object extend size
  108145. */
  108146. getObjectExtendSize(): Vector3;
  108147. /**
  108148. * Gets the object center
  108149. * @returns The object center
  108150. */
  108151. getObjectCenter(): Vector3;
  108152. /**
  108153. * Get a specific parameter from the options parameters
  108154. * @param paramName The object parameter name
  108155. * @returns The object parameter
  108156. */
  108157. getParam(paramName: string): any;
  108158. /**
  108159. * Sets a specific parameter in the options given to the physics plugin
  108160. * @param paramName The parameter name
  108161. * @param value The value of the parameter
  108162. */
  108163. setParam(paramName: string, value: number): void;
  108164. /**
  108165. * Specifically change the body's mass option. Won't recreate the physics body object
  108166. * @param mass The mass of the physics imposter
  108167. */
  108168. setMass(mass: number): void;
  108169. /**
  108170. * Gets the linear velocity
  108171. * @returns linear velocity or null
  108172. */
  108173. getLinearVelocity(): Nullable<Vector3>;
  108174. /**
  108175. * Sets the linear velocity
  108176. * @param velocity linear velocity or null
  108177. */
  108178. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108179. /**
  108180. * Gets the angular velocity
  108181. * @returns angular velocity or null
  108182. */
  108183. getAngularVelocity(): Nullable<Vector3>;
  108184. /**
  108185. * Sets the angular velocity
  108186. * @param velocity The velocity or null
  108187. */
  108188. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108189. /**
  108190. * Execute a function with the physics plugin native code
  108191. * Provide a function the will have two variables - the world object and the physics body object
  108192. * @param func The function to execute with the physics plugin native code
  108193. */
  108194. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108195. /**
  108196. * Register a function that will be executed before the physics world is stepping forward
  108197. * @param func The function to execute before the physics world is stepped forward
  108198. */
  108199. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108200. /**
  108201. * Unregister a function that will be executed before the physics world is stepping forward
  108202. * @param func The function to execute before the physics world is stepped forward
  108203. */
  108204. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108205. /**
  108206. * Register a function that will be executed after the physics step
  108207. * @param func The function to execute after physics step
  108208. */
  108209. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108210. /**
  108211. * Unregisters a function that will be executed after the physics step
  108212. * @param func The function to execute after physics step
  108213. */
  108214. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108215. /**
  108216. * register a function that will be executed when this impostor collides against a different body
  108217. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108218. * @param func Callback that is executed on collision
  108219. */
  108220. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108221. /**
  108222. * Unregisters the physics imposter on contact
  108223. * @param collideAgainst The physics object to collide against
  108224. * @param func Callback to execute on collision
  108225. */
  108226. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108227. private _tmpQuat;
  108228. private _tmpQuat2;
  108229. /**
  108230. * Get the parent rotation
  108231. * @returns The parent rotation
  108232. */
  108233. getParentsRotation(): Quaternion;
  108234. /**
  108235. * this function is executed by the physics engine.
  108236. */
  108237. beforeStep: () => void;
  108238. /**
  108239. * this function is executed by the physics engine
  108240. */
  108241. afterStep: () => void;
  108242. /**
  108243. * Legacy collision detection event support
  108244. */
  108245. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108246. /**
  108247. * event and body object due to cannon's event-based architecture.
  108248. */
  108249. onCollide: (e: {
  108250. body: any;
  108251. }) => void;
  108252. /**
  108253. * Apply a force
  108254. * @param force The force to apply
  108255. * @param contactPoint The contact point for the force
  108256. * @returns The physics imposter
  108257. */
  108258. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108259. /**
  108260. * Apply an impulse
  108261. * @param force The impulse force
  108262. * @param contactPoint The contact point for the impulse force
  108263. * @returns The physics imposter
  108264. */
  108265. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108266. /**
  108267. * A help function to create a joint
  108268. * @param otherImpostor A physics imposter used to create a joint
  108269. * @param jointType The type of joint
  108270. * @param jointData The data for the joint
  108271. * @returns The physics imposter
  108272. */
  108273. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108274. /**
  108275. * Add a joint to this impostor with a different impostor
  108276. * @param otherImpostor A physics imposter used to add a joint
  108277. * @param joint The joint to add
  108278. * @returns The physics imposter
  108279. */
  108280. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108281. /**
  108282. * Add an anchor to a cloth impostor
  108283. * @param otherImpostor rigid impostor to anchor to
  108284. * @param width ratio across width from 0 to 1
  108285. * @param height ratio up height from 0 to 1
  108286. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108287. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108288. * @returns impostor the soft imposter
  108289. */
  108290. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108291. /**
  108292. * Add a hook to a rope impostor
  108293. * @param otherImpostor rigid impostor to anchor to
  108294. * @param length ratio across rope from 0 to 1
  108295. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108296. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108297. * @returns impostor the rope imposter
  108298. */
  108299. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108300. /**
  108301. * Will keep this body still, in a sleep mode.
  108302. * @returns the physics imposter
  108303. */
  108304. sleep(): PhysicsImpostor;
  108305. /**
  108306. * Wake the body up.
  108307. * @returns The physics imposter
  108308. */
  108309. wakeUp(): PhysicsImpostor;
  108310. /**
  108311. * Clones the physics imposter
  108312. * @param newObject The physics imposter clones to this physics-enabled object
  108313. * @returns A nullable physics imposter
  108314. */
  108315. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108316. /**
  108317. * Disposes the physics imposter
  108318. */
  108319. dispose(): void;
  108320. /**
  108321. * Sets the delta position
  108322. * @param position The delta position amount
  108323. */
  108324. setDeltaPosition(position: Vector3): void;
  108325. /**
  108326. * Sets the delta rotation
  108327. * @param rotation The delta rotation amount
  108328. */
  108329. setDeltaRotation(rotation: Quaternion): void;
  108330. /**
  108331. * Gets the box size of the physics imposter and stores the result in the input parameter
  108332. * @param result Stores the box size
  108333. * @returns The physics imposter
  108334. */
  108335. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108336. /**
  108337. * Gets the radius of the physics imposter
  108338. * @returns Radius of the physics imposter
  108339. */
  108340. getRadius(): number;
  108341. /**
  108342. * Sync a bone with this impostor
  108343. * @param bone The bone to sync to the impostor.
  108344. * @param boneMesh The mesh that the bone is influencing.
  108345. * @param jointPivot The pivot of the joint / bone in local space.
  108346. * @param distToJoint Optional distance from the impostor to the joint.
  108347. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108348. */
  108349. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108350. /**
  108351. * Sync impostor to a bone
  108352. * @param bone The bone that the impostor will be synced to.
  108353. * @param boneMesh The mesh that the bone is influencing.
  108354. * @param jointPivot The pivot of the joint / bone in local space.
  108355. * @param distToJoint Optional distance from the impostor to the joint.
  108356. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108357. * @param boneAxis Optional vector3 axis the bone is aligned with
  108358. */
  108359. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108360. /**
  108361. * No-Imposter type
  108362. */
  108363. static NoImpostor: number;
  108364. /**
  108365. * Sphere-Imposter type
  108366. */
  108367. static SphereImpostor: number;
  108368. /**
  108369. * Box-Imposter type
  108370. */
  108371. static BoxImpostor: number;
  108372. /**
  108373. * Plane-Imposter type
  108374. */
  108375. static PlaneImpostor: number;
  108376. /**
  108377. * Mesh-imposter type
  108378. */
  108379. static MeshImpostor: number;
  108380. /**
  108381. * Capsule-Impostor type (Ammo.js plugin only)
  108382. */
  108383. static CapsuleImpostor: number;
  108384. /**
  108385. * Cylinder-Imposter type
  108386. */
  108387. static CylinderImpostor: number;
  108388. /**
  108389. * Particle-Imposter type
  108390. */
  108391. static ParticleImpostor: number;
  108392. /**
  108393. * Heightmap-Imposter type
  108394. */
  108395. static HeightmapImpostor: number;
  108396. /**
  108397. * ConvexHull-Impostor type (Ammo.js plugin only)
  108398. */
  108399. static ConvexHullImpostor: number;
  108400. /**
  108401. * Custom-Imposter type (Ammo.js plugin only)
  108402. */
  108403. static CustomImpostor: number;
  108404. /**
  108405. * Rope-Imposter type
  108406. */
  108407. static RopeImpostor: number;
  108408. /**
  108409. * Cloth-Imposter type
  108410. */
  108411. static ClothImpostor: number;
  108412. /**
  108413. * Softbody-Imposter type
  108414. */
  108415. static SoftbodyImpostor: number;
  108416. }
  108417. }
  108418. declare module BABYLON {
  108419. /**
  108420. * @hidden
  108421. **/
  108422. export class _CreationDataStorage {
  108423. closePath?: boolean;
  108424. closeArray?: boolean;
  108425. idx: number[];
  108426. dashSize: number;
  108427. gapSize: number;
  108428. path3D: Path3D;
  108429. pathArray: Vector3[][];
  108430. arc: number;
  108431. radius: number;
  108432. cap: number;
  108433. tessellation: number;
  108434. }
  108435. /**
  108436. * @hidden
  108437. **/
  108438. class _InstanceDataStorage {
  108439. visibleInstances: any;
  108440. batchCache: _InstancesBatch;
  108441. instancesBufferSize: number;
  108442. instancesBuffer: Nullable<Buffer>;
  108443. instancesData: Float32Array;
  108444. overridenInstanceCount: number;
  108445. isFrozen: boolean;
  108446. previousBatch: Nullable<_InstancesBatch>;
  108447. hardwareInstancedRendering: boolean;
  108448. sideOrientation: number;
  108449. manualUpdate: boolean;
  108450. previousRenderId: number;
  108451. }
  108452. /**
  108453. * @hidden
  108454. **/
  108455. export class _InstancesBatch {
  108456. mustReturn: boolean;
  108457. visibleInstances: Nullable<InstancedMesh[]>[];
  108458. renderSelf: boolean[];
  108459. hardwareInstancedRendering: boolean[];
  108460. }
  108461. /**
  108462. * @hidden
  108463. **/
  108464. class _ThinInstanceDataStorage {
  108465. instancesCount: number;
  108466. matrixBuffer: Nullable<Buffer>;
  108467. matrixBufferSize: number;
  108468. matrixData: Nullable<Float32Array>;
  108469. boundingVectors: Array<Vector3>;
  108470. worldMatrices: Nullable<Matrix[]>;
  108471. }
  108472. /**
  108473. * Class used to represent renderable models
  108474. */
  108475. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108476. /**
  108477. * Mesh side orientation : usually the external or front surface
  108478. */
  108479. static readonly FRONTSIDE: number;
  108480. /**
  108481. * Mesh side orientation : usually the internal or back surface
  108482. */
  108483. static readonly BACKSIDE: number;
  108484. /**
  108485. * Mesh side orientation : both internal and external or front and back surfaces
  108486. */
  108487. static readonly DOUBLESIDE: number;
  108488. /**
  108489. * Mesh side orientation : by default, `FRONTSIDE`
  108490. */
  108491. static readonly DEFAULTSIDE: number;
  108492. /**
  108493. * Mesh cap setting : no cap
  108494. */
  108495. static readonly NO_CAP: number;
  108496. /**
  108497. * Mesh cap setting : one cap at the beginning of the mesh
  108498. */
  108499. static readonly CAP_START: number;
  108500. /**
  108501. * Mesh cap setting : one cap at the end of the mesh
  108502. */
  108503. static readonly CAP_END: number;
  108504. /**
  108505. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108506. */
  108507. static readonly CAP_ALL: number;
  108508. /**
  108509. * Mesh pattern setting : no flip or rotate
  108510. */
  108511. static readonly NO_FLIP: number;
  108512. /**
  108513. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108514. */
  108515. static readonly FLIP_TILE: number;
  108516. /**
  108517. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108518. */
  108519. static readonly ROTATE_TILE: number;
  108520. /**
  108521. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108522. */
  108523. static readonly FLIP_ROW: number;
  108524. /**
  108525. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108526. */
  108527. static readonly ROTATE_ROW: number;
  108528. /**
  108529. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108530. */
  108531. static readonly FLIP_N_ROTATE_TILE: number;
  108532. /**
  108533. * Mesh pattern setting : rotate pattern and rotate
  108534. */
  108535. static readonly FLIP_N_ROTATE_ROW: number;
  108536. /**
  108537. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108538. */
  108539. static readonly CENTER: number;
  108540. /**
  108541. * Mesh tile positioning : part tiles on left
  108542. */
  108543. static readonly LEFT: number;
  108544. /**
  108545. * Mesh tile positioning : part tiles on right
  108546. */
  108547. static readonly RIGHT: number;
  108548. /**
  108549. * Mesh tile positioning : part tiles on top
  108550. */
  108551. static readonly TOP: number;
  108552. /**
  108553. * Mesh tile positioning : part tiles on bottom
  108554. */
  108555. static readonly BOTTOM: number;
  108556. /**
  108557. * Gets the default side orientation.
  108558. * @param orientation the orientation to value to attempt to get
  108559. * @returns the default orientation
  108560. * @hidden
  108561. */
  108562. static _GetDefaultSideOrientation(orientation?: number): number;
  108563. private _internalMeshDataInfo;
  108564. get computeBonesUsingShaders(): boolean;
  108565. set computeBonesUsingShaders(value: boolean);
  108566. /**
  108567. * An event triggered before rendering the mesh
  108568. */
  108569. get onBeforeRenderObservable(): Observable<Mesh>;
  108570. /**
  108571. * An event triggered before binding the mesh
  108572. */
  108573. get onBeforeBindObservable(): Observable<Mesh>;
  108574. /**
  108575. * An event triggered after rendering the mesh
  108576. */
  108577. get onAfterRenderObservable(): Observable<Mesh>;
  108578. /**
  108579. * An event triggered before drawing the mesh
  108580. */
  108581. get onBeforeDrawObservable(): Observable<Mesh>;
  108582. private _onBeforeDrawObserver;
  108583. /**
  108584. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108585. */
  108586. set onBeforeDraw(callback: () => void);
  108587. get hasInstances(): boolean;
  108588. get hasThinInstances(): boolean;
  108589. /**
  108590. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108591. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108592. */
  108593. delayLoadState: number;
  108594. /**
  108595. * Gets the list of instances created from this mesh
  108596. * it is not supposed to be modified manually.
  108597. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108598. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108599. */
  108600. instances: InstancedMesh[];
  108601. /**
  108602. * Gets the file containing delay loading data for this mesh
  108603. */
  108604. delayLoadingFile: string;
  108605. /** @hidden */
  108606. _binaryInfo: any;
  108607. /**
  108608. * User defined function used to change how LOD level selection is done
  108609. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108610. */
  108611. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108612. /**
  108613. * Gets or sets the morph target manager
  108614. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108615. */
  108616. get morphTargetManager(): Nullable<MorphTargetManager>;
  108617. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108618. /** @hidden */
  108619. _creationDataStorage: Nullable<_CreationDataStorage>;
  108620. /** @hidden */
  108621. _geometry: Nullable<Geometry>;
  108622. /** @hidden */
  108623. _delayInfo: Array<string>;
  108624. /** @hidden */
  108625. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108626. /** @hidden */
  108627. _instanceDataStorage: _InstanceDataStorage;
  108628. /** @hidden */
  108629. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108630. private _effectiveMaterial;
  108631. /** @hidden */
  108632. _shouldGenerateFlatShading: boolean;
  108633. /** @hidden */
  108634. _originalBuilderSideOrientation: number;
  108635. /**
  108636. * Use this property to change the original side orientation defined at construction time
  108637. */
  108638. overrideMaterialSideOrientation: Nullable<number>;
  108639. /**
  108640. * Gets the source mesh (the one used to clone this one from)
  108641. */
  108642. get source(): Nullable<Mesh>;
  108643. /**
  108644. * Gets the list of clones of this mesh
  108645. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108646. * Note that useClonedMeshMap=true is the default setting
  108647. */
  108648. get cloneMeshMap(): Nullable<{
  108649. [id: string]: Mesh | undefined;
  108650. }>;
  108651. /**
  108652. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108653. */
  108654. get isUnIndexed(): boolean;
  108655. set isUnIndexed(value: boolean);
  108656. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108657. get worldMatrixInstancedBuffer(): Float32Array;
  108658. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108659. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108660. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108661. /**
  108662. * @constructor
  108663. * @param name The value used by scene.getMeshByName() to do a lookup.
  108664. * @param scene The scene to add this mesh to.
  108665. * @param parent The parent of this mesh, if it has one
  108666. * @param source An optional Mesh from which geometry is shared, cloned.
  108667. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108668. * When false, achieved by calling a clone(), also passing False.
  108669. * This will make creation of children, recursive.
  108670. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108671. */
  108672. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108673. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108674. doNotInstantiate: boolean;
  108675. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108676. /**
  108677. * Gets the class name
  108678. * @returns the string "Mesh".
  108679. */
  108680. getClassName(): string;
  108681. /** @hidden */
  108682. get _isMesh(): boolean;
  108683. /**
  108684. * Returns a description of this mesh
  108685. * @param fullDetails define if full details about this mesh must be used
  108686. * @returns a descriptive string representing this mesh
  108687. */
  108688. toString(fullDetails?: boolean): string;
  108689. /** @hidden */
  108690. _unBindEffect(): void;
  108691. /**
  108692. * Gets a boolean indicating if this mesh has LOD
  108693. */
  108694. get hasLODLevels(): boolean;
  108695. /**
  108696. * Gets the list of MeshLODLevel associated with the current mesh
  108697. * @returns an array of MeshLODLevel
  108698. */
  108699. getLODLevels(): MeshLODLevel[];
  108700. private _sortLODLevels;
  108701. /**
  108702. * Add a mesh as LOD level triggered at the given distance.
  108703. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108704. * @param distance The distance from the center of the object to show this level
  108705. * @param mesh The mesh to be added as LOD level (can be null)
  108706. * @return This mesh (for chaining)
  108707. */
  108708. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108709. /**
  108710. * Returns the LOD level mesh at the passed distance or null if not found.
  108711. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108712. * @param distance The distance from the center of the object to show this level
  108713. * @returns a Mesh or `null`
  108714. */
  108715. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108716. /**
  108717. * Remove a mesh from the LOD array
  108718. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108719. * @param mesh defines the mesh to be removed
  108720. * @return This mesh (for chaining)
  108721. */
  108722. removeLODLevel(mesh: Mesh): Mesh;
  108723. /**
  108724. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108725. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108726. * @param camera defines the camera to use to compute distance
  108727. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108728. * @return This mesh (for chaining)
  108729. */
  108730. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108731. /**
  108732. * Gets the mesh internal Geometry object
  108733. */
  108734. get geometry(): Nullable<Geometry>;
  108735. /**
  108736. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108737. * @returns the total number of vertices
  108738. */
  108739. getTotalVertices(): number;
  108740. /**
  108741. * Returns the content of an associated vertex buffer
  108742. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108743. * - VertexBuffer.PositionKind
  108744. * - VertexBuffer.UVKind
  108745. * - VertexBuffer.UV2Kind
  108746. * - VertexBuffer.UV3Kind
  108747. * - VertexBuffer.UV4Kind
  108748. * - VertexBuffer.UV5Kind
  108749. * - VertexBuffer.UV6Kind
  108750. * - VertexBuffer.ColorKind
  108751. * - VertexBuffer.MatricesIndicesKind
  108752. * - VertexBuffer.MatricesIndicesExtraKind
  108753. * - VertexBuffer.MatricesWeightsKind
  108754. * - VertexBuffer.MatricesWeightsExtraKind
  108755. * @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
  108756. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108757. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108758. */
  108759. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108760. /**
  108761. * Returns the mesh VertexBuffer object from the requested `kind`
  108762. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108763. * - VertexBuffer.PositionKind
  108764. * - VertexBuffer.NormalKind
  108765. * - VertexBuffer.UVKind
  108766. * - VertexBuffer.UV2Kind
  108767. * - VertexBuffer.UV3Kind
  108768. * - VertexBuffer.UV4Kind
  108769. * - VertexBuffer.UV5Kind
  108770. * - VertexBuffer.UV6Kind
  108771. * - VertexBuffer.ColorKind
  108772. * - VertexBuffer.MatricesIndicesKind
  108773. * - VertexBuffer.MatricesIndicesExtraKind
  108774. * - VertexBuffer.MatricesWeightsKind
  108775. * - VertexBuffer.MatricesWeightsExtraKind
  108776. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108777. */
  108778. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108779. /**
  108780. * Tests if a specific vertex buffer is associated with this mesh
  108781. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108782. * - VertexBuffer.PositionKind
  108783. * - VertexBuffer.NormalKind
  108784. * - VertexBuffer.UVKind
  108785. * - VertexBuffer.UV2Kind
  108786. * - VertexBuffer.UV3Kind
  108787. * - VertexBuffer.UV4Kind
  108788. * - VertexBuffer.UV5Kind
  108789. * - VertexBuffer.UV6Kind
  108790. * - VertexBuffer.ColorKind
  108791. * - VertexBuffer.MatricesIndicesKind
  108792. * - VertexBuffer.MatricesIndicesExtraKind
  108793. * - VertexBuffer.MatricesWeightsKind
  108794. * - VertexBuffer.MatricesWeightsExtraKind
  108795. * @returns a boolean
  108796. */
  108797. isVerticesDataPresent(kind: string): boolean;
  108798. /**
  108799. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108800. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108801. * - VertexBuffer.PositionKind
  108802. * - VertexBuffer.UVKind
  108803. * - VertexBuffer.UV2Kind
  108804. * - VertexBuffer.UV3Kind
  108805. * - VertexBuffer.UV4Kind
  108806. * - VertexBuffer.UV5Kind
  108807. * - VertexBuffer.UV6Kind
  108808. * - VertexBuffer.ColorKind
  108809. * - VertexBuffer.MatricesIndicesKind
  108810. * - VertexBuffer.MatricesIndicesExtraKind
  108811. * - VertexBuffer.MatricesWeightsKind
  108812. * - VertexBuffer.MatricesWeightsExtraKind
  108813. * @returns a boolean
  108814. */
  108815. isVertexBufferUpdatable(kind: string): boolean;
  108816. /**
  108817. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108818. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108819. * - VertexBuffer.PositionKind
  108820. * - VertexBuffer.NormalKind
  108821. * - VertexBuffer.UVKind
  108822. * - VertexBuffer.UV2Kind
  108823. * - VertexBuffer.UV3Kind
  108824. * - VertexBuffer.UV4Kind
  108825. * - VertexBuffer.UV5Kind
  108826. * - VertexBuffer.UV6Kind
  108827. * - VertexBuffer.ColorKind
  108828. * - VertexBuffer.MatricesIndicesKind
  108829. * - VertexBuffer.MatricesIndicesExtraKind
  108830. * - VertexBuffer.MatricesWeightsKind
  108831. * - VertexBuffer.MatricesWeightsExtraKind
  108832. * @returns an array of strings
  108833. */
  108834. getVerticesDataKinds(): string[];
  108835. /**
  108836. * Returns a positive integer : the total number of indices in this mesh geometry.
  108837. * @returns the numner of indices or zero if the mesh has no geometry.
  108838. */
  108839. getTotalIndices(): number;
  108840. /**
  108841. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108842. * @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.
  108843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108844. * @returns the indices array or an empty array if the mesh has no geometry
  108845. */
  108846. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108847. get isBlocked(): boolean;
  108848. /**
  108849. * Determine if the current mesh is ready to be rendered
  108850. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108851. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108852. * @returns true if all associated assets are ready (material, textures, shaders)
  108853. */
  108854. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108855. /**
  108856. * 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.
  108857. */
  108858. get areNormalsFrozen(): boolean;
  108859. /**
  108860. * 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.
  108861. * @returns the current mesh
  108862. */
  108863. freezeNormals(): Mesh;
  108864. /**
  108865. * 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
  108866. * @returns the current mesh
  108867. */
  108868. unfreezeNormals(): Mesh;
  108869. /**
  108870. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108871. */
  108872. set overridenInstanceCount(count: number);
  108873. /** @hidden */
  108874. _preActivate(): Mesh;
  108875. /** @hidden */
  108876. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108877. /** @hidden */
  108878. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108879. protected _afterComputeWorldMatrix(): void;
  108880. /** @hidden */
  108881. _postActivate(): void;
  108882. /**
  108883. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108884. * This means the mesh underlying bounding box and sphere are recomputed.
  108885. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108886. * @returns the current mesh
  108887. */
  108888. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108889. /** @hidden */
  108890. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108891. /**
  108892. * This function will subdivide the mesh into multiple submeshes
  108893. * @param count defines the expected number of submeshes
  108894. */
  108895. subdivide(count: number): void;
  108896. /**
  108897. * Copy a FloatArray into a specific associated vertex buffer
  108898. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108899. * - VertexBuffer.PositionKind
  108900. * - VertexBuffer.UVKind
  108901. * - VertexBuffer.UV2Kind
  108902. * - VertexBuffer.UV3Kind
  108903. * - VertexBuffer.UV4Kind
  108904. * - VertexBuffer.UV5Kind
  108905. * - VertexBuffer.UV6Kind
  108906. * - VertexBuffer.ColorKind
  108907. * - VertexBuffer.MatricesIndicesKind
  108908. * - VertexBuffer.MatricesIndicesExtraKind
  108909. * - VertexBuffer.MatricesWeightsKind
  108910. * - VertexBuffer.MatricesWeightsExtraKind
  108911. * @param data defines the data source
  108912. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108913. * @param stride defines the data stride size (can be null)
  108914. * @returns the current mesh
  108915. */
  108916. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108917. /**
  108918. * Delete a vertex buffer associated with this mesh
  108919. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108920. * - VertexBuffer.PositionKind
  108921. * - VertexBuffer.UVKind
  108922. * - VertexBuffer.UV2Kind
  108923. * - VertexBuffer.UV3Kind
  108924. * - VertexBuffer.UV4Kind
  108925. * - VertexBuffer.UV5Kind
  108926. * - VertexBuffer.UV6Kind
  108927. * - VertexBuffer.ColorKind
  108928. * - VertexBuffer.MatricesIndicesKind
  108929. * - VertexBuffer.MatricesIndicesExtraKind
  108930. * - VertexBuffer.MatricesWeightsKind
  108931. * - VertexBuffer.MatricesWeightsExtraKind
  108932. */
  108933. removeVerticesData(kind: string): void;
  108934. /**
  108935. * Flags an associated vertex buffer as updatable
  108936. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108937. * - VertexBuffer.PositionKind
  108938. * - VertexBuffer.UVKind
  108939. * - VertexBuffer.UV2Kind
  108940. * - VertexBuffer.UV3Kind
  108941. * - VertexBuffer.UV4Kind
  108942. * - VertexBuffer.UV5Kind
  108943. * - VertexBuffer.UV6Kind
  108944. * - VertexBuffer.ColorKind
  108945. * - VertexBuffer.MatricesIndicesKind
  108946. * - VertexBuffer.MatricesIndicesExtraKind
  108947. * - VertexBuffer.MatricesWeightsKind
  108948. * - VertexBuffer.MatricesWeightsExtraKind
  108949. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108950. */
  108951. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108952. /**
  108953. * Sets the mesh global Vertex Buffer
  108954. * @param buffer defines the buffer to use
  108955. * @returns the current mesh
  108956. */
  108957. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108958. /**
  108959. * Update a specific associated vertex buffer
  108960. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108961. * - VertexBuffer.PositionKind
  108962. * - VertexBuffer.UVKind
  108963. * - VertexBuffer.UV2Kind
  108964. * - VertexBuffer.UV3Kind
  108965. * - VertexBuffer.UV4Kind
  108966. * - VertexBuffer.UV5Kind
  108967. * - VertexBuffer.UV6Kind
  108968. * - VertexBuffer.ColorKind
  108969. * - VertexBuffer.MatricesIndicesKind
  108970. * - VertexBuffer.MatricesIndicesExtraKind
  108971. * - VertexBuffer.MatricesWeightsKind
  108972. * - VertexBuffer.MatricesWeightsExtraKind
  108973. * @param data defines the data source
  108974. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108975. * @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)
  108976. * @returns the current mesh
  108977. */
  108978. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108979. /**
  108980. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108981. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108982. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108983. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108984. * @returns the current mesh
  108985. */
  108986. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108987. /**
  108988. * Creates a un-shared specific occurence of the geometry for the mesh.
  108989. * @returns the current mesh
  108990. */
  108991. makeGeometryUnique(): Mesh;
  108992. /**
  108993. * Set the index buffer of this mesh
  108994. * @param indices defines the source data
  108995. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108996. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108997. * @returns the current mesh
  108998. */
  108999. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  109000. /**
  109001. * Update the current index buffer
  109002. * @param indices defines the source data
  109003. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109004. * @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)
  109005. * @returns the current mesh
  109006. */
  109007. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109008. /**
  109009. * Invert the geometry to move from a right handed system to a left handed one.
  109010. * @returns the current mesh
  109011. */
  109012. toLeftHanded(): Mesh;
  109013. /** @hidden */
  109014. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109015. /** @hidden */
  109016. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109017. /**
  109018. * Registers for this mesh a javascript function called just before the rendering process
  109019. * @param func defines the function to call before rendering this mesh
  109020. * @returns the current mesh
  109021. */
  109022. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109023. /**
  109024. * Disposes a previously registered javascript function called before the rendering
  109025. * @param func defines the function to remove
  109026. * @returns the current mesh
  109027. */
  109028. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109029. /**
  109030. * Registers for this mesh a javascript function called just after the rendering is complete
  109031. * @param func defines the function to call after rendering this mesh
  109032. * @returns the current mesh
  109033. */
  109034. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109035. /**
  109036. * Disposes a previously registered javascript function called after the rendering.
  109037. * @param func defines the function to remove
  109038. * @returns the current mesh
  109039. */
  109040. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109041. /** @hidden */
  109042. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109043. /** @hidden */
  109044. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109045. /** @hidden */
  109046. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109047. /** @hidden */
  109048. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109049. /** @hidden */
  109050. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109051. /** @hidden */
  109052. _rebuild(): void;
  109053. /** @hidden */
  109054. _freeze(): void;
  109055. /** @hidden */
  109056. _unFreeze(): void;
  109057. /**
  109058. * 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
  109059. * @param subMesh defines the subMesh to render
  109060. * @param enableAlphaMode defines if alpha mode can be changed
  109061. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109062. * @returns the current mesh
  109063. */
  109064. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109065. private _onBeforeDraw;
  109066. /**
  109067. * Renormalize the mesh and patch it up if there are no weights
  109068. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109069. * However in the case of zero weights then we set just a single influence to 1.
  109070. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109071. */
  109072. cleanMatrixWeights(): void;
  109073. private normalizeSkinFourWeights;
  109074. private normalizeSkinWeightsAndExtra;
  109075. /**
  109076. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109077. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109078. * the user know there was an issue with importing the mesh
  109079. * @returns a validation object with skinned, valid and report string
  109080. */
  109081. validateSkinning(): {
  109082. skinned: boolean;
  109083. valid: boolean;
  109084. report: string;
  109085. };
  109086. /** @hidden */
  109087. _checkDelayState(): Mesh;
  109088. private _queueLoad;
  109089. /**
  109090. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109091. * A mesh is in the frustum if its bounding box intersects the frustum
  109092. * @param frustumPlanes defines the frustum to test
  109093. * @returns true if the mesh is in the frustum planes
  109094. */
  109095. isInFrustum(frustumPlanes: Plane[]): boolean;
  109096. /**
  109097. * Sets the mesh material by the material or multiMaterial `id` property
  109098. * @param id is a string identifying the material or the multiMaterial
  109099. * @returns the current mesh
  109100. */
  109101. setMaterialByID(id: string): Mesh;
  109102. /**
  109103. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109104. * @returns an array of IAnimatable
  109105. */
  109106. getAnimatables(): IAnimatable[];
  109107. /**
  109108. * Modifies the mesh geometry according to the passed transformation matrix.
  109109. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109110. * The mesh normals are modified using the same transformation.
  109111. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109112. * @param transform defines the transform matrix to use
  109113. * @see https://doc.babylonjs.com/resources/baking_transformations
  109114. * @returns the current mesh
  109115. */
  109116. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109117. /**
  109118. * Modifies the mesh geometry according to its own current World Matrix.
  109119. * The mesh World Matrix is then reset.
  109120. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109121. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109122. * @see https://doc.babylonjs.com/resources/baking_transformations
  109123. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109124. * @returns the current mesh
  109125. */
  109126. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109127. /** @hidden */
  109128. get _positions(): Nullable<Vector3[]>;
  109129. /** @hidden */
  109130. _resetPointsArrayCache(): Mesh;
  109131. /** @hidden */
  109132. _generatePointsArray(): boolean;
  109133. /**
  109134. * Returns a new Mesh object generated from the current mesh properties.
  109135. * This method must not get confused with createInstance()
  109136. * @param name is a string, the name given to the new mesh
  109137. * @param newParent can be any Node object (default `null`)
  109138. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109139. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109140. * @returns a new mesh
  109141. */
  109142. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109143. /**
  109144. * Releases resources associated with this mesh.
  109145. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109146. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109147. */
  109148. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109149. /** @hidden */
  109150. _disposeInstanceSpecificData(): void;
  109151. /** @hidden */
  109152. _disposeThinInstanceSpecificData(): void;
  109153. /**
  109154. * Modifies the mesh geometry according to a displacement map.
  109155. * 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.
  109156. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109157. * @param url is a string, the URL from the image file is to be downloaded.
  109158. * @param minHeight is the lower limit of the displacement.
  109159. * @param maxHeight is the upper limit of the displacement.
  109160. * @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.
  109161. * @param uvOffset is an optional vector2 used to offset UV.
  109162. * @param uvScale is an optional vector2 used to scale UV.
  109163. * @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.
  109164. * @returns the Mesh.
  109165. */
  109166. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109167. /**
  109168. * Modifies the mesh geometry according to a displacementMap buffer.
  109169. * 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.
  109170. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109171. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109172. * @param heightMapWidth is the width of the buffer image.
  109173. * @param heightMapHeight is the height of the buffer image.
  109174. * @param minHeight is the lower limit of the displacement.
  109175. * @param maxHeight is the upper limit of the displacement.
  109176. * @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.
  109177. * @param uvOffset is an optional vector2 used to offset UV.
  109178. * @param uvScale is an optional vector2 used to scale UV.
  109179. * @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.
  109180. * @returns the Mesh.
  109181. */
  109182. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109183. /**
  109184. * Modify the mesh to get a flat shading rendering.
  109185. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109186. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109187. * @returns current mesh
  109188. */
  109189. convertToFlatShadedMesh(): Mesh;
  109190. /**
  109191. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109192. * In other words, more vertices, no more indices and a single bigger VBO.
  109193. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109194. * @returns current mesh
  109195. */
  109196. convertToUnIndexedMesh(): Mesh;
  109197. /**
  109198. * Inverses facet orientations.
  109199. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109200. * @param flipNormals will also inverts the normals
  109201. * @returns current mesh
  109202. */
  109203. flipFaces(flipNormals?: boolean): Mesh;
  109204. /**
  109205. * Increase the number of facets and hence vertices in a mesh
  109206. * Vertex normals are interpolated from existing vertex normals
  109207. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109208. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109209. */
  109210. increaseVertices(numberPerEdge: number): void;
  109211. /**
  109212. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109213. * This will undo any application of covertToFlatShadedMesh
  109214. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109215. */
  109216. forceSharedVertices(): void;
  109217. /** @hidden */
  109218. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109219. /** @hidden */
  109220. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109221. /**
  109222. * Creates a new InstancedMesh object from the mesh model.
  109223. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109224. * @param name defines the name of the new instance
  109225. * @returns a new InstancedMesh
  109226. */
  109227. createInstance(name: string): InstancedMesh;
  109228. /**
  109229. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109230. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109231. * @returns the current mesh
  109232. */
  109233. synchronizeInstances(): Mesh;
  109234. /**
  109235. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109236. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109237. * This should be used together with the simplification to avoid disappearing triangles.
  109238. * @param successCallback an optional success callback to be called after the optimization finished.
  109239. * @returns the current mesh
  109240. */
  109241. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109242. /**
  109243. * Serialize current mesh
  109244. * @param serializationObject defines the object which will receive the serialization data
  109245. */
  109246. serialize(serializationObject: any): void;
  109247. /** @hidden */
  109248. _syncGeometryWithMorphTargetManager(): void;
  109249. /** @hidden */
  109250. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109251. /**
  109252. * Returns a new Mesh object parsed from the source provided.
  109253. * @param parsedMesh is the source
  109254. * @param scene defines the hosting scene
  109255. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109256. * @returns a new Mesh
  109257. */
  109258. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109259. /**
  109260. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109262. * @param name defines the name of the mesh to create
  109263. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109264. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109265. * @param closePath creates a seam between the first and the last points of each path of the path array
  109266. * @param offset is taken in account only if the `pathArray` is containing a single path
  109267. * @param scene defines the hosting scene
  109268. * @param updatable defines if the mesh must be flagged as updatable
  109269. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109270. * @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)
  109271. * @returns a new Mesh
  109272. */
  109273. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109274. /**
  109275. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109276. * @param name defines the name of the mesh to create
  109277. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109278. * @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
  109279. * @param scene defines the hosting scene
  109280. * @param updatable defines if the mesh must be flagged as updatable
  109281. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109282. * @returns a new Mesh
  109283. */
  109284. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109285. /**
  109286. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109287. * @param name defines the name of the mesh to create
  109288. * @param size sets the size (float) of each box side (default 1)
  109289. * @param scene defines the hosting scene
  109290. * @param updatable defines if the mesh must be flagged as updatable
  109291. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109292. * @returns a new Mesh
  109293. */
  109294. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109295. /**
  109296. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109297. * @param name defines the name of the mesh to create
  109298. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109299. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109300. * @param scene defines the hosting scene
  109301. * @param updatable defines if the mesh must be flagged as updatable
  109302. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109303. * @returns a new Mesh
  109304. */
  109305. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109306. /**
  109307. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109308. * @param name defines the name of the mesh to create
  109309. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109310. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109311. * @param scene defines the hosting scene
  109312. * @returns a new Mesh
  109313. */
  109314. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109315. /**
  109316. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109317. * @param name defines the name of the mesh to create
  109318. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109319. * @param diameterTop set the top cap diameter (floats, default 1)
  109320. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109321. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109322. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109323. * @param scene defines the hosting scene
  109324. * @param updatable defines if the mesh must be flagged as updatable
  109325. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109326. * @returns a new Mesh
  109327. */
  109328. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109329. /**
  109330. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109331. * @param name defines the name of the mesh to create
  109332. * @param diameter sets the diameter size (float) of the torus (default 1)
  109333. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109334. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109335. * @param scene defines the hosting scene
  109336. * @param updatable defines if the mesh must be flagged as updatable
  109337. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109338. * @returns a new Mesh
  109339. */
  109340. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109341. /**
  109342. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109343. * @param name defines the name of the mesh to create
  109344. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109345. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109346. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109347. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109348. * @param p the number of windings on X axis (positive integers, default 2)
  109349. * @param q the number of windings on Y axis (positive integers, default 3)
  109350. * @param scene defines the hosting scene
  109351. * @param updatable defines if the mesh must be flagged as updatable
  109352. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109353. * @returns a new Mesh
  109354. */
  109355. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109356. /**
  109357. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109358. * @param name defines the name of the mesh to create
  109359. * @param points is an array successive Vector3
  109360. * @param scene defines the hosting scene
  109361. * @param updatable defines if the mesh must be flagged as updatable
  109362. * @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).
  109363. * @returns a new Mesh
  109364. */
  109365. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109366. /**
  109367. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109368. * @param name defines the name of the mesh to create
  109369. * @param points is an array successive Vector3
  109370. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109371. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109372. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109373. * @param scene defines the hosting scene
  109374. * @param updatable defines if the mesh must be flagged as updatable
  109375. * @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)
  109376. * @returns a new Mesh
  109377. */
  109378. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109379. /**
  109380. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109381. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109382. * 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.
  109383. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109384. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109385. * Remember you can only change the shape positions, not their number when updating a polygon.
  109386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109387. * @param name defines the name of the mesh to create
  109388. * @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
  109389. * @param scene defines the hosting scene
  109390. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109391. * @param updatable defines if the mesh must be flagged as updatable
  109392. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109393. * @param earcutInjection can be used to inject your own earcut reference
  109394. * @returns a new Mesh
  109395. */
  109396. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109397. /**
  109398. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109400. * @param name defines the name of the mesh to create
  109401. * @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
  109402. * @param depth defines the height of extrusion
  109403. * @param scene defines the hosting scene
  109404. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109405. * @param updatable defines if the mesh must be flagged as updatable
  109406. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109407. * @param earcutInjection can be used to inject your own earcut reference
  109408. * @returns a new Mesh
  109409. */
  109410. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109411. /**
  109412. * Creates an extruded shape mesh.
  109413. * 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
  109414. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109416. * @param name defines the name of the mesh to create
  109417. * @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
  109418. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109419. * @param scale is the value to scale the shape
  109420. * @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
  109421. * @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
  109422. * @param scene defines the hosting scene
  109423. * @param updatable defines if the mesh must be flagged as updatable
  109424. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109425. * @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)
  109426. * @returns a new Mesh
  109427. */
  109428. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109429. /**
  109430. * Creates an custom extruded shape mesh.
  109431. * The custom extrusion is a parametric shape.
  109432. * It has no predefined shape. Its final shape will depend on the input parameters.
  109433. * Please consider using the same method from the MeshBuilder class instead
  109434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109435. * @param name defines the name of the mesh to create
  109436. * @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
  109437. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109438. * @param scaleFunction is a custom Javascript function called on each path point
  109439. * @param rotationFunction is a custom Javascript function called on each path point
  109440. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109441. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109442. * @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
  109443. * @param scene defines the hosting scene
  109444. * @param updatable defines if the mesh must be flagged as updatable
  109445. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109446. * @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)
  109447. * @returns a new Mesh
  109448. */
  109449. 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;
  109450. /**
  109451. * Creates lathe mesh.
  109452. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109453. * Please consider using the same method from the MeshBuilder class instead
  109454. * @param name defines the name of the mesh to create
  109455. * @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
  109456. * @param radius is the radius value of the lathe
  109457. * @param tessellation is the side number of the lathe.
  109458. * @param scene defines the hosting scene
  109459. * @param updatable defines if the mesh must be flagged as updatable
  109460. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109461. * @returns a new Mesh
  109462. */
  109463. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109464. /**
  109465. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109466. * @param name defines the name of the mesh to create
  109467. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109468. * @param scene defines the hosting scene
  109469. * @param updatable defines if the mesh must be flagged as updatable
  109470. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109471. * @returns a new Mesh
  109472. */
  109473. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109474. /**
  109475. * Creates a ground mesh.
  109476. * Please consider using the same method from the MeshBuilder class instead
  109477. * @param name defines the name of the mesh to create
  109478. * @param width set the width of the ground
  109479. * @param height set the height of the ground
  109480. * @param subdivisions sets the number of subdivisions per side
  109481. * @param scene defines the hosting scene
  109482. * @param updatable defines if the mesh must be flagged as updatable
  109483. * @returns a new Mesh
  109484. */
  109485. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109486. /**
  109487. * Creates a tiled ground mesh.
  109488. * Please consider using the same method from the MeshBuilder class instead
  109489. * @param name defines the name of the mesh to create
  109490. * @param xmin set the ground minimum X coordinate
  109491. * @param zmin set the ground minimum Y coordinate
  109492. * @param xmax set the ground maximum X coordinate
  109493. * @param zmax set the ground maximum Z coordinate
  109494. * @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
  109495. * @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
  109496. * @param scene defines the hosting scene
  109497. * @param updatable defines if the mesh must be flagged as updatable
  109498. * @returns a new Mesh
  109499. */
  109500. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109501. w: number;
  109502. h: number;
  109503. }, precision: {
  109504. w: number;
  109505. h: number;
  109506. }, scene: Scene, updatable?: boolean): Mesh;
  109507. /**
  109508. * Creates a ground mesh from a height map.
  109509. * Please consider using the same method from the MeshBuilder class instead
  109510. * @see https://doc.babylonjs.com/babylon101/height_map
  109511. * @param name defines the name of the mesh to create
  109512. * @param url sets the URL of the height map image resource
  109513. * @param width set the ground width size
  109514. * @param height set the ground height size
  109515. * @param subdivisions sets the number of subdivision per side
  109516. * @param minHeight is the minimum altitude on the ground
  109517. * @param maxHeight is the maximum altitude on the ground
  109518. * @param scene defines the hosting scene
  109519. * @param updatable defines if the mesh must be flagged as updatable
  109520. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109521. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109522. * @returns a new Mesh
  109523. */
  109524. 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;
  109525. /**
  109526. * Creates a tube mesh.
  109527. * The tube is a parametric shape.
  109528. * It has no predefined shape. Its final shape will depend on the input parameters.
  109529. * Please consider using the same method from the MeshBuilder class instead
  109530. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109531. * @param name defines the name of the mesh to create
  109532. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109533. * @param radius sets the tube radius size
  109534. * @param tessellation is the number of sides on the tubular surface
  109535. * @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
  109536. * @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
  109537. * @param scene defines the hosting scene
  109538. * @param updatable defines if the mesh must be flagged as updatable
  109539. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109540. * @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)
  109541. * @returns a new Mesh
  109542. */
  109543. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109544. (i: number, distance: number): number;
  109545. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109546. /**
  109547. * Creates a polyhedron mesh.
  109548. * Please consider using the same method from the MeshBuilder class instead.
  109549. * * 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
  109550. * * The parameter `size` (positive float, default 1) sets the polygon size
  109551. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109552. * * 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`
  109553. * * 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
  109554. * * 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)`)
  109555. * * 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
  109556. * * 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
  109557. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109560. * @param name defines the name of the mesh to create
  109561. * @param options defines the options used to create the mesh
  109562. * @param scene defines the hosting scene
  109563. * @returns a new Mesh
  109564. */
  109565. static CreatePolyhedron(name: string, options: {
  109566. type?: number;
  109567. size?: number;
  109568. sizeX?: number;
  109569. sizeY?: number;
  109570. sizeZ?: number;
  109571. custom?: any;
  109572. faceUV?: Vector4[];
  109573. faceColors?: Color4[];
  109574. updatable?: boolean;
  109575. sideOrientation?: number;
  109576. }, scene: Scene): Mesh;
  109577. /**
  109578. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109579. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109580. * * 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`)
  109581. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109582. * * 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
  109583. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109586. * @param name defines the name of the mesh
  109587. * @param options defines the options used to create the mesh
  109588. * @param scene defines the hosting scene
  109589. * @returns a new Mesh
  109590. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109591. */
  109592. static CreateIcoSphere(name: string, options: {
  109593. radius?: number;
  109594. flat?: boolean;
  109595. subdivisions?: number;
  109596. sideOrientation?: number;
  109597. updatable?: boolean;
  109598. }, scene: Scene): Mesh;
  109599. /**
  109600. * Creates a decal mesh.
  109601. * Please consider using the same method from the MeshBuilder class instead.
  109602. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109603. * @param name defines the name of the mesh
  109604. * @param sourceMesh defines the mesh receiving the decal
  109605. * @param position sets the position of the decal in world coordinates
  109606. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109607. * @param size sets the decal scaling
  109608. * @param angle sets the angle to rotate the decal
  109609. * @returns a new Mesh
  109610. */
  109611. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109612. /** Creates a Capsule Mesh
  109613. * @param name defines the name of the mesh.
  109614. * @param options the constructors options used to shape the mesh.
  109615. * @param scene defines the scene the mesh is scoped to.
  109616. * @returns the capsule mesh
  109617. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109618. */
  109619. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109620. /**
  109621. * Prepare internal position array for software CPU skinning
  109622. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109623. */
  109624. setPositionsForCPUSkinning(): Float32Array;
  109625. /**
  109626. * Prepare internal normal array for software CPU skinning
  109627. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109628. */
  109629. setNormalsForCPUSkinning(): Float32Array;
  109630. /**
  109631. * Updates the vertex buffer by applying transformation from the bones
  109632. * @param skeleton defines the skeleton to apply to current mesh
  109633. * @returns the current mesh
  109634. */
  109635. applySkeleton(skeleton: Skeleton): Mesh;
  109636. /**
  109637. * 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
  109638. * @param meshes defines the list of meshes to scan
  109639. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109640. */
  109641. static MinMax(meshes: AbstractMesh[]): {
  109642. min: Vector3;
  109643. max: Vector3;
  109644. };
  109645. /**
  109646. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109647. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109648. * @returns a vector3
  109649. */
  109650. static Center(meshesOrMinMaxVector: {
  109651. min: Vector3;
  109652. max: Vector3;
  109653. } | AbstractMesh[]): Vector3;
  109654. /**
  109655. * Merge the array of meshes into a single mesh for performance reasons.
  109656. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109657. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109658. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109659. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109660. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109661. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109662. * @returns a new mesh
  109663. */
  109664. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109665. /** @hidden */
  109666. addInstance(instance: InstancedMesh): void;
  109667. /** @hidden */
  109668. removeInstance(instance: InstancedMesh): void;
  109669. }
  109670. }
  109671. declare module BABYLON {
  109672. /**
  109673. * This is the base class of all the camera used in the application.
  109674. * @see https://doc.babylonjs.com/features/cameras
  109675. */
  109676. export class Camera extends Node {
  109677. /** @hidden */
  109678. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109679. /**
  109680. * This is the default projection mode used by the cameras.
  109681. * It helps recreating a feeling of perspective and better appreciate depth.
  109682. * This is the best way to simulate real life cameras.
  109683. */
  109684. static readonly PERSPECTIVE_CAMERA: number;
  109685. /**
  109686. * This helps creating camera with an orthographic mode.
  109687. * 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.
  109688. */
  109689. static readonly ORTHOGRAPHIC_CAMERA: number;
  109690. /**
  109691. * This is the default FOV mode for perspective cameras.
  109692. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109693. */
  109694. static readonly FOVMODE_VERTICAL_FIXED: number;
  109695. /**
  109696. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109697. */
  109698. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109699. /**
  109700. * This specifies ther is no need for a camera rig.
  109701. * Basically only one eye is rendered corresponding to the camera.
  109702. */
  109703. static readonly RIG_MODE_NONE: number;
  109704. /**
  109705. * Simulates a camera Rig with one blue eye and one red eye.
  109706. * This can be use with 3d blue and red glasses.
  109707. */
  109708. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109709. /**
  109710. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109711. */
  109712. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109713. /**
  109714. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109715. */
  109716. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109717. /**
  109718. * Defines that both eyes of the camera will be rendered over under each other.
  109719. */
  109720. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109721. /**
  109722. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109723. */
  109724. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109725. /**
  109726. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109727. */
  109728. static readonly RIG_MODE_VR: number;
  109729. /**
  109730. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109731. */
  109732. static readonly RIG_MODE_WEBVR: number;
  109733. /**
  109734. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109735. */
  109736. static readonly RIG_MODE_CUSTOM: number;
  109737. /**
  109738. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109739. */
  109740. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109741. /**
  109742. * Define the input manager associated with the camera.
  109743. */
  109744. inputs: CameraInputsManager<Camera>;
  109745. /** @hidden */
  109746. _position: Vector3;
  109747. /**
  109748. * Define the current local position of the camera in the scene
  109749. */
  109750. get position(): Vector3;
  109751. set position(newPosition: Vector3);
  109752. protected _upVector: Vector3;
  109753. /**
  109754. * The vector the camera should consider as up.
  109755. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109756. */
  109757. set upVector(vec: Vector3);
  109758. get upVector(): Vector3;
  109759. /**
  109760. * Define the current limit on the left side for an orthographic camera
  109761. * In scene unit
  109762. */
  109763. orthoLeft: Nullable<number>;
  109764. /**
  109765. * Define the current limit on the right side for an orthographic camera
  109766. * In scene unit
  109767. */
  109768. orthoRight: Nullable<number>;
  109769. /**
  109770. * Define the current limit on the bottom side for an orthographic camera
  109771. * In scene unit
  109772. */
  109773. orthoBottom: Nullable<number>;
  109774. /**
  109775. * Define the current limit on the top side for an orthographic camera
  109776. * In scene unit
  109777. */
  109778. orthoTop: Nullable<number>;
  109779. /**
  109780. * Field Of View is set in Radians. (default is 0.8)
  109781. */
  109782. fov: number;
  109783. /**
  109784. * Define the minimum distance the camera can see from.
  109785. * This is important to note that the depth buffer are not infinite and the closer it starts
  109786. * the more your scene might encounter depth fighting issue.
  109787. */
  109788. minZ: number;
  109789. /**
  109790. * Define the maximum distance the camera can see to.
  109791. * This is important to note that the depth buffer are not infinite and the further it end
  109792. * the more your scene might encounter depth fighting issue.
  109793. */
  109794. maxZ: number;
  109795. /**
  109796. * Define the default inertia of the camera.
  109797. * This helps giving a smooth feeling to the camera movement.
  109798. */
  109799. inertia: number;
  109800. /**
  109801. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109802. */
  109803. mode: number;
  109804. /**
  109805. * Define whether the camera is intermediate.
  109806. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109807. */
  109808. isIntermediate: boolean;
  109809. /**
  109810. * Define the viewport of the camera.
  109811. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109812. */
  109813. viewport: Viewport;
  109814. /**
  109815. * Restricts the camera to viewing objects with the same layerMask.
  109816. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109817. */
  109818. layerMask: number;
  109819. /**
  109820. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109821. */
  109822. fovMode: number;
  109823. /**
  109824. * Rig mode of the camera.
  109825. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109826. * This is normally controlled byt the camera themselves as internal use.
  109827. */
  109828. cameraRigMode: number;
  109829. /**
  109830. * Defines the distance between both "eyes" in case of a RIG
  109831. */
  109832. interaxialDistance: number;
  109833. /**
  109834. * Defines if stereoscopic rendering is done side by side or over under.
  109835. */
  109836. isStereoscopicSideBySide: boolean;
  109837. /**
  109838. * 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
  109839. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109840. * else in the scene. (Eg. security camera)
  109841. *
  109842. * 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)
  109843. */
  109844. customRenderTargets: RenderTargetTexture[];
  109845. /**
  109846. * When set, the camera will render to this render target instead of the default canvas
  109847. *
  109848. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109849. */
  109850. outputRenderTarget: Nullable<RenderTargetTexture>;
  109851. /**
  109852. * Observable triggered when the camera view matrix has changed.
  109853. */
  109854. onViewMatrixChangedObservable: Observable<Camera>;
  109855. /**
  109856. * Observable triggered when the camera Projection matrix has changed.
  109857. */
  109858. onProjectionMatrixChangedObservable: Observable<Camera>;
  109859. /**
  109860. * Observable triggered when the inputs have been processed.
  109861. */
  109862. onAfterCheckInputsObservable: Observable<Camera>;
  109863. /**
  109864. * Observable triggered when reset has been called and applied to the camera.
  109865. */
  109866. onRestoreStateObservable: Observable<Camera>;
  109867. /**
  109868. * Is this camera a part of a rig system?
  109869. */
  109870. isRigCamera: boolean;
  109871. /**
  109872. * If isRigCamera set to true this will be set with the parent camera.
  109873. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109874. */
  109875. rigParent?: Camera;
  109876. /** @hidden */
  109877. _cameraRigParams: any;
  109878. /** @hidden */
  109879. _rigCameras: Camera[];
  109880. /** @hidden */
  109881. _rigPostProcess: Nullable<PostProcess>;
  109882. protected _webvrViewMatrix: Matrix;
  109883. /** @hidden */
  109884. _skipRendering: boolean;
  109885. /** @hidden */
  109886. _projectionMatrix: Matrix;
  109887. /** @hidden */
  109888. _postProcesses: Nullable<PostProcess>[];
  109889. /** @hidden */
  109890. _activeMeshes: SmartArray<AbstractMesh>;
  109891. protected _globalPosition: Vector3;
  109892. /** @hidden */
  109893. _computedViewMatrix: Matrix;
  109894. private _doNotComputeProjectionMatrix;
  109895. private _transformMatrix;
  109896. private _frustumPlanes;
  109897. private _refreshFrustumPlanes;
  109898. private _storedFov;
  109899. private _stateStored;
  109900. /**
  109901. * Instantiates a new camera object.
  109902. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109903. * @see https://doc.babylonjs.com/features/cameras
  109904. * @param name Defines the name of the camera in the scene
  109905. * @param position Defines the position of the camera
  109906. * @param scene Defines the scene the camera belongs too
  109907. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109908. */
  109909. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109910. /**
  109911. * Store current camera state (fov, position, etc..)
  109912. * @returns the camera
  109913. */
  109914. storeState(): Camera;
  109915. /**
  109916. * Restores the camera state values if it has been stored. You must call storeState() first
  109917. */
  109918. protected _restoreStateValues(): boolean;
  109919. /**
  109920. * Restored camera state. You must call storeState() first.
  109921. * @returns true if restored and false otherwise
  109922. */
  109923. restoreState(): boolean;
  109924. /**
  109925. * Gets the class name of the camera.
  109926. * @returns the class name
  109927. */
  109928. getClassName(): string;
  109929. /** @hidden */
  109930. readonly _isCamera: boolean;
  109931. /**
  109932. * Gets a string representation of the camera useful for debug purpose.
  109933. * @param fullDetails Defines that a more verboe level of logging is required
  109934. * @returns the string representation
  109935. */
  109936. toString(fullDetails?: boolean): string;
  109937. /**
  109938. * Gets the current world space position of the camera.
  109939. */
  109940. get globalPosition(): Vector3;
  109941. /**
  109942. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109943. * @returns the active meshe list
  109944. */
  109945. getActiveMeshes(): SmartArray<AbstractMesh>;
  109946. /**
  109947. * Check whether a mesh is part of the current active mesh list of the camera
  109948. * @param mesh Defines the mesh to check
  109949. * @returns true if active, false otherwise
  109950. */
  109951. isActiveMesh(mesh: Mesh): boolean;
  109952. /**
  109953. * Is this camera ready to be used/rendered
  109954. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109955. * @return true if the camera is ready
  109956. */
  109957. isReady(completeCheck?: boolean): boolean;
  109958. /** @hidden */
  109959. _initCache(): void;
  109960. /** @hidden */
  109961. _updateCache(ignoreParentClass?: boolean): void;
  109962. /** @hidden */
  109963. _isSynchronized(): boolean;
  109964. /** @hidden */
  109965. _isSynchronizedViewMatrix(): boolean;
  109966. /** @hidden */
  109967. _isSynchronizedProjectionMatrix(): boolean;
  109968. /**
  109969. * Attach the input controls to a specific dom element to get the input from.
  109970. * @param element Defines the element the controls should be listened from
  109971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109972. */
  109973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109974. /**
  109975. * Detach the current controls from the specified dom element.
  109976. * @param element Defines the element to stop listening the inputs from
  109977. */
  109978. detachControl(element: HTMLElement): void;
  109979. /**
  109980. * Update the camera state according to the different inputs gathered during the frame.
  109981. */
  109982. update(): void;
  109983. /** @hidden */
  109984. _checkInputs(): void;
  109985. /** @hidden */
  109986. get rigCameras(): Camera[];
  109987. /**
  109988. * Gets the post process used by the rig cameras
  109989. */
  109990. get rigPostProcess(): Nullable<PostProcess>;
  109991. /**
  109992. * Internal, gets the first post proces.
  109993. * @returns the first post process to be run on this camera.
  109994. */
  109995. _getFirstPostProcess(): Nullable<PostProcess>;
  109996. private _cascadePostProcessesToRigCams;
  109997. /**
  109998. * Attach a post process to the camera.
  109999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110000. * @param postProcess The post process to attach to the camera
  110001. * @param insertAt The position of the post process in case several of them are in use in the scene
  110002. * @returns the position the post process has been inserted at
  110003. */
  110004. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110005. /**
  110006. * Detach a post process to the camera.
  110007. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110008. * @param postProcess The post process to detach from the camera
  110009. */
  110010. detachPostProcess(postProcess: PostProcess): void;
  110011. /**
  110012. * Gets the current world matrix of the camera
  110013. */
  110014. getWorldMatrix(): Matrix;
  110015. /** @hidden */
  110016. _getViewMatrix(): Matrix;
  110017. /**
  110018. * Gets the current view matrix of the camera.
  110019. * @param force forces the camera to recompute the matrix without looking at the cached state
  110020. * @returns the view matrix
  110021. */
  110022. getViewMatrix(force?: boolean): Matrix;
  110023. /**
  110024. * Freeze the projection matrix.
  110025. * It will prevent the cache check of the camera projection compute and can speed up perf
  110026. * if no parameter of the camera are meant to change
  110027. * @param projection Defines manually a projection if necessary
  110028. */
  110029. freezeProjectionMatrix(projection?: Matrix): void;
  110030. /**
  110031. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110032. */
  110033. unfreezeProjectionMatrix(): void;
  110034. /**
  110035. * Gets the current projection matrix of the camera.
  110036. * @param force forces the camera to recompute the matrix without looking at the cached state
  110037. * @returns the projection matrix
  110038. */
  110039. getProjectionMatrix(force?: boolean): Matrix;
  110040. /**
  110041. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110042. * @returns a Matrix
  110043. */
  110044. getTransformationMatrix(): Matrix;
  110045. private _updateFrustumPlanes;
  110046. /**
  110047. * Checks if a cullable object (mesh...) is in the camera frustum
  110048. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110049. * @param target The object to check
  110050. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110051. * @returns true if the object is in frustum otherwise false
  110052. */
  110053. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110054. /**
  110055. * Checks if a cullable object (mesh...) is in the camera frustum
  110056. * Unlike isInFrustum this cheks the full bounding box
  110057. * @param target The object to check
  110058. * @returns true if the object is in frustum otherwise false
  110059. */
  110060. isCompletelyInFrustum(target: ICullable): boolean;
  110061. /**
  110062. * Gets a ray in the forward direction from the camera.
  110063. * @param length Defines the length of the ray to create
  110064. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110065. * @param origin Defines the start point of the ray which defaults to the camera position
  110066. * @returns the forward ray
  110067. */
  110068. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110069. /**
  110070. * Gets a ray in the forward direction from the camera.
  110071. * @param refRay the ray to (re)use when setting the values
  110072. * @param length Defines the length of the ray to create
  110073. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110074. * @param origin Defines the start point of the ray which defaults to the camera position
  110075. * @returns the forward ray
  110076. */
  110077. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110078. /**
  110079. * Releases resources associated with this node.
  110080. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110081. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110082. */
  110083. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110084. /** @hidden */
  110085. _isLeftCamera: boolean;
  110086. /**
  110087. * Gets the left camera of a rig setup in case of Rigged Camera
  110088. */
  110089. get isLeftCamera(): boolean;
  110090. /** @hidden */
  110091. _isRightCamera: boolean;
  110092. /**
  110093. * Gets the right camera of a rig setup in case of Rigged Camera
  110094. */
  110095. get isRightCamera(): boolean;
  110096. /**
  110097. * Gets the left camera of a rig setup in case of Rigged Camera
  110098. */
  110099. get leftCamera(): Nullable<FreeCamera>;
  110100. /**
  110101. * Gets the right camera of a rig setup in case of Rigged Camera
  110102. */
  110103. get rightCamera(): Nullable<FreeCamera>;
  110104. /**
  110105. * Gets the left camera target of a rig setup in case of Rigged Camera
  110106. * @returns the target position
  110107. */
  110108. getLeftTarget(): Nullable<Vector3>;
  110109. /**
  110110. * Gets the right camera target of a rig setup in case of Rigged Camera
  110111. * @returns the target position
  110112. */
  110113. getRightTarget(): Nullable<Vector3>;
  110114. /**
  110115. * @hidden
  110116. */
  110117. setCameraRigMode(mode: number, rigParams: any): void;
  110118. /** @hidden */
  110119. static _setStereoscopicRigMode(camera: Camera): void;
  110120. /** @hidden */
  110121. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110122. /** @hidden */
  110123. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110124. /** @hidden */
  110125. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110126. /** @hidden */
  110127. _getVRProjectionMatrix(): Matrix;
  110128. protected _updateCameraRotationMatrix(): void;
  110129. protected _updateWebVRCameraRotationMatrix(): void;
  110130. /**
  110131. * This function MUST be overwritten by the different WebVR cameras available.
  110132. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110133. * @hidden
  110134. */
  110135. _getWebVRProjectionMatrix(): Matrix;
  110136. /**
  110137. * This function MUST be overwritten by the different WebVR cameras available.
  110138. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110139. * @hidden
  110140. */
  110141. _getWebVRViewMatrix(): Matrix;
  110142. /** @hidden */
  110143. setCameraRigParameter(name: string, value: any): void;
  110144. /**
  110145. * needs to be overridden by children so sub has required properties to be copied
  110146. * @hidden
  110147. */
  110148. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110149. /**
  110150. * May need to be overridden by children
  110151. * @hidden
  110152. */
  110153. _updateRigCameras(): void;
  110154. /** @hidden */
  110155. _setupInputs(): void;
  110156. /**
  110157. * Serialiaze the camera setup to a json represention
  110158. * @returns the JSON representation
  110159. */
  110160. serialize(): any;
  110161. /**
  110162. * Clones the current camera.
  110163. * @param name The cloned camera name
  110164. * @returns the cloned camera
  110165. */
  110166. clone(name: string): Camera;
  110167. /**
  110168. * Gets the direction of the camera relative to a given local axis.
  110169. * @param localAxis Defines the reference axis to provide a relative direction.
  110170. * @return the direction
  110171. */
  110172. getDirection(localAxis: Vector3): Vector3;
  110173. /**
  110174. * Returns the current camera absolute rotation
  110175. */
  110176. get absoluteRotation(): Quaternion;
  110177. /**
  110178. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110179. * @param localAxis Defines the reference axis to provide a relative direction.
  110180. * @param result Defines the vector to store the result in
  110181. */
  110182. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110183. /**
  110184. * Gets a camera constructor for a given camera type
  110185. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110186. * @param name The name of the camera the result will be able to instantiate
  110187. * @param scene The scene the result will construct the camera in
  110188. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110189. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110190. * @returns a factory method to construc the camera
  110191. */
  110192. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110193. /**
  110194. * Compute the world matrix of the camera.
  110195. * @returns the camera world matrix
  110196. */
  110197. computeWorldMatrix(): Matrix;
  110198. /**
  110199. * Parse a JSON and creates the camera from the parsed information
  110200. * @param parsedCamera The JSON to parse
  110201. * @param scene The scene to instantiate the camera in
  110202. * @returns the newly constructed camera
  110203. */
  110204. static Parse(parsedCamera: any, scene: Scene): Camera;
  110205. }
  110206. }
  110207. declare module BABYLON {
  110208. /**
  110209. * Class containing static functions to help procedurally build meshes
  110210. */
  110211. export class DiscBuilder {
  110212. /**
  110213. * Creates a plane polygonal mesh. By default, this is a disc
  110214. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110215. * * 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
  110216. * * 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
  110217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110220. * @param name defines the name of the mesh
  110221. * @param options defines the options used to create the mesh
  110222. * @param scene defines the hosting scene
  110223. * @returns the plane polygonal mesh
  110224. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110225. */
  110226. static CreateDisc(name: string, options: {
  110227. radius?: number;
  110228. tessellation?: number;
  110229. arc?: number;
  110230. updatable?: boolean;
  110231. sideOrientation?: number;
  110232. frontUVs?: Vector4;
  110233. backUVs?: Vector4;
  110234. }, scene?: Nullable<Scene>): Mesh;
  110235. }
  110236. }
  110237. declare module BABYLON {
  110238. /**
  110239. * Options to be used when creating a FresnelParameters.
  110240. */
  110241. export type IFresnelParametersCreationOptions = {
  110242. /**
  110243. * Define the color used on edges (grazing angle)
  110244. */
  110245. leftColor?: Color3;
  110246. /**
  110247. * Define the color used on center
  110248. */
  110249. rightColor?: Color3;
  110250. /**
  110251. * Define bias applied to computed fresnel term
  110252. */
  110253. bias?: number;
  110254. /**
  110255. * Defined the power exponent applied to fresnel term
  110256. */
  110257. power?: number;
  110258. /**
  110259. * Define if the fresnel effect is enable or not.
  110260. */
  110261. isEnabled?: boolean;
  110262. };
  110263. /**
  110264. * Serialized format for FresnelParameters.
  110265. */
  110266. export type IFresnelParametersSerialized = {
  110267. /**
  110268. * Define the color used on edges (grazing angle) [as an array]
  110269. */
  110270. leftColor: number[];
  110271. /**
  110272. * Define the color used on center [as an array]
  110273. */
  110274. rightColor: number[];
  110275. /**
  110276. * Define bias applied to computed fresnel term
  110277. */
  110278. bias: number;
  110279. /**
  110280. * Defined the power exponent applied to fresnel term
  110281. */
  110282. power?: number;
  110283. /**
  110284. * Define if the fresnel effect is enable or not.
  110285. */
  110286. isEnabled: boolean;
  110287. };
  110288. /**
  110289. * This represents all the required information to add a fresnel effect on a material:
  110290. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110291. */
  110292. export class FresnelParameters {
  110293. private _isEnabled;
  110294. /**
  110295. * Define if the fresnel effect is enable or not.
  110296. */
  110297. get isEnabled(): boolean;
  110298. set isEnabled(value: boolean);
  110299. /**
  110300. * Define the color used on edges (grazing angle)
  110301. */
  110302. leftColor: Color3;
  110303. /**
  110304. * Define the color used on center
  110305. */
  110306. rightColor: Color3;
  110307. /**
  110308. * Define bias applied to computed fresnel term
  110309. */
  110310. bias: number;
  110311. /**
  110312. * Defined the power exponent applied to fresnel term
  110313. */
  110314. power: number;
  110315. /**
  110316. * Creates a new FresnelParameters object.
  110317. *
  110318. * @param options provide your own settings to optionally to override defaults
  110319. */
  110320. constructor(options?: IFresnelParametersCreationOptions);
  110321. /**
  110322. * Clones the current fresnel and its valuues
  110323. * @returns a clone fresnel configuration
  110324. */
  110325. clone(): FresnelParameters;
  110326. /**
  110327. * Determines equality between FresnelParameters objects
  110328. * @param otherFresnelParameters defines the second operand
  110329. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110330. */
  110331. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110332. /**
  110333. * Serializes the current fresnel parameters to a JSON representation.
  110334. * @return the JSON serialization
  110335. */
  110336. serialize(): IFresnelParametersSerialized;
  110337. /**
  110338. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110339. * @param parsedFresnelParameters Define the JSON representation
  110340. * @returns the parsed parameters
  110341. */
  110342. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110343. }
  110344. }
  110345. declare module BABYLON {
  110346. /**
  110347. * This groups all the flags used to control the materials channel.
  110348. */
  110349. export class MaterialFlags {
  110350. private static _DiffuseTextureEnabled;
  110351. /**
  110352. * Are diffuse textures enabled in the application.
  110353. */
  110354. static get DiffuseTextureEnabled(): boolean;
  110355. static set DiffuseTextureEnabled(value: boolean);
  110356. private static _DetailTextureEnabled;
  110357. /**
  110358. * Are detail textures enabled in the application.
  110359. */
  110360. static get DetailTextureEnabled(): boolean;
  110361. static set DetailTextureEnabled(value: boolean);
  110362. private static _AmbientTextureEnabled;
  110363. /**
  110364. * Are ambient textures enabled in the application.
  110365. */
  110366. static get AmbientTextureEnabled(): boolean;
  110367. static set AmbientTextureEnabled(value: boolean);
  110368. private static _OpacityTextureEnabled;
  110369. /**
  110370. * Are opacity textures enabled in the application.
  110371. */
  110372. static get OpacityTextureEnabled(): boolean;
  110373. static set OpacityTextureEnabled(value: boolean);
  110374. private static _ReflectionTextureEnabled;
  110375. /**
  110376. * Are reflection textures enabled in the application.
  110377. */
  110378. static get ReflectionTextureEnabled(): boolean;
  110379. static set ReflectionTextureEnabled(value: boolean);
  110380. private static _EmissiveTextureEnabled;
  110381. /**
  110382. * Are emissive textures enabled in the application.
  110383. */
  110384. static get EmissiveTextureEnabled(): boolean;
  110385. static set EmissiveTextureEnabled(value: boolean);
  110386. private static _SpecularTextureEnabled;
  110387. /**
  110388. * Are specular textures enabled in the application.
  110389. */
  110390. static get SpecularTextureEnabled(): boolean;
  110391. static set SpecularTextureEnabled(value: boolean);
  110392. private static _BumpTextureEnabled;
  110393. /**
  110394. * Are bump textures enabled in the application.
  110395. */
  110396. static get BumpTextureEnabled(): boolean;
  110397. static set BumpTextureEnabled(value: boolean);
  110398. private static _LightmapTextureEnabled;
  110399. /**
  110400. * Are lightmap textures enabled in the application.
  110401. */
  110402. static get LightmapTextureEnabled(): boolean;
  110403. static set LightmapTextureEnabled(value: boolean);
  110404. private static _RefractionTextureEnabled;
  110405. /**
  110406. * Are refraction textures enabled in the application.
  110407. */
  110408. static get RefractionTextureEnabled(): boolean;
  110409. static set RefractionTextureEnabled(value: boolean);
  110410. private static _ColorGradingTextureEnabled;
  110411. /**
  110412. * Are color grading textures enabled in the application.
  110413. */
  110414. static get ColorGradingTextureEnabled(): boolean;
  110415. static set ColorGradingTextureEnabled(value: boolean);
  110416. private static _FresnelEnabled;
  110417. /**
  110418. * Are fresnels enabled in the application.
  110419. */
  110420. static get FresnelEnabled(): boolean;
  110421. static set FresnelEnabled(value: boolean);
  110422. private static _ClearCoatTextureEnabled;
  110423. /**
  110424. * Are clear coat textures enabled in the application.
  110425. */
  110426. static get ClearCoatTextureEnabled(): boolean;
  110427. static set ClearCoatTextureEnabled(value: boolean);
  110428. private static _ClearCoatBumpTextureEnabled;
  110429. /**
  110430. * Are clear coat bump textures enabled in the application.
  110431. */
  110432. static get ClearCoatBumpTextureEnabled(): boolean;
  110433. static set ClearCoatBumpTextureEnabled(value: boolean);
  110434. private static _ClearCoatTintTextureEnabled;
  110435. /**
  110436. * Are clear coat tint textures enabled in the application.
  110437. */
  110438. static get ClearCoatTintTextureEnabled(): boolean;
  110439. static set ClearCoatTintTextureEnabled(value: boolean);
  110440. private static _SheenTextureEnabled;
  110441. /**
  110442. * Are sheen textures enabled in the application.
  110443. */
  110444. static get SheenTextureEnabled(): boolean;
  110445. static set SheenTextureEnabled(value: boolean);
  110446. private static _AnisotropicTextureEnabled;
  110447. /**
  110448. * Are anisotropic textures enabled in the application.
  110449. */
  110450. static get AnisotropicTextureEnabled(): boolean;
  110451. static set AnisotropicTextureEnabled(value: boolean);
  110452. private static _ThicknessTextureEnabled;
  110453. /**
  110454. * Are thickness textures enabled in the application.
  110455. */
  110456. static get ThicknessTextureEnabled(): boolean;
  110457. static set ThicknessTextureEnabled(value: boolean);
  110458. }
  110459. }
  110460. declare module BABYLON {
  110461. /** @hidden */
  110462. export var defaultFragmentDeclaration: {
  110463. name: string;
  110464. shader: string;
  110465. };
  110466. }
  110467. declare module BABYLON {
  110468. /** @hidden */
  110469. export var defaultUboDeclaration: {
  110470. name: string;
  110471. shader: string;
  110472. };
  110473. }
  110474. declare module BABYLON {
  110475. /** @hidden */
  110476. export var prePassDeclaration: {
  110477. name: string;
  110478. shader: string;
  110479. };
  110480. }
  110481. declare module BABYLON {
  110482. /** @hidden */
  110483. export var lightFragmentDeclaration: {
  110484. name: string;
  110485. shader: string;
  110486. };
  110487. }
  110488. declare module BABYLON {
  110489. /** @hidden */
  110490. export var lightUboDeclaration: {
  110491. name: string;
  110492. shader: string;
  110493. };
  110494. }
  110495. declare module BABYLON {
  110496. /** @hidden */
  110497. export var lightsFragmentFunctions: {
  110498. name: string;
  110499. shader: string;
  110500. };
  110501. }
  110502. declare module BABYLON {
  110503. /** @hidden */
  110504. export var shadowsFragmentFunctions: {
  110505. name: string;
  110506. shader: string;
  110507. };
  110508. }
  110509. declare module BABYLON {
  110510. /** @hidden */
  110511. export var fresnelFunction: {
  110512. name: string;
  110513. shader: string;
  110514. };
  110515. }
  110516. declare module BABYLON {
  110517. /** @hidden */
  110518. export var bumpFragmentMainFunctions: {
  110519. name: string;
  110520. shader: string;
  110521. };
  110522. }
  110523. declare module BABYLON {
  110524. /** @hidden */
  110525. export var bumpFragmentFunctions: {
  110526. name: string;
  110527. shader: string;
  110528. };
  110529. }
  110530. declare module BABYLON {
  110531. /** @hidden */
  110532. export var logDepthDeclaration: {
  110533. name: string;
  110534. shader: string;
  110535. };
  110536. }
  110537. declare module BABYLON {
  110538. /** @hidden */
  110539. export var bumpFragment: {
  110540. name: string;
  110541. shader: string;
  110542. };
  110543. }
  110544. declare module BABYLON {
  110545. /** @hidden */
  110546. export var depthPrePass: {
  110547. name: string;
  110548. shader: string;
  110549. };
  110550. }
  110551. declare module BABYLON {
  110552. /** @hidden */
  110553. export var lightFragment: {
  110554. name: string;
  110555. shader: string;
  110556. };
  110557. }
  110558. declare module BABYLON {
  110559. /** @hidden */
  110560. export var logDepthFragment: {
  110561. name: string;
  110562. shader: string;
  110563. };
  110564. }
  110565. declare module BABYLON {
  110566. /** @hidden */
  110567. export var defaultPixelShader: {
  110568. name: string;
  110569. shader: string;
  110570. };
  110571. }
  110572. declare module BABYLON {
  110573. /** @hidden */
  110574. export var defaultVertexDeclaration: {
  110575. name: string;
  110576. shader: string;
  110577. };
  110578. }
  110579. declare module BABYLON {
  110580. /** @hidden */
  110581. export var bumpVertexDeclaration: {
  110582. name: string;
  110583. shader: string;
  110584. };
  110585. }
  110586. declare module BABYLON {
  110587. /** @hidden */
  110588. export var bumpVertex: {
  110589. name: string;
  110590. shader: string;
  110591. };
  110592. }
  110593. declare module BABYLON {
  110594. /** @hidden */
  110595. export var fogVertex: {
  110596. name: string;
  110597. shader: string;
  110598. };
  110599. }
  110600. declare module BABYLON {
  110601. /** @hidden */
  110602. export var shadowsVertex: {
  110603. name: string;
  110604. shader: string;
  110605. };
  110606. }
  110607. declare module BABYLON {
  110608. /** @hidden */
  110609. export var pointCloudVertex: {
  110610. name: string;
  110611. shader: string;
  110612. };
  110613. }
  110614. declare module BABYLON {
  110615. /** @hidden */
  110616. export var logDepthVertex: {
  110617. name: string;
  110618. shader: string;
  110619. };
  110620. }
  110621. declare module BABYLON {
  110622. /** @hidden */
  110623. export var defaultVertexShader: {
  110624. name: string;
  110625. shader: string;
  110626. };
  110627. }
  110628. declare module BABYLON {
  110629. /**
  110630. * @hidden
  110631. */
  110632. export interface IMaterialDetailMapDefines {
  110633. DETAIL: boolean;
  110634. DETAILDIRECTUV: number;
  110635. DETAIL_NORMALBLENDMETHOD: number;
  110636. /** @hidden */
  110637. _areTexturesDirty: boolean;
  110638. }
  110639. /**
  110640. * Define the code related to the detail map parameters of a material
  110641. *
  110642. * Inspired from:
  110643. * 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
  110644. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110645. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110646. */
  110647. export class DetailMapConfiguration {
  110648. private _texture;
  110649. /**
  110650. * The detail texture of the material.
  110651. */
  110652. texture: Nullable<BaseTexture>;
  110653. /**
  110654. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110655. * Bigger values mean stronger blending
  110656. */
  110657. diffuseBlendLevel: number;
  110658. /**
  110659. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110660. * Bigger values mean stronger blending. Only used with PBR materials
  110661. */
  110662. roughnessBlendLevel: number;
  110663. /**
  110664. * Defines how strong the bump effect from the detail map is
  110665. * Bigger values mean stronger effect
  110666. */
  110667. bumpLevel: number;
  110668. private _normalBlendMethod;
  110669. /**
  110670. * The method used to blend the bump and detail normals together
  110671. */
  110672. normalBlendMethod: number;
  110673. private _isEnabled;
  110674. /**
  110675. * Enable or disable the detail map on this material
  110676. */
  110677. isEnabled: boolean;
  110678. /** @hidden */
  110679. private _internalMarkAllSubMeshesAsTexturesDirty;
  110680. /** @hidden */
  110681. _markAllSubMeshesAsTexturesDirty(): void;
  110682. /**
  110683. * Instantiate a new detail map
  110684. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110685. */
  110686. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110687. /**
  110688. * Gets whether the submesh is ready to be used or not.
  110689. * @param defines the list of "defines" to update.
  110690. * @param scene defines the scene the material belongs to.
  110691. * @returns - boolean indicating that the submesh is ready or not.
  110692. */
  110693. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110694. /**
  110695. * Update the defines for detail map usage
  110696. * @param defines the list of "defines" to update.
  110697. * @param scene defines the scene the material belongs to.
  110698. */
  110699. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110700. /**
  110701. * Binds the material data.
  110702. * @param uniformBuffer defines the Uniform buffer to fill in.
  110703. * @param scene defines the scene the material belongs to.
  110704. * @param isFrozen defines whether the material is frozen or not.
  110705. */
  110706. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110707. /**
  110708. * Checks to see if a texture is used in the material.
  110709. * @param texture - Base texture to use.
  110710. * @returns - Boolean specifying if a texture is used in the material.
  110711. */
  110712. hasTexture(texture: BaseTexture): boolean;
  110713. /**
  110714. * Returns an array of the actively used textures.
  110715. * @param activeTextures Array of BaseTextures
  110716. */
  110717. getActiveTextures(activeTextures: BaseTexture[]): void;
  110718. /**
  110719. * Returns the animatable textures.
  110720. * @param animatables Array of animatable textures.
  110721. */
  110722. getAnimatables(animatables: IAnimatable[]): void;
  110723. /**
  110724. * Disposes the resources of the material.
  110725. * @param forceDisposeTextures - Forces the disposal of all textures.
  110726. */
  110727. dispose(forceDisposeTextures?: boolean): void;
  110728. /**
  110729. * Get the current class name useful for serialization or dynamic coding.
  110730. * @returns "DetailMap"
  110731. */
  110732. getClassName(): string;
  110733. /**
  110734. * Add the required uniforms to the current list.
  110735. * @param uniforms defines the current uniform list.
  110736. */
  110737. static AddUniforms(uniforms: string[]): void;
  110738. /**
  110739. * Add the required samplers to the current list.
  110740. * @param samplers defines the current sampler list.
  110741. */
  110742. static AddSamplers(samplers: string[]): void;
  110743. /**
  110744. * Add the required uniforms to the current buffer.
  110745. * @param uniformBuffer defines the current uniform buffer.
  110746. */
  110747. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110748. /**
  110749. * Makes a duplicate of the current instance into another one.
  110750. * @param detailMap define the instance where to copy the info
  110751. */
  110752. copyTo(detailMap: DetailMapConfiguration): void;
  110753. /**
  110754. * Serializes this detail map instance
  110755. * @returns - An object with the serialized instance.
  110756. */
  110757. serialize(): any;
  110758. /**
  110759. * Parses a detail map setting from a serialized object.
  110760. * @param source - Serialized object.
  110761. * @param scene Defines the scene we are parsing for
  110762. * @param rootUrl Defines the rootUrl to load from
  110763. */
  110764. parse(source: any, scene: Scene, rootUrl: string): void;
  110765. }
  110766. }
  110767. declare module BABYLON {
  110768. /** @hidden */
  110769. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110770. MAINUV1: boolean;
  110771. MAINUV2: boolean;
  110772. DIFFUSE: boolean;
  110773. DIFFUSEDIRECTUV: number;
  110774. DETAIL: boolean;
  110775. DETAILDIRECTUV: number;
  110776. DETAIL_NORMALBLENDMETHOD: number;
  110777. AMBIENT: boolean;
  110778. AMBIENTDIRECTUV: number;
  110779. OPACITY: boolean;
  110780. OPACITYDIRECTUV: number;
  110781. OPACITYRGB: boolean;
  110782. REFLECTION: boolean;
  110783. EMISSIVE: boolean;
  110784. EMISSIVEDIRECTUV: number;
  110785. SPECULAR: boolean;
  110786. SPECULARDIRECTUV: number;
  110787. BUMP: boolean;
  110788. BUMPDIRECTUV: number;
  110789. PARALLAX: boolean;
  110790. PARALLAXOCCLUSION: boolean;
  110791. SPECULAROVERALPHA: boolean;
  110792. CLIPPLANE: boolean;
  110793. CLIPPLANE2: boolean;
  110794. CLIPPLANE3: boolean;
  110795. CLIPPLANE4: boolean;
  110796. CLIPPLANE5: boolean;
  110797. CLIPPLANE6: boolean;
  110798. ALPHATEST: boolean;
  110799. DEPTHPREPASS: boolean;
  110800. ALPHAFROMDIFFUSE: boolean;
  110801. POINTSIZE: boolean;
  110802. FOG: boolean;
  110803. SPECULARTERM: boolean;
  110804. DIFFUSEFRESNEL: boolean;
  110805. OPACITYFRESNEL: boolean;
  110806. REFLECTIONFRESNEL: boolean;
  110807. REFRACTIONFRESNEL: boolean;
  110808. EMISSIVEFRESNEL: boolean;
  110809. FRESNEL: boolean;
  110810. NORMAL: boolean;
  110811. UV1: boolean;
  110812. UV2: boolean;
  110813. VERTEXCOLOR: boolean;
  110814. VERTEXALPHA: boolean;
  110815. NUM_BONE_INFLUENCERS: number;
  110816. BonesPerMesh: number;
  110817. BONETEXTURE: boolean;
  110818. INSTANCES: boolean;
  110819. THIN_INSTANCES: boolean;
  110820. GLOSSINESS: boolean;
  110821. ROUGHNESS: boolean;
  110822. EMISSIVEASILLUMINATION: boolean;
  110823. LINKEMISSIVEWITHDIFFUSE: boolean;
  110824. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110825. LIGHTMAP: boolean;
  110826. LIGHTMAPDIRECTUV: number;
  110827. OBJECTSPACE_NORMALMAP: boolean;
  110828. USELIGHTMAPASSHADOWMAP: boolean;
  110829. REFLECTIONMAP_3D: boolean;
  110830. REFLECTIONMAP_SPHERICAL: boolean;
  110831. REFLECTIONMAP_PLANAR: boolean;
  110832. REFLECTIONMAP_CUBIC: boolean;
  110833. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110834. REFLECTIONMAP_PROJECTION: boolean;
  110835. REFLECTIONMAP_SKYBOX: boolean;
  110836. REFLECTIONMAP_EXPLICIT: boolean;
  110837. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110838. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110839. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110840. INVERTCUBICMAP: boolean;
  110841. LOGARITHMICDEPTH: boolean;
  110842. REFRACTION: boolean;
  110843. REFRACTIONMAP_3D: boolean;
  110844. REFLECTIONOVERALPHA: boolean;
  110845. TWOSIDEDLIGHTING: boolean;
  110846. SHADOWFLOAT: boolean;
  110847. MORPHTARGETS: boolean;
  110848. MORPHTARGETS_NORMAL: boolean;
  110849. MORPHTARGETS_TANGENT: boolean;
  110850. MORPHTARGETS_UV: boolean;
  110851. NUM_MORPH_INFLUENCERS: number;
  110852. NONUNIFORMSCALING: boolean;
  110853. PREMULTIPLYALPHA: boolean;
  110854. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110855. ALPHABLEND: boolean;
  110856. PREPASS: boolean;
  110857. PREPASS_IRRADIANCE: boolean;
  110858. PREPASS_IRRADIANCE_INDEX: number;
  110859. PREPASS_ALBEDO: boolean;
  110860. PREPASS_ALBEDO_INDEX: number;
  110861. PREPASS_DEPTHNORMAL: boolean;
  110862. PREPASS_DEPTHNORMAL_INDEX: number;
  110863. SCENE_MRT_COUNT: number;
  110864. RGBDLIGHTMAP: boolean;
  110865. RGBDREFLECTION: boolean;
  110866. RGBDREFRACTION: boolean;
  110867. IMAGEPROCESSING: boolean;
  110868. VIGNETTE: boolean;
  110869. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110870. VIGNETTEBLENDMODEOPAQUE: boolean;
  110871. TONEMAPPING: boolean;
  110872. TONEMAPPING_ACES: boolean;
  110873. CONTRAST: boolean;
  110874. COLORCURVES: boolean;
  110875. COLORGRADING: boolean;
  110876. COLORGRADING3D: boolean;
  110877. SAMPLER3DGREENDEPTH: boolean;
  110878. SAMPLER3DBGRMAP: boolean;
  110879. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110880. MULTIVIEW: boolean;
  110881. /**
  110882. * If the reflection texture on this material is in linear color space
  110883. * @hidden
  110884. */
  110885. IS_REFLECTION_LINEAR: boolean;
  110886. /**
  110887. * If the refraction texture on this material is in linear color space
  110888. * @hidden
  110889. */
  110890. IS_REFRACTION_LINEAR: boolean;
  110891. EXPOSURE: boolean;
  110892. constructor();
  110893. setReflectionMode(modeToEnable: string): void;
  110894. }
  110895. /**
  110896. * This is the default material used in Babylon. It is the best trade off between quality
  110897. * and performances.
  110898. * @see https://doc.babylonjs.com/babylon101/materials
  110899. */
  110900. export class StandardMaterial extends PushMaterial {
  110901. private _diffuseTexture;
  110902. /**
  110903. * The basic texture of the material as viewed under a light.
  110904. */
  110905. diffuseTexture: Nullable<BaseTexture>;
  110906. private _ambientTexture;
  110907. /**
  110908. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110909. */
  110910. ambientTexture: Nullable<BaseTexture>;
  110911. private _opacityTexture;
  110912. /**
  110913. * Define the transparency of the material from a texture.
  110914. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110915. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110916. */
  110917. opacityTexture: Nullable<BaseTexture>;
  110918. private _reflectionTexture;
  110919. /**
  110920. * Define the texture used to display the reflection.
  110921. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110922. */
  110923. reflectionTexture: Nullable<BaseTexture>;
  110924. private _emissiveTexture;
  110925. /**
  110926. * Define texture of the material as if self lit.
  110927. * This will be mixed in the final result even in the absence of light.
  110928. */
  110929. emissiveTexture: Nullable<BaseTexture>;
  110930. private _specularTexture;
  110931. /**
  110932. * Define how the color and intensity of the highlight given by the light in the material.
  110933. */
  110934. specularTexture: Nullable<BaseTexture>;
  110935. private _bumpTexture;
  110936. /**
  110937. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110938. * 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.
  110939. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110940. */
  110941. bumpTexture: Nullable<BaseTexture>;
  110942. private _lightmapTexture;
  110943. /**
  110944. * Complex lighting can be computationally expensive to compute at runtime.
  110945. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110946. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110947. */
  110948. lightmapTexture: Nullable<BaseTexture>;
  110949. private _refractionTexture;
  110950. /**
  110951. * Define the texture used to display the refraction.
  110952. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110953. */
  110954. refractionTexture: Nullable<BaseTexture>;
  110955. /**
  110956. * The color of the material lit by the environmental background lighting.
  110957. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110958. */
  110959. ambientColor: Color3;
  110960. /**
  110961. * The basic color of the material as viewed under a light.
  110962. */
  110963. diffuseColor: Color3;
  110964. /**
  110965. * Define how the color and intensity of the highlight given by the light in the material.
  110966. */
  110967. specularColor: Color3;
  110968. /**
  110969. * Define the color of the material as if self lit.
  110970. * This will be mixed in the final result even in the absence of light.
  110971. */
  110972. emissiveColor: Color3;
  110973. /**
  110974. * Defines how sharp are the highlights in the material.
  110975. * The bigger the value the sharper giving a more glossy feeling to the result.
  110976. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110977. */
  110978. specularPower: number;
  110979. private _useAlphaFromDiffuseTexture;
  110980. /**
  110981. * Does the transparency come from the diffuse texture alpha channel.
  110982. */
  110983. useAlphaFromDiffuseTexture: boolean;
  110984. private _useEmissiveAsIllumination;
  110985. /**
  110986. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110987. */
  110988. useEmissiveAsIllumination: boolean;
  110989. private _linkEmissiveWithDiffuse;
  110990. /**
  110991. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110992. * the emissive level when the final color is close to one.
  110993. */
  110994. linkEmissiveWithDiffuse: boolean;
  110995. private _useSpecularOverAlpha;
  110996. /**
  110997. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110998. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110999. */
  111000. useSpecularOverAlpha: boolean;
  111001. private _useReflectionOverAlpha;
  111002. /**
  111003. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111004. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111005. */
  111006. useReflectionOverAlpha: boolean;
  111007. private _disableLighting;
  111008. /**
  111009. * Does lights from the scene impacts this material.
  111010. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111011. */
  111012. disableLighting: boolean;
  111013. private _useObjectSpaceNormalMap;
  111014. /**
  111015. * Allows using an object space normal map (instead of tangent space).
  111016. */
  111017. useObjectSpaceNormalMap: boolean;
  111018. private _useParallax;
  111019. /**
  111020. * Is parallax enabled or not.
  111021. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111022. */
  111023. useParallax: boolean;
  111024. private _useParallaxOcclusion;
  111025. /**
  111026. * Is parallax occlusion enabled or not.
  111027. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111028. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111029. */
  111030. useParallaxOcclusion: boolean;
  111031. /**
  111032. * 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.
  111033. */
  111034. parallaxScaleBias: number;
  111035. private _roughness;
  111036. /**
  111037. * Helps to define how blurry the reflections should appears in the material.
  111038. */
  111039. roughness: number;
  111040. /**
  111041. * In case of refraction, define the value of the index of refraction.
  111042. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111043. */
  111044. indexOfRefraction: number;
  111045. /**
  111046. * Invert the refraction texture alongside the y axis.
  111047. * It can be useful with procedural textures or probe for instance.
  111048. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111049. */
  111050. invertRefractionY: boolean;
  111051. /**
  111052. * Defines the alpha limits in alpha test mode.
  111053. */
  111054. alphaCutOff: number;
  111055. private _useLightmapAsShadowmap;
  111056. /**
  111057. * In case of light mapping, define whether the map contains light or shadow informations.
  111058. */
  111059. useLightmapAsShadowmap: boolean;
  111060. private _diffuseFresnelParameters;
  111061. /**
  111062. * Define the diffuse fresnel parameters of the material.
  111063. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111064. */
  111065. diffuseFresnelParameters: FresnelParameters;
  111066. private _opacityFresnelParameters;
  111067. /**
  111068. * Define the opacity fresnel parameters of the material.
  111069. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111070. */
  111071. opacityFresnelParameters: FresnelParameters;
  111072. private _reflectionFresnelParameters;
  111073. /**
  111074. * Define the reflection fresnel parameters of the material.
  111075. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111076. */
  111077. reflectionFresnelParameters: FresnelParameters;
  111078. private _refractionFresnelParameters;
  111079. /**
  111080. * Define the refraction fresnel parameters of the material.
  111081. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111082. */
  111083. refractionFresnelParameters: FresnelParameters;
  111084. private _emissiveFresnelParameters;
  111085. /**
  111086. * Define the emissive fresnel parameters of the material.
  111087. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111088. */
  111089. emissiveFresnelParameters: FresnelParameters;
  111090. private _useReflectionFresnelFromSpecular;
  111091. /**
  111092. * If true automatically deducts the fresnels values from the material specularity.
  111093. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111094. */
  111095. useReflectionFresnelFromSpecular: boolean;
  111096. private _useGlossinessFromSpecularMapAlpha;
  111097. /**
  111098. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111099. */
  111100. useGlossinessFromSpecularMapAlpha: boolean;
  111101. private _maxSimultaneousLights;
  111102. /**
  111103. * Defines the maximum number of lights that can be used in the material
  111104. */
  111105. maxSimultaneousLights: number;
  111106. private _invertNormalMapX;
  111107. /**
  111108. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111109. */
  111110. invertNormalMapX: boolean;
  111111. private _invertNormalMapY;
  111112. /**
  111113. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111114. */
  111115. invertNormalMapY: boolean;
  111116. private _twoSidedLighting;
  111117. /**
  111118. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111119. */
  111120. twoSidedLighting: boolean;
  111121. /**
  111122. * Default configuration related to image processing available in the standard Material.
  111123. */
  111124. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111125. /**
  111126. * Gets the image processing configuration used either in this material.
  111127. */
  111128. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111129. /**
  111130. * Sets the Default image processing configuration used either in the this material.
  111131. *
  111132. * If sets to null, the scene one is in use.
  111133. */
  111134. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111135. /**
  111136. * Keep track of the image processing observer to allow dispose and replace.
  111137. */
  111138. private _imageProcessingObserver;
  111139. /**
  111140. * Attaches a new image processing configuration to the Standard Material.
  111141. * @param configuration
  111142. */
  111143. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111144. /**
  111145. * Gets wether the color curves effect is enabled.
  111146. */
  111147. get cameraColorCurvesEnabled(): boolean;
  111148. /**
  111149. * Sets wether the color curves effect is enabled.
  111150. */
  111151. set cameraColorCurvesEnabled(value: boolean);
  111152. /**
  111153. * Gets wether the color grading effect is enabled.
  111154. */
  111155. get cameraColorGradingEnabled(): boolean;
  111156. /**
  111157. * Gets wether the color grading effect is enabled.
  111158. */
  111159. set cameraColorGradingEnabled(value: boolean);
  111160. /**
  111161. * Gets wether tonemapping is enabled or not.
  111162. */
  111163. get cameraToneMappingEnabled(): boolean;
  111164. /**
  111165. * Sets wether tonemapping is enabled or not
  111166. */
  111167. set cameraToneMappingEnabled(value: boolean);
  111168. /**
  111169. * The camera exposure used on this material.
  111170. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111171. * This corresponds to a photographic exposure.
  111172. */
  111173. get cameraExposure(): number;
  111174. /**
  111175. * The camera exposure used on this material.
  111176. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111177. * This corresponds to a photographic exposure.
  111178. */
  111179. set cameraExposure(value: number);
  111180. /**
  111181. * Gets The camera contrast used on this material.
  111182. */
  111183. get cameraContrast(): number;
  111184. /**
  111185. * Sets The camera contrast used on this material.
  111186. */
  111187. set cameraContrast(value: number);
  111188. /**
  111189. * Gets the Color Grading 2D Lookup Texture.
  111190. */
  111191. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111192. /**
  111193. * Sets the Color Grading 2D Lookup Texture.
  111194. */
  111195. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111196. /**
  111197. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111198. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111199. * 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;
  111200. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111201. */
  111202. get cameraColorCurves(): Nullable<ColorCurves>;
  111203. /**
  111204. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111205. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111206. * 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;
  111207. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111208. */
  111209. set cameraColorCurves(value: Nullable<ColorCurves>);
  111210. /**
  111211. * Can this material render to several textures at once
  111212. */
  111213. get canRenderToMRT(): boolean;
  111214. /**
  111215. * Defines the detail map parameters for the material.
  111216. */
  111217. readonly detailMap: DetailMapConfiguration;
  111218. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111219. protected _worldViewProjectionMatrix: Matrix;
  111220. protected _globalAmbientColor: Color3;
  111221. protected _useLogarithmicDepth: boolean;
  111222. protected _rebuildInParallel: boolean;
  111223. /**
  111224. * Instantiates a new standard material.
  111225. * This is the default material used in Babylon. It is the best trade off between quality
  111226. * and performances.
  111227. * @see https://doc.babylonjs.com/babylon101/materials
  111228. * @param name Define the name of the material in the scene
  111229. * @param scene Define the scene the material belong to
  111230. */
  111231. constructor(name: string, scene: Scene);
  111232. /**
  111233. * Gets a boolean indicating that current material needs to register RTT
  111234. */
  111235. get hasRenderTargetTextures(): boolean;
  111236. /**
  111237. * Gets the current class name of the material e.g. "StandardMaterial"
  111238. * Mainly use in serialization.
  111239. * @returns the class name
  111240. */
  111241. getClassName(): string;
  111242. /**
  111243. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111244. * You can try switching to logarithmic depth.
  111245. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111246. */
  111247. get useLogarithmicDepth(): boolean;
  111248. set useLogarithmicDepth(value: boolean);
  111249. /**
  111250. * Specifies if the material will require alpha blending
  111251. * @returns a boolean specifying if alpha blending is needed
  111252. */
  111253. needAlphaBlending(): boolean;
  111254. /**
  111255. * Specifies if this material should be rendered in alpha test mode
  111256. * @returns a boolean specifying if an alpha test is needed.
  111257. */
  111258. needAlphaTesting(): boolean;
  111259. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111260. /**
  111261. * Get the texture used for alpha test purpose.
  111262. * @returns the diffuse texture in case of the standard material.
  111263. */
  111264. getAlphaTestTexture(): Nullable<BaseTexture>;
  111265. /**
  111266. * Get if the submesh is ready to be used and all its information available.
  111267. * Child classes can use it to update shaders
  111268. * @param mesh defines the mesh to check
  111269. * @param subMesh defines which submesh to check
  111270. * @param useInstances specifies that instances should be used
  111271. * @returns a boolean indicating that the submesh is ready or not
  111272. */
  111273. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111274. /**
  111275. * Builds the material UBO layouts.
  111276. * Used internally during the effect preparation.
  111277. */
  111278. buildUniformLayout(): void;
  111279. /**
  111280. * Unbinds the material from the mesh
  111281. */
  111282. unbind(): void;
  111283. /**
  111284. * Binds the submesh to this material by preparing the effect and shader to draw
  111285. * @param world defines the world transformation matrix
  111286. * @param mesh defines the mesh containing the submesh
  111287. * @param subMesh defines the submesh to bind the material to
  111288. */
  111289. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111290. /**
  111291. * Get the list of animatables in the material.
  111292. * @returns the list of animatables object used in the material
  111293. */
  111294. getAnimatables(): IAnimatable[];
  111295. /**
  111296. * Gets the active textures from the material
  111297. * @returns an array of textures
  111298. */
  111299. getActiveTextures(): BaseTexture[];
  111300. /**
  111301. * Specifies if the material uses a texture
  111302. * @param texture defines the texture to check against the material
  111303. * @returns a boolean specifying if the material uses the texture
  111304. */
  111305. hasTexture(texture: BaseTexture): boolean;
  111306. /**
  111307. * Disposes the material
  111308. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111309. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111310. */
  111311. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111312. /**
  111313. * Makes a duplicate of the material, and gives it a new name
  111314. * @param name defines the new name for the duplicated material
  111315. * @returns the cloned material
  111316. */
  111317. clone(name: string): StandardMaterial;
  111318. /**
  111319. * Serializes this material in a JSON representation
  111320. * @returns the serialized material object
  111321. */
  111322. serialize(): any;
  111323. /**
  111324. * Creates a standard material from parsed material data
  111325. * @param source defines the JSON representation of the material
  111326. * @param scene defines the hosting scene
  111327. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111328. * @returns a new standard material
  111329. */
  111330. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111331. /**
  111332. * Are diffuse textures enabled in the application.
  111333. */
  111334. static get DiffuseTextureEnabled(): boolean;
  111335. static set DiffuseTextureEnabled(value: boolean);
  111336. /**
  111337. * Are detail textures enabled in the application.
  111338. */
  111339. static get DetailTextureEnabled(): boolean;
  111340. static set DetailTextureEnabled(value: boolean);
  111341. /**
  111342. * Are ambient textures enabled in the application.
  111343. */
  111344. static get AmbientTextureEnabled(): boolean;
  111345. static set AmbientTextureEnabled(value: boolean);
  111346. /**
  111347. * Are opacity textures enabled in the application.
  111348. */
  111349. static get OpacityTextureEnabled(): boolean;
  111350. static set OpacityTextureEnabled(value: boolean);
  111351. /**
  111352. * Are reflection textures enabled in the application.
  111353. */
  111354. static get ReflectionTextureEnabled(): boolean;
  111355. static set ReflectionTextureEnabled(value: boolean);
  111356. /**
  111357. * Are emissive textures enabled in the application.
  111358. */
  111359. static get EmissiveTextureEnabled(): boolean;
  111360. static set EmissiveTextureEnabled(value: boolean);
  111361. /**
  111362. * Are specular textures enabled in the application.
  111363. */
  111364. static get SpecularTextureEnabled(): boolean;
  111365. static set SpecularTextureEnabled(value: boolean);
  111366. /**
  111367. * Are bump textures enabled in the application.
  111368. */
  111369. static get BumpTextureEnabled(): boolean;
  111370. static set BumpTextureEnabled(value: boolean);
  111371. /**
  111372. * Are lightmap textures enabled in the application.
  111373. */
  111374. static get LightmapTextureEnabled(): boolean;
  111375. static set LightmapTextureEnabled(value: boolean);
  111376. /**
  111377. * Are refraction textures enabled in the application.
  111378. */
  111379. static get RefractionTextureEnabled(): boolean;
  111380. static set RefractionTextureEnabled(value: boolean);
  111381. /**
  111382. * Are color grading textures enabled in the application.
  111383. */
  111384. static get ColorGradingTextureEnabled(): boolean;
  111385. static set ColorGradingTextureEnabled(value: boolean);
  111386. /**
  111387. * Are fresnels enabled in the application.
  111388. */
  111389. static get FresnelEnabled(): boolean;
  111390. static set FresnelEnabled(value: boolean);
  111391. }
  111392. }
  111393. declare module BABYLON {
  111394. /**
  111395. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111396. *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.
  111397. * The SPS is also a particle system. It provides some methods to manage the particles.
  111398. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111399. *
  111400. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111401. */
  111402. export class SolidParticleSystem implements IDisposable {
  111403. /**
  111404. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111405. * Example : var p = SPS.particles[i];
  111406. */
  111407. particles: SolidParticle[];
  111408. /**
  111409. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111410. */
  111411. nbParticles: number;
  111412. /**
  111413. * If the particles must ever face the camera (default false). Useful for planar particles.
  111414. */
  111415. billboard: boolean;
  111416. /**
  111417. * Recompute normals when adding a shape
  111418. */
  111419. recomputeNormals: boolean;
  111420. /**
  111421. * This a counter ofr your own usage. It's not set by any SPS functions.
  111422. */
  111423. counter: number;
  111424. /**
  111425. * The SPS name. This name is also given to the underlying mesh.
  111426. */
  111427. name: string;
  111428. /**
  111429. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111430. */
  111431. mesh: Mesh;
  111432. /**
  111433. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111434. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111435. */
  111436. vars: any;
  111437. /**
  111438. * This array is populated when the SPS is set as 'pickable'.
  111439. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111440. * Each element of this array is an object `{idx: int, faceId: int}`.
  111441. * `idx` is the picked particle index in the `SPS.particles` array
  111442. * `faceId` is the picked face index counted within this particle.
  111443. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111444. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111445. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111446. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111447. */
  111448. pickedParticles: {
  111449. idx: number;
  111450. faceId: number;
  111451. }[];
  111452. /**
  111453. * This array is populated when the SPS is set as 'pickable'
  111454. * Each key of this array is a submesh index.
  111455. * Each element of this array is a second array defined like this :
  111456. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111457. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111458. * `idx` is the picked particle index in the `SPS.particles` array
  111459. * `faceId` is the picked face index counted within this particle.
  111460. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111461. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111462. */
  111463. pickedBySubMesh: {
  111464. idx: number;
  111465. faceId: number;
  111466. }[][];
  111467. /**
  111468. * This array is populated when `enableDepthSort` is set to true.
  111469. * Each element of this array is an instance of the class DepthSortedParticle.
  111470. */
  111471. depthSortedParticles: DepthSortedParticle[];
  111472. /**
  111473. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111474. * @hidden
  111475. */
  111476. _bSphereOnly: boolean;
  111477. /**
  111478. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111479. * @hidden
  111480. */
  111481. _bSphereRadiusFactor: number;
  111482. private _scene;
  111483. private _positions;
  111484. private _indices;
  111485. private _normals;
  111486. private _colors;
  111487. private _uvs;
  111488. private _indices32;
  111489. private _positions32;
  111490. private _normals32;
  111491. private _fixedNormal32;
  111492. private _colors32;
  111493. private _uvs32;
  111494. private _index;
  111495. private _updatable;
  111496. private _pickable;
  111497. private _isVisibilityBoxLocked;
  111498. private _alwaysVisible;
  111499. private _depthSort;
  111500. private _expandable;
  111501. private _shapeCounter;
  111502. private _copy;
  111503. private _color;
  111504. private _computeParticleColor;
  111505. private _computeParticleTexture;
  111506. private _computeParticleRotation;
  111507. private _computeParticleVertex;
  111508. private _computeBoundingBox;
  111509. private _depthSortParticles;
  111510. private _camera;
  111511. private _mustUnrotateFixedNormals;
  111512. private _particlesIntersect;
  111513. private _needs32Bits;
  111514. private _isNotBuilt;
  111515. private _lastParticleId;
  111516. private _idxOfId;
  111517. private _multimaterialEnabled;
  111518. private _useModelMaterial;
  111519. private _indicesByMaterial;
  111520. private _materialIndexes;
  111521. private _depthSortFunction;
  111522. private _materialSortFunction;
  111523. private _materials;
  111524. private _multimaterial;
  111525. private _materialIndexesById;
  111526. private _defaultMaterial;
  111527. private _autoUpdateSubMeshes;
  111528. private _tmpVertex;
  111529. /**
  111530. * Creates a SPS (Solid Particle System) object.
  111531. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111532. * @param scene (Scene) is the scene in which the SPS is added.
  111533. * @param options defines the options of the sps e.g.
  111534. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111535. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111536. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111537. * * 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.
  111538. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111539. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111540. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111541. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111542. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111543. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111544. */
  111545. constructor(name: string, scene: Scene, options?: {
  111546. updatable?: boolean;
  111547. isPickable?: boolean;
  111548. enableDepthSort?: boolean;
  111549. particleIntersection?: boolean;
  111550. boundingSphereOnly?: boolean;
  111551. bSphereRadiusFactor?: number;
  111552. expandable?: boolean;
  111553. useModelMaterial?: boolean;
  111554. enableMultiMaterial?: boolean;
  111555. });
  111556. /**
  111557. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111558. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111559. * @returns the created mesh
  111560. */
  111561. buildMesh(): Mesh;
  111562. /**
  111563. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111564. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111565. * Thus the particles generated from `digest()` have their property `position` set yet.
  111566. * @param mesh ( Mesh ) is the mesh to be digested
  111567. * @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
  111568. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111569. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111570. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111571. * @returns the current SPS
  111572. */
  111573. digest(mesh: Mesh, options?: {
  111574. facetNb?: number;
  111575. number?: number;
  111576. delta?: number;
  111577. storage?: [];
  111578. }): SolidParticleSystem;
  111579. /**
  111580. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111581. * @hidden
  111582. */
  111583. private _unrotateFixedNormals;
  111584. /**
  111585. * Resets the temporary working copy particle
  111586. * @hidden
  111587. */
  111588. private _resetCopy;
  111589. /**
  111590. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111591. * @param p the current index in the positions array to be updated
  111592. * @param ind the current index in the indices array
  111593. * @param shape a Vector3 array, the shape geometry
  111594. * @param positions the positions array to be updated
  111595. * @param meshInd the shape indices array
  111596. * @param indices the indices array to be updated
  111597. * @param meshUV the shape uv array
  111598. * @param uvs the uv array to be updated
  111599. * @param meshCol the shape color array
  111600. * @param colors the color array to be updated
  111601. * @param meshNor the shape normals array
  111602. * @param normals the normals array to be updated
  111603. * @param idx the particle index
  111604. * @param idxInShape the particle index in its shape
  111605. * @param options the addShape() method passed options
  111606. * @model the particle model
  111607. * @hidden
  111608. */
  111609. private _meshBuilder;
  111610. /**
  111611. * Returns a shape Vector3 array from positions float array
  111612. * @param positions float array
  111613. * @returns a vector3 array
  111614. * @hidden
  111615. */
  111616. private _posToShape;
  111617. /**
  111618. * Returns a shapeUV array from a float uvs (array deep copy)
  111619. * @param uvs as a float array
  111620. * @returns a shapeUV array
  111621. * @hidden
  111622. */
  111623. private _uvsToShapeUV;
  111624. /**
  111625. * Adds a new particle object in the particles array
  111626. * @param idx particle index in particles array
  111627. * @param id particle id
  111628. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111629. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111630. * @param model particle ModelShape object
  111631. * @param shapeId model shape identifier
  111632. * @param idxInShape index of the particle in the current model
  111633. * @param bInfo model bounding info object
  111634. * @param storage target storage array, if any
  111635. * @hidden
  111636. */
  111637. private _addParticle;
  111638. /**
  111639. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111640. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111641. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111642. * @param nb (positive integer) the number of particles to be created from this model
  111643. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111644. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111645. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111646. * @returns the number of shapes in the system
  111647. */
  111648. addShape(mesh: Mesh, nb: number, options?: {
  111649. positionFunction?: any;
  111650. vertexFunction?: any;
  111651. storage?: [];
  111652. }): number;
  111653. /**
  111654. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111655. * @hidden
  111656. */
  111657. private _rebuildParticle;
  111658. /**
  111659. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111660. * @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.
  111661. * @returns the SPS.
  111662. */
  111663. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111664. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111665. * Returns an array with the removed particles.
  111666. * 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.
  111667. * The SPS can't be empty so at least one particle needs to remain in place.
  111668. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111669. * @param start index of the first particle to remove
  111670. * @param end index of the last particle to remove (included)
  111671. * @returns an array populated with the removed particles
  111672. */
  111673. removeParticles(start: number, end: number): SolidParticle[];
  111674. /**
  111675. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111676. * @param solidParticleArray an array populated with Solid Particles objects
  111677. * @returns the SPS
  111678. */
  111679. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111680. /**
  111681. * Creates a new particle and modifies the SPS mesh geometry :
  111682. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111683. * - calls _addParticle() to populate the particle array
  111684. * factorized code from addShape() and insertParticlesFromArray()
  111685. * @param idx particle index in the particles array
  111686. * @param i particle index in its shape
  111687. * @param modelShape particle ModelShape object
  111688. * @param shape shape vertex array
  111689. * @param meshInd shape indices array
  111690. * @param meshUV shape uv array
  111691. * @param meshCol shape color array
  111692. * @param meshNor shape normals array
  111693. * @param bbInfo shape bounding info
  111694. * @param storage target particle storage
  111695. * @options addShape() passed options
  111696. * @hidden
  111697. */
  111698. private _insertNewParticle;
  111699. /**
  111700. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111701. * This method calls `updateParticle()` for each particle of the SPS.
  111702. * For an animated SPS, it is usually called within the render loop.
  111703. * 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.
  111704. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111705. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111706. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111707. * @returns the SPS.
  111708. */
  111709. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111710. /**
  111711. * Disposes the SPS.
  111712. */
  111713. dispose(): void;
  111714. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111715. * idx is the particle index in the SPS
  111716. * faceId is the picked face index counted within this particle.
  111717. * Returns null if the pickInfo can't identify a picked particle.
  111718. * @param pickingInfo (PickingInfo object)
  111719. * @returns {idx: number, faceId: number} or null
  111720. */
  111721. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111722. idx: number;
  111723. faceId: number;
  111724. }>;
  111725. /**
  111726. * Returns a SolidParticle object from its identifier : particle.id
  111727. * @param id (integer) the particle Id
  111728. * @returns the searched particle or null if not found in the SPS.
  111729. */
  111730. getParticleById(id: number): Nullable<SolidParticle>;
  111731. /**
  111732. * Returns a new array populated with the particles having the passed shapeId.
  111733. * @param shapeId (integer) the shape identifier
  111734. * @returns a new solid particle array
  111735. */
  111736. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111737. /**
  111738. * Populates the passed array "ref" with the particles having the passed shapeId.
  111739. * @param shapeId the shape identifier
  111740. * @returns the SPS
  111741. * @param ref
  111742. */
  111743. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111744. /**
  111745. * Computes the required SubMeshes according the materials assigned to the particles.
  111746. * @returns the solid particle system.
  111747. * Does nothing if called before the SPS mesh is built.
  111748. */
  111749. computeSubMeshes(): SolidParticleSystem;
  111750. /**
  111751. * Sorts the solid particles by material when MultiMaterial is enabled.
  111752. * Updates the indices32 array.
  111753. * Updates the indicesByMaterial array.
  111754. * Updates the mesh indices array.
  111755. * @returns the SPS
  111756. * @hidden
  111757. */
  111758. private _sortParticlesByMaterial;
  111759. /**
  111760. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111761. * @hidden
  111762. */
  111763. private _setMaterialIndexesById;
  111764. /**
  111765. * Returns an array with unique values of Materials from the passed array
  111766. * @param array the material array to be checked and filtered
  111767. * @hidden
  111768. */
  111769. private _filterUniqueMaterialId;
  111770. /**
  111771. * Sets a new Standard Material as _defaultMaterial if not already set.
  111772. * @hidden
  111773. */
  111774. private _setDefaultMaterial;
  111775. /**
  111776. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111777. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111778. * @returns the SPS.
  111779. */
  111780. refreshVisibleSize(): SolidParticleSystem;
  111781. /**
  111782. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111783. * @param size the size (float) of the visibility box
  111784. * note : this doesn't lock the SPS mesh bounding box.
  111785. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111786. */
  111787. setVisibilityBox(size: number): void;
  111788. /**
  111789. * Gets whether the SPS as always visible or not
  111790. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111791. */
  111792. get isAlwaysVisible(): boolean;
  111793. /**
  111794. * Sets the SPS as always visible or not
  111795. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111796. */
  111797. set isAlwaysVisible(val: boolean);
  111798. /**
  111799. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111800. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111801. */
  111802. set isVisibilityBoxLocked(val: boolean);
  111803. /**
  111804. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111805. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111806. */
  111807. get isVisibilityBoxLocked(): boolean;
  111808. /**
  111809. * Tells to `setParticles()` to compute the particle rotations or not.
  111810. * Default value : true. The SPS is faster when it's set to false.
  111811. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111812. */
  111813. set computeParticleRotation(val: boolean);
  111814. /**
  111815. * Tells to `setParticles()` to compute the particle colors or not.
  111816. * Default value : true. The SPS is faster when it's set to false.
  111817. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111818. */
  111819. set computeParticleColor(val: boolean);
  111820. set computeParticleTexture(val: boolean);
  111821. /**
  111822. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111823. * Default value : false. The SPS is faster when it's set to false.
  111824. * Note : the particle custom vertex positions aren't stored values.
  111825. */
  111826. set computeParticleVertex(val: boolean);
  111827. /**
  111828. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111829. */
  111830. set computeBoundingBox(val: boolean);
  111831. /**
  111832. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111833. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111834. * Default : `true`
  111835. */
  111836. set depthSortParticles(val: boolean);
  111837. /**
  111838. * Gets if `setParticles()` computes the particle rotations or not.
  111839. * Default value : true. The SPS is faster when it's set to false.
  111840. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111841. */
  111842. get computeParticleRotation(): boolean;
  111843. /**
  111844. * Gets if `setParticles()` computes the particle colors or not.
  111845. * Default value : true. The SPS is faster when it's set to false.
  111846. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111847. */
  111848. get computeParticleColor(): boolean;
  111849. /**
  111850. * Gets if `setParticles()` computes the particle textures or not.
  111851. * Default value : true. The SPS is faster when it's set to false.
  111852. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111853. */
  111854. get computeParticleTexture(): boolean;
  111855. /**
  111856. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111857. * Default value : false. The SPS is faster when it's set to false.
  111858. * Note : the particle custom vertex positions aren't stored values.
  111859. */
  111860. get computeParticleVertex(): boolean;
  111861. /**
  111862. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111863. */
  111864. get computeBoundingBox(): boolean;
  111865. /**
  111866. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111867. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111868. * Default : `true`
  111869. */
  111870. get depthSortParticles(): boolean;
  111871. /**
  111872. * Gets if the SPS is created as expandable at construction time.
  111873. * Default : `false`
  111874. */
  111875. get expandable(): boolean;
  111876. /**
  111877. * Gets if the SPS supports the Multi Materials
  111878. */
  111879. get multimaterialEnabled(): boolean;
  111880. /**
  111881. * Gets if the SPS uses the model materials for its own multimaterial.
  111882. */
  111883. get useModelMaterial(): boolean;
  111884. /**
  111885. * The SPS used material array.
  111886. */
  111887. get materials(): Material[];
  111888. /**
  111889. * Sets the SPS MultiMaterial from the passed materials.
  111890. * Note : the passed array is internally copied and not used then by reference.
  111891. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111892. */
  111893. setMultiMaterial(materials: Material[]): void;
  111894. /**
  111895. * The SPS computed multimaterial object
  111896. */
  111897. get multimaterial(): MultiMaterial;
  111898. set multimaterial(mm: MultiMaterial);
  111899. /**
  111900. * If the subMeshes must be updated on the next call to setParticles()
  111901. */
  111902. get autoUpdateSubMeshes(): boolean;
  111903. set autoUpdateSubMeshes(val: boolean);
  111904. /**
  111905. * This function does nothing. It may be overwritten to set all the particle first values.
  111906. * The SPS doesn't call this function, you may have to call it by your own.
  111907. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111908. */
  111909. initParticles(): void;
  111910. /**
  111911. * This function does nothing. It may be overwritten to recycle a particle.
  111912. * The SPS doesn't call this function, you may have to call it by your own.
  111913. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111914. * @param particle The particle to recycle
  111915. * @returns the recycled particle
  111916. */
  111917. recycleParticle(particle: SolidParticle): SolidParticle;
  111918. /**
  111919. * Updates a particle : this function should be overwritten by the user.
  111920. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111921. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111922. * @example : just set a particle position or velocity and recycle conditions
  111923. * @param particle The particle to update
  111924. * @returns the updated particle
  111925. */
  111926. updateParticle(particle: SolidParticle): SolidParticle;
  111927. /**
  111928. * Updates a vertex of a particle : it can be overwritten by the user.
  111929. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111930. * @param particle the current particle
  111931. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111932. * @param pt the index of the current vertex in the particle shape
  111933. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111934. * @example : just set a vertex particle position or color
  111935. * @returns the sps
  111936. */
  111937. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111938. /**
  111939. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111940. * This does nothing and may be overwritten by the user.
  111941. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111942. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111943. * @param update the boolean update value actually passed to setParticles()
  111944. */
  111945. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111946. /**
  111947. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111948. * This will be passed three parameters.
  111949. * This does nothing and may be overwritten by the user.
  111950. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111951. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111952. * @param update the boolean update value actually passed to setParticles()
  111953. */
  111954. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111955. }
  111956. }
  111957. declare module BABYLON {
  111958. /**
  111959. * Represents one particle of a solid particle system.
  111960. */
  111961. export class SolidParticle {
  111962. /**
  111963. * particle global index
  111964. */
  111965. idx: number;
  111966. /**
  111967. * particle identifier
  111968. */
  111969. id: number;
  111970. /**
  111971. * The color of the particle
  111972. */
  111973. color: Nullable<Color4>;
  111974. /**
  111975. * The world space position of the particle.
  111976. */
  111977. position: Vector3;
  111978. /**
  111979. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111980. */
  111981. rotation: Vector3;
  111982. /**
  111983. * The world space rotation quaternion of the particle.
  111984. */
  111985. rotationQuaternion: Nullable<Quaternion>;
  111986. /**
  111987. * The scaling of the particle.
  111988. */
  111989. scaling: Vector3;
  111990. /**
  111991. * The uvs of the particle.
  111992. */
  111993. uvs: Vector4;
  111994. /**
  111995. * The current speed of the particle.
  111996. */
  111997. velocity: Vector3;
  111998. /**
  111999. * The pivot point in the particle local space.
  112000. */
  112001. pivot: Vector3;
  112002. /**
  112003. * Must the particle be translated from its pivot point in its local space ?
  112004. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112005. * Default : false
  112006. */
  112007. translateFromPivot: boolean;
  112008. /**
  112009. * Is the particle active or not ?
  112010. */
  112011. alive: boolean;
  112012. /**
  112013. * Is the particle visible or not ?
  112014. */
  112015. isVisible: boolean;
  112016. /**
  112017. * Index of this particle in the global "positions" array (Internal use)
  112018. * @hidden
  112019. */
  112020. _pos: number;
  112021. /**
  112022. * @hidden Index of this particle in the global "indices" array (Internal use)
  112023. */
  112024. _ind: number;
  112025. /**
  112026. * @hidden ModelShape of this particle (Internal use)
  112027. */
  112028. _model: ModelShape;
  112029. /**
  112030. * ModelShape id of this particle
  112031. */
  112032. shapeId: number;
  112033. /**
  112034. * Index of the particle in its shape id
  112035. */
  112036. idxInShape: number;
  112037. /**
  112038. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112039. */
  112040. _modelBoundingInfo: BoundingInfo;
  112041. /**
  112042. * @hidden Particle BoundingInfo object (Internal use)
  112043. */
  112044. _boundingInfo: BoundingInfo;
  112045. /**
  112046. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112047. */
  112048. _sps: SolidParticleSystem;
  112049. /**
  112050. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112051. */
  112052. _stillInvisible: boolean;
  112053. /**
  112054. * @hidden Last computed particle rotation matrix
  112055. */
  112056. _rotationMatrix: number[];
  112057. /**
  112058. * Parent particle Id, if any.
  112059. * Default null.
  112060. */
  112061. parentId: Nullable<number>;
  112062. /**
  112063. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112064. */
  112065. materialIndex: Nullable<number>;
  112066. /**
  112067. * Custom object or properties.
  112068. */
  112069. props: Nullable<any>;
  112070. /**
  112071. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112072. * The possible values are :
  112073. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112074. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112075. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112076. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112077. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112078. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112079. * */
  112080. cullingStrategy: number;
  112081. /**
  112082. * @hidden Internal global position in the SPS.
  112083. */
  112084. _globalPosition: Vector3;
  112085. /**
  112086. * Creates a Solid Particle object.
  112087. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112088. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112089. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112090. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112091. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112092. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112093. * @param shapeId (integer) is the model shape identifier in the SPS.
  112094. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112095. * @param sps defines the sps it is associated to
  112096. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112097. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112098. */
  112099. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112100. /**
  112101. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112102. * @param target the particle target
  112103. * @returns the current particle
  112104. */
  112105. copyToRef(target: SolidParticle): SolidParticle;
  112106. /**
  112107. * Legacy support, changed scale to scaling
  112108. */
  112109. get scale(): Vector3;
  112110. /**
  112111. * Legacy support, changed scale to scaling
  112112. */
  112113. set scale(scale: Vector3);
  112114. /**
  112115. * Legacy support, changed quaternion to rotationQuaternion
  112116. */
  112117. get quaternion(): Nullable<Quaternion>;
  112118. /**
  112119. * Legacy support, changed quaternion to rotationQuaternion
  112120. */
  112121. set quaternion(q: Nullable<Quaternion>);
  112122. /**
  112123. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112124. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112125. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112126. * @returns true if it intersects
  112127. */
  112128. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112129. /**
  112130. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112131. * A particle is in the frustum if its bounding box intersects the frustum
  112132. * @param frustumPlanes defines the frustum to test
  112133. * @returns true if the particle is in the frustum planes
  112134. */
  112135. isInFrustum(frustumPlanes: Plane[]): boolean;
  112136. /**
  112137. * get the rotation matrix of the particle
  112138. * @hidden
  112139. */
  112140. getRotationMatrix(m: Matrix): void;
  112141. }
  112142. /**
  112143. * Represents the shape of the model used by one particle of a solid particle system.
  112144. * SPS internal tool, don't use it manually.
  112145. */
  112146. export class ModelShape {
  112147. /**
  112148. * The shape id
  112149. * @hidden
  112150. */
  112151. shapeID: number;
  112152. /**
  112153. * flat array of model positions (internal use)
  112154. * @hidden
  112155. */
  112156. _shape: Vector3[];
  112157. /**
  112158. * flat array of model UVs (internal use)
  112159. * @hidden
  112160. */
  112161. _shapeUV: number[];
  112162. /**
  112163. * color array of the model
  112164. * @hidden
  112165. */
  112166. _shapeColors: number[];
  112167. /**
  112168. * indices array of the model
  112169. * @hidden
  112170. */
  112171. _indices: number[];
  112172. /**
  112173. * normals array of the model
  112174. * @hidden
  112175. */
  112176. _normals: number[];
  112177. /**
  112178. * length of the shape in the model indices array (internal use)
  112179. * @hidden
  112180. */
  112181. _indicesLength: number;
  112182. /**
  112183. * Custom position function (internal use)
  112184. * @hidden
  112185. */
  112186. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112187. /**
  112188. * Custom vertex function (internal use)
  112189. * @hidden
  112190. */
  112191. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112192. /**
  112193. * Model material (internal use)
  112194. * @hidden
  112195. */
  112196. _material: Nullable<Material>;
  112197. /**
  112198. * 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.
  112199. * SPS internal tool, don't use it manually.
  112200. * @hidden
  112201. */
  112202. 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>);
  112203. }
  112204. /**
  112205. * Represents a Depth Sorted Particle in the solid particle system.
  112206. * @hidden
  112207. */
  112208. export class DepthSortedParticle {
  112209. /**
  112210. * Particle index
  112211. */
  112212. idx: number;
  112213. /**
  112214. * Index of the particle in the "indices" array
  112215. */
  112216. ind: number;
  112217. /**
  112218. * Length of the particle shape in the "indices" array
  112219. */
  112220. indicesLength: number;
  112221. /**
  112222. * Squared distance from the particle to the camera
  112223. */
  112224. sqDistance: number;
  112225. /**
  112226. * Material index when used with MultiMaterials
  112227. */
  112228. materialIndex: number;
  112229. /**
  112230. * Creates a new sorted particle
  112231. * @param materialIndex
  112232. */
  112233. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112234. }
  112235. /**
  112236. * Represents a solid particle vertex
  112237. */
  112238. export class SolidParticleVertex {
  112239. /**
  112240. * Vertex position
  112241. */
  112242. position: Vector3;
  112243. /**
  112244. * Vertex color
  112245. */
  112246. color: Color4;
  112247. /**
  112248. * Vertex UV
  112249. */
  112250. uv: Vector2;
  112251. /**
  112252. * Creates a new solid particle vertex
  112253. */
  112254. constructor();
  112255. /** Vertex x coordinate */
  112256. get x(): number;
  112257. set x(val: number);
  112258. /** Vertex y coordinate */
  112259. get y(): number;
  112260. set y(val: number);
  112261. /** Vertex z coordinate */
  112262. get z(): number;
  112263. set z(val: number);
  112264. }
  112265. }
  112266. declare module BABYLON {
  112267. /**
  112268. * @hidden
  112269. */
  112270. export class _MeshCollisionData {
  112271. _checkCollisions: boolean;
  112272. _collisionMask: number;
  112273. _collisionGroup: number;
  112274. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112275. _collider: Nullable<Collider>;
  112276. _oldPositionForCollisions: Vector3;
  112277. _diffPositionForCollisions: Vector3;
  112278. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112279. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112280. _collisionResponse: boolean;
  112281. }
  112282. }
  112283. declare module BABYLON {
  112284. /** @hidden */
  112285. class _FacetDataStorage {
  112286. facetPositions: Vector3[];
  112287. facetNormals: Vector3[];
  112288. facetPartitioning: number[][];
  112289. facetNb: number;
  112290. partitioningSubdivisions: number;
  112291. partitioningBBoxRatio: number;
  112292. facetDataEnabled: boolean;
  112293. facetParameters: any;
  112294. bbSize: Vector3;
  112295. subDiv: {
  112296. max: number;
  112297. X: number;
  112298. Y: number;
  112299. Z: number;
  112300. };
  112301. facetDepthSort: boolean;
  112302. facetDepthSortEnabled: boolean;
  112303. depthSortedIndices: IndicesArray;
  112304. depthSortedFacets: {
  112305. ind: number;
  112306. sqDistance: number;
  112307. }[];
  112308. facetDepthSortFunction: (f1: {
  112309. ind: number;
  112310. sqDistance: number;
  112311. }, f2: {
  112312. ind: number;
  112313. sqDistance: number;
  112314. }) => number;
  112315. facetDepthSortFrom: Vector3;
  112316. facetDepthSortOrigin: Vector3;
  112317. invertedMatrix: Matrix;
  112318. }
  112319. /**
  112320. * @hidden
  112321. **/
  112322. class _InternalAbstractMeshDataInfo {
  112323. _hasVertexAlpha: boolean;
  112324. _useVertexColors: boolean;
  112325. _numBoneInfluencers: number;
  112326. _applyFog: boolean;
  112327. _receiveShadows: boolean;
  112328. _facetData: _FacetDataStorage;
  112329. _visibility: number;
  112330. _skeleton: Nullable<Skeleton>;
  112331. _layerMask: number;
  112332. _computeBonesUsingShaders: boolean;
  112333. _isActive: boolean;
  112334. _onlyForInstances: boolean;
  112335. _isActiveIntermediate: boolean;
  112336. _onlyForInstancesIntermediate: boolean;
  112337. _actAsRegularMesh: boolean;
  112338. }
  112339. /**
  112340. * Class used to store all common mesh properties
  112341. */
  112342. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112343. /** No occlusion */
  112344. static OCCLUSION_TYPE_NONE: number;
  112345. /** Occlusion set to optimisitic */
  112346. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112347. /** Occlusion set to strict */
  112348. static OCCLUSION_TYPE_STRICT: number;
  112349. /** Use an accurante occlusion algorithm */
  112350. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112351. /** Use a conservative occlusion algorithm */
  112352. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112353. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112354. * Test order :
  112355. * Is the bounding sphere outside the frustum ?
  112356. * If not, are the bounding box vertices outside the frustum ?
  112357. * It not, then the cullable object is in the frustum.
  112358. */
  112359. static readonly CULLINGSTRATEGY_STANDARD: number;
  112360. /** Culling strategy : Bounding Sphere Only.
  112361. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112362. * It's also less accurate than the standard because some not visible objects can still be selected.
  112363. * Test : is the bounding sphere outside the frustum ?
  112364. * If not, then the cullable object is in the frustum.
  112365. */
  112366. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112367. /** Culling strategy : Optimistic Inclusion.
  112368. * This in an inclusion test first, then the standard exclusion test.
  112369. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112370. * 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.
  112371. * Anyway, it's as accurate as the standard strategy.
  112372. * Test :
  112373. * Is the cullable object bounding sphere center in the frustum ?
  112374. * If not, apply the default culling strategy.
  112375. */
  112376. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112377. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112378. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112379. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112380. * 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.
  112381. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112382. * Test :
  112383. * Is the cullable object bounding sphere center in the frustum ?
  112384. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112385. */
  112386. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112387. /**
  112388. * No billboard
  112389. */
  112390. static get BILLBOARDMODE_NONE(): number;
  112391. /** Billboard on X axis */
  112392. static get BILLBOARDMODE_X(): number;
  112393. /** Billboard on Y axis */
  112394. static get BILLBOARDMODE_Y(): number;
  112395. /** Billboard on Z axis */
  112396. static get BILLBOARDMODE_Z(): number;
  112397. /** Billboard on all axes */
  112398. static get BILLBOARDMODE_ALL(): number;
  112399. /** Billboard on using position instead of orientation */
  112400. static get BILLBOARDMODE_USE_POSITION(): number;
  112401. /** @hidden */
  112402. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112403. /**
  112404. * The culling strategy to use to check whether the mesh must be rendered or not.
  112405. * This value can be changed at any time and will be used on the next render mesh selection.
  112406. * The possible values are :
  112407. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112408. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112409. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112410. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112411. * Please read each static variable documentation to get details about the culling process.
  112412. * */
  112413. cullingStrategy: number;
  112414. /**
  112415. * Gets the number of facets in the mesh
  112416. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112417. */
  112418. get facetNb(): number;
  112419. /**
  112420. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112421. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112422. */
  112423. get partitioningSubdivisions(): number;
  112424. set partitioningSubdivisions(nb: number);
  112425. /**
  112426. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112427. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112428. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112429. */
  112430. get partitioningBBoxRatio(): number;
  112431. set partitioningBBoxRatio(ratio: number);
  112432. /**
  112433. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112434. * Works only for updatable meshes.
  112435. * Doesn't work with multi-materials
  112436. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112437. */
  112438. get mustDepthSortFacets(): boolean;
  112439. set mustDepthSortFacets(sort: boolean);
  112440. /**
  112441. * The location (Vector3) where the facet depth sort must be computed from.
  112442. * By default, the active camera position.
  112443. * Used only when facet depth sort is enabled
  112444. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112445. */
  112446. get facetDepthSortFrom(): Vector3;
  112447. set facetDepthSortFrom(location: Vector3);
  112448. /**
  112449. * gets a boolean indicating if facetData is enabled
  112450. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112451. */
  112452. get isFacetDataEnabled(): boolean;
  112453. /** @hidden */
  112454. _updateNonUniformScalingState(value: boolean): boolean;
  112455. /**
  112456. * An event triggered when this mesh collides with another one
  112457. */
  112458. onCollideObservable: Observable<AbstractMesh>;
  112459. /** Set a function to call when this mesh collides with another one */
  112460. set onCollide(callback: () => void);
  112461. /**
  112462. * An event triggered when the collision's position changes
  112463. */
  112464. onCollisionPositionChangeObservable: Observable<Vector3>;
  112465. /** Set a function to call when the collision's position changes */
  112466. set onCollisionPositionChange(callback: () => void);
  112467. /**
  112468. * An event triggered when material is changed
  112469. */
  112470. onMaterialChangedObservable: Observable<AbstractMesh>;
  112471. /**
  112472. * Gets or sets the orientation for POV movement & rotation
  112473. */
  112474. definedFacingForward: boolean;
  112475. /** @hidden */
  112476. _occlusionQuery: Nullable<WebGLQuery>;
  112477. /** @hidden */
  112478. _renderingGroup: Nullable<RenderingGroup>;
  112479. /**
  112480. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112481. */
  112482. get visibility(): number;
  112483. /**
  112484. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112485. */
  112486. set visibility(value: number);
  112487. /** Gets or sets the alpha index used to sort transparent meshes
  112488. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112489. */
  112490. alphaIndex: number;
  112491. /**
  112492. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112493. */
  112494. isVisible: boolean;
  112495. /**
  112496. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112497. */
  112498. isPickable: boolean;
  112499. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112500. showSubMeshesBoundingBox: boolean;
  112501. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112502. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112503. */
  112504. isBlocker: boolean;
  112505. /**
  112506. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112507. */
  112508. enablePointerMoveEvents: boolean;
  112509. private _renderingGroupId;
  112510. /**
  112511. * Specifies the rendering group id for this mesh (0 by default)
  112512. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112513. */
  112514. get renderingGroupId(): number;
  112515. set renderingGroupId(value: number);
  112516. private _material;
  112517. /** Gets or sets current material */
  112518. get material(): Nullable<Material>;
  112519. set material(value: Nullable<Material>);
  112520. /**
  112521. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112522. * @see https://doc.babylonjs.com/babylon101/shadows
  112523. */
  112524. get receiveShadows(): boolean;
  112525. set receiveShadows(value: boolean);
  112526. /** Defines color to use when rendering outline */
  112527. outlineColor: Color3;
  112528. /** Define width to use when rendering outline */
  112529. outlineWidth: number;
  112530. /** Defines color to use when rendering overlay */
  112531. overlayColor: Color3;
  112532. /** Defines alpha to use when rendering overlay */
  112533. overlayAlpha: number;
  112534. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112535. get hasVertexAlpha(): boolean;
  112536. set hasVertexAlpha(value: boolean);
  112537. /** 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) */
  112538. get useVertexColors(): boolean;
  112539. set useVertexColors(value: boolean);
  112540. /**
  112541. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112542. */
  112543. get computeBonesUsingShaders(): boolean;
  112544. set computeBonesUsingShaders(value: boolean);
  112545. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112546. get numBoneInfluencers(): number;
  112547. set numBoneInfluencers(value: number);
  112548. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112549. get applyFog(): boolean;
  112550. set applyFog(value: boolean);
  112551. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112552. useOctreeForRenderingSelection: boolean;
  112553. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112554. useOctreeForPicking: boolean;
  112555. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112556. useOctreeForCollisions: boolean;
  112557. /**
  112558. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112559. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112560. */
  112561. get layerMask(): number;
  112562. set layerMask(value: number);
  112563. /**
  112564. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112565. */
  112566. alwaysSelectAsActiveMesh: boolean;
  112567. /**
  112568. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112569. */
  112570. doNotSyncBoundingInfo: boolean;
  112571. /**
  112572. * Gets or sets the current action manager
  112573. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112574. */
  112575. actionManager: Nullable<AbstractActionManager>;
  112576. private _meshCollisionData;
  112577. /**
  112578. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112579. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112580. */
  112581. ellipsoid: Vector3;
  112582. /**
  112583. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112584. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112585. */
  112586. ellipsoidOffset: Vector3;
  112587. /**
  112588. * Gets or sets a collision mask used to mask collisions (default is -1).
  112589. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112590. */
  112591. get collisionMask(): number;
  112592. set collisionMask(mask: number);
  112593. /**
  112594. * Gets or sets a collision response flag (default is true).
  112595. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112596. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112597. * to respond to the collision.
  112598. */
  112599. get collisionResponse(): boolean;
  112600. set collisionResponse(response: boolean);
  112601. /**
  112602. * Gets or sets the current collision group mask (-1 by default).
  112603. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112604. */
  112605. get collisionGroup(): number;
  112606. set collisionGroup(mask: number);
  112607. /**
  112608. * Gets or sets current surrounding meshes (null by default).
  112609. *
  112610. * By default collision detection is tested against every mesh in the scene.
  112611. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112612. * meshes will be tested for the collision.
  112613. *
  112614. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112615. */
  112616. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112617. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112618. /**
  112619. * Defines edge width used when edgesRenderer is enabled
  112620. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112621. */
  112622. edgesWidth: number;
  112623. /**
  112624. * Defines edge color used when edgesRenderer is enabled
  112625. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112626. */
  112627. edgesColor: Color4;
  112628. /** @hidden */
  112629. _edgesRenderer: Nullable<IEdgesRenderer>;
  112630. /** @hidden */
  112631. _masterMesh: Nullable<AbstractMesh>;
  112632. /** @hidden */
  112633. _boundingInfo: Nullable<BoundingInfo>;
  112634. /** @hidden */
  112635. _renderId: number;
  112636. /**
  112637. * Gets or sets the list of subMeshes
  112638. * @see https://doc.babylonjs.com/how_to/multi_materials
  112639. */
  112640. subMeshes: SubMesh[];
  112641. /** @hidden */
  112642. _intersectionsInProgress: AbstractMesh[];
  112643. /** @hidden */
  112644. _unIndexed: boolean;
  112645. /** @hidden */
  112646. _lightSources: Light[];
  112647. /** Gets the list of lights affecting that mesh */
  112648. get lightSources(): Light[];
  112649. /** @hidden */
  112650. get _positions(): Nullable<Vector3[]>;
  112651. /** @hidden */
  112652. _waitingData: {
  112653. lods: Nullable<any>;
  112654. actions: Nullable<any>;
  112655. freezeWorldMatrix: Nullable<boolean>;
  112656. };
  112657. /** @hidden */
  112658. _bonesTransformMatrices: Nullable<Float32Array>;
  112659. /** @hidden */
  112660. _transformMatrixTexture: Nullable<RawTexture>;
  112661. /**
  112662. * Gets or sets a skeleton to apply skining transformations
  112663. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112664. */
  112665. set skeleton(value: Nullable<Skeleton>);
  112666. get skeleton(): Nullable<Skeleton>;
  112667. /**
  112668. * An event triggered when the mesh is rebuilt.
  112669. */
  112670. onRebuildObservable: Observable<AbstractMesh>;
  112671. /**
  112672. * Creates a new AbstractMesh
  112673. * @param name defines the name of the mesh
  112674. * @param scene defines the hosting scene
  112675. */
  112676. constructor(name: string, scene?: Nullable<Scene>);
  112677. /**
  112678. * Returns the string "AbstractMesh"
  112679. * @returns "AbstractMesh"
  112680. */
  112681. getClassName(): string;
  112682. /**
  112683. * Gets a string representation of the current mesh
  112684. * @param fullDetails defines a boolean indicating if full details must be included
  112685. * @returns a string representation of the current mesh
  112686. */
  112687. toString(fullDetails?: boolean): string;
  112688. /**
  112689. * @hidden
  112690. */
  112691. protected _getEffectiveParent(): Nullable<Node>;
  112692. /** @hidden */
  112693. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112694. /** @hidden */
  112695. _rebuild(): void;
  112696. /** @hidden */
  112697. _resyncLightSources(): void;
  112698. /** @hidden */
  112699. _resyncLightSource(light: Light): void;
  112700. /** @hidden */
  112701. _unBindEffect(): void;
  112702. /** @hidden */
  112703. _removeLightSource(light: Light, dispose: boolean): void;
  112704. private _markSubMeshesAsDirty;
  112705. /** @hidden */
  112706. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112707. /** @hidden */
  112708. _markSubMeshesAsAttributesDirty(): void;
  112709. /** @hidden */
  112710. _markSubMeshesAsMiscDirty(): void;
  112711. /**
  112712. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112713. */
  112714. get scaling(): Vector3;
  112715. set scaling(newScaling: Vector3);
  112716. /**
  112717. * Returns true if the mesh is blocked. Implemented by child classes
  112718. */
  112719. get isBlocked(): boolean;
  112720. /**
  112721. * Returns the mesh itself by default. Implemented by child classes
  112722. * @param camera defines the camera to use to pick the right LOD level
  112723. * @returns the currentAbstractMesh
  112724. */
  112725. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112726. /**
  112727. * Returns 0 by default. Implemented by child classes
  112728. * @returns an integer
  112729. */
  112730. getTotalVertices(): number;
  112731. /**
  112732. * Returns a positive integer : the total number of indices in this mesh geometry.
  112733. * @returns the numner of indices or zero if the mesh has no geometry.
  112734. */
  112735. getTotalIndices(): number;
  112736. /**
  112737. * Returns null by default. Implemented by child classes
  112738. * @returns null
  112739. */
  112740. getIndices(): Nullable<IndicesArray>;
  112741. /**
  112742. * Returns the array of the requested vertex data kind. Implemented by child classes
  112743. * @param kind defines the vertex data kind to use
  112744. * @returns null
  112745. */
  112746. getVerticesData(kind: string): Nullable<FloatArray>;
  112747. /**
  112748. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112749. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112750. * Note that a new underlying VertexBuffer object is created each call.
  112751. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112752. * @param kind defines vertex data kind:
  112753. * * VertexBuffer.PositionKind
  112754. * * VertexBuffer.UVKind
  112755. * * VertexBuffer.UV2Kind
  112756. * * VertexBuffer.UV3Kind
  112757. * * VertexBuffer.UV4Kind
  112758. * * VertexBuffer.UV5Kind
  112759. * * VertexBuffer.UV6Kind
  112760. * * VertexBuffer.ColorKind
  112761. * * VertexBuffer.MatricesIndicesKind
  112762. * * VertexBuffer.MatricesIndicesExtraKind
  112763. * * VertexBuffer.MatricesWeightsKind
  112764. * * VertexBuffer.MatricesWeightsExtraKind
  112765. * @param data defines the data source
  112766. * @param updatable defines if the data must be flagged as updatable (or static)
  112767. * @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
  112768. * @returns the current mesh
  112769. */
  112770. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112771. /**
  112772. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112773. * If the mesh has no geometry, it is simply returned as it is.
  112774. * @param kind defines vertex data kind:
  112775. * * VertexBuffer.PositionKind
  112776. * * VertexBuffer.UVKind
  112777. * * VertexBuffer.UV2Kind
  112778. * * VertexBuffer.UV3Kind
  112779. * * VertexBuffer.UV4Kind
  112780. * * VertexBuffer.UV5Kind
  112781. * * VertexBuffer.UV6Kind
  112782. * * VertexBuffer.ColorKind
  112783. * * VertexBuffer.MatricesIndicesKind
  112784. * * VertexBuffer.MatricesIndicesExtraKind
  112785. * * VertexBuffer.MatricesWeightsKind
  112786. * * VertexBuffer.MatricesWeightsExtraKind
  112787. * @param data defines the data source
  112788. * @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
  112789. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112790. * @returns the current mesh
  112791. */
  112792. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112793. /**
  112794. * Sets the mesh indices,
  112795. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112796. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112797. * @param totalVertices Defines the total number of vertices
  112798. * @returns the current mesh
  112799. */
  112800. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112801. /**
  112802. * Gets a boolean indicating if specific vertex data is present
  112803. * @param kind defines the vertex data kind to use
  112804. * @returns true is data kind is present
  112805. */
  112806. isVerticesDataPresent(kind: string): boolean;
  112807. /**
  112808. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112809. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112810. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112811. * @returns a BoundingInfo
  112812. */
  112813. getBoundingInfo(): BoundingInfo;
  112814. /**
  112815. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112816. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112817. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112818. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112819. * @returns the current mesh
  112820. */
  112821. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112822. /**
  112823. * Overwrite the current bounding info
  112824. * @param boundingInfo defines the new bounding info
  112825. * @returns the current mesh
  112826. */
  112827. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112828. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112829. get useBones(): boolean;
  112830. /** @hidden */
  112831. _preActivate(): void;
  112832. /** @hidden */
  112833. _preActivateForIntermediateRendering(renderId: number): void;
  112834. /** @hidden */
  112835. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112836. /** @hidden */
  112837. _postActivate(): void;
  112838. /** @hidden */
  112839. _freeze(): void;
  112840. /** @hidden */
  112841. _unFreeze(): void;
  112842. /**
  112843. * Gets the current world matrix
  112844. * @returns a Matrix
  112845. */
  112846. getWorldMatrix(): Matrix;
  112847. /** @hidden */
  112848. _getWorldMatrixDeterminant(): number;
  112849. /**
  112850. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112851. */
  112852. get isAnInstance(): boolean;
  112853. /**
  112854. * Gets a boolean indicating if this mesh has instances
  112855. */
  112856. get hasInstances(): boolean;
  112857. /**
  112858. * Gets a boolean indicating if this mesh has thin instances
  112859. */
  112860. get hasThinInstances(): boolean;
  112861. /**
  112862. * Perform relative position change from the point of view of behind the front of the mesh.
  112863. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112864. * Supports definition of mesh facing forward or backward
  112865. * @param amountRight defines the distance on the right axis
  112866. * @param amountUp defines the distance on the up axis
  112867. * @param amountForward defines the distance on the forward axis
  112868. * @returns the current mesh
  112869. */
  112870. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112871. /**
  112872. * Calculate relative position change from the point of view of behind the front of the mesh.
  112873. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112874. * Supports definition of mesh facing forward or backward
  112875. * @param amountRight defines the distance on the right axis
  112876. * @param amountUp defines the distance on the up axis
  112877. * @param amountForward defines the distance on the forward axis
  112878. * @returns the new displacement vector
  112879. */
  112880. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112881. /**
  112882. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112883. * Supports definition of mesh facing forward or backward
  112884. * @param flipBack defines the flip
  112885. * @param twirlClockwise defines the twirl
  112886. * @param tiltRight defines the tilt
  112887. * @returns the current mesh
  112888. */
  112889. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112890. /**
  112891. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112892. * Supports definition of mesh facing forward or backward.
  112893. * @param flipBack defines the flip
  112894. * @param twirlClockwise defines the twirl
  112895. * @param tiltRight defines the tilt
  112896. * @returns the new rotation vector
  112897. */
  112898. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112899. /**
  112900. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112901. * This means the mesh underlying bounding box and sphere are recomputed.
  112902. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112903. * @returns the current mesh
  112904. */
  112905. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112906. /** @hidden */
  112907. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112908. /** @hidden */
  112909. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112910. /** @hidden */
  112911. _updateBoundingInfo(): AbstractMesh;
  112912. /** @hidden */
  112913. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112914. /** @hidden */
  112915. protected _afterComputeWorldMatrix(): void;
  112916. /** @hidden */
  112917. get _effectiveMesh(): AbstractMesh;
  112918. /**
  112919. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112920. * A mesh is in the frustum if its bounding box intersects the frustum
  112921. * @param frustumPlanes defines the frustum to test
  112922. * @returns true if the mesh is in the frustum planes
  112923. */
  112924. isInFrustum(frustumPlanes: Plane[]): boolean;
  112925. /**
  112926. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112927. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112928. * @param frustumPlanes defines the frustum to test
  112929. * @returns true if the mesh is completely in the frustum planes
  112930. */
  112931. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112932. /**
  112933. * True if the mesh intersects another mesh or a SolidParticle object
  112934. * @param mesh defines a target mesh or SolidParticle to test
  112935. * @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)
  112936. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112937. * @returns true if there is an intersection
  112938. */
  112939. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112940. /**
  112941. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112942. * @param point defines the point to test
  112943. * @returns true if there is an intersection
  112944. */
  112945. intersectsPoint(point: Vector3): boolean;
  112946. /**
  112947. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112948. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112949. */
  112950. get checkCollisions(): boolean;
  112951. set checkCollisions(collisionEnabled: boolean);
  112952. /**
  112953. * Gets Collider object used to compute collisions (not physics)
  112954. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112955. */
  112956. get collider(): Nullable<Collider>;
  112957. /**
  112958. * Move the mesh using collision engine
  112959. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112960. * @param displacement defines the requested displacement vector
  112961. * @returns the current mesh
  112962. */
  112963. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112964. private _onCollisionPositionChange;
  112965. /** @hidden */
  112966. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112967. /** @hidden */
  112968. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112969. /** @hidden */
  112970. _checkCollision(collider: Collider): AbstractMesh;
  112971. /** @hidden */
  112972. _generatePointsArray(): boolean;
  112973. /**
  112974. * Checks if the passed Ray intersects with the mesh
  112975. * @param ray defines the ray to use
  112976. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112977. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112978. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112979. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112980. * @returns the picking info
  112981. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112982. */
  112983. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112984. /**
  112985. * Clones the current mesh
  112986. * @param name defines the mesh name
  112987. * @param newParent defines the new mesh parent
  112988. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112989. * @returns the new mesh
  112990. */
  112991. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112992. /**
  112993. * Disposes all the submeshes of the current meshnp
  112994. * @returns the current mesh
  112995. */
  112996. releaseSubMeshes(): AbstractMesh;
  112997. /**
  112998. * Releases resources associated with this abstract mesh.
  112999. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113000. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113001. */
  113002. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113003. /**
  113004. * Adds the passed mesh as a child to the current mesh
  113005. * @param mesh defines the child mesh
  113006. * @returns the current mesh
  113007. */
  113008. addChild(mesh: AbstractMesh): AbstractMesh;
  113009. /**
  113010. * Removes the passed mesh from the current mesh children list
  113011. * @param mesh defines the child mesh
  113012. * @returns the current mesh
  113013. */
  113014. removeChild(mesh: AbstractMesh): AbstractMesh;
  113015. /** @hidden */
  113016. private _initFacetData;
  113017. /**
  113018. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113019. * This method can be called within the render loop.
  113020. * 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
  113021. * @returns the current mesh
  113022. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113023. */
  113024. updateFacetData(): AbstractMesh;
  113025. /**
  113026. * Returns the facetLocalNormals array.
  113027. * The normals are expressed in the mesh local spac
  113028. * @returns an array of Vector3
  113029. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113030. */
  113031. getFacetLocalNormals(): Vector3[];
  113032. /**
  113033. * Returns the facetLocalPositions array.
  113034. * The facet positions are expressed in the mesh local space
  113035. * @returns an array of Vector3
  113036. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113037. */
  113038. getFacetLocalPositions(): Vector3[];
  113039. /**
  113040. * Returns the facetLocalPartioning array
  113041. * @returns an array of array of numbers
  113042. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113043. */
  113044. getFacetLocalPartitioning(): number[][];
  113045. /**
  113046. * Returns the i-th facet position in the world system.
  113047. * This method allocates a new Vector3 per call
  113048. * @param i defines the facet index
  113049. * @returns a new Vector3
  113050. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113051. */
  113052. getFacetPosition(i: number): Vector3;
  113053. /**
  113054. * Sets the reference Vector3 with the i-th facet position in the world system
  113055. * @param i defines the facet index
  113056. * @param ref defines the target vector
  113057. * @returns the current mesh
  113058. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113059. */
  113060. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113061. /**
  113062. * Returns the i-th facet normal in the world system.
  113063. * This method allocates a new Vector3 per call
  113064. * @param i defines the facet index
  113065. * @returns a new Vector3
  113066. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113067. */
  113068. getFacetNormal(i: number): Vector3;
  113069. /**
  113070. * Sets the reference Vector3 with the i-th facet normal in the world system
  113071. * @param i defines the facet index
  113072. * @param ref defines the target vector
  113073. * @returns the current mesh
  113074. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113075. */
  113076. getFacetNormalToRef(i: number, ref: Vector3): this;
  113077. /**
  113078. * 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)
  113079. * @param x defines x coordinate
  113080. * @param y defines y coordinate
  113081. * @param z defines z coordinate
  113082. * @returns the array of facet indexes
  113083. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113084. */
  113085. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113086. /**
  113087. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113088. * @param projected sets as the (x,y,z) world projection on the facet
  113089. * @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
  113090. * @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
  113091. * @param x defines x coordinate
  113092. * @param y defines y coordinate
  113093. * @param z defines z coordinate
  113094. * @returns the face index if found (or null instead)
  113095. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113096. */
  113097. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113098. /**
  113099. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113100. * @param projected sets as the (x,y,z) local projection on the facet
  113101. * @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
  113102. * @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
  113103. * @param x defines x coordinate
  113104. * @param y defines y coordinate
  113105. * @param z defines z coordinate
  113106. * @returns the face index if found (or null instead)
  113107. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113108. */
  113109. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113110. /**
  113111. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113112. * @returns the parameters
  113113. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113114. */
  113115. getFacetDataParameters(): any;
  113116. /**
  113117. * Disables the feature FacetData and frees the related memory
  113118. * @returns the current mesh
  113119. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113120. */
  113121. disableFacetData(): AbstractMesh;
  113122. /**
  113123. * Updates the AbstractMesh indices array
  113124. * @param indices defines the data source
  113125. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113126. * @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)
  113127. * @returns the current mesh
  113128. */
  113129. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113130. /**
  113131. * Creates new normals data for the mesh
  113132. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113133. * @returns the current mesh
  113134. */
  113135. createNormals(updatable: boolean): AbstractMesh;
  113136. /**
  113137. * Align the mesh with a normal
  113138. * @param normal defines the normal to use
  113139. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113140. * @returns the current mesh
  113141. */
  113142. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113143. /** @hidden */
  113144. _checkOcclusionQuery(): boolean;
  113145. /**
  113146. * Disables the mesh edge rendering mode
  113147. * @returns the currentAbstractMesh
  113148. */
  113149. disableEdgesRendering(): AbstractMesh;
  113150. /**
  113151. * Enables the edge rendering mode on the mesh.
  113152. * This mode makes the mesh edges visible
  113153. * @param epsilon defines the maximal distance between two angles to detect a face
  113154. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113155. * @returns the currentAbstractMesh
  113156. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113157. */
  113158. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113159. /**
  113160. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113161. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113162. */
  113163. getConnectedParticleSystems(): IParticleSystem[];
  113164. }
  113165. }
  113166. declare module BABYLON {
  113167. /**
  113168. * Interface used to define ActionEvent
  113169. */
  113170. export interface IActionEvent {
  113171. /** The mesh or sprite that triggered the action */
  113172. source: any;
  113173. /** The X mouse cursor position at the time of the event */
  113174. pointerX: number;
  113175. /** The Y mouse cursor position at the time of the event */
  113176. pointerY: number;
  113177. /** The mesh that is currently pointed at (can be null) */
  113178. meshUnderPointer: Nullable<AbstractMesh>;
  113179. /** the original (browser) event that triggered the ActionEvent */
  113180. sourceEvent?: any;
  113181. /** additional data for the event */
  113182. additionalData?: any;
  113183. }
  113184. /**
  113185. * ActionEvent is the event being sent when an action is triggered.
  113186. */
  113187. export class ActionEvent implements IActionEvent {
  113188. /** The mesh or sprite that triggered the action */
  113189. source: any;
  113190. /** The X mouse cursor position at the time of the event */
  113191. pointerX: number;
  113192. /** The Y mouse cursor position at the time of the event */
  113193. pointerY: number;
  113194. /** The mesh that is currently pointed at (can be null) */
  113195. meshUnderPointer: Nullable<AbstractMesh>;
  113196. /** the original (browser) event that triggered the ActionEvent */
  113197. sourceEvent?: any;
  113198. /** additional data for the event */
  113199. additionalData?: any;
  113200. /**
  113201. * Creates a new ActionEvent
  113202. * @param source The mesh or sprite that triggered the action
  113203. * @param pointerX The X mouse cursor position at the time of the event
  113204. * @param pointerY The Y mouse cursor position at the time of the event
  113205. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113206. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113207. * @param additionalData additional data for the event
  113208. */
  113209. constructor(
  113210. /** The mesh or sprite that triggered the action */
  113211. source: any,
  113212. /** The X mouse cursor position at the time of the event */
  113213. pointerX: number,
  113214. /** The Y mouse cursor position at the time of the event */
  113215. pointerY: number,
  113216. /** The mesh that is currently pointed at (can be null) */
  113217. meshUnderPointer: Nullable<AbstractMesh>,
  113218. /** the original (browser) event that triggered the ActionEvent */
  113219. sourceEvent?: any,
  113220. /** additional data for the event */
  113221. additionalData?: any);
  113222. /**
  113223. * Helper function to auto-create an ActionEvent from a source mesh.
  113224. * @param source The source mesh that triggered the event
  113225. * @param evt The original (browser) event
  113226. * @param additionalData additional data for the event
  113227. * @returns the new ActionEvent
  113228. */
  113229. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113230. /**
  113231. * Helper function to auto-create an ActionEvent from a source sprite
  113232. * @param source The source sprite that triggered the event
  113233. * @param scene Scene associated with the sprite
  113234. * @param evt The original (browser) event
  113235. * @param additionalData additional data for the event
  113236. * @returns the new ActionEvent
  113237. */
  113238. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113239. /**
  113240. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113241. * @param scene the scene where the event occurred
  113242. * @param evt The original (browser) event
  113243. * @returns the new ActionEvent
  113244. */
  113245. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113246. /**
  113247. * Helper function to auto-create an ActionEvent from a primitive
  113248. * @param prim defines the target primitive
  113249. * @param pointerPos defines the pointer position
  113250. * @param evt The original (browser) event
  113251. * @param additionalData additional data for the event
  113252. * @returns the new ActionEvent
  113253. */
  113254. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113255. }
  113256. }
  113257. declare module BABYLON {
  113258. /**
  113259. * Abstract class used to decouple action Manager from scene and meshes.
  113260. * Do not instantiate.
  113261. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113262. */
  113263. export abstract class AbstractActionManager implements IDisposable {
  113264. /** Gets the list of active triggers */
  113265. static Triggers: {
  113266. [key: string]: number;
  113267. };
  113268. /** Gets the cursor to use when hovering items */
  113269. hoverCursor: string;
  113270. /** Gets the list of actions */
  113271. actions: IAction[];
  113272. /**
  113273. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113274. */
  113275. isRecursive: boolean;
  113276. /**
  113277. * Releases all associated resources
  113278. */
  113279. abstract dispose(): void;
  113280. /**
  113281. * Does this action manager has pointer triggers
  113282. */
  113283. abstract get hasPointerTriggers(): boolean;
  113284. /**
  113285. * Does this action manager has pick triggers
  113286. */
  113287. abstract get hasPickTriggers(): boolean;
  113288. /**
  113289. * Process a specific trigger
  113290. * @param trigger defines the trigger to process
  113291. * @param evt defines the event details to be processed
  113292. */
  113293. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113294. /**
  113295. * Does this action manager handles actions of any of the given triggers
  113296. * @param triggers defines the triggers to be tested
  113297. * @return a boolean indicating whether one (or more) of the triggers is handled
  113298. */
  113299. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113300. /**
  113301. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113302. * speed.
  113303. * @param triggerA defines the trigger to be tested
  113304. * @param triggerB defines the trigger to be tested
  113305. * @return a boolean indicating whether one (or more) of the triggers is handled
  113306. */
  113307. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113308. /**
  113309. * Does this action manager handles actions of a given trigger
  113310. * @param trigger defines the trigger to be tested
  113311. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113312. * @return whether the trigger is handled
  113313. */
  113314. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113315. /**
  113316. * Serialize this manager to a JSON object
  113317. * @param name defines the property name to store this manager
  113318. * @returns a JSON representation of this manager
  113319. */
  113320. abstract serialize(name: string): any;
  113321. /**
  113322. * Registers an action to this action manager
  113323. * @param action defines the action to be registered
  113324. * @return the action amended (prepared) after registration
  113325. */
  113326. abstract registerAction(action: IAction): Nullable<IAction>;
  113327. /**
  113328. * Unregisters an action to this action manager
  113329. * @param action defines the action to be unregistered
  113330. * @return a boolean indicating whether the action has been unregistered
  113331. */
  113332. abstract unregisterAction(action: IAction): Boolean;
  113333. /**
  113334. * Does exist one action manager with at least one trigger
  113335. **/
  113336. static get HasTriggers(): boolean;
  113337. /**
  113338. * Does exist one action manager with at least one pick trigger
  113339. **/
  113340. static get HasPickTriggers(): boolean;
  113341. /**
  113342. * Does exist one action manager that handles actions of a given trigger
  113343. * @param trigger defines the trigger to be tested
  113344. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113345. **/
  113346. static HasSpecificTrigger(trigger: number): boolean;
  113347. }
  113348. }
  113349. declare module BABYLON {
  113350. /**
  113351. * Defines how a node can be built from a string name.
  113352. */
  113353. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113354. /**
  113355. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113356. */
  113357. export class Node implements IBehaviorAware<Node> {
  113358. /** @hidden */
  113359. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113360. private static _NodeConstructors;
  113361. /**
  113362. * Add a new node constructor
  113363. * @param type defines the type name of the node to construct
  113364. * @param constructorFunc defines the constructor function
  113365. */
  113366. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113367. /**
  113368. * Returns a node constructor based on type name
  113369. * @param type defines the type name
  113370. * @param name defines the new node name
  113371. * @param scene defines the hosting scene
  113372. * @param options defines optional options to transmit to constructors
  113373. * @returns the new constructor or null
  113374. */
  113375. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113376. /**
  113377. * Gets or sets the name of the node
  113378. */
  113379. name: string;
  113380. /**
  113381. * Gets or sets the id of the node
  113382. */
  113383. id: string;
  113384. /**
  113385. * Gets or sets the unique id of the node
  113386. */
  113387. uniqueId: number;
  113388. /**
  113389. * Gets or sets a string used to store user defined state for the node
  113390. */
  113391. state: string;
  113392. /**
  113393. * Gets or sets an object used to store user defined information for the node
  113394. */
  113395. metadata: any;
  113396. /**
  113397. * For internal use only. Please do not use.
  113398. */
  113399. reservedDataStore: any;
  113400. /**
  113401. * List of inspectable custom properties (used by the Inspector)
  113402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113403. */
  113404. inspectableCustomProperties: IInspectable[];
  113405. private _doNotSerialize;
  113406. /**
  113407. * Gets or sets a boolean used to define if the node must be serialized
  113408. */
  113409. get doNotSerialize(): boolean;
  113410. set doNotSerialize(value: boolean);
  113411. /** @hidden */
  113412. _isDisposed: boolean;
  113413. /**
  113414. * Gets a list of Animations associated with the node
  113415. */
  113416. animations: Animation[];
  113417. protected _ranges: {
  113418. [name: string]: Nullable<AnimationRange>;
  113419. };
  113420. /**
  113421. * Callback raised when the node is ready to be used
  113422. */
  113423. onReady: Nullable<(node: Node) => void>;
  113424. private _isEnabled;
  113425. private _isParentEnabled;
  113426. private _isReady;
  113427. /** @hidden */
  113428. _currentRenderId: number;
  113429. private _parentUpdateId;
  113430. /** @hidden */
  113431. _childUpdateId: number;
  113432. /** @hidden */
  113433. _waitingParentId: Nullable<string>;
  113434. /** @hidden */
  113435. _scene: Scene;
  113436. /** @hidden */
  113437. _cache: any;
  113438. private _parentNode;
  113439. private _children;
  113440. /** @hidden */
  113441. _worldMatrix: Matrix;
  113442. /** @hidden */
  113443. _worldMatrixDeterminant: number;
  113444. /** @hidden */
  113445. _worldMatrixDeterminantIsDirty: boolean;
  113446. /** @hidden */
  113447. private _sceneRootNodesIndex;
  113448. /**
  113449. * Gets a boolean indicating if the node has been disposed
  113450. * @returns true if the node was disposed
  113451. */
  113452. isDisposed(): boolean;
  113453. /**
  113454. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113455. * @see https://doc.babylonjs.com/how_to/parenting
  113456. */
  113457. set parent(parent: Nullable<Node>);
  113458. get parent(): Nullable<Node>;
  113459. /** @hidden */
  113460. _addToSceneRootNodes(): void;
  113461. /** @hidden */
  113462. _removeFromSceneRootNodes(): void;
  113463. private _animationPropertiesOverride;
  113464. /**
  113465. * Gets or sets the animation properties override
  113466. */
  113467. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113468. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113469. /**
  113470. * Gets a string identifying the name of the class
  113471. * @returns "Node" string
  113472. */
  113473. getClassName(): string;
  113474. /** @hidden */
  113475. readonly _isNode: boolean;
  113476. /**
  113477. * An event triggered when the mesh is disposed
  113478. */
  113479. onDisposeObservable: Observable<Node>;
  113480. private _onDisposeObserver;
  113481. /**
  113482. * Sets a callback that will be raised when the node will be disposed
  113483. */
  113484. set onDispose(callback: () => void);
  113485. /**
  113486. * Creates a new Node
  113487. * @param name the name and id to be given to this node
  113488. * @param scene the scene this node will be added to
  113489. */
  113490. constructor(name: string, scene?: Nullable<Scene>);
  113491. /**
  113492. * Gets the scene of the node
  113493. * @returns a scene
  113494. */
  113495. getScene(): Scene;
  113496. /**
  113497. * Gets the engine of the node
  113498. * @returns a Engine
  113499. */
  113500. getEngine(): Engine;
  113501. private _behaviors;
  113502. /**
  113503. * Attach a behavior to the node
  113504. * @see https://doc.babylonjs.com/features/behaviour
  113505. * @param behavior defines the behavior to attach
  113506. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113507. * @returns the current Node
  113508. */
  113509. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113510. /**
  113511. * Remove an attached behavior
  113512. * @see https://doc.babylonjs.com/features/behaviour
  113513. * @param behavior defines the behavior to attach
  113514. * @returns the current Node
  113515. */
  113516. removeBehavior(behavior: Behavior<Node>): Node;
  113517. /**
  113518. * Gets the list of attached behaviors
  113519. * @see https://doc.babylonjs.com/features/behaviour
  113520. */
  113521. get behaviors(): Behavior<Node>[];
  113522. /**
  113523. * Gets an attached behavior by name
  113524. * @param name defines the name of the behavior to look for
  113525. * @see https://doc.babylonjs.com/features/behaviour
  113526. * @returns null if behavior was not found else the requested behavior
  113527. */
  113528. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113529. /**
  113530. * Returns the latest update of the World matrix
  113531. * @returns a Matrix
  113532. */
  113533. getWorldMatrix(): Matrix;
  113534. /** @hidden */
  113535. _getWorldMatrixDeterminant(): number;
  113536. /**
  113537. * Returns directly the latest state of the mesh World matrix.
  113538. * A Matrix is returned.
  113539. */
  113540. get worldMatrixFromCache(): Matrix;
  113541. /** @hidden */
  113542. _initCache(): void;
  113543. /** @hidden */
  113544. updateCache(force?: boolean): void;
  113545. /** @hidden */
  113546. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113547. /** @hidden */
  113548. _updateCache(ignoreParentClass?: boolean): void;
  113549. /** @hidden */
  113550. _isSynchronized(): boolean;
  113551. /** @hidden */
  113552. _markSyncedWithParent(): void;
  113553. /** @hidden */
  113554. isSynchronizedWithParent(): boolean;
  113555. /** @hidden */
  113556. isSynchronized(): boolean;
  113557. /**
  113558. * Is this node ready to be used/rendered
  113559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113560. * @return true if the node is ready
  113561. */
  113562. isReady(completeCheck?: boolean): boolean;
  113563. /**
  113564. * Is this node enabled?
  113565. * 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
  113566. * @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
  113567. * @return whether this node (and its parent) is enabled
  113568. */
  113569. isEnabled(checkAncestors?: boolean): boolean;
  113570. /** @hidden */
  113571. protected _syncParentEnabledState(): void;
  113572. /**
  113573. * Set the enabled state of this node
  113574. * @param value defines the new enabled state
  113575. */
  113576. setEnabled(value: boolean): void;
  113577. /**
  113578. * Is this node a descendant of the given node?
  113579. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113580. * @param ancestor defines the parent node to inspect
  113581. * @returns a boolean indicating if this node is a descendant of the given node
  113582. */
  113583. isDescendantOf(ancestor: Node): boolean;
  113584. /** @hidden */
  113585. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113586. /**
  113587. * Will return all nodes that have this node as ascendant
  113588. * @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
  113589. * @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
  113590. * @return all children nodes of all types
  113591. */
  113592. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113593. /**
  113594. * Get all child-meshes of this node
  113595. * @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)
  113596. * @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
  113597. * @returns an array of AbstractMesh
  113598. */
  113599. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113600. /**
  113601. * Get all direct children of this node
  113602. * @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
  113603. * @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)
  113604. * @returns an array of Node
  113605. */
  113606. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113607. /** @hidden */
  113608. _setReady(state: boolean): void;
  113609. /**
  113610. * Get an animation by name
  113611. * @param name defines the name of the animation to look for
  113612. * @returns null if not found else the requested animation
  113613. */
  113614. getAnimationByName(name: string): Nullable<Animation>;
  113615. /**
  113616. * Creates an animation range for this node
  113617. * @param name defines the name of the range
  113618. * @param from defines the starting key
  113619. * @param to defines the end key
  113620. */
  113621. createAnimationRange(name: string, from: number, to: number): void;
  113622. /**
  113623. * Delete a specific animation range
  113624. * @param name defines the name of the range to delete
  113625. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113626. */
  113627. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113628. /**
  113629. * Get an animation range by name
  113630. * @param name defines the name of the animation range to look for
  113631. * @returns null if not found else the requested animation range
  113632. */
  113633. getAnimationRange(name: string): Nullable<AnimationRange>;
  113634. /**
  113635. * Gets the list of all animation ranges defined on this node
  113636. * @returns an array
  113637. */
  113638. getAnimationRanges(): Nullable<AnimationRange>[];
  113639. /**
  113640. * Will start the animation sequence
  113641. * @param name defines the range frames for animation sequence
  113642. * @param loop defines if the animation should loop (false by default)
  113643. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113644. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113645. * @returns the object created for this animation. If range does not exist, it will return null
  113646. */
  113647. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113648. /**
  113649. * Serialize animation ranges into a JSON compatible object
  113650. * @returns serialization object
  113651. */
  113652. serializeAnimationRanges(): any;
  113653. /**
  113654. * Computes the world matrix of the node
  113655. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113656. * @returns the world matrix
  113657. */
  113658. computeWorldMatrix(force?: boolean): Matrix;
  113659. /**
  113660. * Releases resources associated with this node.
  113661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113663. */
  113664. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113665. /**
  113666. * Parse animation range data from a serialization object and store them into a given node
  113667. * @param node defines where to store the animation ranges
  113668. * @param parsedNode defines the serialization object to read data from
  113669. * @param scene defines the hosting scene
  113670. */
  113671. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113672. /**
  113673. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113674. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113675. * @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
  113676. * @returns the new bounding vectors
  113677. */
  113678. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113679. min: Vector3;
  113680. max: Vector3;
  113681. };
  113682. }
  113683. }
  113684. declare module BABYLON {
  113685. /**
  113686. * @hidden
  113687. */
  113688. export class _IAnimationState {
  113689. key: number;
  113690. repeatCount: number;
  113691. workValue?: any;
  113692. loopMode?: number;
  113693. offsetValue?: any;
  113694. highLimitValue?: any;
  113695. }
  113696. /**
  113697. * Class used to store any kind of animation
  113698. */
  113699. export class Animation {
  113700. /**Name of the animation */
  113701. name: string;
  113702. /**Property to animate */
  113703. targetProperty: string;
  113704. /**The frames per second of the animation */
  113705. framePerSecond: number;
  113706. /**The data type of the animation */
  113707. dataType: number;
  113708. /**The loop mode of the animation */
  113709. loopMode?: number | undefined;
  113710. /**Specifies if blending should be enabled */
  113711. enableBlending?: boolean | undefined;
  113712. /**
  113713. * Use matrix interpolation instead of using direct key value when animating matrices
  113714. */
  113715. static AllowMatricesInterpolation: boolean;
  113716. /**
  113717. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113718. */
  113719. static AllowMatrixDecomposeForInterpolation: boolean;
  113720. /** Define the Url to load snippets */
  113721. static SnippetUrl: string;
  113722. /** Snippet ID if the animation was created from the snippet server */
  113723. snippetId: string;
  113724. /**
  113725. * Stores the key frames of the animation
  113726. */
  113727. private _keys;
  113728. /**
  113729. * Stores the easing function of the animation
  113730. */
  113731. private _easingFunction;
  113732. /**
  113733. * @hidden Internal use only
  113734. */
  113735. _runtimeAnimations: RuntimeAnimation[];
  113736. /**
  113737. * The set of event that will be linked to this animation
  113738. */
  113739. private _events;
  113740. /**
  113741. * Stores an array of target property paths
  113742. */
  113743. targetPropertyPath: string[];
  113744. /**
  113745. * Stores the blending speed of the animation
  113746. */
  113747. blendingSpeed: number;
  113748. /**
  113749. * Stores the animation ranges for the animation
  113750. */
  113751. private _ranges;
  113752. /**
  113753. * @hidden Internal use
  113754. */
  113755. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113756. /**
  113757. * Sets up an animation
  113758. * @param property The property to animate
  113759. * @param animationType The animation type to apply
  113760. * @param framePerSecond The frames per second of the animation
  113761. * @param easingFunction The easing function used in the animation
  113762. * @returns The created animation
  113763. */
  113764. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113765. /**
  113766. * Create and start an animation on a node
  113767. * @param name defines the name of the global animation that will be run on all nodes
  113768. * @param node defines the root node where the animation will take place
  113769. * @param targetProperty defines property to animate
  113770. * @param framePerSecond defines the number of frame per second yo use
  113771. * @param totalFrame defines the number of frames in total
  113772. * @param from defines the initial value
  113773. * @param to defines the final value
  113774. * @param loopMode defines which loop mode you want to use (off by default)
  113775. * @param easingFunction defines the easing function to use (linear by default)
  113776. * @param onAnimationEnd defines the callback to call when animation end
  113777. * @returns the animatable created for this animation
  113778. */
  113779. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113780. /**
  113781. * Create and start an animation on a node and its descendants
  113782. * @param name defines the name of the global animation that will be run on all nodes
  113783. * @param node defines the root node where the animation will take place
  113784. * @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
  113785. * @param targetProperty defines property to animate
  113786. * @param framePerSecond defines the number of frame per second to use
  113787. * @param totalFrame defines the number of frames in total
  113788. * @param from defines the initial value
  113789. * @param to defines the final value
  113790. * @param loopMode defines which loop mode you want to use (off by default)
  113791. * @param easingFunction defines the easing function to use (linear by default)
  113792. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113793. * @returns the list of animatables created for all nodes
  113794. * @example https://www.babylonjs-playground.com/#MH0VLI
  113795. */
  113796. 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[]>;
  113797. /**
  113798. * Creates a new animation, merges it with the existing animations and starts it
  113799. * @param name Name of the animation
  113800. * @param node Node which contains the scene that begins the animations
  113801. * @param targetProperty Specifies which property to animate
  113802. * @param framePerSecond The frames per second of the animation
  113803. * @param totalFrame The total number of frames
  113804. * @param from The frame at the beginning of the animation
  113805. * @param to The frame at the end of the animation
  113806. * @param loopMode Specifies the loop mode of the animation
  113807. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113808. * @param onAnimationEnd Callback to run once the animation is complete
  113809. * @returns Nullable animation
  113810. */
  113811. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113812. /**
  113813. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113814. * @param sourceAnimation defines the Animation containing keyframes to convert
  113815. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113816. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113817. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113818. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113819. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113820. */
  113821. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113822. /**
  113823. * Transition property of an host to the target Value
  113824. * @param property The property to transition
  113825. * @param targetValue The target Value of the property
  113826. * @param host The object where the property to animate belongs
  113827. * @param scene Scene used to run the animation
  113828. * @param frameRate Framerate (in frame/s) to use
  113829. * @param transition The transition type we want to use
  113830. * @param duration The duration of the animation, in milliseconds
  113831. * @param onAnimationEnd Callback trigger at the end of the animation
  113832. * @returns Nullable animation
  113833. */
  113834. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113835. /**
  113836. * Return the array of runtime animations currently using this animation
  113837. */
  113838. get runtimeAnimations(): RuntimeAnimation[];
  113839. /**
  113840. * Specifies if any of the runtime animations are currently running
  113841. */
  113842. get hasRunningRuntimeAnimations(): boolean;
  113843. /**
  113844. * Initializes the animation
  113845. * @param name Name of the animation
  113846. * @param targetProperty Property to animate
  113847. * @param framePerSecond The frames per second of the animation
  113848. * @param dataType The data type of the animation
  113849. * @param loopMode The loop mode of the animation
  113850. * @param enableBlending Specifies if blending should be enabled
  113851. */
  113852. constructor(
  113853. /**Name of the animation */
  113854. name: string,
  113855. /**Property to animate */
  113856. targetProperty: string,
  113857. /**The frames per second of the animation */
  113858. framePerSecond: number,
  113859. /**The data type of the animation */
  113860. dataType: number,
  113861. /**The loop mode of the animation */
  113862. loopMode?: number | undefined,
  113863. /**Specifies if blending should be enabled */
  113864. enableBlending?: boolean | undefined);
  113865. /**
  113866. * Converts the animation to a string
  113867. * @param fullDetails support for multiple levels of logging within scene loading
  113868. * @returns String form of the animation
  113869. */
  113870. toString(fullDetails?: boolean): string;
  113871. /**
  113872. * Add an event to this animation
  113873. * @param event Event to add
  113874. */
  113875. addEvent(event: AnimationEvent): void;
  113876. /**
  113877. * Remove all events found at the given frame
  113878. * @param frame The frame to remove events from
  113879. */
  113880. removeEvents(frame: number): void;
  113881. /**
  113882. * Retrieves all the events from the animation
  113883. * @returns Events from the animation
  113884. */
  113885. getEvents(): AnimationEvent[];
  113886. /**
  113887. * Creates an animation range
  113888. * @param name Name of the animation range
  113889. * @param from Starting frame of the animation range
  113890. * @param to Ending frame of the animation
  113891. */
  113892. createRange(name: string, from: number, to: number): void;
  113893. /**
  113894. * Deletes an animation range by name
  113895. * @param name Name of the animation range to delete
  113896. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113897. */
  113898. deleteRange(name: string, deleteFrames?: boolean): void;
  113899. /**
  113900. * Gets the animation range by name, or null if not defined
  113901. * @param name Name of the animation range
  113902. * @returns Nullable animation range
  113903. */
  113904. getRange(name: string): Nullable<AnimationRange>;
  113905. /**
  113906. * Gets the key frames from the animation
  113907. * @returns The key frames of the animation
  113908. */
  113909. getKeys(): Array<IAnimationKey>;
  113910. /**
  113911. * Gets the highest frame rate of the animation
  113912. * @returns Highest frame rate of the animation
  113913. */
  113914. getHighestFrame(): number;
  113915. /**
  113916. * Gets the easing function of the animation
  113917. * @returns Easing function of the animation
  113918. */
  113919. getEasingFunction(): IEasingFunction;
  113920. /**
  113921. * Sets the easing function of the animation
  113922. * @param easingFunction A custom mathematical formula for animation
  113923. */
  113924. setEasingFunction(easingFunction: EasingFunction): void;
  113925. /**
  113926. * Interpolates a scalar linearly
  113927. * @param startValue Start value of the animation curve
  113928. * @param endValue End value of the animation curve
  113929. * @param gradient Scalar amount to interpolate
  113930. * @returns Interpolated scalar value
  113931. */
  113932. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113933. /**
  113934. * Interpolates a scalar cubically
  113935. * @param startValue Start value of the animation curve
  113936. * @param outTangent End tangent of the animation
  113937. * @param endValue End value of the animation curve
  113938. * @param inTangent Start tangent of the animation curve
  113939. * @param gradient Scalar amount to interpolate
  113940. * @returns Interpolated scalar value
  113941. */
  113942. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113943. /**
  113944. * Interpolates a quaternion using a spherical linear interpolation
  113945. * @param startValue Start value of the animation curve
  113946. * @param endValue End value of the animation curve
  113947. * @param gradient Scalar amount to interpolate
  113948. * @returns Interpolated quaternion value
  113949. */
  113950. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113951. /**
  113952. * Interpolates a quaternion cubically
  113953. * @param startValue Start value of the animation curve
  113954. * @param outTangent End tangent of the animation curve
  113955. * @param endValue End value of the animation curve
  113956. * @param inTangent Start tangent of the animation curve
  113957. * @param gradient Scalar amount to interpolate
  113958. * @returns Interpolated quaternion value
  113959. */
  113960. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113961. /**
  113962. * Interpolates a Vector3 linearl
  113963. * @param startValue Start value of the animation curve
  113964. * @param endValue End value of the animation curve
  113965. * @param gradient Scalar amount to interpolate
  113966. * @returns Interpolated scalar value
  113967. */
  113968. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113969. /**
  113970. * Interpolates a Vector3 cubically
  113971. * @param startValue Start value of the animation curve
  113972. * @param outTangent End tangent of the animation
  113973. * @param endValue End value of the animation curve
  113974. * @param inTangent Start tangent of the animation curve
  113975. * @param gradient Scalar amount to interpolate
  113976. * @returns InterpolatedVector3 value
  113977. */
  113978. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113979. /**
  113980. * Interpolates a Vector2 linearly
  113981. * @param startValue Start value of the animation curve
  113982. * @param endValue End value of the animation curve
  113983. * @param gradient Scalar amount to interpolate
  113984. * @returns Interpolated Vector2 value
  113985. */
  113986. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113987. /**
  113988. * Interpolates a Vector2 cubically
  113989. * @param startValue Start value of the animation curve
  113990. * @param outTangent End tangent of the animation
  113991. * @param endValue End value of the animation curve
  113992. * @param inTangent Start tangent of the animation curve
  113993. * @param gradient Scalar amount to interpolate
  113994. * @returns Interpolated Vector2 value
  113995. */
  113996. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113997. /**
  113998. * Interpolates a size linearly
  113999. * @param startValue Start value of the animation curve
  114000. * @param endValue End value of the animation curve
  114001. * @param gradient Scalar amount to interpolate
  114002. * @returns Interpolated Size value
  114003. */
  114004. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114005. /**
  114006. * Interpolates a Color3 linearly
  114007. * @param startValue Start value of the animation curve
  114008. * @param endValue End value of the animation curve
  114009. * @param gradient Scalar amount to interpolate
  114010. * @returns Interpolated Color3 value
  114011. */
  114012. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114013. /**
  114014. * Interpolates a Color4 linearly
  114015. * @param startValue Start value of the animation curve
  114016. * @param endValue End value of the animation curve
  114017. * @param gradient Scalar amount to interpolate
  114018. * @returns Interpolated Color3 value
  114019. */
  114020. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114021. /**
  114022. * @hidden Internal use only
  114023. */
  114024. _getKeyValue(value: any): any;
  114025. /**
  114026. * @hidden Internal use only
  114027. */
  114028. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114029. /**
  114030. * Defines the function to use to interpolate matrices
  114031. * @param startValue defines the start matrix
  114032. * @param endValue defines the end matrix
  114033. * @param gradient defines the gradient between both matrices
  114034. * @param result defines an optional target matrix where to store the interpolation
  114035. * @returns the interpolated matrix
  114036. */
  114037. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114038. /**
  114039. * Makes a copy of the animation
  114040. * @returns Cloned animation
  114041. */
  114042. clone(): Animation;
  114043. /**
  114044. * Sets the key frames of the animation
  114045. * @param values The animation key frames to set
  114046. */
  114047. setKeys(values: Array<IAnimationKey>): void;
  114048. /**
  114049. * Serializes the animation to an object
  114050. * @returns Serialized object
  114051. */
  114052. serialize(): any;
  114053. /**
  114054. * Float animation type
  114055. */
  114056. static readonly ANIMATIONTYPE_FLOAT: number;
  114057. /**
  114058. * Vector3 animation type
  114059. */
  114060. static readonly ANIMATIONTYPE_VECTOR3: number;
  114061. /**
  114062. * Quaternion animation type
  114063. */
  114064. static readonly ANIMATIONTYPE_QUATERNION: number;
  114065. /**
  114066. * Matrix animation type
  114067. */
  114068. static readonly ANIMATIONTYPE_MATRIX: number;
  114069. /**
  114070. * Color3 animation type
  114071. */
  114072. static readonly ANIMATIONTYPE_COLOR3: number;
  114073. /**
  114074. * Color3 animation type
  114075. */
  114076. static readonly ANIMATIONTYPE_COLOR4: number;
  114077. /**
  114078. * Vector2 animation type
  114079. */
  114080. static readonly ANIMATIONTYPE_VECTOR2: number;
  114081. /**
  114082. * Size animation type
  114083. */
  114084. static readonly ANIMATIONTYPE_SIZE: number;
  114085. /**
  114086. * Relative Loop Mode
  114087. */
  114088. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114089. /**
  114090. * Cycle Loop Mode
  114091. */
  114092. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114093. /**
  114094. * Constant Loop Mode
  114095. */
  114096. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114097. /** @hidden */
  114098. static _UniversalLerp(left: any, right: any, amount: number): any;
  114099. /**
  114100. * Parses an animation object and creates an animation
  114101. * @param parsedAnimation Parsed animation object
  114102. * @returns Animation object
  114103. */
  114104. static Parse(parsedAnimation: any): Animation;
  114105. /**
  114106. * Appends the serialized animations from the source animations
  114107. * @param source Source containing the animations
  114108. * @param destination Target to store the animations
  114109. */
  114110. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114111. /**
  114112. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114113. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114114. * @param url defines the url to load from
  114115. * @returns a promise that will resolve to the new animation or an array of animations
  114116. */
  114117. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114118. /**
  114119. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114120. * @param snippetId defines the snippet to load
  114121. * @returns a promise that will resolve to the new animation or a new array of animations
  114122. */
  114123. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114124. }
  114125. }
  114126. declare module BABYLON {
  114127. /**
  114128. * Interface containing an array of animations
  114129. */
  114130. export interface IAnimatable {
  114131. /**
  114132. * Array of animations
  114133. */
  114134. animations: Nullable<Array<Animation>>;
  114135. }
  114136. }
  114137. declare module BABYLON {
  114138. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114139. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114140. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114141. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114142. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114143. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114144. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114145. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114146. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114147. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114148. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114149. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114150. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114151. /**
  114152. * Decorator used to define property that can be serialized as reference to a camera
  114153. * @param sourceName defines the name of the property to decorate
  114154. */
  114155. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114156. /**
  114157. * Class used to help serialization objects
  114158. */
  114159. export class SerializationHelper {
  114160. /** @hidden */
  114161. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114162. /** @hidden */
  114163. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114164. /** @hidden */
  114165. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114166. /** @hidden */
  114167. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114168. /**
  114169. * Appends the serialized animations from the source animations
  114170. * @param source Source containing the animations
  114171. * @param destination Target to store the animations
  114172. */
  114173. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114174. /**
  114175. * Static function used to serialized a specific entity
  114176. * @param entity defines the entity to serialize
  114177. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114178. * @returns a JSON compatible object representing the serialization of the entity
  114179. */
  114180. static Serialize<T>(entity: T, serializationObject?: any): any;
  114181. /**
  114182. * Creates a new entity from a serialization data object
  114183. * @param creationFunction defines a function used to instanciated the new entity
  114184. * @param source defines the source serialization data
  114185. * @param scene defines the hosting scene
  114186. * @param rootUrl defines the root url for resources
  114187. * @returns a new entity
  114188. */
  114189. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114190. /**
  114191. * Clones an object
  114192. * @param creationFunction defines the function used to instanciate the new object
  114193. * @param source defines the source object
  114194. * @returns the cloned object
  114195. */
  114196. static Clone<T>(creationFunction: () => T, source: T): T;
  114197. /**
  114198. * Instanciates a new object based on a source one (some data will be shared between both object)
  114199. * @param creationFunction defines the function used to instanciate the new object
  114200. * @param source defines the source object
  114201. * @returns the new object
  114202. */
  114203. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114204. }
  114205. }
  114206. declare module BABYLON {
  114207. /**
  114208. * Base class of all the textures in babylon.
  114209. * It groups all the common properties the materials, post process, lights... might need
  114210. * in order to make a correct use of the texture.
  114211. */
  114212. export class BaseTexture implements IAnimatable {
  114213. /**
  114214. * Default anisotropic filtering level for the application.
  114215. * It is set to 4 as a good tradeoff between perf and quality.
  114216. */
  114217. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114218. /**
  114219. * Gets or sets the unique id of the texture
  114220. */
  114221. uniqueId: number;
  114222. /**
  114223. * Define the name of the texture.
  114224. */
  114225. name: string;
  114226. /**
  114227. * Gets or sets an object used to store user defined information.
  114228. */
  114229. metadata: any;
  114230. /**
  114231. * For internal use only. Please do not use.
  114232. */
  114233. reservedDataStore: any;
  114234. private _hasAlpha;
  114235. /**
  114236. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114237. */
  114238. set hasAlpha(value: boolean);
  114239. get hasAlpha(): boolean;
  114240. /**
  114241. * Defines if the alpha value should be determined via the rgb values.
  114242. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114243. */
  114244. getAlphaFromRGB: boolean;
  114245. /**
  114246. * Intensity or strength of the texture.
  114247. * It is commonly used by materials to fine tune the intensity of the texture
  114248. */
  114249. level: number;
  114250. /**
  114251. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114252. * This is part of the texture as textures usually maps to one uv set.
  114253. */
  114254. coordinatesIndex: number;
  114255. protected _coordinatesMode: number;
  114256. /**
  114257. * How a texture is mapped.
  114258. *
  114259. * | Value | Type | Description |
  114260. * | ----- | ----------------------------------- | ----------- |
  114261. * | 0 | EXPLICIT_MODE | |
  114262. * | 1 | SPHERICAL_MODE | |
  114263. * | 2 | PLANAR_MODE | |
  114264. * | 3 | CUBIC_MODE | |
  114265. * | 4 | PROJECTION_MODE | |
  114266. * | 5 | SKYBOX_MODE | |
  114267. * | 6 | INVCUBIC_MODE | |
  114268. * | 7 | EQUIRECTANGULAR_MODE | |
  114269. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114270. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114271. */
  114272. set coordinatesMode(value: number);
  114273. get coordinatesMode(): number;
  114274. private _wrapU;
  114275. /**
  114276. * | Value | Type | Description |
  114277. * | ----- | ------------------ | ----------- |
  114278. * | 0 | CLAMP_ADDRESSMODE | |
  114279. * | 1 | WRAP_ADDRESSMODE | |
  114280. * | 2 | MIRROR_ADDRESSMODE | |
  114281. */
  114282. get wrapU(): number;
  114283. set wrapU(value: number);
  114284. private _wrapV;
  114285. /**
  114286. * | Value | Type | Description |
  114287. * | ----- | ------------------ | ----------- |
  114288. * | 0 | CLAMP_ADDRESSMODE | |
  114289. * | 1 | WRAP_ADDRESSMODE | |
  114290. * | 2 | MIRROR_ADDRESSMODE | |
  114291. */
  114292. get wrapV(): number;
  114293. set wrapV(value: number);
  114294. /**
  114295. * | Value | Type | Description |
  114296. * | ----- | ------------------ | ----------- |
  114297. * | 0 | CLAMP_ADDRESSMODE | |
  114298. * | 1 | WRAP_ADDRESSMODE | |
  114299. * | 2 | MIRROR_ADDRESSMODE | |
  114300. */
  114301. wrapR: number;
  114302. /**
  114303. * With compliant hardware and browser (supporting anisotropic filtering)
  114304. * this defines the level of anisotropic filtering in the texture.
  114305. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114306. */
  114307. anisotropicFilteringLevel: number;
  114308. /**
  114309. * Define if the texture is a cube texture or if false a 2d texture.
  114310. */
  114311. get isCube(): boolean;
  114312. set isCube(value: boolean);
  114313. /**
  114314. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114315. */
  114316. get is3D(): boolean;
  114317. set is3D(value: boolean);
  114318. /**
  114319. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114320. */
  114321. get is2DArray(): boolean;
  114322. set is2DArray(value: boolean);
  114323. private _gammaSpace;
  114324. /**
  114325. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114326. * HDR texture are usually stored in linear space.
  114327. * This only impacts the PBR and Background materials
  114328. */
  114329. get gammaSpace(): boolean;
  114330. set gammaSpace(gamma: boolean);
  114331. /**
  114332. * Gets or sets whether or not the texture contains RGBD data.
  114333. */
  114334. get isRGBD(): boolean;
  114335. set isRGBD(value: boolean);
  114336. /**
  114337. * Is Z inverted in the texture (useful in a cube texture).
  114338. */
  114339. invertZ: boolean;
  114340. /**
  114341. * Are mip maps generated for this texture or not.
  114342. */
  114343. get noMipmap(): boolean;
  114344. /**
  114345. * @hidden
  114346. */
  114347. lodLevelInAlpha: boolean;
  114348. /**
  114349. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114350. */
  114351. get lodGenerationOffset(): number;
  114352. set lodGenerationOffset(value: number);
  114353. /**
  114354. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114355. */
  114356. get lodGenerationScale(): number;
  114357. set lodGenerationScale(value: number);
  114358. /**
  114359. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114360. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114361. * average roughness values.
  114362. */
  114363. get linearSpecularLOD(): boolean;
  114364. set linearSpecularLOD(value: boolean);
  114365. /**
  114366. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114367. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114368. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114369. */
  114370. get irradianceTexture(): Nullable<BaseTexture>;
  114371. set irradianceTexture(value: Nullable<BaseTexture>);
  114372. /**
  114373. * Define if the texture is a render target.
  114374. */
  114375. isRenderTarget: boolean;
  114376. /**
  114377. * Define the unique id of the texture in the scene.
  114378. */
  114379. get uid(): string;
  114380. /** @hidden */
  114381. _prefiltered: boolean;
  114382. /**
  114383. * Return a string representation of the texture.
  114384. * @returns the texture as a string
  114385. */
  114386. toString(): string;
  114387. /**
  114388. * Get the class name of the texture.
  114389. * @returns "BaseTexture"
  114390. */
  114391. getClassName(): string;
  114392. /**
  114393. * Define the list of animation attached to the texture.
  114394. */
  114395. animations: Animation[];
  114396. /**
  114397. * An event triggered when the texture is disposed.
  114398. */
  114399. onDisposeObservable: Observable<BaseTexture>;
  114400. private _onDisposeObserver;
  114401. /**
  114402. * Callback triggered when the texture has been disposed.
  114403. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114404. */
  114405. set onDispose(callback: () => void);
  114406. /**
  114407. * Define the current state of the loading sequence when in delayed load mode.
  114408. */
  114409. delayLoadState: number;
  114410. protected _scene: Nullable<Scene>;
  114411. protected _engine: Nullable<ThinEngine>;
  114412. /** @hidden */
  114413. _texture: Nullable<InternalTexture>;
  114414. private _uid;
  114415. /**
  114416. * Define if the texture is preventinga material to render or not.
  114417. * If not and the texture is not ready, the engine will use a default black texture instead.
  114418. */
  114419. get isBlocking(): boolean;
  114420. /**
  114421. * Instantiates a new BaseTexture.
  114422. * Base class of all the textures in babylon.
  114423. * It groups all the common properties the materials, post process, lights... might need
  114424. * in order to make a correct use of the texture.
  114425. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114426. */
  114427. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114428. /**
  114429. * Get the scene the texture belongs to.
  114430. * @returns the scene or null if undefined
  114431. */
  114432. getScene(): Nullable<Scene>;
  114433. /** @hidden */
  114434. protected _getEngine(): Nullable<ThinEngine>;
  114435. /**
  114436. * Get the texture transform matrix used to offset tile the texture for istance.
  114437. * @returns the transformation matrix
  114438. */
  114439. getTextureMatrix(): Matrix;
  114440. /**
  114441. * Get the texture reflection matrix used to rotate/transform the reflection.
  114442. * @returns the reflection matrix
  114443. */
  114444. getReflectionTextureMatrix(): Matrix;
  114445. /**
  114446. * Get the underlying lower level texture from Babylon.
  114447. * @returns the insternal texture
  114448. */
  114449. getInternalTexture(): Nullable<InternalTexture>;
  114450. /**
  114451. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114452. * @returns true if ready or not blocking
  114453. */
  114454. isReadyOrNotBlocking(): boolean;
  114455. /**
  114456. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114457. * @returns true if fully ready
  114458. */
  114459. isReady(): boolean;
  114460. private _cachedSize;
  114461. /**
  114462. * Get the size of the texture.
  114463. * @returns the texture size.
  114464. */
  114465. getSize(): ISize;
  114466. /**
  114467. * Get the base size of the texture.
  114468. * It can be different from the size if the texture has been resized for POT for instance
  114469. * @returns the base size
  114470. */
  114471. getBaseSize(): ISize;
  114472. /**
  114473. * Update the sampling mode of the texture.
  114474. * Default is Trilinear mode.
  114475. *
  114476. * | Value | Type | Description |
  114477. * | ----- | ------------------ | ----------- |
  114478. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114479. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114480. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114481. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114482. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114483. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114484. * | 7 | NEAREST_LINEAR | |
  114485. * | 8 | NEAREST_NEAREST | |
  114486. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114487. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114488. * | 11 | LINEAR_LINEAR | |
  114489. * | 12 | LINEAR_NEAREST | |
  114490. *
  114491. * > _mag_: magnification filter (close to the viewer)
  114492. * > _min_: minification filter (far from the viewer)
  114493. * > _mip_: filter used between mip map levels
  114494. *@param samplingMode Define the new sampling mode of the texture
  114495. */
  114496. updateSamplingMode(samplingMode: number): void;
  114497. /**
  114498. * Scales the texture if is `canRescale()`
  114499. * @param ratio the resize factor we want to use to rescale
  114500. */
  114501. scale(ratio: number): void;
  114502. /**
  114503. * Get if the texture can rescale.
  114504. */
  114505. get canRescale(): boolean;
  114506. /** @hidden */
  114507. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114508. /** @hidden */
  114509. _rebuild(): void;
  114510. /**
  114511. * Triggers the load sequence in delayed load mode.
  114512. */
  114513. delayLoad(): void;
  114514. /**
  114515. * Clones the texture.
  114516. * @returns the cloned texture
  114517. */
  114518. clone(): Nullable<BaseTexture>;
  114519. /**
  114520. * Get the texture underlying type (INT, FLOAT...)
  114521. */
  114522. get textureType(): number;
  114523. /**
  114524. * Get the texture underlying format (RGB, RGBA...)
  114525. */
  114526. get textureFormat(): number;
  114527. /**
  114528. * Indicates that textures need to be re-calculated for all materials
  114529. */
  114530. protected _markAllSubMeshesAsTexturesDirty(): void;
  114531. /**
  114532. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114533. * This will returns an RGBA array buffer containing either in values (0-255) or
  114534. * float values (0-1) depending of the underlying buffer type.
  114535. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114536. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114537. * @param buffer defines a user defined buffer to fill with data (can be null)
  114538. * @returns The Array buffer containing the pixels data.
  114539. */
  114540. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114541. /**
  114542. * Release and destroy the underlying lower level texture aka internalTexture.
  114543. */
  114544. releaseInternalTexture(): void;
  114545. /** @hidden */
  114546. get _lodTextureHigh(): Nullable<BaseTexture>;
  114547. /** @hidden */
  114548. get _lodTextureMid(): Nullable<BaseTexture>;
  114549. /** @hidden */
  114550. get _lodTextureLow(): Nullable<BaseTexture>;
  114551. /**
  114552. * Dispose the texture and release its associated resources.
  114553. */
  114554. dispose(): void;
  114555. /**
  114556. * Serialize the texture into a JSON representation that can be parsed later on.
  114557. * @returns the JSON representation of the texture
  114558. */
  114559. serialize(): any;
  114560. /**
  114561. * Helper function to be called back once a list of texture contains only ready textures.
  114562. * @param textures Define the list of textures to wait for
  114563. * @param callback Define the callback triggered once the entire list will be ready
  114564. */
  114565. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114566. private static _isScene;
  114567. }
  114568. }
  114569. declare module BABYLON {
  114570. /**
  114571. * Options to be used when creating an effect.
  114572. */
  114573. export interface IEffectCreationOptions {
  114574. /**
  114575. * Atrributes that will be used in the shader.
  114576. */
  114577. attributes: string[];
  114578. /**
  114579. * Uniform varible names that will be set in the shader.
  114580. */
  114581. uniformsNames: string[];
  114582. /**
  114583. * Uniform buffer variable names that will be set in the shader.
  114584. */
  114585. uniformBuffersNames: string[];
  114586. /**
  114587. * Sampler texture variable names that will be set in the shader.
  114588. */
  114589. samplers: string[];
  114590. /**
  114591. * Define statements that will be set in the shader.
  114592. */
  114593. defines: any;
  114594. /**
  114595. * Possible fallbacks for this effect to improve performance when needed.
  114596. */
  114597. fallbacks: Nullable<IEffectFallbacks>;
  114598. /**
  114599. * Callback that will be called when the shader is compiled.
  114600. */
  114601. onCompiled: Nullable<(effect: Effect) => void>;
  114602. /**
  114603. * Callback that will be called if an error occurs during shader compilation.
  114604. */
  114605. onError: Nullable<(effect: Effect, errors: string) => void>;
  114606. /**
  114607. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114608. */
  114609. indexParameters?: any;
  114610. /**
  114611. * Max number of lights that can be used in the shader.
  114612. */
  114613. maxSimultaneousLights?: number;
  114614. /**
  114615. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114616. */
  114617. transformFeedbackVaryings?: Nullable<string[]>;
  114618. /**
  114619. * 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
  114620. */
  114621. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114622. /**
  114623. * Is this effect rendering to several color attachments ?
  114624. */
  114625. multiTarget?: boolean;
  114626. }
  114627. /**
  114628. * Effect containing vertex and fragment shader that can be executed on an object.
  114629. */
  114630. export class Effect implements IDisposable {
  114631. /**
  114632. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114633. */
  114634. static ShadersRepository: string;
  114635. /**
  114636. * Enable logging of the shader code when a compilation error occurs
  114637. */
  114638. static LogShaderCodeOnCompilationError: boolean;
  114639. /**
  114640. * Name of the effect.
  114641. */
  114642. name: any;
  114643. /**
  114644. * String container all the define statements that should be set on the shader.
  114645. */
  114646. defines: string;
  114647. /**
  114648. * Callback that will be called when the shader is compiled.
  114649. */
  114650. onCompiled: Nullable<(effect: Effect) => void>;
  114651. /**
  114652. * Callback that will be called if an error occurs during shader compilation.
  114653. */
  114654. onError: Nullable<(effect: Effect, errors: string) => void>;
  114655. /**
  114656. * Callback that will be called when effect is bound.
  114657. */
  114658. onBind: Nullable<(effect: Effect) => void>;
  114659. /**
  114660. * Unique ID of the effect.
  114661. */
  114662. uniqueId: number;
  114663. /**
  114664. * Observable that will be called when the shader is compiled.
  114665. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114666. */
  114667. onCompileObservable: Observable<Effect>;
  114668. /**
  114669. * Observable that will be called if an error occurs during shader compilation.
  114670. */
  114671. onErrorObservable: Observable<Effect>;
  114672. /** @hidden */
  114673. _onBindObservable: Nullable<Observable<Effect>>;
  114674. /**
  114675. * @hidden
  114676. * Specifies if the effect was previously ready
  114677. */
  114678. _wasPreviouslyReady: boolean;
  114679. /**
  114680. * Observable that will be called when effect is bound.
  114681. */
  114682. get onBindObservable(): Observable<Effect>;
  114683. /** @hidden */
  114684. _bonesComputationForcedToCPU: boolean;
  114685. /** @hidden */
  114686. _multiTarget: boolean;
  114687. private static _uniqueIdSeed;
  114688. private _engine;
  114689. private _uniformBuffersNames;
  114690. private _uniformBuffersNamesList;
  114691. private _uniformsNames;
  114692. private _samplerList;
  114693. private _samplers;
  114694. private _isReady;
  114695. private _compilationError;
  114696. private _allFallbacksProcessed;
  114697. private _attributesNames;
  114698. private _attributes;
  114699. private _attributeLocationByName;
  114700. private _uniforms;
  114701. /**
  114702. * Key for the effect.
  114703. * @hidden
  114704. */
  114705. _key: string;
  114706. private _indexParameters;
  114707. private _fallbacks;
  114708. private _vertexSourceCode;
  114709. private _fragmentSourceCode;
  114710. private _vertexSourceCodeOverride;
  114711. private _fragmentSourceCodeOverride;
  114712. private _transformFeedbackVaryings;
  114713. /**
  114714. * Compiled shader to webGL program.
  114715. * @hidden
  114716. */
  114717. _pipelineContext: Nullable<IPipelineContext>;
  114718. private _valueCache;
  114719. private static _baseCache;
  114720. /**
  114721. * Instantiates an effect.
  114722. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114723. * @param baseName Name of the effect.
  114724. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114725. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114726. * @param samplers List of sampler variables that will be passed to the shader.
  114727. * @param engine Engine to be used to render the effect
  114728. * @param defines Define statements to be added to the shader.
  114729. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114730. * @param onCompiled Callback that will be called when the shader is compiled.
  114731. * @param onError Callback that will be called if an error occurs during shader compilation.
  114732. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114733. */
  114734. 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);
  114735. private _useFinalCode;
  114736. /**
  114737. * Unique key for this effect
  114738. */
  114739. get key(): string;
  114740. /**
  114741. * If the effect has been compiled and prepared.
  114742. * @returns if the effect is compiled and prepared.
  114743. */
  114744. isReady(): boolean;
  114745. private _isReadyInternal;
  114746. /**
  114747. * The engine the effect was initialized with.
  114748. * @returns the engine.
  114749. */
  114750. getEngine(): Engine;
  114751. /**
  114752. * The pipeline context for this effect
  114753. * @returns the associated pipeline context
  114754. */
  114755. getPipelineContext(): Nullable<IPipelineContext>;
  114756. /**
  114757. * The set of names of attribute variables for the shader.
  114758. * @returns An array of attribute names.
  114759. */
  114760. getAttributesNames(): string[];
  114761. /**
  114762. * Returns the attribute at the given index.
  114763. * @param index The index of the attribute.
  114764. * @returns The location of the attribute.
  114765. */
  114766. getAttributeLocation(index: number): number;
  114767. /**
  114768. * Returns the attribute based on the name of the variable.
  114769. * @param name of the attribute to look up.
  114770. * @returns the attribute location.
  114771. */
  114772. getAttributeLocationByName(name: string): number;
  114773. /**
  114774. * The number of attributes.
  114775. * @returns the numnber of attributes.
  114776. */
  114777. getAttributesCount(): number;
  114778. /**
  114779. * Gets the index of a uniform variable.
  114780. * @param uniformName of the uniform to look up.
  114781. * @returns the index.
  114782. */
  114783. getUniformIndex(uniformName: string): number;
  114784. /**
  114785. * Returns the attribute based on the name of the variable.
  114786. * @param uniformName of the uniform to look up.
  114787. * @returns the location of the uniform.
  114788. */
  114789. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114790. /**
  114791. * Returns an array of sampler variable names
  114792. * @returns The array of sampler variable names.
  114793. */
  114794. getSamplers(): string[];
  114795. /**
  114796. * Returns an array of uniform variable names
  114797. * @returns The array of uniform variable names.
  114798. */
  114799. getUniformNames(): string[];
  114800. /**
  114801. * Returns an array of uniform buffer variable names
  114802. * @returns The array of uniform buffer variable names.
  114803. */
  114804. getUniformBuffersNames(): string[];
  114805. /**
  114806. * Returns the index parameters used to create the effect
  114807. * @returns The index parameters object
  114808. */
  114809. getIndexParameters(): any;
  114810. /**
  114811. * The error from the last compilation.
  114812. * @returns the error string.
  114813. */
  114814. getCompilationError(): string;
  114815. /**
  114816. * Gets a boolean indicating that all fallbacks were used during compilation
  114817. * @returns true if all fallbacks were used
  114818. */
  114819. allFallbacksProcessed(): boolean;
  114820. /**
  114821. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114822. * @param func The callback to be used.
  114823. */
  114824. executeWhenCompiled(func: (effect: Effect) => void): void;
  114825. private _checkIsReady;
  114826. private _loadShader;
  114827. /**
  114828. * Gets the vertex shader source code of this effect
  114829. */
  114830. get vertexSourceCode(): string;
  114831. /**
  114832. * Gets the fragment shader source code of this effect
  114833. */
  114834. get fragmentSourceCode(): string;
  114835. /**
  114836. * Recompiles the webGL program
  114837. * @param vertexSourceCode The source code for the vertex shader.
  114838. * @param fragmentSourceCode The source code for the fragment shader.
  114839. * @param onCompiled Callback called when completed.
  114840. * @param onError Callback called on error.
  114841. * @hidden
  114842. */
  114843. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114844. /**
  114845. * Prepares the effect
  114846. * @hidden
  114847. */
  114848. _prepareEffect(): void;
  114849. private _getShaderCodeAndErrorLine;
  114850. private _processCompilationErrors;
  114851. /**
  114852. * Checks if the effect is supported. (Must be called after compilation)
  114853. */
  114854. get isSupported(): boolean;
  114855. /**
  114856. * Binds a texture to the engine to be used as output of the shader.
  114857. * @param channel Name of the output variable.
  114858. * @param texture Texture to bind.
  114859. * @hidden
  114860. */
  114861. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114862. /**
  114863. * Sets a texture on the engine to be used in the shader.
  114864. * @param channel Name of the sampler variable.
  114865. * @param texture Texture to set.
  114866. */
  114867. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114868. /**
  114869. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114870. * @param channel Name of the sampler variable.
  114871. * @param texture Texture to set.
  114872. */
  114873. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114874. /**
  114875. * Sets an array of textures on the engine to be used in the shader.
  114876. * @param channel Name of the variable.
  114877. * @param textures Textures to set.
  114878. */
  114879. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114880. /**
  114881. * 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)
  114882. * @param channel Name of the sampler variable.
  114883. * @param postProcess Post process to get the input texture from.
  114884. */
  114885. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114886. /**
  114887. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114888. * 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)
  114889. * @param channel Name of the sampler variable.
  114890. * @param postProcess Post process to get the output texture from.
  114891. */
  114892. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114893. /** @hidden */
  114894. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114895. /** @hidden */
  114896. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114897. /** @hidden */
  114898. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114899. /** @hidden */
  114900. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114901. /**
  114902. * Binds a buffer to a uniform.
  114903. * @param buffer Buffer to bind.
  114904. * @param name Name of the uniform variable to bind to.
  114905. */
  114906. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114907. /**
  114908. * Binds block to a uniform.
  114909. * @param blockName Name of the block to bind.
  114910. * @param index Index to bind.
  114911. */
  114912. bindUniformBlock(blockName: string, index: number): void;
  114913. /**
  114914. * Sets an interger value on a uniform variable.
  114915. * @param uniformName Name of the variable.
  114916. * @param value Value to be set.
  114917. * @returns this effect.
  114918. */
  114919. setInt(uniformName: string, value: number): Effect;
  114920. /**
  114921. * Sets an int array on a uniform variable.
  114922. * @param uniformName Name of the variable.
  114923. * @param array array to be set.
  114924. * @returns this effect.
  114925. */
  114926. setIntArray(uniformName: string, array: Int32Array): Effect;
  114927. /**
  114928. * 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)
  114929. * @param uniformName Name of the variable.
  114930. * @param array array to be set.
  114931. * @returns this effect.
  114932. */
  114933. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114934. /**
  114935. * 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)
  114936. * @param uniformName Name of the variable.
  114937. * @param array array to be set.
  114938. * @returns this effect.
  114939. */
  114940. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114941. /**
  114942. * 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)
  114943. * @param uniformName Name of the variable.
  114944. * @param array array to be set.
  114945. * @returns this effect.
  114946. */
  114947. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114948. /**
  114949. * Sets an float array on a uniform variable.
  114950. * @param uniformName Name of the variable.
  114951. * @param array array to be set.
  114952. * @returns this effect.
  114953. */
  114954. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114955. /**
  114956. * 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)
  114957. * @param uniformName Name of the variable.
  114958. * @param array array to be set.
  114959. * @returns this effect.
  114960. */
  114961. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114962. /**
  114963. * 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)
  114964. * @param uniformName Name of the variable.
  114965. * @param array array to be set.
  114966. * @returns this effect.
  114967. */
  114968. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114969. /**
  114970. * 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)
  114971. * @param uniformName Name of the variable.
  114972. * @param array array to be set.
  114973. * @returns this effect.
  114974. */
  114975. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114976. /**
  114977. * Sets an array on a uniform variable.
  114978. * @param uniformName Name of the variable.
  114979. * @param array array to be set.
  114980. * @returns this effect.
  114981. */
  114982. setArray(uniformName: string, array: number[]): Effect;
  114983. /**
  114984. * 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)
  114985. * @param uniformName Name of the variable.
  114986. * @param array array to be set.
  114987. * @returns this effect.
  114988. */
  114989. setArray2(uniformName: string, array: number[]): Effect;
  114990. /**
  114991. * 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)
  114992. * @param uniformName Name of the variable.
  114993. * @param array array to be set.
  114994. * @returns this effect.
  114995. */
  114996. setArray3(uniformName: string, array: number[]): Effect;
  114997. /**
  114998. * 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)
  114999. * @param uniformName Name of the variable.
  115000. * @param array array to be set.
  115001. * @returns this effect.
  115002. */
  115003. setArray4(uniformName: string, array: number[]): Effect;
  115004. /**
  115005. * Sets matrices on a uniform variable.
  115006. * @param uniformName Name of the variable.
  115007. * @param matrices matrices to be set.
  115008. * @returns this effect.
  115009. */
  115010. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115011. /**
  115012. * Sets matrix on a uniform variable.
  115013. * @param uniformName Name of the variable.
  115014. * @param matrix matrix to be set.
  115015. * @returns this effect.
  115016. */
  115017. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115018. /**
  115019. * 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)
  115020. * @param uniformName Name of the variable.
  115021. * @param matrix matrix to be set.
  115022. * @returns this effect.
  115023. */
  115024. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115025. /**
  115026. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115027. * @param uniformName Name of the variable.
  115028. * @param matrix matrix to be set.
  115029. * @returns this effect.
  115030. */
  115031. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115032. /**
  115033. * Sets a float on a uniform variable.
  115034. * @param uniformName Name of the variable.
  115035. * @param value value to be set.
  115036. * @returns this effect.
  115037. */
  115038. setFloat(uniformName: string, value: number): Effect;
  115039. /**
  115040. * Sets a boolean on a uniform variable.
  115041. * @param uniformName Name of the variable.
  115042. * @param bool value to be set.
  115043. * @returns this effect.
  115044. */
  115045. setBool(uniformName: string, bool: boolean): Effect;
  115046. /**
  115047. * Sets a Vector2 on a uniform variable.
  115048. * @param uniformName Name of the variable.
  115049. * @param vector2 vector2 to be set.
  115050. * @returns this effect.
  115051. */
  115052. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115053. /**
  115054. * Sets a float2 on a uniform variable.
  115055. * @param uniformName Name of the variable.
  115056. * @param x First float in float2.
  115057. * @param y Second float in float2.
  115058. * @returns this effect.
  115059. */
  115060. setFloat2(uniformName: string, x: number, y: number): Effect;
  115061. /**
  115062. * Sets a Vector3 on a uniform variable.
  115063. * @param uniformName Name of the variable.
  115064. * @param vector3 Value to be set.
  115065. * @returns this effect.
  115066. */
  115067. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115068. /**
  115069. * Sets a float3 on a uniform variable.
  115070. * @param uniformName Name of the variable.
  115071. * @param x First float in float3.
  115072. * @param y Second float in float3.
  115073. * @param z Third float in float3.
  115074. * @returns this effect.
  115075. */
  115076. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115077. /**
  115078. * Sets a Vector4 on a uniform variable.
  115079. * @param uniformName Name of the variable.
  115080. * @param vector4 Value to be set.
  115081. * @returns this effect.
  115082. */
  115083. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115084. /**
  115085. * Sets a float4 on a uniform variable.
  115086. * @param uniformName Name of the variable.
  115087. * @param x First float in float4.
  115088. * @param y Second float in float4.
  115089. * @param z Third float in float4.
  115090. * @param w Fourth float in float4.
  115091. * @returns this effect.
  115092. */
  115093. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115094. /**
  115095. * Sets a Color3 on a uniform variable.
  115096. * @param uniformName Name of the variable.
  115097. * @param color3 Value to be set.
  115098. * @returns this effect.
  115099. */
  115100. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115101. /**
  115102. * Sets a Color4 on a uniform variable.
  115103. * @param uniformName Name of the variable.
  115104. * @param color3 Value to be set.
  115105. * @param alpha Alpha value to be set.
  115106. * @returns this effect.
  115107. */
  115108. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115109. /**
  115110. * Sets a Color4 on a uniform variable
  115111. * @param uniformName defines the name of the variable
  115112. * @param color4 defines the value to be set
  115113. * @returns this effect.
  115114. */
  115115. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115116. /** Release all associated resources */
  115117. dispose(): void;
  115118. /**
  115119. * This function will add a new shader to the shader store
  115120. * @param name the name of the shader
  115121. * @param pixelShader optional pixel shader content
  115122. * @param vertexShader optional vertex shader content
  115123. */
  115124. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115125. /**
  115126. * Store of each shader (The can be looked up using effect.key)
  115127. */
  115128. static ShadersStore: {
  115129. [key: string]: string;
  115130. };
  115131. /**
  115132. * Store of each included file for a shader (The can be looked up using effect.key)
  115133. */
  115134. static IncludesShadersStore: {
  115135. [key: string]: string;
  115136. };
  115137. /**
  115138. * Resets the cache of effects.
  115139. */
  115140. static ResetCache(): void;
  115141. }
  115142. }
  115143. declare module BABYLON {
  115144. /**
  115145. * Interface used to describe the capabilities of the engine relatively to the current browser
  115146. */
  115147. export interface EngineCapabilities {
  115148. /** Maximum textures units per fragment shader */
  115149. maxTexturesImageUnits: number;
  115150. /** Maximum texture units per vertex shader */
  115151. maxVertexTextureImageUnits: number;
  115152. /** Maximum textures units in the entire pipeline */
  115153. maxCombinedTexturesImageUnits: number;
  115154. /** Maximum texture size */
  115155. maxTextureSize: number;
  115156. /** Maximum texture samples */
  115157. maxSamples?: number;
  115158. /** Maximum cube texture size */
  115159. maxCubemapTextureSize: number;
  115160. /** Maximum render texture size */
  115161. maxRenderTextureSize: number;
  115162. /** Maximum number of vertex attributes */
  115163. maxVertexAttribs: number;
  115164. /** Maximum number of varyings */
  115165. maxVaryingVectors: number;
  115166. /** Maximum number of uniforms per vertex shader */
  115167. maxVertexUniformVectors: number;
  115168. /** Maximum number of uniforms per fragment shader */
  115169. maxFragmentUniformVectors: number;
  115170. /** Defines if standard derivates (dx/dy) are supported */
  115171. standardDerivatives: boolean;
  115172. /** Defines if s3tc texture compression is supported */
  115173. s3tc?: WEBGL_compressed_texture_s3tc;
  115174. /** Defines if pvrtc texture compression is supported */
  115175. pvrtc: any;
  115176. /** Defines if etc1 texture compression is supported */
  115177. etc1: any;
  115178. /** Defines if etc2 texture compression is supported */
  115179. etc2: any;
  115180. /** Defines if astc texture compression is supported */
  115181. astc: any;
  115182. /** Defines if bptc texture compression is supported */
  115183. bptc: any;
  115184. /** Defines if float textures are supported */
  115185. textureFloat: boolean;
  115186. /** Defines if vertex array objects are supported */
  115187. vertexArrayObject: boolean;
  115188. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115189. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115190. /** Gets the maximum level of anisotropy supported */
  115191. maxAnisotropy: number;
  115192. /** Defines if instancing is supported */
  115193. instancedArrays: boolean;
  115194. /** Defines if 32 bits indices are supported */
  115195. uintIndices: boolean;
  115196. /** Defines if high precision shaders are supported */
  115197. highPrecisionShaderSupported: boolean;
  115198. /** Defines if depth reading in the fragment shader is supported */
  115199. fragmentDepthSupported: boolean;
  115200. /** Defines if float texture linear filtering is supported*/
  115201. textureFloatLinearFiltering: boolean;
  115202. /** Defines if rendering to float textures is supported */
  115203. textureFloatRender: boolean;
  115204. /** Defines if half float textures are supported*/
  115205. textureHalfFloat: boolean;
  115206. /** Defines if half float texture linear filtering is supported*/
  115207. textureHalfFloatLinearFiltering: boolean;
  115208. /** Defines if rendering to half float textures is supported */
  115209. textureHalfFloatRender: boolean;
  115210. /** Defines if textureLOD shader command is supported */
  115211. textureLOD: boolean;
  115212. /** Defines if draw buffers extension is supported */
  115213. drawBuffersExtension: boolean;
  115214. /** Defines if depth textures are supported */
  115215. depthTextureExtension: boolean;
  115216. /** Defines if float color buffer are supported */
  115217. colorBufferFloat: boolean;
  115218. /** Gets disjoint timer query extension (null if not supported) */
  115219. timerQuery?: EXT_disjoint_timer_query;
  115220. /** Defines if timestamp can be used with timer query */
  115221. canUseTimestampForTimerQuery: boolean;
  115222. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115223. multiview?: any;
  115224. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115225. oculusMultiview?: any;
  115226. /** Function used to let the system compiles shaders in background */
  115227. parallelShaderCompile?: {
  115228. COMPLETION_STATUS_KHR: number;
  115229. };
  115230. /** Max number of texture samples for MSAA */
  115231. maxMSAASamples: number;
  115232. /** Defines if the blend min max extension is supported */
  115233. blendMinMax: boolean;
  115234. }
  115235. }
  115236. declare module BABYLON {
  115237. /**
  115238. * @hidden
  115239. **/
  115240. export class DepthCullingState {
  115241. private _isDepthTestDirty;
  115242. private _isDepthMaskDirty;
  115243. private _isDepthFuncDirty;
  115244. private _isCullFaceDirty;
  115245. private _isCullDirty;
  115246. private _isZOffsetDirty;
  115247. private _isFrontFaceDirty;
  115248. private _depthTest;
  115249. private _depthMask;
  115250. private _depthFunc;
  115251. private _cull;
  115252. private _cullFace;
  115253. private _zOffset;
  115254. private _frontFace;
  115255. /**
  115256. * Initializes the state.
  115257. */
  115258. constructor();
  115259. get isDirty(): boolean;
  115260. get zOffset(): number;
  115261. set zOffset(value: number);
  115262. get cullFace(): Nullable<number>;
  115263. set cullFace(value: Nullable<number>);
  115264. get cull(): Nullable<boolean>;
  115265. set cull(value: Nullable<boolean>);
  115266. get depthFunc(): Nullable<number>;
  115267. set depthFunc(value: Nullable<number>);
  115268. get depthMask(): boolean;
  115269. set depthMask(value: boolean);
  115270. get depthTest(): boolean;
  115271. set depthTest(value: boolean);
  115272. get frontFace(): Nullable<number>;
  115273. set frontFace(value: Nullable<number>);
  115274. reset(): void;
  115275. apply(gl: WebGLRenderingContext): void;
  115276. }
  115277. }
  115278. declare module BABYLON {
  115279. /**
  115280. * @hidden
  115281. **/
  115282. export class StencilState {
  115283. /** 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 */
  115284. static readonly ALWAYS: number;
  115285. /** Passed to stencilOperation to specify that stencil value must be kept */
  115286. static readonly KEEP: number;
  115287. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115288. static readonly REPLACE: number;
  115289. private _isStencilTestDirty;
  115290. private _isStencilMaskDirty;
  115291. private _isStencilFuncDirty;
  115292. private _isStencilOpDirty;
  115293. private _stencilTest;
  115294. private _stencilMask;
  115295. private _stencilFunc;
  115296. private _stencilFuncRef;
  115297. private _stencilFuncMask;
  115298. private _stencilOpStencilFail;
  115299. private _stencilOpDepthFail;
  115300. private _stencilOpStencilDepthPass;
  115301. get isDirty(): boolean;
  115302. get stencilFunc(): number;
  115303. set stencilFunc(value: number);
  115304. get stencilFuncRef(): number;
  115305. set stencilFuncRef(value: number);
  115306. get stencilFuncMask(): number;
  115307. set stencilFuncMask(value: number);
  115308. get stencilOpStencilFail(): number;
  115309. set stencilOpStencilFail(value: number);
  115310. get stencilOpDepthFail(): number;
  115311. set stencilOpDepthFail(value: number);
  115312. get stencilOpStencilDepthPass(): number;
  115313. set stencilOpStencilDepthPass(value: number);
  115314. get stencilMask(): number;
  115315. set stencilMask(value: number);
  115316. get stencilTest(): boolean;
  115317. set stencilTest(value: boolean);
  115318. constructor();
  115319. reset(): void;
  115320. apply(gl: WebGLRenderingContext): void;
  115321. }
  115322. }
  115323. declare module BABYLON {
  115324. /**
  115325. * @hidden
  115326. **/
  115327. export class AlphaState {
  115328. private _isAlphaBlendDirty;
  115329. private _isBlendFunctionParametersDirty;
  115330. private _isBlendEquationParametersDirty;
  115331. private _isBlendConstantsDirty;
  115332. private _alphaBlend;
  115333. private _blendFunctionParameters;
  115334. private _blendEquationParameters;
  115335. private _blendConstants;
  115336. /**
  115337. * Initializes the state.
  115338. */
  115339. constructor();
  115340. get isDirty(): boolean;
  115341. get alphaBlend(): boolean;
  115342. set alphaBlend(value: boolean);
  115343. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115344. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115345. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115346. reset(): void;
  115347. apply(gl: WebGLRenderingContext): void;
  115348. }
  115349. }
  115350. declare module BABYLON {
  115351. /** @hidden */
  115352. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115353. attributeProcessor(attribute: string): string;
  115354. varyingProcessor(varying: string, isFragment: boolean): string;
  115355. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115356. }
  115357. }
  115358. declare module BABYLON {
  115359. /**
  115360. * Interface for attribute information associated with buffer instanciation
  115361. */
  115362. export interface InstancingAttributeInfo {
  115363. /**
  115364. * Name of the GLSL attribute
  115365. * if attribute index is not specified, this is used to retrieve the index from the effect
  115366. */
  115367. attributeName: string;
  115368. /**
  115369. * Index/offset of the attribute in the vertex shader
  115370. * if not specified, this will be computes from the name.
  115371. */
  115372. index?: number;
  115373. /**
  115374. * size of the attribute, 1, 2, 3 or 4
  115375. */
  115376. attributeSize: number;
  115377. /**
  115378. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115379. */
  115380. offset: number;
  115381. /**
  115382. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115383. * default to 1
  115384. */
  115385. divisor?: number;
  115386. /**
  115387. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115388. * default is FLOAT
  115389. */
  115390. attributeType?: number;
  115391. /**
  115392. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115393. */
  115394. normalized?: boolean;
  115395. }
  115396. }
  115397. declare module BABYLON {
  115398. interface ThinEngine {
  115399. /**
  115400. * Update a video texture
  115401. * @param texture defines the texture to update
  115402. * @param video defines the video element to use
  115403. * @param invertY defines if data must be stored with Y axis inverted
  115404. */
  115405. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115406. }
  115407. }
  115408. declare module BABYLON {
  115409. interface ThinEngine {
  115410. /**
  115411. * Creates a dynamic texture
  115412. * @param width defines the width of the texture
  115413. * @param height defines the height of the texture
  115414. * @param generateMipMaps defines if the engine should generate the mip levels
  115415. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115416. * @returns the dynamic texture inside an InternalTexture
  115417. */
  115418. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115419. /**
  115420. * Update the content of a dynamic texture
  115421. * @param texture defines the texture to update
  115422. * @param canvas defines the canvas containing the source
  115423. * @param invertY defines if data must be stored with Y axis inverted
  115424. * @param premulAlpha defines if alpha is stored as premultiplied
  115425. * @param format defines the format of the data
  115426. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115427. */
  115428. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115429. }
  115430. }
  115431. declare module BABYLON {
  115432. /**
  115433. * Settings for finer control over video usage
  115434. */
  115435. export interface VideoTextureSettings {
  115436. /**
  115437. * Applies `autoplay` to video, if specified
  115438. */
  115439. autoPlay?: boolean;
  115440. /**
  115441. * Applies `loop` to video, if specified
  115442. */
  115443. loop?: boolean;
  115444. /**
  115445. * Automatically updates internal texture from video at every frame in the render loop
  115446. */
  115447. autoUpdateTexture: boolean;
  115448. /**
  115449. * Image src displayed during the video loading or until the user interacts with the video.
  115450. */
  115451. poster?: string;
  115452. }
  115453. /**
  115454. * If you want to display a video in your scene, this is the special texture for that.
  115455. * This special texture works similar to other textures, with the exception of a few parameters.
  115456. * @see https://doc.babylonjs.com/how_to/video_texture
  115457. */
  115458. export class VideoTexture extends Texture {
  115459. /**
  115460. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115461. */
  115462. readonly autoUpdateTexture: boolean;
  115463. /**
  115464. * The video instance used by the texture internally
  115465. */
  115466. readonly video: HTMLVideoElement;
  115467. private _onUserActionRequestedObservable;
  115468. /**
  115469. * Event triggerd when a dom action is required by the user to play the video.
  115470. * This happens due to recent changes in browser policies preventing video to auto start.
  115471. */
  115472. get onUserActionRequestedObservable(): Observable<Texture>;
  115473. private _generateMipMaps;
  115474. private _stillImageCaptured;
  115475. private _displayingPosterTexture;
  115476. private _settings;
  115477. private _createInternalTextureOnEvent;
  115478. private _frameId;
  115479. private _currentSrc;
  115480. /**
  115481. * Creates a video texture.
  115482. * If you want to display a video in your scene, this is the special texture for that.
  115483. * This special texture works similar to other textures, with the exception of a few parameters.
  115484. * @see https://doc.babylonjs.com/how_to/video_texture
  115485. * @param name optional name, will detect from video source, if not defined
  115486. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115487. * @param scene is obviously the current scene.
  115488. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115489. * @param invertY is false by default but can be used to invert video on Y axis
  115490. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115491. * @param settings allows finer control over video usage
  115492. */
  115493. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115494. private _getName;
  115495. private _getVideo;
  115496. private _createInternalTexture;
  115497. private reset;
  115498. /**
  115499. * @hidden Internal method to initiate `update`.
  115500. */
  115501. _rebuild(): void;
  115502. /**
  115503. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115504. */
  115505. update(): void;
  115506. /**
  115507. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115508. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115509. */
  115510. updateTexture(isVisible: boolean): void;
  115511. protected _updateInternalTexture: () => void;
  115512. /**
  115513. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115514. * @param url New url.
  115515. */
  115516. updateURL(url: string): void;
  115517. /**
  115518. * Clones the texture.
  115519. * @returns the cloned texture
  115520. */
  115521. clone(): VideoTexture;
  115522. /**
  115523. * Dispose the texture and release its associated resources.
  115524. */
  115525. dispose(): void;
  115526. /**
  115527. * Creates a video texture straight from a stream.
  115528. * @param scene Define the scene the texture should be created in
  115529. * @param stream Define the stream the texture should be created from
  115530. * @returns The created video texture as a promise
  115531. */
  115532. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115533. /**
  115534. * Creates a video texture straight from your WebCam video feed.
  115535. * @param scene Define the scene the texture should be created in
  115536. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115537. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115538. * @returns The created video texture as a promise
  115539. */
  115540. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115541. minWidth: number;
  115542. maxWidth: number;
  115543. minHeight: number;
  115544. maxHeight: number;
  115545. deviceId: string;
  115546. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115547. /**
  115548. * Creates a video texture straight from your WebCam video feed.
  115549. * @param scene Define the scene the texture should be created in
  115550. * @param onReady Define a callback to triggered once the texture will be ready
  115551. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115552. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115553. */
  115554. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115555. minWidth: number;
  115556. maxWidth: number;
  115557. minHeight: number;
  115558. maxHeight: number;
  115559. deviceId: string;
  115560. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115561. }
  115562. }
  115563. declare module BABYLON {
  115564. /**
  115565. * Defines the interface used by objects working like Scene
  115566. * @hidden
  115567. */
  115568. export interface ISceneLike {
  115569. _addPendingData(data: any): void;
  115570. _removePendingData(data: any): void;
  115571. offlineProvider: IOfflineProvider;
  115572. }
  115573. /**
  115574. * Information about the current host
  115575. */
  115576. export interface HostInformation {
  115577. /**
  115578. * Defines if the current host is a mobile
  115579. */
  115580. isMobile: boolean;
  115581. }
  115582. /** Interface defining initialization parameters for Engine class */
  115583. export interface EngineOptions extends WebGLContextAttributes {
  115584. /**
  115585. * Defines if the engine should no exceed a specified device ratio
  115586. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115587. */
  115588. limitDeviceRatio?: number;
  115589. /**
  115590. * Defines if webvr should be enabled automatically
  115591. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115592. */
  115593. autoEnableWebVR?: boolean;
  115594. /**
  115595. * Defines if webgl2 should be turned off even if supported
  115596. * @see https://doc.babylonjs.com/features/webgl2
  115597. */
  115598. disableWebGL2Support?: boolean;
  115599. /**
  115600. * Defines if webaudio should be initialized as well
  115601. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115602. */
  115603. audioEngine?: boolean;
  115604. /**
  115605. * Defines if animations should run using a deterministic lock step
  115606. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115607. */
  115608. deterministicLockstep?: boolean;
  115609. /** Defines the maximum steps to use with deterministic lock step mode */
  115610. lockstepMaxSteps?: number;
  115611. /** Defines the seconds between each deterministic lock step */
  115612. timeStep?: number;
  115613. /**
  115614. * Defines that engine should ignore context lost events
  115615. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115616. */
  115617. doNotHandleContextLost?: boolean;
  115618. /**
  115619. * Defines that engine should ignore modifying touch action attribute and style
  115620. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115621. */
  115622. doNotHandleTouchAction?: boolean;
  115623. /**
  115624. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115625. */
  115626. useHighPrecisionFloats?: boolean;
  115627. /**
  115628. * Make the canvas XR Compatible for XR sessions
  115629. */
  115630. xrCompatible?: boolean;
  115631. /**
  115632. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115633. */
  115634. useHighPrecisionMatrix?: boolean;
  115635. }
  115636. /**
  115637. * The base engine class (root of all engines)
  115638. */
  115639. export class ThinEngine {
  115640. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115641. static ExceptionList: ({
  115642. key: string;
  115643. capture: string;
  115644. captureConstraint: number;
  115645. targets: string[];
  115646. } | {
  115647. key: string;
  115648. capture: null;
  115649. captureConstraint: null;
  115650. targets: string[];
  115651. })[];
  115652. /** @hidden */
  115653. static _TextureLoaders: IInternalTextureLoader[];
  115654. /**
  115655. * Returns the current npm package of the sdk
  115656. */
  115657. static get NpmPackage(): string;
  115658. /**
  115659. * Returns the current version of the framework
  115660. */
  115661. static get Version(): string;
  115662. /**
  115663. * Returns a string describing the current engine
  115664. */
  115665. get description(): string;
  115666. /**
  115667. * Gets or sets the epsilon value used by collision engine
  115668. */
  115669. static CollisionsEpsilon: number;
  115670. /**
  115671. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115672. */
  115673. static get ShadersRepository(): string;
  115674. static set ShadersRepository(value: string);
  115675. /** @hidden */
  115676. _shaderProcessor: IShaderProcessor;
  115677. /**
  115678. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115679. */
  115680. forcePOTTextures: boolean;
  115681. /**
  115682. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115683. */
  115684. isFullscreen: boolean;
  115685. /**
  115686. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115687. */
  115688. cullBackFaces: boolean;
  115689. /**
  115690. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115691. */
  115692. renderEvenInBackground: boolean;
  115693. /**
  115694. * Gets or sets a boolean indicating that cache can be kept between frames
  115695. */
  115696. preventCacheWipeBetweenFrames: boolean;
  115697. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115698. validateShaderPrograms: boolean;
  115699. /**
  115700. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115701. * This can provide greater z depth for distant objects.
  115702. */
  115703. useReverseDepthBuffer: boolean;
  115704. /**
  115705. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115706. */
  115707. disableUniformBuffers: boolean;
  115708. /** @hidden */
  115709. _uniformBuffers: UniformBuffer[];
  115710. /**
  115711. * Gets a boolean indicating that the engine supports uniform buffers
  115712. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115713. */
  115714. get supportsUniformBuffers(): boolean;
  115715. /** @hidden */
  115716. _gl: WebGLRenderingContext;
  115717. /** @hidden */
  115718. _webGLVersion: number;
  115719. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115720. protected _windowIsBackground: boolean;
  115721. protected _creationOptions: EngineOptions;
  115722. protected _highPrecisionShadersAllowed: boolean;
  115723. /** @hidden */
  115724. get _shouldUseHighPrecisionShader(): boolean;
  115725. /**
  115726. * Gets a boolean indicating that only power of 2 textures are supported
  115727. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115728. */
  115729. get needPOTTextures(): boolean;
  115730. /** @hidden */
  115731. _badOS: boolean;
  115732. /** @hidden */
  115733. _badDesktopOS: boolean;
  115734. private _hardwareScalingLevel;
  115735. /** @hidden */
  115736. _caps: EngineCapabilities;
  115737. private _isStencilEnable;
  115738. private _glVersion;
  115739. private _glRenderer;
  115740. private _glVendor;
  115741. /** @hidden */
  115742. _videoTextureSupported: boolean;
  115743. protected _renderingQueueLaunched: boolean;
  115744. protected _activeRenderLoops: (() => void)[];
  115745. /**
  115746. * Observable signaled when a context lost event is raised
  115747. */
  115748. onContextLostObservable: Observable<ThinEngine>;
  115749. /**
  115750. * Observable signaled when a context restored event is raised
  115751. */
  115752. onContextRestoredObservable: Observable<ThinEngine>;
  115753. private _onContextLost;
  115754. private _onContextRestored;
  115755. protected _contextWasLost: boolean;
  115756. /** @hidden */
  115757. _doNotHandleContextLost: boolean;
  115758. /**
  115759. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115760. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115761. */
  115762. get doNotHandleContextLost(): boolean;
  115763. set doNotHandleContextLost(value: boolean);
  115764. /**
  115765. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115766. */
  115767. disableVertexArrayObjects: boolean;
  115768. /** @hidden */
  115769. protected _colorWrite: boolean;
  115770. /** @hidden */
  115771. protected _colorWriteChanged: boolean;
  115772. /** @hidden */
  115773. protected _depthCullingState: DepthCullingState;
  115774. /** @hidden */
  115775. protected _stencilState: StencilState;
  115776. /** @hidden */
  115777. _alphaState: AlphaState;
  115778. /** @hidden */
  115779. _alphaMode: number;
  115780. /** @hidden */
  115781. _alphaEquation: number;
  115782. /** @hidden */
  115783. _internalTexturesCache: InternalTexture[];
  115784. /** @hidden */
  115785. protected _activeChannel: number;
  115786. private _currentTextureChannel;
  115787. /** @hidden */
  115788. protected _boundTexturesCache: {
  115789. [key: string]: Nullable<InternalTexture>;
  115790. };
  115791. /** @hidden */
  115792. protected _currentEffect: Nullable<Effect>;
  115793. /** @hidden */
  115794. protected _currentProgram: Nullable<WebGLProgram>;
  115795. private _compiledEffects;
  115796. private _vertexAttribArraysEnabled;
  115797. /** @hidden */
  115798. protected _cachedViewport: Nullable<IViewportLike>;
  115799. private _cachedVertexArrayObject;
  115800. /** @hidden */
  115801. protected _cachedVertexBuffers: any;
  115802. /** @hidden */
  115803. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115804. /** @hidden */
  115805. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115806. /** @hidden */
  115807. _currentRenderTarget: Nullable<InternalTexture>;
  115808. private _uintIndicesCurrentlySet;
  115809. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115810. /** @hidden */
  115811. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115812. /** @hidden */
  115813. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115814. private _currentBufferPointers;
  115815. private _currentInstanceLocations;
  115816. private _currentInstanceBuffers;
  115817. private _textureUnits;
  115818. /** @hidden */
  115819. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115820. /** @hidden */
  115821. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115822. /** @hidden */
  115823. _boundRenderFunction: any;
  115824. private _vaoRecordInProgress;
  115825. private _mustWipeVertexAttributes;
  115826. private _emptyTexture;
  115827. private _emptyCubeTexture;
  115828. private _emptyTexture3D;
  115829. private _emptyTexture2DArray;
  115830. /** @hidden */
  115831. _frameHandler: number;
  115832. private _nextFreeTextureSlots;
  115833. private _maxSimultaneousTextures;
  115834. private _activeRequests;
  115835. /** @hidden */
  115836. _transformTextureUrl: Nullable<(url: string) => string>;
  115837. /**
  115838. * Gets information about the current host
  115839. */
  115840. hostInformation: HostInformation;
  115841. protected get _supportsHardwareTextureRescaling(): boolean;
  115842. private _framebufferDimensionsObject;
  115843. /**
  115844. * sets the object from which width and height will be taken from when getting render width and height
  115845. * Will fallback to the gl object
  115846. * @param dimensions the framebuffer width and height that will be used.
  115847. */
  115848. set framebufferDimensionsObject(dimensions: Nullable<{
  115849. framebufferWidth: number;
  115850. framebufferHeight: number;
  115851. }>);
  115852. /**
  115853. * Gets the current viewport
  115854. */
  115855. get currentViewport(): Nullable<IViewportLike>;
  115856. /**
  115857. * Gets the default empty texture
  115858. */
  115859. get emptyTexture(): InternalTexture;
  115860. /**
  115861. * Gets the default empty 3D texture
  115862. */
  115863. get emptyTexture3D(): InternalTexture;
  115864. /**
  115865. * Gets the default empty 2D array texture
  115866. */
  115867. get emptyTexture2DArray(): InternalTexture;
  115868. /**
  115869. * Gets the default empty cube texture
  115870. */
  115871. get emptyCubeTexture(): InternalTexture;
  115872. /**
  115873. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115874. */
  115875. readonly premultipliedAlpha: boolean;
  115876. /**
  115877. * Observable event triggered before each texture is initialized
  115878. */
  115879. onBeforeTextureInitObservable: Observable<Texture>;
  115880. /**
  115881. * Creates a new engine
  115882. * @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
  115883. * @param antialias defines enable antialiasing (default: false)
  115884. * @param options defines further options to be sent to the getContext() function
  115885. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115886. */
  115887. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115888. private _rebuildInternalTextures;
  115889. private _rebuildEffects;
  115890. /**
  115891. * Gets a boolean indicating if all created effects are ready
  115892. * @returns true if all effects are ready
  115893. */
  115894. areAllEffectsReady(): boolean;
  115895. protected _rebuildBuffers(): void;
  115896. protected _initGLContext(): void;
  115897. /**
  115898. * Gets version of the current webGL context
  115899. */
  115900. get webGLVersion(): number;
  115901. /**
  115902. * Gets a string identifying the name of the class
  115903. * @returns "Engine" string
  115904. */
  115905. getClassName(): string;
  115906. /**
  115907. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115908. */
  115909. get isStencilEnable(): boolean;
  115910. /** @hidden */
  115911. _prepareWorkingCanvas(): void;
  115912. /**
  115913. * Reset the texture cache to empty state
  115914. */
  115915. resetTextureCache(): void;
  115916. /**
  115917. * Gets an object containing information about the current webGL context
  115918. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115919. */
  115920. getGlInfo(): {
  115921. vendor: string;
  115922. renderer: string;
  115923. version: string;
  115924. };
  115925. /**
  115926. * Defines the hardware scaling level.
  115927. * By default the hardware scaling level is computed from the window device ratio.
  115928. * 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.
  115929. * @param level defines the level to use
  115930. */
  115931. setHardwareScalingLevel(level: number): void;
  115932. /**
  115933. * Gets the current hardware scaling level.
  115934. * By default the hardware scaling level is computed from the window device ratio.
  115935. * 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.
  115936. * @returns a number indicating the current hardware scaling level
  115937. */
  115938. getHardwareScalingLevel(): number;
  115939. /**
  115940. * Gets the list of loaded textures
  115941. * @returns an array containing all loaded textures
  115942. */
  115943. getLoadedTexturesCache(): InternalTexture[];
  115944. /**
  115945. * Gets the object containing all engine capabilities
  115946. * @returns the EngineCapabilities object
  115947. */
  115948. getCaps(): EngineCapabilities;
  115949. /**
  115950. * stop executing a render loop function and remove it from the execution array
  115951. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115952. */
  115953. stopRenderLoop(renderFunction?: () => void): void;
  115954. /** @hidden */
  115955. _renderLoop(): void;
  115956. /**
  115957. * Gets the HTML canvas attached with the current webGL context
  115958. * @returns a HTML canvas
  115959. */
  115960. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115961. /**
  115962. * Gets host window
  115963. * @returns the host window object
  115964. */
  115965. getHostWindow(): Nullable<Window>;
  115966. /**
  115967. * Gets the current render width
  115968. * @param useScreen defines if screen size must be used (or the current render target if any)
  115969. * @returns a number defining the current render width
  115970. */
  115971. getRenderWidth(useScreen?: boolean): number;
  115972. /**
  115973. * Gets the current render height
  115974. * @param useScreen defines if screen size must be used (or the current render target if any)
  115975. * @returns a number defining the current render height
  115976. */
  115977. getRenderHeight(useScreen?: boolean): number;
  115978. /**
  115979. * Can be used to override the current requestAnimationFrame requester.
  115980. * @hidden
  115981. */
  115982. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115983. /**
  115984. * Register and execute a render loop. The engine can have more than one render function
  115985. * @param renderFunction defines the function to continuously execute
  115986. */
  115987. runRenderLoop(renderFunction: () => void): void;
  115988. /**
  115989. * Clear the current render buffer or the current render target (if any is set up)
  115990. * @param color defines the color to use
  115991. * @param backBuffer defines if the back buffer must be cleared
  115992. * @param depth defines if the depth buffer must be cleared
  115993. * @param stencil defines if the stencil buffer must be cleared
  115994. */
  115995. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115996. private _viewportCached;
  115997. /** @hidden */
  115998. _viewport(x: number, y: number, width: number, height: number): void;
  115999. /**
  116000. * Set the WebGL's viewport
  116001. * @param viewport defines the viewport element to be used
  116002. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116003. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116004. */
  116005. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116006. /**
  116007. * Begin a new frame
  116008. */
  116009. beginFrame(): void;
  116010. /**
  116011. * Enf the current frame
  116012. */
  116013. endFrame(): void;
  116014. /**
  116015. * Resize the view according to the canvas' size
  116016. */
  116017. resize(): void;
  116018. /**
  116019. * Force a specific size of the canvas
  116020. * @param width defines the new canvas' width
  116021. * @param height defines the new canvas' height
  116022. * @returns true if the size was changed
  116023. */
  116024. setSize(width: number, height: number): boolean;
  116025. /**
  116026. * Binds the frame buffer to the specified texture.
  116027. * @param texture The texture to render to or null for the default canvas
  116028. * @param faceIndex The face of the texture to render to in case of cube texture
  116029. * @param requiredWidth The width of the target to render to
  116030. * @param requiredHeight The height of the target to render to
  116031. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116032. * @param lodLevel defines the lod level to bind to the frame buffer
  116033. * @param layer defines the 2d array index to bind to frame buffer to
  116034. */
  116035. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116036. /** @hidden */
  116037. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116038. /**
  116039. * Unbind the current render target texture from the webGL context
  116040. * @param texture defines the render target texture to unbind
  116041. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116042. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116043. */
  116044. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116045. /**
  116046. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116047. */
  116048. flushFramebuffer(): void;
  116049. /**
  116050. * Unbind the current render target and bind the default framebuffer
  116051. */
  116052. restoreDefaultFramebuffer(): void;
  116053. /** @hidden */
  116054. protected _resetVertexBufferBinding(): void;
  116055. /**
  116056. * Creates a vertex buffer
  116057. * @param data the data for the vertex buffer
  116058. * @returns the new WebGL static buffer
  116059. */
  116060. createVertexBuffer(data: DataArray): DataBuffer;
  116061. private _createVertexBuffer;
  116062. /**
  116063. * Creates a dynamic vertex buffer
  116064. * @param data the data for the dynamic vertex buffer
  116065. * @returns the new WebGL dynamic buffer
  116066. */
  116067. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116068. protected _resetIndexBufferBinding(): void;
  116069. /**
  116070. * Creates a new index buffer
  116071. * @param indices defines the content of the index buffer
  116072. * @param updatable defines if the index buffer must be updatable
  116073. * @returns a new webGL buffer
  116074. */
  116075. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116076. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116077. /**
  116078. * Bind a webGL buffer to the webGL context
  116079. * @param buffer defines the buffer to bind
  116080. */
  116081. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116082. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116083. private bindBuffer;
  116084. /**
  116085. * update the bound buffer with the given data
  116086. * @param data defines the data to update
  116087. */
  116088. updateArrayBuffer(data: Float32Array): void;
  116089. private _vertexAttribPointer;
  116090. /** @hidden */
  116091. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116092. private _bindVertexBuffersAttributes;
  116093. /**
  116094. * Records a vertex array object
  116095. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116096. * @param vertexBuffers defines the list of vertex buffers to store
  116097. * @param indexBuffer defines the index buffer to store
  116098. * @param effect defines the effect to store
  116099. * @returns the new vertex array object
  116100. */
  116101. recordVertexArrayObject(vertexBuffers: {
  116102. [key: string]: VertexBuffer;
  116103. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116104. /**
  116105. * Bind a specific vertex array object
  116106. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116107. * @param vertexArrayObject defines the vertex array object to bind
  116108. * @param indexBuffer defines the index buffer to bind
  116109. */
  116110. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116111. /**
  116112. * Bind webGl buffers directly to the webGL context
  116113. * @param vertexBuffer defines the vertex buffer to bind
  116114. * @param indexBuffer defines the index buffer to bind
  116115. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116116. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116117. * @param effect defines the effect associated with the vertex buffer
  116118. */
  116119. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116120. private _unbindVertexArrayObject;
  116121. /**
  116122. * Bind a list of vertex buffers to the webGL context
  116123. * @param vertexBuffers defines the list of vertex buffers to bind
  116124. * @param indexBuffer defines the index buffer to bind
  116125. * @param effect defines the effect associated with the vertex buffers
  116126. */
  116127. bindBuffers(vertexBuffers: {
  116128. [key: string]: Nullable<VertexBuffer>;
  116129. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116130. /**
  116131. * Unbind all instance attributes
  116132. */
  116133. unbindInstanceAttributes(): void;
  116134. /**
  116135. * Release and free the memory of a vertex array object
  116136. * @param vao defines the vertex array object to delete
  116137. */
  116138. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116139. /** @hidden */
  116140. _releaseBuffer(buffer: DataBuffer): boolean;
  116141. protected _deleteBuffer(buffer: DataBuffer): void;
  116142. /**
  116143. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116144. * @param instancesBuffer defines the webGL buffer to update and bind
  116145. * @param data defines the data to store in the buffer
  116146. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116147. */
  116148. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116149. /**
  116150. * Bind the content of a webGL buffer used with instantiation
  116151. * @param instancesBuffer defines the webGL buffer to bind
  116152. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116153. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116154. */
  116155. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116156. /**
  116157. * Disable the instance attribute corresponding to the name in parameter
  116158. * @param name defines the name of the attribute to disable
  116159. */
  116160. disableInstanceAttributeByName(name: string): void;
  116161. /**
  116162. * Disable the instance attribute corresponding to the location in parameter
  116163. * @param attributeLocation defines the attribute location of the attribute to disable
  116164. */
  116165. disableInstanceAttribute(attributeLocation: number): void;
  116166. /**
  116167. * Disable the attribute corresponding to the location in parameter
  116168. * @param attributeLocation defines the attribute location of the attribute to disable
  116169. */
  116170. disableAttributeByIndex(attributeLocation: number): void;
  116171. /**
  116172. * Send a draw order
  116173. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116174. * @param indexStart defines the starting index
  116175. * @param indexCount defines the number of index to draw
  116176. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116177. */
  116178. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116179. /**
  116180. * Draw a list of points
  116181. * @param verticesStart defines the index of first vertex to draw
  116182. * @param verticesCount defines the count of vertices to draw
  116183. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116184. */
  116185. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116186. /**
  116187. * Draw a list of unindexed primitives
  116188. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116189. * @param verticesStart defines the index of first vertex to draw
  116190. * @param verticesCount defines the count of vertices to draw
  116191. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116192. */
  116193. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116194. /**
  116195. * Draw a list of indexed primitives
  116196. * @param fillMode defines the primitive to use
  116197. * @param indexStart defines the starting index
  116198. * @param indexCount defines the number of index to draw
  116199. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116200. */
  116201. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116202. /**
  116203. * Draw a list of unindexed primitives
  116204. * @param fillMode defines the primitive to use
  116205. * @param verticesStart defines the index of first vertex to draw
  116206. * @param verticesCount defines the count of vertices to draw
  116207. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116208. */
  116209. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116210. private _drawMode;
  116211. /** @hidden */
  116212. protected _reportDrawCall(): void;
  116213. /** @hidden */
  116214. _releaseEffect(effect: Effect): void;
  116215. /** @hidden */
  116216. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116217. /**
  116218. * Create a new effect (used to store vertex/fragment shaders)
  116219. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116220. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116221. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116222. * @param samplers defines an array of string used to represent textures
  116223. * @param defines defines the string containing the defines to use to compile the shaders
  116224. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116225. * @param onCompiled defines a function to call when the effect creation is successful
  116226. * @param onError defines a function to call when the effect creation has failed
  116227. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116228. * @returns the new Effect
  116229. */
  116230. 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;
  116231. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116232. private _compileShader;
  116233. private _compileRawShader;
  116234. /** @hidden */
  116235. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116236. /**
  116237. * Directly creates a webGL program
  116238. * @param pipelineContext defines the pipeline context to attach to
  116239. * @param vertexCode defines the vertex shader code to use
  116240. * @param fragmentCode defines the fragment shader code to use
  116241. * @param context defines the webGL context to use (if not set, the current one will be used)
  116242. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116243. * @returns the new webGL program
  116244. */
  116245. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116246. /**
  116247. * Creates a webGL program
  116248. * @param pipelineContext defines the pipeline context to attach to
  116249. * @param vertexCode defines the vertex shader code to use
  116250. * @param fragmentCode defines the fragment shader code to use
  116251. * @param defines defines the string containing the defines to use to compile the shaders
  116252. * @param context defines the webGL context to use (if not set, the current one will be used)
  116253. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116254. * @returns the new webGL program
  116255. */
  116256. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116257. /**
  116258. * Creates a new pipeline context
  116259. * @returns the new pipeline
  116260. */
  116261. createPipelineContext(): IPipelineContext;
  116262. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116263. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116264. /** @hidden */
  116265. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116266. /** @hidden */
  116267. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116268. /** @hidden */
  116269. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116270. /**
  116271. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116272. * @param pipelineContext defines the pipeline context to use
  116273. * @param uniformsNames defines the list of uniform names
  116274. * @returns an array of webGL uniform locations
  116275. */
  116276. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116277. /**
  116278. * Gets the lsit of active attributes for a given webGL program
  116279. * @param pipelineContext defines the pipeline context to use
  116280. * @param attributesNames defines the list of attribute names to get
  116281. * @returns an array of indices indicating the offset of each attribute
  116282. */
  116283. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116284. /**
  116285. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116286. * @param effect defines the effect to activate
  116287. */
  116288. enableEffect(effect: Nullable<Effect>): void;
  116289. /**
  116290. * Set the value of an uniform to a number (int)
  116291. * @param uniform defines the webGL uniform location where to store the value
  116292. * @param value defines the int number to store
  116293. * @returns true if the value was set
  116294. */
  116295. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116296. /**
  116297. * Set the value of an uniform to an array of int32
  116298. * @param uniform defines the webGL uniform location where to store the value
  116299. * @param array defines the array of int32 to store
  116300. * @returns true if the value was set
  116301. */
  116302. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116303. /**
  116304. * Set the value of an uniform to an array of int32 (stored as vec2)
  116305. * @param uniform defines the webGL uniform location where to store the value
  116306. * @param array defines the array of int32 to store
  116307. * @returns true if the value was set
  116308. */
  116309. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116310. /**
  116311. * Set the value of an uniform to an array of int32 (stored as vec3)
  116312. * @param uniform defines the webGL uniform location where to store the value
  116313. * @param array defines the array of int32 to store
  116314. * @returns true if the value was set
  116315. */
  116316. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116317. /**
  116318. * Set the value of an uniform to an array of int32 (stored as vec4)
  116319. * @param uniform defines the webGL uniform location where to store the value
  116320. * @param array defines the array of int32 to store
  116321. * @returns true if the value was set
  116322. */
  116323. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116324. /**
  116325. * Set the value of an uniform to an array of number
  116326. * @param uniform defines the webGL uniform location where to store the value
  116327. * @param array defines the array of number to store
  116328. * @returns true if the value was set
  116329. */
  116330. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116331. /**
  116332. * Set the value of an uniform to an array of number (stored as vec2)
  116333. * @param uniform defines the webGL uniform location where to store the value
  116334. * @param array defines the array of number to store
  116335. * @returns true if the value was set
  116336. */
  116337. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116338. /**
  116339. * Set the value of an uniform to an array of number (stored as vec3)
  116340. * @param uniform defines the webGL uniform location where to store the value
  116341. * @param array defines the array of number to store
  116342. * @returns true if the value was set
  116343. */
  116344. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116345. /**
  116346. * Set the value of an uniform to an array of number (stored as vec4)
  116347. * @param uniform defines the webGL uniform location where to store the value
  116348. * @param array defines the array of number to store
  116349. * @returns true if the value was set
  116350. */
  116351. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116352. /**
  116353. * Set the value of an uniform to an array of float32 (stored as matrices)
  116354. * @param uniform defines the webGL uniform location where to store the value
  116355. * @param matrices defines the array of float32 to store
  116356. * @returns true if the value was set
  116357. */
  116358. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116359. /**
  116360. * Set the value of an uniform to a matrix (3x3)
  116361. * @param uniform defines the webGL uniform location where to store the value
  116362. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116363. * @returns true if the value was set
  116364. */
  116365. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116366. /**
  116367. * Set the value of an uniform to a matrix (2x2)
  116368. * @param uniform defines the webGL uniform location where to store the value
  116369. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116370. * @returns true if the value was set
  116371. */
  116372. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116373. /**
  116374. * Set the value of an uniform to a number (float)
  116375. * @param uniform defines the webGL uniform location where to store the value
  116376. * @param value defines the float number to store
  116377. * @returns true if the value was transfered
  116378. */
  116379. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116380. /**
  116381. * Set the value of an uniform to a vec2
  116382. * @param uniform defines the webGL uniform location where to store the value
  116383. * @param x defines the 1st component of the value
  116384. * @param y defines the 2nd component of the value
  116385. * @returns true if the value was set
  116386. */
  116387. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116388. /**
  116389. * Set the value of an uniform to a vec3
  116390. * @param uniform defines the webGL uniform location where to store the value
  116391. * @param x defines the 1st component of the value
  116392. * @param y defines the 2nd component of the value
  116393. * @param z defines the 3rd component of the value
  116394. * @returns true if the value was set
  116395. */
  116396. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116397. /**
  116398. * Set the value of an uniform to a vec4
  116399. * @param uniform defines the webGL uniform location where to store the value
  116400. * @param x defines the 1st component of the value
  116401. * @param y defines the 2nd component of the value
  116402. * @param z defines the 3rd component of the value
  116403. * @param w defines the 4th component of the value
  116404. * @returns true if the value was set
  116405. */
  116406. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116407. /**
  116408. * Apply all cached states (depth, culling, stencil and alpha)
  116409. */
  116410. applyStates(): void;
  116411. /**
  116412. * Enable or disable color writing
  116413. * @param enable defines the state to set
  116414. */
  116415. setColorWrite(enable: boolean): void;
  116416. /**
  116417. * Gets a boolean indicating if color writing is enabled
  116418. * @returns the current color writing state
  116419. */
  116420. getColorWrite(): boolean;
  116421. /**
  116422. * Gets the depth culling state manager
  116423. */
  116424. get depthCullingState(): DepthCullingState;
  116425. /**
  116426. * Gets the alpha state manager
  116427. */
  116428. get alphaState(): AlphaState;
  116429. /**
  116430. * Gets the stencil state manager
  116431. */
  116432. get stencilState(): StencilState;
  116433. /**
  116434. * Clears the list of texture accessible through engine.
  116435. * This can help preventing texture load conflict due to name collision.
  116436. */
  116437. clearInternalTexturesCache(): void;
  116438. /**
  116439. * Force the entire cache to be cleared
  116440. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116441. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116442. */
  116443. wipeCaches(bruteForce?: boolean): void;
  116444. /** @hidden */
  116445. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116446. min: number;
  116447. mag: number;
  116448. };
  116449. /** @hidden */
  116450. _createTexture(): WebGLTexture;
  116451. /**
  116452. * Usually called from Texture.ts.
  116453. * Passed information to create a WebGLTexture
  116454. * @param url defines a value which contains one of the following:
  116455. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116456. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116457. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116458. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116459. * @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)
  116460. * @param scene needed for loading to the correct scene
  116461. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116462. * @param onLoad optional callback to be called upon successful completion
  116463. * @param onError optional callback to be called upon failure
  116464. * @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
  116465. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116466. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116467. * @param forcedExtension defines the extension to use to pick the right loader
  116468. * @param mimeType defines an optional mime type
  116469. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116470. */
  116471. 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;
  116472. /**
  116473. * Loads an image as an HTMLImageElement.
  116474. * @param input url string, ArrayBuffer, or Blob to load
  116475. * @param onLoad callback called when the image successfully loads
  116476. * @param onError callback called when the image fails to load
  116477. * @param offlineProvider offline provider for caching
  116478. * @param mimeType optional mime type
  116479. * @returns the HTMLImageElement of the loaded image
  116480. * @hidden
  116481. */
  116482. 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>;
  116483. /**
  116484. * @hidden
  116485. */
  116486. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116487. private _unpackFlipYCached;
  116488. /**
  116489. * In case you are sharing the context with other applications, it might
  116490. * be interested to not cache the unpack flip y state to ensure a consistent
  116491. * value would be set.
  116492. */
  116493. enableUnpackFlipYCached: boolean;
  116494. /** @hidden */
  116495. _unpackFlipY(value: boolean): void;
  116496. /** @hidden */
  116497. _getUnpackAlignement(): number;
  116498. private _getTextureTarget;
  116499. /**
  116500. * Update the sampling mode of a given texture
  116501. * @param samplingMode defines the required sampling mode
  116502. * @param texture defines the texture to update
  116503. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116504. */
  116505. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116506. /**
  116507. * Update the sampling mode of a given texture
  116508. * @param texture defines the texture to update
  116509. * @param wrapU defines the texture wrap mode of the u coordinates
  116510. * @param wrapV defines the texture wrap mode of the v coordinates
  116511. * @param wrapR defines the texture wrap mode of the r coordinates
  116512. */
  116513. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116514. /** @hidden */
  116515. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116516. width: number;
  116517. height: number;
  116518. layers?: number;
  116519. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116520. /** @hidden */
  116521. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116522. /** @hidden */
  116523. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116524. /**
  116525. * Update a portion of an internal texture
  116526. * @param texture defines the texture to update
  116527. * @param imageData defines the data to store into the texture
  116528. * @param xOffset defines the x coordinates of the update rectangle
  116529. * @param yOffset defines the y coordinates of the update rectangle
  116530. * @param width defines the width of the update rectangle
  116531. * @param height defines the height of the update rectangle
  116532. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116533. * @param lod defines the lod level to update (0 by default)
  116534. */
  116535. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116536. /** @hidden */
  116537. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116538. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116539. private _prepareWebGLTexture;
  116540. /** @hidden */
  116541. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116542. private _getDepthStencilBuffer;
  116543. /** @hidden */
  116544. _releaseFramebufferObjects(texture: InternalTexture): void;
  116545. /** @hidden */
  116546. _releaseTexture(texture: InternalTexture): void;
  116547. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116548. protected _setProgram(program: WebGLProgram): void;
  116549. protected _boundUniforms: {
  116550. [key: number]: WebGLUniformLocation;
  116551. };
  116552. /**
  116553. * Binds an effect to the webGL context
  116554. * @param effect defines the effect to bind
  116555. */
  116556. bindSamplers(effect: Effect): void;
  116557. private _activateCurrentTexture;
  116558. /** @hidden */
  116559. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116560. /** @hidden */
  116561. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116562. /**
  116563. * Unbind all textures from the webGL context
  116564. */
  116565. unbindAllTextures(): void;
  116566. /**
  116567. * Sets a texture to the according uniform.
  116568. * @param channel The texture channel
  116569. * @param uniform The uniform to set
  116570. * @param texture The texture to apply
  116571. */
  116572. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116573. private _bindSamplerUniformToChannel;
  116574. private _getTextureWrapMode;
  116575. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116576. /**
  116577. * Sets an array of texture to the webGL context
  116578. * @param channel defines the channel where the texture array must be set
  116579. * @param uniform defines the associated uniform location
  116580. * @param textures defines the array of textures to bind
  116581. */
  116582. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116583. /** @hidden */
  116584. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116585. private _setTextureParameterFloat;
  116586. private _setTextureParameterInteger;
  116587. /**
  116588. * Unbind all vertex attributes from the webGL context
  116589. */
  116590. unbindAllAttributes(): void;
  116591. /**
  116592. * 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
  116593. */
  116594. releaseEffects(): void;
  116595. /**
  116596. * Dispose and release all associated resources
  116597. */
  116598. dispose(): void;
  116599. /**
  116600. * Attach a new callback raised when context lost event is fired
  116601. * @param callback defines the callback to call
  116602. */
  116603. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116604. /**
  116605. * Attach a new callback raised when context restored event is fired
  116606. * @param callback defines the callback to call
  116607. */
  116608. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116609. /**
  116610. * Get the current error code of the webGL context
  116611. * @returns the error code
  116612. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116613. */
  116614. getError(): number;
  116615. private _canRenderToFloatFramebuffer;
  116616. private _canRenderToHalfFloatFramebuffer;
  116617. private _canRenderToFramebuffer;
  116618. /** @hidden */
  116619. _getWebGLTextureType(type: number): number;
  116620. /** @hidden */
  116621. _getInternalFormat(format: number): number;
  116622. /** @hidden */
  116623. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116624. /** @hidden */
  116625. _getRGBAMultiSampleBufferFormat(type: number): number;
  116626. /** @hidden */
  116627. _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;
  116628. /**
  116629. * Loads a file from a url
  116630. * @param url url to load
  116631. * @param onSuccess callback called when the file successfully loads
  116632. * @param onProgress callback called while file is loading (if the server supports this mode)
  116633. * @param offlineProvider defines the offline provider for caching
  116634. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116635. * @param onError callback called when the file fails to load
  116636. * @returns a file request object
  116637. * @hidden
  116638. */
  116639. 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;
  116640. /**
  116641. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116642. * @param x defines the x coordinate of the rectangle where pixels must be read
  116643. * @param y defines the y coordinate of the rectangle where pixels must be read
  116644. * @param width defines the width of the rectangle where pixels must be read
  116645. * @param height defines the height of the rectangle where pixels must be read
  116646. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116647. * @returns a Uint8Array containing RGBA colors
  116648. */
  116649. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116650. private static _isSupported;
  116651. /**
  116652. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116653. * @returns true if the engine can be created
  116654. * @ignorenaming
  116655. */
  116656. static isSupported(): boolean;
  116657. /**
  116658. * Find the next highest power of two.
  116659. * @param x Number to start search from.
  116660. * @return Next highest power of two.
  116661. */
  116662. static CeilingPOT(x: number): number;
  116663. /**
  116664. * Find the next lowest power of two.
  116665. * @param x Number to start search from.
  116666. * @return Next lowest power of two.
  116667. */
  116668. static FloorPOT(x: number): number;
  116669. /**
  116670. * Find the nearest power of two.
  116671. * @param x Number to start search from.
  116672. * @return Next nearest power of two.
  116673. */
  116674. static NearestPOT(x: number): number;
  116675. /**
  116676. * Get the closest exponent of two
  116677. * @param value defines the value to approximate
  116678. * @param max defines the maximum value to return
  116679. * @param mode defines how to define the closest value
  116680. * @returns closest exponent of two of the given value
  116681. */
  116682. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116683. /**
  116684. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116685. * @param func - the function to be called
  116686. * @param requester - the object that will request the next frame. Falls back to window.
  116687. * @returns frame number
  116688. */
  116689. static QueueNewFrame(func: () => void, requester?: any): number;
  116690. /**
  116691. * Gets host document
  116692. * @returns the host document object
  116693. */
  116694. getHostDocument(): Nullable<Document>;
  116695. }
  116696. }
  116697. declare module BABYLON {
  116698. /**
  116699. * Class representing spherical harmonics coefficients to the 3rd degree
  116700. */
  116701. export class SphericalHarmonics {
  116702. /**
  116703. * Defines whether or not the harmonics have been prescaled for rendering.
  116704. */
  116705. preScaled: boolean;
  116706. /**
  116707. * The l0,0 coefficients of the spherical harmonics
  116708. */
  116709. l00: Vector3;
  116710. /**
  116711. * The l1,-1 coefficients of the spherical harmonics
  116712. */
  116713. l1_1: Vector3;
  116714. /**
  116715. * The l1,0 coefficients of the spherical harmonics
  116716. */
  116717. l10: Vector3;
  116718. /**
  116719. * The l1,1 coefficients of the spherical harmonics
  116720. */
  116721. l11: Vector3;
  116722. /**
  116723. * The l2,-2 coefficients of the spherical harmonics
  116724. */
  116725. l2_2: Vector3;
  116726. /**
  116727. * The l2,-1 coefficients of the spherical harmonics
  116728. */
  116729. l2_1: Vector3;
  116730. /**
  116731. * The l2,0 coefficients of the spherical harmonics
  116732. */
  116733. l20: Vector3;
  116734. /**
  116735. * The l2,1 coefficients of the spherical harmonics
  116736. */
  116737. l21: Vector3;
  116738. /**
  116739. * The l2,2 coefficients of the spherical harmonics
  116740. */
  116741. l22: Vector3;
  116742. /**
  116743. * Adds a light to the spherical harmonics
  116744. * @param direction the direction of the light
  116745. * @param color the color of the light
  116746. * @param deltaSolidAngle the delta solid angle of the light
  116747. */
  116748. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116749. /**
  116750. * Scales the spherical harmonics by the given amount
  116751. * @param scale the amount to scale
  116752. */
  116753. scaleInPlace(scale: number): void;
  116754. /**
  116755. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116756. *
  116757. * ```
  116758. * E_lm = A_l * L_lm
  116759. * ```
  116760. *
  116761. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116762. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116763. * the scaling factors are given in equation 9.
  116764. */
  116765. convertIncidentRadianceToIrradiance(): void;
  116766. /**
  116767. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116768. *
  116769. * ```
  116770. * L = (1/pi) * E * rho
  116771. * ```
  116772. *
  116773. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116774. */
  116775. convertIrradianceToLambertianRadiance(): void;
  116776. /**
  116777. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116778. * required operations at run time.
  116779. *
  116780. * This is simply done by scaling back the SH with Ylm constants parameter.
  116781. * The trigonometric part being applied by the shader at run time.
  116782. */
  116783. preScaleForRendering(): void;
  116784. /**
  116785. * Constructs a spherical harmonics from an array.
  116786. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116787. * @returns the spherical harmonics
  116788. */
  116789. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116790. /**
  116791. * Gets the spherical harmonics from polynomial
  116792. * @param polynomial the spherical polynomial
  116793. * @returns the spherical harmonics
  116794. */
  116795. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116796. }
  116797. /**
  116798. * Class representing spherical polynomial coefficients to the 3rd degree
  116799. */
  116800. export class SphericalPolynomial {
  116801. private _harmonics;
  116802. /**
  116803. * The spherical harmonics used to create the polynomials.
  116804. */
  116805. get preScaledHarmonics(): SphericalHarmonics;
  116806. /**
  116807. * The x coefficients of the spherical polynomial
  116808. */
  116809. x: Vector3;
  116810. /**
  116811. * The y coefficients of the spherical polynomial
  116812. */
  116813. y: Vector3;
  116814. /**
  116815. * The z coefficients of the spherical polynomial
  116816. */
  116817. z: Vector3;
  116818. /**
  116819. * The xx coefficients of the spherical polynomial
  116820. */
  116821. xx: Vector3;
  116822. /**
  116823. * The yy coefficients of the spherical polynomial
  116824. */
  116825. yy: Vector3;
  116826. /**
  116827. * The zz coefficients of the spherical polynomial
  116828. */
  116829. zz: Vector3;
  116830. /**
  116831. * The xy coefficients of the spherical polynomial
  116832. */
  116833. xy: Vector3;
  116834. /**
  116835. * The yz coefficients of the spherical polynomial
  116836. */
  116837. yz: Vector3;
  116838. /**
  116839. * The zx coefficients of the spherical polynomial
  116840. */
  116841. zx: Vector3;
  116842. /**
  116843. * Adds an ambient color to the spherical polynomial
  116844. * @param color the color to add
  116845. */
  116846. addAmbient(color: Color3): void;
  116847. /**
  116848. * Scales the spherical polynomial by the given amount
  116849. * @param scale the amount to scale
  116850. */
  116851. scaleInPlace(scale: number): void;
  116852. /**
  116853. * Gets the spherical polynomial from harmonics
  116854. * @param harmonics the spherical harmonics
  116855. * @returns the spherical polynomial
  116856. */
  116857. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116858. /**
  116859. * Constructs a spherical polynomial from an array.
  116860. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116861. * @returns the spherical polynomial
  116862. */
  116863. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116864. }
  116865. }
  116866. declare module BABYLON {
  116867. /**
  116868. * Defines the source of the internal texture
  116869. */
  116870. export enum InternalTextureSource {
  116871. /**
  116872. * The source of the texture data is unknown
  116873. */
  116874. Unknown = 0,
  116875. /**
  116876. * Texture data comes from an URL
  116877. */
  116878. Url = 1,
  116879. /**
  116880. * Texture data is only used for temporary storage
  116881. */
  116882. Temp = 2,
  116883. /**
  116884. * Texture data comes from raw data (ArrayBuffer)
  116885. */
  116886. Raw = 3,
  116887. /**
  116888. * Texture content is dynamic (video or dynamic texture)
  116889. */
  116890. Dynamic = 4,
  116891. /**
  116892. * Texture content is generated by rendering to it
  116893. */
  116894. RenderTarget = 5,
  116895. /**
  116896. * Texture content is part of a multi render target process
  116897. */
  116898. MultiRenderTarget = 6,
  116899. /**
  116900. * Texture data comes from a cube data file
  116901. */
  116902. Cube = 7,
  116903. /**
  116904. * Texture data comes from a raw cube data
  116905. */
  116906. CubeRaw = 8,
  116907. /**
  116908. * Texture data come from a prefiltered cube data file
  116909. */
  116910. CubePrefiltered = 9,
  116911. /**
  116912. * Texture content is raw 3D data
  116913. */
  116914. Raw3D = 10,
  116915. /**
  116916. * Texture content is raw 2D array data
  116917. */
  116918. Raw2DArray = 11,
  116919. /**
  116920. * Texture content is a depth texture
  116921. */
  116922. Depth = 12,
  116923. /**
  116924. * Texture data comes from a raw cube data encoded with RGBD
  116925. */
  116926. CubeRawRGBD = 13
  116927. }
  116928. /**
  116929. * Class used to store data associated with WebGL texture data for the engine
  116930. * This class should not be used directly
  116931. */
  116932. export class InternalTexture {
  116933. /** @hidden */
  116934. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116935. /**
  116936. * Defines if the texture is ready
  116937. */
  116938. isReady: boolean;
  116939. /**
  116940. * Defines if the texture is a cube texture
  116941. */
  116942. isCube: boolean;
  116943. /**
  116944. * Defines if the texture contains 3D data
  116945. */
  116946. is3D: boolean;
  116947. /**
  116948. * Defines if the texture contains 2D array data
  116949. */
  116950. is2DArray: boolean;
  116951. /**
  116952. * Defines if the texture contains multiview data
  116953. */
  116954. isMultiview: boolean;
  116955. /**
  116956. * Gets the URL used to load this texture
  116957. */
  116958. url: string;
  116959. /**
  116960. * Gets the sampling mode of the texture
  116961. */
  116962. samplingMode: number;
  116963. /**
  116964. * Gets a boolean indicating if the texture needs mipmaps generation
  116965. */
  116966. generateMipMaps: boolean;
  116967. /**
  116968. * Gets the number of samples used by the texture (WebGL2+ only)
  116969. */
  116970. samples: number;
  116971. /**
  116972. * Gets the type of the texture (int, float...)
  116973. */
  116974. type: number;
  116975. /**
  116976. * Gets the format of the texture (RGB, RGBA...)
  116977. */
  116978. format: number;
  116979. /**
  116980. * Observable called when the texture is loaded
  116981. */
  116982. onLoadedObservable: Observable<InternalTexture>;
  116983. /**
  116984. * Gets the width of the texture
  116985. */
  116986. width: number;
  116987. /**
  116988. * Gets the height of the texture
  116989. */
  116990. height: number;
  116991. /**
  116992. * Gets the depth of the texture
  116993. */
  116994. depth: number;
  116995. /**
  116996. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116997. */
  116998. baseWidth: number;
  116999. /**
  117000. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  117001. */
  117002. baseHeight: number;
  117003. /**
  117004. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117005. */
  117006. baseDepth: number;
  117007. /**
  117008. * Gets a boolean indicating if the texture is inverted on Y axis
  117009. */
  117010. invertY: boolean;
  117011. /** @hidden */
  117012. _invertVScale: boolean;
  117013. /** @hidden */
  117014. _associatedChannel: number;
  117015. /** @hidden */
  117016. _source: InternalTextureSource;
  117017. /** @hidden */
  117018. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117019. /** @hidden */
  117020. _bufferView: Nullable<ArrayBufferView>;
  117021. /** @hidden */
  117022. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117023. /** @hidden */
  117024. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117025. /** @hidden */
  117026. _size: number;
  117027. /** @hidden */
  117028. _extension: string;
  117029. /** @hidden */
  117030. _files: Nullable<string[]>;
  117031. /** @hidden */
  117032. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117033. /** @hidden */
  117034. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117035. /** @hidden */
  117036. _framebuffer: Nullable<WebGLFramebuffer>;
  117037. /** @hidden */
  117038. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117039. /** @hidden */
  117040. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117041. /** @hidden */
  117042. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117043. /** @hidden */
  117044. _attachments: Nullable<number[]>;
  117045. /** @hidden */
  117046. _textureArray: Nullable<InternalTexture[]>;
  117047. /** @hidden */
  117048. _cachedCoordinatesMode: Nullable<number>;
  117049. /** @hidden */
  117050. _cachedWrapU: Nullable<number>;
  117051. /** @hidden */
  117052. _cachedWrapV: Nullable<number>;
  117053. /** @hidden */
  117054. _cachedWrapR: Nullable<number>;
  117055. /** @hidden */
  117056. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117057. /** @hidden */
  117058. _isDisabled: boolean;
  117059. /** @hidden */
  117060. _compression: Nullable<string>;
  117061. /** @hidden */
  117062. _generateStencilBuffer: boolean;
  117063. /** @hidden */
  117064. _generateDepthBuffer: boolean;
  117065. /** @hidden */
  117066. _comparisonFunction: number;
  117067. /** @hidden */
  117068. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117069. /** @hidden */
  117070. _lodGenerationScale: number;
  117071. /** @hidden */
  117072. _lodGenerationOffset: number;
  117073. /** @hidden */
  117074. _depthStencilTexture: Nullable<InternalTexture>;
  117075. /** @hidden */
  117076. _colorTextureArray: Nullable<WebGLTexture>;
  117077. /** @hidden */
  117078. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117079. /** @hidden */
  117080. _lodTextureHigh: Nullable<BaseTexture>;
  117081. /** @hidden */
  117082. _lodTextureMid: Nullable<BaseTexture>;
  117083. /** @hidden */
  117084. _lodTextureLow: Nullable<BaseTexture>;
  117085. /** @hidden */
  117086. _isRGBD: boolean;
  117087. /** @hidden */
  117088. _linearSpecularLOD: boolean;
  117089. /** @hidden */
  117090. _irradianceTexture: Nullable<BaseTexture>;
  117091. /** @hidden */
  117092. _webGLTexture: Nullable<WebGLTexture>;
  117093. /** @hidden */
  117094. _references: number;
  117095. /** @hidden */
  117096. _gammaSpace: Nullable<boolean>;
  117097. private _engine;
  117098. /**
  117099. * Gets the Engine the texture belongs to.
  117100. * @returns The babylon engine
  117101. */
  117102. getEngine(): ThinEngine;
  117103. /**
  117104. * Gets the data source type of the texture
  117105. */
  117106. get source(): InternalTextureSource;
  117107. /**
  117108. * Creates a new InternalTexture
  117109. * @param engine defines the engine to use
  117110. * @param source defines the type of data that will be used
  117111. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117112. */
  117113. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117114. /**
  117115. * Increments the number of references (ie. the number of Texture that point to it)
  117116. */
  117117. incrementReferences(): void;
  117118. /**
  117119. * Change the size of the texture (not the size of the content)
  117120. * @param width defines the new width
  117121. * @param height defines the new height
  117122. * @param depth defines the new depth (1 by default)
  117123. */
  117124. updateSize(width: int, height: int, depth?: int): void;
  117125. /** @hidden */
  117126. _rebuild(): void;
  117127. /** @hidden */
  117128. _swapAndDie(target: InternalTexture): void;
  117129. /**
  117130. * Dispose the current allocated resources
  117131. */
  117132. dispose(): void;
  117133. }
  117134. }
  117135. declare module BABYLON {
  117136. /**
  117137. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117139. */
  117140. export class Analyser {
  117141. /**
  117142. * Gets or sets the smoothing
  117143. * @ignorenaming
  117144. */
  117145. SMOOTHING: number;
  117146. /**
  117147. * Gets or sets the FFT table size
  117148. * @ignorenaming
  117149. */
  117150. FFT_SIZE: number;
  117151. /**
  117152. * Gets or sets the bar graph amplitude
  117153. * @ignorenaming
  117154. */
  117155. BARGRAPHAMPLITUDE: number;
  117156. /**
  117157. * Gets or sets the position of the debug canvas
  117158. * @ignorenaming
  117159. */
  117160. DEBUGCANVASPOS: {
  117161. x: number;
  117162. y: number;
  117163. };
  117164. /**
  117165. * Gets or sets the debug canvas size
  117166. * @ignorenaming
  117167. */
  117168. DEBUGCANVASSIZE: {
  117169. width: number;
  117170. height: number;
  117171. };
  117172. private _byteFreqs;
  117173. private _byteTime;
  117174. private _floatFreqs;
  117175. private _webAudioAnalyser;
  117176. private _debugCanvas;
  117177. private _debugCanvasContext;
  117178. private _scene;
  117179. private _registerFunc;
  117180. private _audioEngine;
  117181. /**
  117182. * Creates a new analyser
  117183. * @param scene defines hosting scene
  117184. */
  117185. constructor(scene: Scene);
  117186. /**
  117187. * Get the number of data values you will have to play with for the visualization
  117188. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117189. * @returns a number
  117190. */
  117191. getFrequencyBinCount(): number;
  117192. /**
  117193. * Gets the current frequency data as a byte array
  117194. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117195. * @returns a Uint8Array
  117196. */
  117197. getByteFrequencyData(): Uint8Array;
  117198. /**
  117199. * Gets the current waveform as a byte array
  117200. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117201. * @returns a Uint8Array
  117202. */
  117203. getByteTimeDomainData(): Uint8Array;
  117204. /**
  117205. * Gets the current frequency data as a float array
  117206. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117207. * @returns a Float32Array
  117208. */
  117209. getFloatFrequencyData(): Float32Array;
  117210. /**
  117211. * Renders the debug canvas
  117212. */
  117213. drawDebugCanvas(): void;
  117214. /**
  117215. * Stops rendering the debug canvas and removes it
  117216. */
  117217. stopDebugCanvas(): void;
  117218. /**
  117219. * Connects two audio nodes
  117220. * @param inputAudioNode defines first node to connect
  117221. * @param outputAudioNode defines second node to connect
  117222. */
  117223. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117224. /**
  117225. * Releases all associated resources
  117226. */
  117227. dispose(): void;
  117228. }
  117229. }
  117230. declare module BABYLON {
  117231. /**
  117232. * This represents an audio engine and it is responsible
  117233. * to play, synchronize and analyse sounds throughout the application.
  117234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117235. */
  117236. export interface IAudioEngine extends IDisposable {
  117237. /**
  117238. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117239. */
  117240. readonly canUseWebAudio: boolean;
  117241. /**
  117242. * Gets the current AudioContext if available.
  117243. */
  117244. readonly audioContext: Nullable<AudioContext>;
  117245. /**
  117246. * The master gain node defines the global audio volume of your audio engine.
  117247. */
  117248. readonly masterGain: GainNode;
  117249. /**
  117250. * Gets whether or not mp3 are supported by your browser.
  117251. */
  117252. readonly isMP3supported: boolean;
  117253. /**
  117254. * Gets whether or not ogg are supported by your browser.
  117255. */
  117256. readonly isOGGsupported: boolean;
  117257. /**
  117258. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117259. * @ignoreNaming
  117260. */
  117261. WarnedWebAudioUnsupported: boolean;
  117262. /**
  117263. * Defines if the audio engine relies on a custom unlocked button.
  117264. * In this case, the embedded button will not be displayed.
  117265. */
  117266. useCustomUnlockedButton: boolean;
  117267. /**
  117268. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117269. */
  117270. readonly unlocked: boolean;
  117271. /**
  117272. * Event raised when audio has been unlocked on the browser.
  117273. */
  117274. onAudioUnlockedObservable: Observable<AudioEngine>;
  117275. /**
  117276. * Event raised when audio has been locked on the browser.
  117277. */
  117278. onAudioLockedObservable: Observable<AudioEngine>;
  117279. /**
  117280. * Flags the audio engine in Locked state.
  117281. * This happens due to new browser policies preventing audio to autoplay.
  117282. */
  117283. lock(): void;
  117284. /**
  117285. * Unlocks the audio engine once a user action has been done on the dom.
  117286. * This is helpful to resume play once browser policies have been satisfied.
  117287. */
  117288. unlock(): void;
  117289. /**
  117290. * Gets the global volume sets on the master gain.
  117291. * @returns the global volume if set or -1 otherwise
  117292. */
  117293. getGlobalVolume(): number;
  117294. /**
  117295. * Sets the global volume of your experience (sets on the master gain).
  117296. * @param newVolume Defines the new global volume of the application
  117297. */
  117298. setGlobalVolume(newVolume: number): void;
  117299. /**
  117300. * Connect the audio engine to an audio analyser allowing some amazing
  117301. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117302. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117303. * @param analyser The analyser to connect to the engine
  117304. */
  117305. connectToAnalyser(analyser: Analyser): void;
  117306. }
  117307. /**
  117308. * This represents the default audio engine used in babylon.
  117309. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117310. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117311. */
  117312. export class AudioEngine implements IAudioEngine {
  117313. private _audioContext;
  117314. private _audioContextInitialized;
  117315. private _muteButton;
  117316. private _hostElement;
  117317. /**
  117318. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117319. */
  117320. canUseWebAudio: boolean;
  117321. /**
  117322. * The master gain node defines the global audio volume of your audio engine.
  117323. */
  117324. masterGain: GainNode;
  117325. /**
  117326. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117327. * @ignoreNaming
  117328. */
  117329. WarnedWebAudioUnsupported: boolean;
  117330. /**
  117331. * Gets whether or not mp3 are supported by your browser.
  117332. */
  117333. isMP3supported: boolean;
  117334. /**
  117335. * Gets whether or not ogg are supported by your browser.
  117336. */
  117337. isOGGsupported: boolean;
  117338. /**
  117339. * Gets whether audio has been unlocked on the device.
  117340. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117341. * a user interaction has happened.
  117342. */
  117343. unlocked: boolean;
  117344. /**
  117345. * Defines if the audio engine relies on a custom unlocked button.
  117346. * In this case, the embedded button will not be displayed.
  117347. */
  117348. useCustomUnlockedButton: boolean;
  117349. /**
  117350. * Event raised when audio has been unlocked on the browser.
  117351. */
  117352. onAudioUnlockedObservable: Observable<AudioEngine>;
  117353. /**
  117354. * Event raised when audio has been locked on the browser.
  117355. */
  117356. onAudioLockedObservable: Observable<AudioEngine>;
  117357. /**
  117358. * Gets the current AudioContext if available.
  117359. */
  117360. get audioContext(): Nullable<AudioContext>;
  117361. private _connectedAnalyser;
  117362. /**
  117363. * Instantiates a new audio engine.
  117364. *
  117365. * There should be only one per page as some browsers restrict the number
  117366. * of audio contexts you can create.
  117367. * @param hostElement defines the host element where to display the mute icon if necessary
  117368. */
  117369. constructor(hostElement?: Nullable<HTMLElement>);
  117370. /**
  117371. * Flags the audio engine in Locked state.
  117372. * This happens due to new browser policies preventing audio to autoplay.
  117373. */
  117374. lock(): void;
  117375. /**
  117376. * Unlocks the audio engine once a user action has been done on the dom.
  117377. * This is helpful to resume play once browser policies have been satisfied.
  117378. */
  117379. unlock(): void;
  117380. private _resumeAudioContext;
  117381. private _initializeAudioContext;
  117382. private _tryToRun;
  117383. private _triggerRunningState;
  117384. private _triggerSuspendedState;
  117385. private _displayMuteButton;
  117386. private _moveButtonToTopLeft;
  117387. private _onResize;
  117388. private _hideMuteButton;
  117389. /**
  117390. * Destroy and release the resources associated with the audio ccontext.
  117391. */
  117392. dispose(): void;
  117393. /**
  117394. * Gets the global volume sets on the master gain.
  117395. * @returns the global volume if set or -1 otherwise
  117396. */
  117397. getGlobalVolume(): number;
  117398. /**
  117399. * Sets the global volume of your experience (sets on the master gain).
  117400. * @param newVolume Defines the new global volume of the application
  117401. */
  117402. setGlobalVolume(newVolume: number): void;
  117403. /**
  117404. * Connect the audio engine to an audio analyser allowing some amazing
  117405. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117407. * @param analyser The analyser to connect to the engine
  117408. */
  117409. connectToAnalyser(analyser: Analyser): void;
  117410. }
  117411. }
  117412. declare module BABYLON {
  117413. /**
  117414. * Interface used to present a loading screen while loading a scene
  117415. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117416. */
  117417. export interface ILoadingScreen {
  117418. /**
  117419. * Function called to display the loading screen
  117420. */
  117421. displayLoadingUI: () => void;
  117422. /**
  117423. * Function called to hide the loading screen
  117424. */
  117425. hideLoadingUI: () => void;
  117426. /**
  117427. * Gets or sets the color to use for the background
  117428. */
  117429. loadingUIBackgroundColor: string;
  117430. /**
  117431. * Gets or sets the text to display while loading
  117432. */
  117433. loadingUIText: string;
  117434. }
  117435. /**
  117436. * Class used for the default loading screen
  117437. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117438. */
  117439. export class DefaultLoadingScreen implements ILoadingScreen {
  117440. private _renderingCanvas;
  117441. private _loadingText;
  117442. private _loadingDivBackgroundColor;
  117443. private _loadingDiv;
  117444. private _loadingTextDiv;
  117445. /** Gets or sets the logo url to use for the default loading screen */
  117446. static DefaultLogoUrl: string;
  117447. /** Gets or sets the spinner url to use for the default loading screen */
  117448. static DefaultSpinnerUrl: string;
  117449. /**
  117450. * Creates a new default loading screen
  117451. * @param _renderingCanvas defines the canvas used to render the scene
  117452. * @param _loadingText defines the default text to display
  117453. * @param _loadingDivBackgroundColor defines the default background color
  117454. */
  117455. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117456. /**
  117457. * Function called to display the loading screen
  117458. */
  117459. displayLoadingUI(): void;
  117460. /**
  117461. * Function called to hide the loading screen
  117462. */
  117463. hideLoadingUI(): void;
  117464. /**
  117465. * Gets or sets the text to display while loading
  117466. */
  117467. set loadingUIText(text: string);
  117468. get loadingUIText(): string;
  117469. /**
  117470. * Gets or sets the color to use for the background
  117471. */
  117472. get loadingUIBackgroundColor(): string;
  117473. set loadingUIBackgroundColor(color: string);
  117474. private _resizeLoadingUI;
  117475. }
  117476. }
  117477. declare module BABYLON {
  117478. /**
  117479. * Interface for any object that can request an animation frame
  117480. */
  117481. export interface ICustomAnimationFrameRequester {
  117482. /**
  117483. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117484. */
  117485. renderFunction?: Function;
  117486. /**
  117487. * Called to request the next frame to render to
  117488. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117489. */
  117490. requestAnimationFrame: Function;
  117491. /**
  117492. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117493. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117494. */
  117495. requestID?: number;
  117496. }
  117497. }
  117498. declare module BABYLON {
  117499. /**
  117500. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117501. */
  117502. export class PerformanceMonitor {
  117503. private _enabled;
  117504. private _rollingFrameTime;
  117505. private _lastFrameTimeMs;
  117506. /**
  117507. * constructor
  117508. * @param frameSampleSize The number of samples required to saturate the sliding window
  117509. */
  117510. constructor(frameSampleSize?: number);
  117511. /**
  117512. * Samples current frame
  117513. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117514. */
  117515. sampleFrame(timeMs?: number): void;
  117516. /**
  117517. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117518. */
  117519. get averageFrameTime(): number;
  117520. /**
  117521. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117522. */
  117523. get averageFrameTimeVariance(): number;
  117524. /**
  117525. * Returns the frame time of the most recent frame
  117526. */
  117527. get instantaneousFrameTime(): number;
  117528. /**
  117529. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117530. */
  117531. get averageFPS(): number;
  117532. /**
  117533. * Returns the average framerate in frames per second using the most recent frame time
  117534. */
  117535. get instantaneousFPS(): number;
  117536. /**
  117537. * Returns true if enough samples have been taken to completely fill the sliding window
  117538. */
  117539. get isSaturated(): boolean;
  117540. /**
  117541. * Enables contributions to the sliding window sample set
  117542. */
  117543. enable(): void;
  117544. /**
  117545. * Disables contributions to the sliding window sample set
  117546. * Samples will not be interpolated over the disabled period
  117547. */
  117548. disable(): void;
  117549. /**
  117550. * Returns true if sampling is enabled
  117551. */
  117552. get isEnabled(): boolean;
  117553. /**
  117554. * Resets performance monitor
  117555. */
  117556. reset(): void;
  117557. }
  117558. /**
  117559. * RollingAverage
  117560. *
  117561. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117562. */
  117563. export class RollingAverage {
  117564. /**
  117565. * Current average
  117566. */
  117567. average: number;
  117568. /**
  117569. * Current variance
  117570. */
  117571. variance: number;
  117572. protected _samples: Array<number>;
  117573. protected _sampleCount: number;
  117574. protected _pos: number;
  117575. protected _m2: number;
  117576. /**
  117577. * constructor
  117578. * @param length The number of samples required to saturate the sliding window
  117579. */
  117580. constructor(length: number);
  117581. /**
  117582. * Adds a sample to the sample set
  117583. * @param v The sample value
  117584. */
  117585. add(v: number): void;
  117586. /**
  117587. * Returns previously added values or null if outside of history or outside the sliding window domain
  117588. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117589. * @return Value previously recorded with add() or null if outside of range
  117590. */
  117591. history(i: number): number;
  117592. /**
  117593. * Returns true if enough samples have been taken to completely fill the sliding window
  117594. * @return true if sample-set saturated
  117595. */
  117596. isSaturated(): boolean;
  117597. /**
  117598. * Resets the rolling average (equivalent to 0 samples taken so far)
  117599. */
  117600. reset(): void;
  117601. /**
  117602. * Wraps a value around the sample range boundaries
  117603. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117604. * @return Wrapped position in sample range
  117605. */
  117606. protected _wrapPosition(i: number): number;
  117607. }
  117608. }
  117609. declare module BABYLON {
  117610. /**
  117611. * This class is used to track a performance counter which is number based.
  117612. * The user has access to many properties which give statistics of different nature.
  117613. *
  117614. * The implementer can track two kinds of Performance Counter: time and count.
  117615. * 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.
  117616. * 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.
  117617. */
  117618. export class PerfCounter {
  117619. /**
  117620. * Gets or sets a global boolean to turn on and off all the counters
  117621. */
  117622. static Enabled: boolean;
  117623. /**
  117624. * Returns the smallest value ever
  117625. */
  117626. get min(): number;
  117627. /**
  117628. * Returns the biggest value ever
  117629. */
  117630. get max(): number;
  117631. /**
  117632. * Returns the average value since the performance counter is running
  117633. */
  117634. get average(): number;
  117635. /**
  117636. * Returns the average value of the last second the counter was monitored
  117637. */
  117638. get lastSecAverage(): number;
  117639. /**
  117640. * Returns the current value
  117641. */
  117642. get current(): number;
  117643. /**
  117644. * Gets the accumulated total
  117645. */
  117646. get total(): number;
  117647. /**
  117648. * Gets the total value count
  117649. */
  117650. get count(): number;
  117651. /**
  117652. * Creates a new counter
  117653. */
  117654. constructor();
  117655. /**
  117656. * Call this method to start monitoring a new frame.
  117657. * 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.
  117658. */
  117659. fetchNewFrame(): void;
  117660. /**
  117661. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117662. * @param newCount the count value to add to the monitored count
  117663. * @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.
  117664. */
  117665. addCount(newCount: number, fetchResult: boolean): void;
  117666. /**
  117667. * Start monitoring this performance counter
  117668. */
  117669. beginMonitoring(): void;
  117670. /**
  117671. * Compute the time lapsed since the previous beginMonitoring() call.
  117672. * @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
  117673. */
  117674. endMonitoring(newFrame?: boolean): void;
  117675. private _fetchResult;
  117676. private _startMonitoringTime;
  117677. private _min;
  117678. private _max;
  117679. private _average;
  117680. private _current;
  117681. private _totalValueCount;
  117682. private _totalAccumulated;
  117683. private _lastSecAverage;
  117684. private _lastSecAccumulated;
  117685. private _lastSecTime;
  117686. private _lastSecValueCount;
  117687. }
  117688. }
  117689. declare module BABYLON {
  117690. interface ThinEngine {
  117691. /** @hidden */
  117692. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117693. }
  117694. }
  117695. declare module BABYLON {
  117696. /**
  117697. * Defines the interface used by display changed events
  117698. */
  117699. export interface IDisplayChangedEventArgs {
  117700. /** Gets the vrDisplay object (if any) */
  117701. vrDisplay: Nullable<any>;
  117702. /** Gets a boolean indicating if webVR is supported */
  117703. vrSupported: boolean;
  117704. }
  117705. /**
  117706. * Defines the interface used by objects containing a viewport (like a camera)
  117707. */
  117708. interface IViewportOwnerLike {
  117709. /**
  117710. * Gets or sets the viewport
  117711. */
  117712. viewport: IViewportLike;
  117713. }
  117714. /**
  117715. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117716. */
  117717. export class Engine extends ThinEngine {
  117718. /** Defines that alpha blending is disabled */
  117719. static readonly ALPHA_DISABLE: number;
  117720. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117721. static readonly ALPHA_ADD: number;
  117722. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117723. static readonly ALPHA_COMBINE: number;
  117724. /** Defines that alpha blending to DEST - SRC * DEST */
  117725. static readonly ALPHA_SUBTRACT: number;
  117726. /** Defines that alpha blending to SRC * DEST */
  117727. static readonly ALPHA_MULTIPLY: number;
  117728. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117729. static readonly ALPHA_MAXIMIZED: number;
  117730. /** Defines that alpha blending to SRC + DEST */
  117731. static readonly ALPHA_ONEONE: number;
  117732. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117733. static readonly ALPHA_PREMULTIPLIED: number;
  117734. /**
  117735. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117736. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117737. */
  117738. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117739. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117740. static readonly ALPHA_INTERPOLATE: number;
  117741. /**
  117742. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117743. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117744. */
  117745. static readonly ALPHA_SCREENMODE: number;
  117746. /** Defines that the ressource is not delayed*/
  117747. static readonly DELAYLOADSTATE_NONE: number;
  117748. /** Defines that the ressource was successfully delay loaded */
  117749. static readonly DELAYLOADSTATE_LOADED: number;
  117750. /** Defines that the ressource is currently delay loading */
  117751. static readonly DELAYLOADSTATE_LOADING: number;
  117752. /** Defines that the ressource is delayed and has not started loading */
  117753. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117754. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117755. static readonly NEVER: number;
  117756. /** 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 */
  117757. static readonly ALWAYS: number;
  117758. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117759. static readonly LESS: number;
  117760. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117761. static readonly EQUAL: number;
  117762. /** 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 */
  117763. static readonly LEQUAL: number;
  117764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117765. static readonly GREATER: number;
  117766. /** 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 */
  117767. static readonly GEQUAL: number;
  117768. /** 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 */
  117769. static readonly NOTEQUAL: number;
  117770. /** Passed to stencilOperation to specify that stencil value must be kept */
  117771. static readonly KEEP: number;
  117772. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117773. static readonly REPLACE: number;
  117774. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117775. static readonly INCR: number;
  117776. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117777. static readonly DECR: number;
  117778. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117779. static readonly INVERT: number;
  117780. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117781. static readonly INCR_WRAP: number;
  117782. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117783. static readonly DECR_WRAP: number;
  117784. /** Texture is not repeating outside of 0..1 UVs */
  117785. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117786. /** Texture is repeating outside of 0..1 UVs */
  117787. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117788. /** Texture is repeating and mirrored */
  117789. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117790. /** ALPHA */
  117791. static readonly TEXTUREFORMAT_ALPHA: number;
  117792. /** LUMINANCE */
  117793. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117794. /** LUMINANCE_ALPHA */
  117795. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117796. /** RGB */
  117797. static readonly TEXTUREFORMAT_RGB: number;
  117798. /** RGBA */
  117799. static readonly TEXTUREFORMAT_RGBA: number;
  117800. /** RED */
  117801. static readonly TEXTUREFORMAT_RED: number;
  117802. /** RED (2nd reference) */
  117803. static readonly TEXTUREFORMAT_R: number;
  117804. /** RG */
  117805. static readonly TEXTUREFORMAT_RG: number;
  117806. /** RED_INTEGER */
  117807. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117808. /** RED_INTEGER (2nd reference) */
  117809. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117810. /** RG_INTEGER */
  117811. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117812. /** RGB_INTEGER */
  117813. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117814. /** RGBA_INTEGER */
  117815. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117816. /** UNSIGNED_BYTE */
  117817. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117818. /** UNSIGNED_BYTE (2nd reference) */
  117819. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117820. /** FLOAT */
  117821. static readonly TEXTURETYPE_FLOAT: number;
  117822. /** HALF_FLOAT */
  117823. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117824. /** BYTE */
  117825. static readonly TEXTURETYPE_BYTE: number;
  117826. /** SHORT */
  117827. static readonly TEXTURETYPE_SHORT: number;
  117828. /** UNSIGNED_SHORT */
  117829. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117830. /** INT */
  117831. static readonly TEXTURETYPE_INT: number;
  117832. /** UNSIGNED_INT */
  117833. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117834. /** UNSIGNED_SHORT_4_4_4_4 */
  117835. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117836. /** UNSIGNED_SHORT_5_5_5_1 */
  117837. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117838. /** UNSIGNED_SHORT_5_6_5 */
  117839. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117840. /** UNSIGNED_INT_2_10_10_10_REV */
  117841. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117842. /** UNSIGNED_INT_24_8 */
  117843. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117844. /** UNSIGNED_INT_10F_11F_11F_REV */
  117845. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117846. /** UNSIGNED_INT_5_9_9_9_REV */
  117847. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117848. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117849. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117850. /** nearest is mag = nearest and min = nearest and mip = linear */
  117851. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117852. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117853. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117854. /** Trilinear is mag = linear and min = linear and mip = linear */
  117855. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117856. /** nearest is mag = nearest and min = nearest and mip = linear */
  117857. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117858. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117859. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117860. /** Trilinear is mag = linear and min = linear and mip = linear */
  117861. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117862. /** mag = nearest and min = nearest and mip = nearest */
  117863. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117864. /** mag = nearest and min = linear and mip = nearest */
  117865. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117866. /** mag = nearest and min = linear and mip = linear */
  117867. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117868. /** mag = nearest and min = linear and mip = none */
  117869. static readonly TEXTURE_NEAREST_LINEAR: number;
  117870. /** mag = nearest and min = nearest and mip = none */
  117871. static readonly TEXTURE_NEAREST_NEAREST: number;
  117872. /** mag = linear and min = nearest and mip = nearest */
  117873. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117874. /** mag = linear and min = nearest and mip = linear */
  117875. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117876. /** mag = linear and min = linear and mip = none */
  117877. static readonly TEXTURE_LINEAR_LINEAR: number;
  117878. /** mag = linear and min = nearest and mip = none */
  117879. static readonly TEXTURE_LINEAR_NEAREST: number;
  117880. /** Explicit coordinates mode */
  117881. static readonly TEXTURE_EXPLICIT_MODE: number;
  117882. /** Spherical coordinates mode */
  117883. static readonly TEXTURE_SPHERICAL_MODE: number;
  117884. /** Planar coordinates mode */
  117885. static readonly TEXTURE_PLANAR_MODE: number;
  117886. /** Cubic coordinates mode */
  117887. static readonly TEXTURE_CUBIC_MODE: number;
  117888. /** Projection coordinates mode */
  117889. static readonly TEXTURE_PROJECTION_MODE: number;
  117890. /** Skybox coordinates mode */
  117891. static readonly TEXTURE_SKYBOX_MODE: number;
  117892. /** Inverse Cubic coordinates mode */
  117893. static readonly TEXTURE_INVCUBIC_MODE: number;
  117894. /** Equirectangular coordinates mode */
  117895. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117896. /** Equirectangular Fixed coordinates mode */
  117897. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117898. /** Equirectangular Fixed Mirrored coordinates mode */
  117899. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117900. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117901. static readonly SCALEMODE_FLOOR: number;
  117902. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117903. static readonly SCALEMODE_NEAREST: number;
  117904. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117905. static readonly SCALEMODE_CEILING: number;
  117906. /**
  117907. * Returns the current npm package of the sdk
  117908. */
  117909. static get NpmPackage(): string;
  117910. /**
  117911. * Returns the current version of the framework
  117912. */
  117913. static get Version(): string;
  117914. /** Gets the list of created engines */
  117915. static get Instances(): Engine[];
  117916. /**
  117917. * Gets the latest created engine
  117918. */
  117919. static get LastCreatedEngine(): Nullable<Engine>;
  117920. /**
  117921. * Gets the latest created scene
  117922. */
  117923. static get LastCreatedScene(): Nullable<Scene>;
  117924. /**
  117925. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117926. * @param flag defines which part of the materials must be marked as dirty
  117927. * @param predicate defines a predicate used to filter which materials should be affected
  117928. */
  117929. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117930. /**
  117931. * Method called to create the default loading screen.
  117932. * This can be overriden in your own app.
  117933. * @param canvas The rendering canvas element
  117934. * @returns The loading screen
  117935. */
  117936. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117937. /**
  117938. * Method called to create the default rescale post process on each engine.
  117939. */
  117940. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117941. /**
  117942. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117943. **/
  117944. enableOfflineSupport: boolean;
  117945. /**
  117946. * 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)
  117947. **/
  117948. disableManifestCheck: boolean;
  117949. /**
  117950. * Gets the list of created scenes
  117951. */
  117952. scenes: Scene[];
  117953. /**
  117954. * Event raised when a new scene is created
  117955. */
  117956. onNewSceneAddedObservable: Observable<Scene>;
  117957. /**
  117958. * Gets the list of created postprocesses
  117959. */
  117960. postProcesses: PostProcess[];
  117961. /**
  117962. * Gets a boolean indicating if the pointer is currently locked
  117963. */
  117964. isPointerLock: boolean;
  117965. /**
  117966. * Observable event triggered each time the rendering canvas is resized
  117967. */
  117968. onResizeObservable: Observable<Engine>;
  117969. /**
  117970. * Observable event triggered each time the canvas loses focus
  117971. */
  117972. onCanvasBlurObservable: Observable<Engine>;
  117973. /**
  117974. * Observable event triggered each time the canvas gains focus
  117975. */
  117976. onCanvasFocusObservable: Observable<Engine>;
  117977. /**
  117978. * Observable event triggered each time the canvas receives pointerout event
  117979. */
  117980. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117981. /**
  117982. * Observable raised when the engine begins a new frame
  117983. */
  117984. onBeginFrameObservable: Observable<Engine>;
  117985. /**
  117986. * If set, will be used to request the next animation frame for the render loop
  117987. */
  117988. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117989. /**
  117990. * Observable raised when the engine ends the current frame
  117991. */
  117992. onEndFrameObservable: Observable<Engine>;
  117993. /**
  117994. * Observable raised when the engine is about to compile a shader
  117995. */
  117996. onBeforeShaderCompilationObservable: Observable<Engine>;
  117997. /**
  117998. * Observable raised when the engine has jsut compiled a shader
  117999. */
  118000. onAfterShaderCompilationObservable: Observable<Engine>;
  118001. /**
  118002. * Gets the audio engine
  118003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118004. * @ignorenaming
  118005. */
  118006. static audioEngine: IAudioEngine;
  118007. /**
  118008. * Default AudioEngine factory responsible of creating the Audio Engine.
  118009. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118010. */
  118011. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118012. /**
  118013. * Default offline support factory responsible of creating a tool used to store data locally.
  118014. * By default, this will create a Database object if the workload has been embedded.
  118015. */
  118016. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118017. private _loadingScreen;
  118018. private _pointerLockRequested;
  118019. private _rescalePostProcess;
  118020. private _deterministicLockstep;
  118021. private _lockstepMaxSteps;
  118022. private _timeStep;
  118023. protected get _supportsHardwareTextureRescaling(): boolean;
  118024. private _fps;
  118025. private _deltaTime;
  118026. /** @hidden */
  118027. _drawCalls: PerfCounter;
  118028. /** 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 */
  118029. canvasTabIndex: number;
  118030. /**
  118031. * Turn this value on if you want to pause FPS computation when in background
  118032. */
  118033. disablePerformanceMonitorInBackground: boolean;
  118034. private _performanceMonitor;
  118035. /**
  118036. * Gets the performance monitor attached to this engine
  118037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118038. */
  118039. get performanceMonitor(): PerformanceMonitor;
  118040. private _onFocus;
  118041. private _onBlur;
  118042. private _onCanvasPointerOut;
  118043. private _onCanvasBlur;
  118044. private _onCanvasFocus;
  118045. private _onFullscreenChange;
  118046. private _onPointerLockChange;
  118047. /**
  118048. * Gets the HTML element used to attach event listeners
  118049. * @returns a HTML element
  118050. */
  118051. getInputElement(): Nullable<HTMLElement>;
  118052. /**
  118053. * Creates a new engine
  118054. * @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
  118055. * @param antialias defines enable antialiasing (default: false)
  118056. * @param options defines further options to be sent to the getContext() function
  118057. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118058. */
  118059. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118060. /**
  118061. * Gets current aspect ratio
  118062. * @param viewportOwner defines the camera to use to get the aspect ratio
  118063. * @param useScreen defines if screen size must be used (or the current render target if any)
  118064. * @returns a number defining the aspect ratio
  118065. */
  118066. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118067. /**
  118068. * Gets current screen aspect ratio
  118069. * @returns a number defining the aspect ratio
  118070. */
  118071. getScreenAspectRatio(): number;
  118072. /**
  118073. * Gets the client rect of the HTML canvas attached with the current webGL context
  118074. * @returns a client rectanglee
  118075. */
  118076. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118077. /**
  118078. * Gets the client rect of the HTML element used for events
  118079. * @returns a client rectanglee
  118080. */
  118081. getInputElementClientRect(): Nullable<ClientRect>;
  118082. /**
  118083. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118084. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118085. * @returns true if engine is in deterministic lock step mode
  118086. */
  118087. isDeterministicLockStep(): boolean;
  118088. /**
  118089. * Gets the max steps when engine is running in deterministic lock step
  118090. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118091. * @returns the max steps
  118092. */
  118093. getLockstepMaxSteps(): number;
  118094. /**
  118095. * Returns the time in ms between steps when using deterministic lock step.
  118096. * @returns time step in (ms)
  118097. */
  118098. getTimeStep(): number;
  118099. /**
  118100. * Force the mipmap generation for the given render target texture
  118101. * @param texture defines the render target texture to use
  118102. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118103. */
  118104. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118105. /** States */
  118106. /**
  118107. * Set various states to the webGL context
  118108. * @param culling defines backface culling state
  118109. * @param zOffset defines the value to apply to zOffset (0 by default)
  118110. * @param force defines if states must be applied even if cache is up to date
  118111. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118112. */
  118113. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118114. /**
  118115. * Set the z offset to apply to current rendering
  118116. * @param value defines the offset to apply
  118117. */
  118118. setZOffset(value: number): void;
  118119. /**
  118120. * Gets the current value of the zOffset
  118121. * @returns the current zOffset state
  118122. */
  118123. getZOffset(): number;
  118124. /**
  118125. * Enable or disable depth buffering
  118126. * @param enable defines the state to set
  118127. */
  118128. setDepthBuffer(enable: boolean): void;
  118129. /**
  118130. * Gets a boolean indicating if depth writing is enabled
  118131. * @returns the current depth writing state
  118132. */
  118133. getDepthWrite(): boolean;
  118134. /**
  118135. * Enable or disable depth writing
  118136. * @param enable defines the state to set
  118137. */
  118138. setDepthWrite(enable: boolean): void;
  118139. /**
  118140. * Gets a boolean indicating if stencil buffer is enabled
  118141. * @returns the current stencil buffer state
  118142. */
  118143. getStencilBuffer(): boolean;
  118144. /**
  118145. * Enable or disable the stencil buffer
  118146. * @param enable defines if the stencil buffer must be enabled or disabled
  118147. */
  118148. setStencilBuffer(enable: boolean): void;
  118149. /**
  118150. * Gets the current stencil mask
  118151. * @returns a number defining the new stencil mask to use
  118152. */
  118153. getStencilMask(): number;
  118154. /**
  118155. * Sets the current stencil mask
  118156. * @param mask defines the new stencil mask to use
  118157. */
  118158. setStencilMask(mask: number): void;
  118159. /**
  118160. * Gets the current stencil function
  118161. * @returns a number defining the stencil function to use
  118162. */
  118163. getStencilFunction(): number;
  118164. /**
  118165. * Gets the current stencil reference value
  118166. * @returns a number defining the stencil reference value to use
  118167. */
  118168. getStencilFunctionReference(): number;
  118169. /**
  118170. * Gets the current stencil mask
  118171. * @returns a number defining the stencil mask to use
  118172. */
  118173. getStencilFunctionMask(): number;
  118174. /**
  118175. * Sets the current stencil function
  118176. * @param stencilFunc defines the new stencil function to use
  118177. */
  118178. setStencilFunction(stencilFunc: number): void;
  118179. /**
  118180. * Sets the current stencil reference
  118181. * @param reference defines the new stencil reference to use
  118182. */
  118183. setStencilFunctionReference(reference: number): void;
  118184. /**
  118185. * Sets the current stencil mask
  118186. * @param mask defines the new stencil mask to use
  118187. */
  118188. setStencilFunctionMask(mask: number): void;
  118189. /**
  118190. * Gets the current stencil operation when stencil fails
  118191. * @returns a number defining stencil operation to use when stencil fails
  118192. */
  118193. getStencilOperationFail(): number;
  118194. /**
  118195. * Gets the current stencil operation when depth fails
  118196. * @returns a number defining stencil operation to use when depth fails
  118197. */
  118198. getStencilOperationDepthFail(): number;
  118199. /**
  118200. * Gets the current stencil operation when stencil passes
  118201. * @returns a number defining stencil operation to use when stencil passes
  118202. */
  118203. getStencilOperationPass(): number;
  118204. /**
  118205. * Sets the stencil operation to use when stencil fails
  118206. * @param operation defines the stencil operation to use when stencil fails
  118207. */
  118208. setStencilOperationFail(operation: number): void;
  118209. /**
  118210. * Sets the stencil operation to use when depth fails
  118211. * @param operation defines the stencil operation to use when depth fails
  118212. */
  118213. setStencilOperationDepthFail(operation: number): void;
  118214. /**
  118215. * Sets the stencil operation to use when stencil passes
  118216. * @param operation defines the stencil operation to use when stencil passes
  118217. */
  118218. setStencilOperationPass(operation: number): void;
  118219. /**
  118220. * Sets a boolean indicating if the dithering state is enabled or disabled
  118221. * @param value defines the dithering state
  118222. */
  118223. setDitheringState(value: boolean): void;
  118224. /**
  118225. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118226. * @param value defines the rasterizer state
  118227. */
  118228. setRasterizerState(value: boolean): void;
  118229. /**
  118230. * Gets the current depth function
  118231. * @returns a number defining the depth function
  118232. */
  118233. getDepthFunction(): Nullable<number>;
  118234. /**
  118235. * Sets the current depth function
  118236. * @param depthFunc defines the function to use
  118237. */
  118238. setDepthFunction(depthFunc: number): void;
  118239. /**
  118240. * Sets the current depth function to GREATER
  118241. */
  118242. setDepthFunctionToGreater(): void;
  118243. /**
  118244. * Sets the current depth function to GEQUAL
  118245. */
  118246. setDepthFunctionToGreaterOrEqual(): void;
  118247. /**
  118248. * Sets the current depth function to LESS
  118249. */
  118250. setDepthFunctionToLess(): void;
  118251. /**
  118252. * Sets the current depth function to LEQUAL
  118253. */
  118254. setDepthFunctionToLessOrEqual(): void;
  118255. private _cachedStencilBuffer;
  118256. private _cachedStencilFunction;
  118257. private _cachedStencilMask;
  118258. private _cachedStencilOperationPass;
  118259. private _cachedStencilOperationFail;
  118260. private _cachedStencilOperationDepthFail;
  118261. private _cachedStencilReference;
  118262. /**
  118263. * Caches the the state of the stencil buffer
  118264. */
  118265. cacheStencilState(): void;
  118266. /**
  118267. * Restores the state of the stencil buffer
  118268. */
  118269. restoreStencilState(): void;
  118270. /**
  118271. * Directly set the WebGL Viewport
  118272. * @param x defines the x coordinate of the viewport (in screen space)
  118273. * @param y defines the y coordinate of the viewport (in screen space)
  118274. * @param width defines the width of the viewport (in screen space)
  118275. * @param height defines the height of the viewport (in screen space)
  118276. * @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
  118277. */
  118278. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118279. /**
  118280. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118281. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118282. * @param y defines the y-coordinate of the corner of the clear rectangle
  118283. * @param width defines the width of the clear rectangle
  118284. * @param height defines the height of the clear rectangle
  118285. * @param clearColor defines the clear color
  118286. */
  118287. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118288. /**
  118289. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118290. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118291. * @param y defines the y-coordinate of the corner of the clear rectangle
  118292. * @param width defines the width of the clear rectangle
  118293. * @param height defines the height of the clear rectangle
  118294. */
  118295. enableScissor(x: number, y: number, width: number, height: number): void;
  118296. /**
  118297. * Disable previously set scissor test rectangle
  118298. */
  118299. disableScissor(): void;
  118300. protected _reportDrawCall(): void;
  118301. /**
  118302. * Initializes a webVR display and starts listening to display change events
  118303. * The onVRDisplayChangedObservable will be notified upon these changes
  118304. * @returns The onVRDisplayChangedObservable
  118305. */
  118306. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118307. /** @hidden */
  118308. _prepareVRComponent(): void;
  118309. /** @hidden */
  118310. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118311. /** @hidden */
  118312. _submitVRFrame(): void;
  118313. /**
  118314. * Call this function to leave webVR mode
  118315. * Will do nothing if webVR is not supported or if there is no webVR device
  118316. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118317. */
  118318. disableVR(): void;
  118319. /**
  118320. * Gets a boolean indicating that the system is in VR mode and is presenting
  118321. * @returns true if VR mode is engaged
  118322. */
  118323. isVRPresenting(): boolean;
  118324. /** @hidden */
  118325. _requestVRFrame(): void;
  118326. /** @hidden */
  118327. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118328. /**
  118329. * Gets the source code of the vertex shader associated with a specific webGL program
  118330. * @param program defines the program to use
  118331. * @returns a string containing the source code of the vertex shader associated with the program
  118332. */
  118333. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118334. /**
  118335. * Gets the source code of the fragment shader associated with a specific webGL program
  118336. * @param program defines the program to use
  118337. * @returns a string containing the source code of the fragment shader associated with the program
  118338. */
  118339. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118340. /**
  118341. * Sets a depth stencil texture from a render target to the according uniform.
  118342. * @param channel The texture channel
  118343. * @param uniform The uniform to set
  118344. * @param texture The render target texture containing the depth stencil texture to apply
  118345. */
  118346. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118347. /**
  118348. * Sets a texture to the webGL context from a postprocess
  118349. * @param channel defines the channel to use
  118350. * @param postProcess defines the source postprocess
  118351. */
  118352. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118353. /**
  118354. * Binds the output of the passed in post process to the texture channel specified
  118355. * @param channel The channel the texture should be bound to
  118356. * @param postProcess The post process which's output should be bound
  118357. */
  118358. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118359. protected _rebuildBuffers(): void;
  118360. /** @hidden */
  118361. _renderFrame(): void;
  118362. _renderLoop(): void;
  118363. /** @hidden */
  118364. _renderViews(): boolean;
  118365. /**
  118366. * Toggle full screen mode
  118367. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118368. */
  118369. switchFullscreen(requestPointerLock: boolean): void;
  118370. /**
  118371. * Enters full screen mode
  118372. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118373. */
  118374. enterFullscreen(requestPointerLock: boolean): void;
  118375. /**
  118376. * Exits full screen mode
  118377. */
  118378. exitFullscreen(): void;
  118379. /**
  118380. * Enters Pointerlock mode
  118381. */
  118382. enterPointerlock(): void;
  118383. /**
  118384. * Exits Pointerlock mode
  118385. */
  118386. exitPointerlock(): void;
  118387. /**
  118388. * Begin a new frame
  118389. */
  118390. beginFrame(): void;
  118391. /**
  118392. * Enf the current frame
  118393. */
  118394. endFrame(): void;
  118395. resize(): void;
  118396. /**
  118397. * Force a specific size of the canvas
  118398. * @param width defines the new canvas' width
  118399. * @param height defines the new canvas' height
  118400. * @returns true if the size was changed
  118401. */
  118402. setSize(width: number, height: number): boolean;
  118403. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118404. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118405. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118406. _releaseTexture(texture: InternalTexture): void;
  118407. /**
  118408. * @hidden
  118409. * Rescales a texture
  118410. * @param source input texutre
  118411. * @param destination destination texture
  118412. * @param scene scene to use to render the resize
  118413. * @param internalFormat format to use when resizing
  118414. * @param onComplete callback to be called when resize has completed
  118415. */
  118416. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118417. /**
  118418. * Gets the current framerate
  118419. * @returns a number representing the framerate
  118420. */
  118421. getFps(): number;
  118422. /**
  118423. * Gets the time spent between current and previous frame
  118424. * @returns a number representing the delta time in ms
  118425. */
  118426. getDeltaTime(): number;
  118427. private _measureFps;
  118428. /** @hidden */
  118429. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118430. /**
  118431. * Updates the sample count of a render target texture
  118432. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118433. * @param texture defines the texture to update
  118434. * @param samples defines the sample count to set
  118435. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118436. */
  118437. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118438. /**
  118439. * Updates a depth texture Comparison Mode and Function.
  118440. * If the comparison Function is equal to 0, the mode will be set to none.
  118441. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118442. * @param texture The texture to set the comparison function for
  118443. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118444. */
  118445. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118446. /**
  118447. * Creates a webGL buffer to use with instanciation
  118448. * @param capacity defines the size of the buffer
  118449. * @returns the webGL buffer
  118450. */
  118451. createInstancesBuffer(capacity: number): DataBuffer;
  118452. /**
  118453. * Delete a webGL buffer used with instanciation
  118454. * @param buffer defines the webGL buffer to delete
  118455. */
  118456. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118457. private _clientWaitAsync;
  118458. /** @hidden */
  118459. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118460. dispose(): void;
  118461. private _disableTouchAction;
  118462. /**
  118463. * Display the loading screen
  118464. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118465. */
  118466. displayLoadingUI(): void;
  118467. /**
  118468. * Hide the loading screen
  118469. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118470. */
  118471. hideLoadingUI(): void;
  118472. /**
  118473. * Gets the current loading screen object
  118474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118475. */
  118476. get loadingScreen(): ILoadingScreen;
  118477. /**
  118478. * Sets the current loading screen object
  118479. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118480. */
  118481. set loadingScreen(loadingScreen: ILoadingScreen);
  118482. /**
  118483. * Sets the current loading screen text
  118484. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118485. */
  118486. set loadingUIText(text: string);
  118487. /**
  118488. * Sets the current loading screen background color
  118489. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118490. */
  118491. set loadingUIBackgroundColor(color: string);
  118492. /** Pointerlock and fullscreen */
  118493. /**
  118494. * Ask the browser to promote the current element to pointerlock mode
  118495. * @param element defines the DOM element to promote
  118496. */
  118497. static _RequestPointerlock(element: HTMLElement): void;
  118498. /**
  118499. * Asks the browser to exit pointerlock mode
  118500. */
  118501. static _ExitPointerlock(): void;
  118502. /**
  118503. * Ask the browser to promote the current element to fullscreen rendering mode
  118504. * @param element defines the DOM element to promote
  118505. */
  118506. static _RequestFullscreen(element: HTMLElement): void;
  118507. /**
  118508. * Asks the browser to exit fullscreen mode
  118509. */
  118510. static _ExitFullscreen(): void;
  118511. }
  118512. }
  118513. declare module BABYLON {
  118514. /**
  118515. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118516. * during the life time of the application.
  118517. */
  118518. export class EngineStore {
  118519. /** Gets the list of created engines */
  118520. static Instances: Engine[];
  118521. /** @hidden */
  118522. static _LastCreatedScene: Nullable<Scene>;
  118523. /**
  118524. * Gets the latest created engine
  118525. */
  118526. static get LastCreatedEngine(): Nullable<Engine>;
  118527. /**
  118528. * Gets the latest created scene
  118529. */
  118530. static get LastCreatedScene(): Nullable<Scene>;
  118531. /**
  118532. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118533. * @ignorenaming
  118534. */
  118535. static UseFallbackTexture: boolean;
  118536. /**
  118537. * Texture content used if a texture cannot loaded
  118538. * @ignorenaming
  118539. */
  118540. static FallbackTexture: string;
  118541. }
  118542. }
  118543. declare module BABYLON {
  118544. /**
  118545. * Helper class that provides a small promise polyfill
  118546. */
  118547. export class PromisePolyfill {
  118548. /**
  118549. * Static function used to check if the polyfill is required
  118550. * If this is the case then the function will inject the polyfill to window.Promise
  118551. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118552. */
  118553. static Apply(force?: boolean): void;
  118554. }
  118555. }
  118556. declare module BABYLON {
  118557. /**
  118558. * Interface for screenshot methods with describe argument called `size` as object with options
  118559. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118560. */
  118561. export interface IScreenshotSize {
  118562. /**
  118563. * number in pixels for canvas height
  118564. */
  118565. height?: number;
  118566. /**
  118567. * multiplier allowing render at a higher or lower resolution
  118568. * If value is defined then height and width will be ignored and taken from camera
  118569. */
  118570. precision?: number;
  118571. /**
  118572. * number in pixels for canvas width
  118573. */
  118574. width?: number;
  118575. }
  118576. }
  118577. declare module BABYLON {
  118578. interface IColor4Like {
  118579. r: float;
  118580. g: float;
  118581. b: float;
  118582. a: float;
  118583. }
  118584. /**
  118585. * Class containing a set of static utilities functions
  118586. */
  118587. export class Tools {
  118588. /**
  118589. * Gets or sets the base URL to use to load assets
  118590. */
  118591. static get BaseUrl(): string;
  118592. static set BaseUrl(value: string);
  118593. /**
  118594. * Enable/Disable Custom HTTP Request Headers globally.
  118595. * default = false
  118596. * @see CustomRequestHeaders
  118597. */
  118598. static UseCustomRequestHeaders: boolean;
  118599. /**
  118600. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118601. * i.e. when loading files, where the server/service expects an Authorization header
  118602. */
  118603. static CustomRequestHeaders: {
  118604. [key: string]: string;
  118605. };
  118606. /**
  118607. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118608. */
  118609. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118610. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118611. /**
  118612. * Default behaviour for cors in the application.
  118613. * It can be a string if the expected behavior is identical in the entire app.
  118614. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118615. */
  118616. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118617. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118618. /**
  118619. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118620. * @ignorenaming
  118621. */
  118622. static get UseFallbackTexture(): boolean;
  118623. static set UseFallbackTexture(value: boolean);
  118624. /**
  118625. * Use this object to register external classes like custom textures or material
  118626. * to allow the laoders to instantiate them
  118627. */
  118628. static get RegisteredExternalClasses(): {
  118629. [key: string]: Object;
  118630. };
  118631. static set RegisteredExternalClasses(classes: {
  118632. [key: string]: Object;
  118633. });
  118634. /**
  118635. * Texture content used if a texture cannot loaded
  118636. * @ignorenaming
  118637. */
  118638. static get fallbackTexture(): string;
  118639. static set fallbackTexture(value: string);
  118640. /**
  118641. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118642. * @param u defines the coordinate on X axis
  118643. * @param v defines the coordinate on Y axis
  118644. * @param width defines the width of the source data
  118645. * @param height defines the height of the source data
  118646. * @param pixels defines the source byte array
  118647. * @param color defines the output color
  118648. */
  118649. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118650. /**
  118651. * Interpolates between a and b via alpha
  118652. * @param a The lower value (returned when alpha = 0)
  118653. * @param b The upper value (returned when alpha = 1)
  118654. * @param alpha The interpolation-factor
  118655. * @return The mixed value
  118656. */
  118657. static Mix(a: number, b: number, alpha: number): number;
  118658. /**
  118659. * Tries to instantiate a new object from a given class name
  118660. * @param className defines the class name to instantiate
  118661. * @returns the new object or null if the system was not able to do the instantiation
  118662. */
  118663. static Instantiate(className: string): any;
  118664. /**
  118665. * Provides a slice function that will work even on IE
  118666. * @param data defines the array to slice
  118667. * @param start defines the start of the data (optional)
  118668. * @param end defines the end of the data (optional)
  118669. * @returns the new sliced array
  118670. */
  118671. static Slice<T>(data: T, start?: number, end?: number): T;
  118672. /**
  118673. * Polyfill for setImmediate
  118674. * @param action defines the action to execute after the current execution block
  118675. */
  118676. static SetImmediate(action: () => void): void;
  118677. /**
  118678. * Function indicating if a number is an exponent of 2
  118679. * @param value defines the value to test
  118680. * @returns true if the value is an exponent of 2
  118681. */
  118682. static IsExponentOfTwo(value: number): boolean;
  118683. private static _tmpFloatArray;
  118684. /**
  118685. * Returns the nearest 32-bit single precision float representation of a Number
  118686. * @param value A Number. If the parameter is of a different type, it will get converted
  118687. * to a number or to NaN if it cannot be converted
  118688. * @returns number
  118689. */
  118690. static FloatRound(value: number): number;
  118691. /**
  118692. * Extracts the filename from a path
  118693. * @param path defines the path to use
  118694. * @returns the filename
  118695. */
  118696. static GetFilename(path: string): string;
  118697. /**
  118698. * Extracts the "folder" part of a path (everything before the filename).
  118699. * @param uri The URI to extract the info from
  118700. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118701. * @returns The "folder" part of the path
  118702. */
  118703. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118704. /**
  118705. * Extracts text content from a DOM element hierarchy
  118706. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118707. */
  118708. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118709. /**
  118710. * Convert an angle in radians to degrees
  118711. * @param angle defines the angle to convert
  118712. * @returns the angle in degrees
  118713. */
  118714. static ToDegrees(angle: number): number;
  118715. /**
  118716. * Convert an angle in degrees to radians
  118717. * @param angle defines the angle to convert
  118718. * @returns the angle in radians
  118719. */
  118720. static ToRadians(angle: number): number;
  118721. /**
  118722. * Returns an array if obj is not an array
  118723. * @param obj defines the object to evaluate as an array
  118724. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118725. * @returns either obj directly if obj is an array or a new array containing obj
  118726. */
  118727. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118728. /**
  118729. * Gets the pointer prefix to use
  118730. * @param engine defines the engine we are finding the prefix for
  118731. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118732. */
  118733. static GetPointerPrefix(engine: Engine): string;
  118734. /**
  118735. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118736. * @param url define the url we are trying
  118737. * @param element define the dom element where to configure the cors policy
  118738. */
  118739. static SetCorsBehavior(url: string | string[], element: {
  118740. crossOrigin: string | null;
  118741. }): void;
  118742. /**
  118743. * Removes unwanted characters from an url
  118744. * @param url defines the url to clean
  118745. * @returns the cleaned url
  118746. */
  118747. static CleanUrl(url: string): string;
  118748. /**
  118749. * Gets or sets a function used to pre-process url before using them to load assets
  118750. */
  118751. static get PreprocessUrl(): (url: string) => string;
  118752. static set PreprocessUrl(processor: (url: string) => string);
  118753. /**
  118754. * Loads an image as an HTMLImageElement.
  118755. * @param input url string, ArrayBuffer, or Blob to load
  118756. * @param onLoad callback called when the image successfully loads
  118757. * @param onError callback called when the image fails to load
  118758. * @param offlineProvider offline provider for caching
  118759. * @param mimeType optional mime type
  118760. * @returns the HTMLImageElement of the loaded image
  118761. */
  118762. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118763. /**
  118764. * Loads a file from a url
  118765. * @param url url string, ArrayBuffer, or Blob to load
  118766. * @param onSuccess callback called when the file successfully loads
  118767. * @param onProgress callback called while file is loading (if the server supports this mode)
  118768. * @param offlineProvider defines the offline provider for caching
  118769. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118770. * @param onError callback called when the file fails to load
  118771. * @returns a file request object
  118772. */
  118773. 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;
  118774. /**
  118775. * Loads a file from a url
  118776. * @param url the file url to load
  118777. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118778. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118779. */
  118780. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118781. /**
  118782. * Load a script (identified by an url). When the url returns, the
  118783. * content of this file is added into a new script element, attached to the DOM (body element)
  118784. * @param scriptUrl defines the url of the script to laod
  118785. * @param onSuccess defines the callback called when the script is loaded
  118786. * @param onError defines the callback to call if an error occurs
  118787. * @param scriptId defines the id of the script element
  118788. */
  118789. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118790. /**
  118791. * Load an asynchronous script (identified by an url). When the url returns, the
  118792. * content of this file is added into a new script element, attached to the DOM (body element)
  118793. * @param scriptUrl defines the url of the script to laod
  118794. * @param scriptId defines the id of the script element
  118795. * @returns a promise request object
  118796. */
  118797. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118798. /**
  118799. * Loads a file from a blob
  118800. * @param fileToLoad defines the blob to use
  118801. * @param callback defines the callback to call when data is loaded
  118802. * @param progressCallback defines the callback to call during loading process
  118803. * @returns a file request object
  118804. */
  118805. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118806. /**
  118807. * Reads a file from a File object
  118808. * @param file defines the file to load
  118809. * @param onSuccess defines the callback to call when data is loaded
  118810. * @param onProgress defines the callback to call during loading process
  118811. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118812. * @param onError defines the callback to call when an error occurs
  118813. * @returns a file request object
  118814. */
  118815. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118816. /**
  118817. * Creates a data url from a given string content
  118818. * @param content defines the content to convert
  118819. * @returns the new data url link
  118820. */
  118821. static FileAsURL(content: string): string;
  118822. /**
  118823. * Format the given number to a specific decimal format
  118824. * @param value defines the number to format
  118825. * @param decimals defines the number of decimals to use
  118826. * @returns the formatted string
  118827. */
  118828. static Format(value: number, decimals?: number): string;
  118829. /**
  118830. * Tries to copy an object by duplicating every property
  118831. * @param source defines the source object
  118832. * @param destination defines the target object
  118833. * @param doNotCopyList defines a list of properties to avoid
  118834. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118835. */
  118836. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118837. /**
  118838. * Gets a boolean indicating if the given object has no own property
  118839. * @param obj defines the object to test
  118840. * @returns true if object has no own property
  118841. */
  118842. static IsEmpty(obj: any): boolean;
  118843. /**
  118844. * Function used to register events at window level
  118845. * @param windowElement defines the Window object to use
  118846. * @param events defines the events to register
  118847. */
  118848. static RegisterTopRootEvents(windowElement: Window, events: {
  118849. name: string;
  118850. handler: Nullable<(e: FocusEvent) => any>;
  118851. }[]): void;
  118852. /**
  118853. * Function used to unregister events from window level
  118854. * @param windowElement defines the Window object to use
  118855. * @param events defines the events to unregister
  118856. */
  118857. static UnregisterTopRootEvents(windowElement: Window, events: {
  118858. name: string;
  118859. handler: Nullable<(e: FocusEvent) => any>;
  118860. }[]): void;
  118861. /**
  118862. * @ignore
  118863. */
  118864. static _ScreenshotCanvas: HTMLCanvasElement;
  118865. /**
  118866. * Dumps the current bound framebuffer
  118867. * @param width defines the rendering width
  118868. * @param height defines the rendering height
  118869. * @param engine defines the hosting engine
  118870. * @param successCallback defines the callback triggered once the data are available
  118871. * @param mimeType defines the mime type of the result
  118872. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118873. */
  118874. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118875. /**
  118876. * Converts the canvas data to blob.
  118877. * This acts as a polyfill for browsers not supporting the to blob function.
  118878. * @param canvas Defines the canvas to extract the data from
  118879. * @param successCallback Defines the callback triggered once the data are available
  118880. * @param mimeType Defines the mime type of the result
  118881. */
  118882. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118883. /**
  118884. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118885. * @param successCallback defines the callback triggered once the data are available
  118886. * @param mimeType defines the mime type of the result
  118887. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118888. */
  118889. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118890. /**
  118891. * Downloads a blob in the browser
  118892. * @param blob defines the blob to download
  118893. * @param fileName defines the name of the downloaded file
  118894. */
  118895. static Download(blob: Blob, fileName: string): void;
  118896. /**
  118897. * Captures a screenshot of the current rendering
  118898. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118899. * @param engine defines the rendering engine
  118900. * @param camera defines the source camera
  118901. * @param size This parameter can be set to a single number or to an object with the
  118902. * following (optional) properties: precision, width, height. If a single number is passed,
  118903. * it will be used for both width and height. If an object is passed, the screenshot size
  118904. * will be derived from the parameters. The precision property is a multiplier allowing
  118905. * rendering at a higher or lower resolution
  118906. * @param successCallback defines the callback receives a single parameter which contains the
  118907. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118908. * src parameter of an <img> to display it
  118909. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118910. * Check your browser for supported MIME types
  118911. */
  118912. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118913. /**
  118914. * Captures a screenshot of the current rendering
  118915. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118916. * @param engine defines the rendering engine
  118917. * @param camera defines the source camera
  118918. * @param size This parameter can be set to a single number or to an object with the
  118919. * following (optional) properties: precision, width, height. If a single number is passed,
  118920. * it will be used for both width and height. If an object is passed, the screenshot size
  118921. * will be derived from the parameters. The precision property is a multiplier allowing
  118922. * rendering at a higher or lower resolution
  118923. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118924. * Check your browser for supported MIME types
  118925. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118926. * to the src parameter of an <img> to display it
  118927. */
  118928. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118929. /**
  118930. * Generates an image screenshot from the specified camera.
  118931. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118932. * @param engine The engine to use for rendering
  118933. * @param camera The camera to use for rendering
  118934. * @param size This parameter can be set to a single number or to an object with the
  118935. * following (optional) properties: precision, width, height. If a single number is passed,
  118936. * it will be used for both width and height. If an object is passed, the screenshot size
  118937. * will be derived from the parameters. The precision property is a multiplier allowing
  118938. * rendering at a higher or lower resolution
  118939. * @param successCallback The callback receives a single parameter which contains the
  118940. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118941. * src parameter of an <img> to display it
  118942. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118943. * Check your browser for supported MIME types
  118944. * @param samples Texture samples (default: 1)
  118945. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118946. * @param fileName A name for for the downloaded file.
  118947. */
  118948. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118949. /**
  118950. * Generates an image screenshot from the specified camera.
  118951. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118952. * @param engine The engine to use for rendering
  118953. * @param camera The camera to use for rendering
  118954. * @param size This parameter can be set to a single number or to an object with the
  118955. * following (optional) properties: precision, width, height. If a single number is passed,
  118956. * it will be used for both width and height. If an object is passed, the screenshot size
  118957. * will be derived from the parameters. The precision property is a multiplier allowing
  118958. * rendering at a higher or lower resolution
  118959. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118960. * Check your browser for supported MIME types
  118961. * @param samples Texture samples (default: 1)
  118962. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118963. * @param fileName A name for for the downloaded file.
  118964. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118965. * to the src parameter of an <img> to display it
  118966. */
  118967. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118968. /**
  118969. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118970. * Be aware Math.random() could cause collisions, but:
  118971. * "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"
  118972. * @returns a pseudo random id
  118973. */
  118974. static RandomId(): string;
  118975. /**
  118976. * Test if the given uri is a base64 string
  118977. * @param uri The uri to test
  118978. * @return True if the uri is a base64 string or false otherwise
  118979. */
  118980. static IsBase64(uri: string): boolean;
  118981. /**
  118982. * Decode the given base64 uri.
  118983. * @param uri The uri to decode
  118984. * @return The decoded base64 data.
  118985. */
  118986. static DecodeBase64(uri: string): ArrayBuffer;
  118987. /**
  118988. * Gets the absolute url.
  118989. * @param url the input url
  118990. * @return the absolute url
  118991. */
  118992. static GetAbsoluteUrl(url: string): string;
  118993. /**
  118994. * No log
  118995. */
  118996. static readonly NoneLogLevel: number;
  118997. /**
  118998. * Only message logs
  118999. */
  119000. static readonly MessageLogLevel: number;
  119001. /**
  119002. * Only warning logs
  119003. */
  119004. static readonly WarningLogLevel: number;
  119005. /**
  119006. * Only error logs
  119007. */
  119008. static readonly ErrorLogLevel: number;
  119009. /**
  119010. * All logs
  119011. */
  119012. static readonly AllLogLevel: number;
  119013. /**
  119014. * Gets a value indicating the number of loading errors
  119015. * @ignorenaming
  119016. */
  119017. static get errorsCount(): number;
  119018. /**
  119019. * Callback called when a new log is added
  119020. */
  119021. static OnNewCacheEntry: (entry: string) => void;
  119022. /**
  119023. * Log a message to the console
  119024. * @param message defines the message to log
  119025. */
  119026. static Log(message: string): void;
  119027. /**
  119028. * Write a warning message to the console
  119029. * @param message defines the message to log
  119030. */
  119031. static Warn(message: string): void;
  119032. /**
  119033. * Write an error message to the console
  119034. * @param message defines the message to log
  119035. */
  119036. static Error(message: string): void;
  119037. /**
  119038. * Gets current log cache (list of logs)
  119039. */
  119040. static get LogCache(): string;
  119041. /**
  119042. * Clears the log cache
  119043. */
  119044. static ClearLogCache(): void;
  119045. /**
  119046. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119047. */
  119048. static set LogLevels(level: number);
  119049. /**
  119050. * Checks if the window object exists
  119051. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119052. */
  119053. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119054. /**
  119055. * No performance log
  119056. */
  119057. static readonly PerformanceNoneLogLevel: number;
  119058. /**
  119059. * Use user marks to log performance
  119060. */
  119061. static readonly PerformanceUserMarkLogLevel: number;
  119062. /**
  119063. * Log performance to the console
  119064. */
  119065. static readonly PerformanceConsoleLogLevel: number;
  119066. private static _performance;
  119067. /**
  119068. * Sets the current performance log level
  119069. */
  119070. static set PerformanceLogLevel(level: number);
  119071. private static _StartPerformanceCounterDisabled;
  119072. private static _EndPerformanceCounterDisabled;
  119073. private static _StartUserMark;
  119074. private static _EndUserMark;
  119075. private static _StartPerformanceConsole;
  119076. private static _EndPerformanceConsole;
  119077. /**
  119078. * Starts a performance counter
  119079. */
  119080. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119081. /**
  119082. * Ends a specific performance coutner
  119083. */
  119084. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119085. /**
  119086. * Gets either window.performance.now() if supported or Date.now() else
  119087. */
  119088. static get Now(): number;
  119089. /**
  119090. * This method will return the name of the class used to create the instance of the given object.
  119091. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119092. * @param object the object to get the class name from
  119093. * @param isType defines if the object is actually a type
  119094. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119095. */
  119096. static GetClassName(object: any, isType?: boolean): string;
  119097. /**
  119098. * Gets the first element of an array satisfying a given predicate
  119099. * @param array defines the array to browse
  119100. * @param predicate defines the predicate to use
  119101. * @returns null if not found or the element
  119102. */
  119103. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119104. /**
  119105. * This method will return the name of the full name of the class, including its owning module (if any).
  119106. * 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).
  119107. * @param object the object to get the class name from
  119108. * @param isType defines if the object is actually a type
  119109. * @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.
  119110. * @ignorenaming
  119111. */
  119112. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119113. /**
  119114. * Returns a promise that resolves after the given amount of time.
  119115. * @param delay Number of milliseconds to delay
  119116. * @returns Promise that resolves after the given amount of time
  119117. */
  119118. static DelayAsync(delay: number): Promise<void>;
  119119. /**
  119120. * Utility function to detect if the current user agent is Safari
  119121. * @returns whether or not the current user agent is safari
  119122. */
  119123. static IsSafari(): boolean;
  119124. }
  119125. /**
  119126. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119127. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119128. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119129. * @param name The name of the class, case should be preserved
  119130. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119131. */
  119132. export function className(name: string, module?: string): (target: Object) => void;
  119133. /**
  119134. * An implementation of a loop for asynchronous functions.
  119135. */
  119136. export class AsyncLoop {
  119137. /**
  119138. * Defines the number of iterations for the loop
  119139. */
  119140. iterations: number;
  119141. /**
  119142. * Defines the current index of the loop.
  119143. */
  119144. index: number;
  119145. private _done;
  119146. private _fn;
  119147. private _successCallback;
  119148. /**
  119149. * Constructor.
  119150. * @param iterations the number of iterations.
  119151. * @param func the function to run each iteration
  119152. * @param successCallback the callback that will be called upon succesful execution
  119153. * @param offset starting offset.
  119154. */
  119155. constructor(
  119156. /**
  119157. * Defines the number of iterations for the loop
  119158. */
  119159. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119160. /**
  119161. * Execute the next iteration. Must be called after the last iteration was finished.
  119162. */
  119163. executeNext(): void;
  119164. /**
  119165. * Break the loop and run the success callback.
  119166. */
  119167. breakLoop(): void;
  119168. /**
  119169. * Create and run an async loop.
  119170. * @param iterations the number of iterations.
  119171. * @param fn the function to run each iteration
  119172. * @param successCallback the callback that will be called upon succesful execution
  119173. * @param offset starting offset.
  119174. * @returns the created async loop object
  119175. */
  119176. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119177. /**
  119178. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119179. * @param iterations total number of iterations
  119180. * @param syncedIterations number of synchronous iterations in each async iteration.
  119181. * @param fn the function to call each iteration.
  119182. * @param callback a success call back that will be called when iterating stops.
  119183. * @param breakFunction a break condition (optional)
  119184. * @param timeout timeout settings for the setTimeout function. default - 0.
  119185. * @returns the created async loop object
  119186. */
  119187. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119188. }
  119189. }
  119190. declare module BABYLON {
  119191. /**
  119192. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119193. * The underlying implementation relies on an associative array to ensure the best performances.
  119194. * The value can be anything including 'null' but except 'undefined'
  119195. */
  119196. export class StringDictionary<T> {
  119197. /**
  119198. * This will clear this dictionary and copy the content from the 'source' one.
  119199. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119200. * @param source the dictionary to take the content from and copy to this dictionary
  119201. */
  119202. copyFrom(source: StringDictionary<T>): void;
  119203. /**
  119204. * Get a value based from its key
  119205. * @param key the given key to get the matching value from
  119206. * @return the value if found, otherwise undefined is returned
  119207. */
  119208. get(key: string): T | undefined;
  119209. /**
  119210. * Get a value from its key or add it if it doesn't exist.
  119211. * This method will ensure you that a given key/data will be present in the dictionary.
  119212. * @param key the given key to get the matching value from
  119213. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119214. * The factory will only be invoked if there's no data for the given key.
  119215. * @return the value corresponding to the key.
  119216. */
  119217. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119218. /**
  119219. * Get a value from its key if present in the dictionary otherwise add it
  119220. * @param key the key to get the value from
  119221. * @param val if there's no such key/value pair in the dictionary add it with this value
  119222. * @return the value corresponding to the key
  119223. */
  119224. getOrAdd(key: string, val: T): T;
  119225. /**
  119226. * Check if there's a given key in the dictionary
  119227. * @param key the key to check for
  119228. * @return true if the key is present, false otherwise
  119229. */
  119230. contains(key: string): boolean;
  119231. /**
  119232. * Add a new key and its corresponding value
  119233. * @param key the key to add
  119234. * @param value the value corresponding to the key
  119235. * @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
  119236. */
  119237. add(key: string, value: T): boolean;
  119238. /**
  119239. * Update a specific value associated to a key
  119240. * @param key defines the key to use
  119241. * @param value defines the value to store
  119242. * @returns true if the value was updated (or false if the key was not found)
  119243. */
  119244. set(key: string, value: T): boolean;
  119245. /**
  119246. * Get the element of the given key and remove it from the dictionary
  119247. * @param key defines the key to search
  119248. * @returns the value associated with the key or null if not found
  119249. */
  119250. getAndRemove(key: string): Nullable<T>;
  119251. /**
  119252. * Remove a key/value from the dictionary.
  119253. * @param key the key to remove
  119254. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119255. */
  119256. remove(key: string): boolean;
  119257. /**
  119258. * Clear the whole content of the dictionary
  119259. */
  119260. clear(): void;
  119261. /**
  119262. * Gets the current count
  119263. */
  119264. get count(): number;
  119265. /**
  119266. * Execute a callback on each key/val of the dictionary.
  119267. * Note that you can remove any element in this dictionary in the callback implementation
  119268. * @param callback the callback to execute on a given key/value pair
  119269. */
  119270. forEach(callback: (key: string, val: T) => void): void;
  119271. /**
  119272. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119273. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119274. * Note that you can remove any element in this dictionary in the callback implementation
  119275. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119276. * @returns the first item
  119277. */
  119278. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119279. private _count;
  119280. private _data;
  119281. }
  119282. }
  119283. declare module BABYLON {
  119284. /** @hidden */
  119285. export interface ICollisionCoordinator {
  119286. createCollider(): Collider;
  119287. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119288. init(scene: Scene): void;
  119289. }
  119290. /** @hidden */
  119291. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119292. private _scene;
  119293. private _scaledPosition;
  119294. private _scaledVelocity;
  119295. private _finalPosition;
  119296. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119297. createCollider(): Collider;
  119298. init(scene: Scene): void;
  119299. private _collideWithWorld;
  119300. }
  119301. }
  119302. declare module BABYLON {
  119303. /**
  119304. * Class used to manage all inputs for the scene.
  119305. */
  119306. export class InputManager {
  119307. /** The distance in pixel that you have to move to prevent some events */
  119308. static DragMovementThreshold: number;
  119309. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119310. static LongPressDelay: number;
  119311. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119312. static DoubleClickDelay: number;
  119313. /** If you need to check double click without raising a single click at first click, enable this flag */
  119314. static ExclusiveDoubleClickMode: boolean;
  119315. /** 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. */
  119316. private _alreadyAttached;
  119317. private _wheelEventName;
  119318. private _onPointerMove;
  119319. private _onPointerDown;
  119320. private _onPointerUp;
  119321. private _initClickEvent;
  119322. private _initActionManager;
  119323. private _delayedSimpleClick;
  119324. private _delayedSimpleClickTimeout;
  119325. private _previousDelayedSimpleClickTimeout;
  119326. private _meshPickProceed;
  119327. private _previousButtonPressed;
  119328. private _currentPickResult;
  119329. private _previousPickResult;
  119330. private _totalPointersPressed;
  119331. private _doubleClickOccured;
  119332. private _pointerOverMesh;
  119333. private _pickedDownMesh;
  119334. private _pickedUpMesh;
  119335. private _pointerX;
  119336. private _pointerY;
  119337. private _unTranslatedPointerX;
  119338. private _unTranslatedPointerY;
  119339. private _startingPointerPosition;
  119340. private _previousStartingPointerPosition;
  119341. private _startingPointerTime;
  119342. private _previousStartingPointerTime;
  119343. private _pointerCaptures;
  119344. private _meshUnderPointerId;
  119345. private _onKeyDown;
  119346. private _onKeyUp;
  119347. private _onCanvasFocusObserver;
  119348. private _onCanvasBlurObserver;
  119349. private _scene;
  119350. /**
  119351. * Creates a new InputManager
  119352. * @param scene defines the hosting scene
  119353. */
  119354. constructor(scene: Scene);
  119355. /**
  119356. * Gets the mesh that is currently under the pointer
  119357. */
  119358. get meshUnderPointer(): Nullable<AbstractMesh>;
  119359. /**
  119360. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119361. * @param pointerId the pointer id to use
  119362. * @returns The mesh under this pointer id or null if not found
  119363. */
  119364. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119365. /**
  119366. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119367. */
  119368. get unTranslatedPointer(): Vector2;
  119369. /**
  119370. * Gets or sets the current on-screen X position of the pointer
  119371. */
  119372. get pointerX(): number;
  119373. set pointerX(value: number);
  119374. /**
  119375. * Gets or sets the current on-screen Y position of the pointer
  119376. */
  119377. get pointerY(): number;
  119378. set pointerY(value: number);
  119379. private _updatePointerPosition;
  119380. private _processPointerMove;
  119381. private _setRayOnPointerInfo;
  119382. private _checkPrePointerObservable;
  119383. /**
  119384. * Use this method to simulate a pointer move on a mesh
  119385. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119386. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119387. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119388. */
  119389. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119390. /**
  119391. * Use this method to simulate a pointer down on a mesh
  119392. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119393. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119394. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119395. */
  119396. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119397. private _processPointerDown;
  119398. /** @hidden */
  119399. _isPointerSwiping(): boolean;
  119400. /**
  119401. * Use this method to simulate a pointer up on a mesh
  119402. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119403. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119404. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119405. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119406. */
  119407. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119408. private _processPointerUp;
  119409. /**
  119410. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119411. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119412. * @returns true if the pointer was captured
  119413. */
  119414. isPointerCaptured(pointerId?: number): boolean;
  119415. /**
  119416. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119417. * @param attachUp defines if you want to attach events to pointerup
  119418. * @param attachDown defines if you want to attach events to pointerdown
  119419. * @param attachMove defines if you want to attach events to pointermove
  119420. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119421. */
  119422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119423. /**
  119424. * Detaches all event handlers
  119425. */
  119426. detachControl(): void;
  119427. /**
  119428. * Force the value of meshUnderPointer
  119429. * @param mesh defines the mesh to use
  119430. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119431. */
  119432. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119433. /**
  119434. * Gets the mesh under the pointer
  119435. * @returns a Mesh or null if no mesh is under the pointer
  119436. */
  119437. getPointerOverMesh(): Nullable<AbstractMesh>;
  119438. }
  119439. }
  119440. declare module BABYLON {
  119441. /**
  119442. * This class defines the direct association between an animation and a target
  119443. */
  119444. export class TargetedAnimation {
  119445. /**
  119446. * Animation to perform
  119447. */
  119448. animation: Animation;
  119449. /**
  119450. * Target to animate
  119451. */
  119452. target: any;
  119453. /**
  119454. * Returns the string "TargetedAnimation"
  119455. * @returns "TargetedAnimation"
  119456. */
  119457. getClassName(): string;
  119458. /**
  119459. * Serialize the object
  119460. * @returns the JSON object representing the current entity
  119461. */
  119462. serialize(): any;
  119463. }
  119464. /**
  119465. * Use this class to create coordinated animations on multiple targets
  119466. */
  119467. export class AnimationGroup implements IDisposable {
  119468. /** The name of the animation group */
  119469. name: string;
  119470. private _scene;
  119471. private _targetedAnimations;
  119472. private _animatables;
  119473. private _from;
  119474. private _to;
  119475. private _isStarted;
  119476. private _isPaused;
  119477. private _speedRatio;
  119478. private _loopAnimation;
  119479. private _isAdditive;
  119480. /**
  119481. * Gets or sets the unique id of the node
  119482. */
  119483. uniqueId: number;
  119484. /**
  119485. * This observable will notify when one animation have ended
  119486. */
  119487. onAnimationEndObservable: Observable<TargetedAnimation>;
  119488. /**
  119489. * Observer raised when one animation loops
  119490. */
  119491. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119492. /**
  119493. * Observer raised when all animations have looped
  119494. */
  119495. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119496. /**
  119497. * This observable will notify when all animations have ended.
  119498. */
  119499. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119500. /**
  119501. * This observable will notify when all animations have paused.
  119502. */
  119503. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119504. /**
  119505. * This observable will notify when all animations are playing.
  119506. */
  119507. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119508. /**
  119509. * Gets the first frame
  119510. */
  119511. get from(): number;
  119512. /**
  119513. * Gets the last frame
  119514. */
  119515. get to(): number;
  119516. /**
  119517. * Define if the animations are started
  119518. */
  119519. get isStarted(): boolean;
  119520. /**
  119521. * Gets a value indicating that the current group is playing
  119522. */
  119523. get isPlaying(): boolean;
  119524. /**
  119525. * Gets or sets the speed ratio to use for all animations
  119526. */
  119527. get speedRatio(): number;
  119528. /**
  119529. * Gets or sets the speed ratio to use for all animations
  119530. */
  119531. set speedRatio(value: number);
  119532. /**
  119533. * Gets or sets if all animations should loop or not
  119534. */
  119535. get loopAnimation(): boolean;
  119536. set loopAnimation(value: boolean);
  119537. /**
  119538. * Gets or sets if all animations should be evaluated additively
  119539. */
  119540. get isAdditive(): boolean;
  119541. set isAdditive(value: boolean);
  119542. /**
  119543. * Gets the targeted animations for this animation group
  119544. */
  119545. get targetedAnimations(): Array<TargetedAnimation>;
  119546. /**
  119547. * returning the list of animatables controlled by this animation group.
  119548. */
  119549. get animatables(): Array<Animatable>;
  119550. /**
  119551. * Gets the list of target animations
  119552. */
  119553. get children(): TargetedAnimation[];
  119554. /**
  119555. * Instantiates a new Animation Group.
  119556. * This helps managing several animations at once.
  119557. * @see https://doc.babylonjs.com/how_to/group
  119558. * @param name Defines the name of the group
  119559. * @param scene Defines the scene the group belongs to
  119560. */
  119561. constructor(
  119562. /** The name of the animation group */
  119563. name: string, scene?: Nullable<Scene>);
  119564. /**
  119565. * Add an animation (with its target) in the group
  119566. * @param animation defines the animation we want to add
  119567. * @param target defines the target of the animation
  119568. * @returns the TargetedAnimation object
  119569. */
  119570. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119571. /**
  119572. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119573. * It can add constant keys at begin or end
  119574. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119575. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119576. * @returns the animation group
  119577. */
  119578. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119579. private _animationLoopCount;
  119580. private _animationLoopFlags;
  119581. private _processLoop;
  119582. /**
  119583. * Start all animations on given targets
  119584. * @param loop defines if animations must loop
  119585. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119586. * @param from defines the from key (optional)
  119587. * @param to defines the to key (optional)
  119588. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119589. * @returns the current animation group
  119590. */
  119591. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119592. /**
  119593. * Pause all animations
  119594. * @returns the animation group
  119595. */
  119596. pause(): AnimationGroup;
  119597. /**
  119598. * Play all animations to initial state
  119599. * This function will start() the animations if they were not started or will restart() them if they were paused
  119600. * @param loop defines if animations must loop
  119601. * @returns the animation group
  119602. */
  119603. play(loop?: boolean): AnimationGroup;
  119604. /**
  119605. * Reset all animations to initial state
  119606. * @returns the animation group
  119607. */
  119608. reset(): AnimationGroup;
  119609. /**
  119610. * Restart animations from key 0
  119611. * @returns the animation group
  119612. */
  119613. restart(): AnimationGroup;
  119614. /**
  119615. * Stop all animations
  119616. * @returns the animation group
  119617. */
  119618. stop(): AnimationGroup;
  119619. /**
  119620. * Set animation weight for all animatables
  119621. * @param weight defines the weight to use
  119622. * @return the animationGroup
  119623. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119624. */
  119625. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119626. /**
  119627. * Synchronize and normalize all animatables with a source animatable
  119628. * @param root defines the root animatable to synchronize with
  119629. * @return the animationGroup
  119630. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119631. */
  119632. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119633. /**
  119634. * Goes to a specific frame in this animation group
  119635. * @param frame the frame number to go to
  119636. * @return the animationGroup
  119637. */
  119638. goToFrame(frame: number): AnimationGroup;
  119639. /**
  119640. * Dispose all associated resources
  119641. */
  119642. dispose(): void;
  119643. private _checkAnimationGroupEnded;
  119644. /**
  119645. * Clone the current animation group and returns a copy
  119646. * @param newName defines the name of the new group
  119647. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119648. * @returns the new aniamtion group
  119649. */
  119650. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119651. /**
  119652. * Serializes the animationGroup to an object
  119653. * @returns Serialized object
  119654. */
  119655. serialize(): any;
  119656. /**
  119657. * Returns a new AnimationGroup object parsed from the source provided.
  119658. * @param parsedAnimationGroup defines the source
  119659. * @param scene defines the scene that will receive the animationGroup
  119660. * @returns a new AnimationGroup
  119661. */
  119662. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119663. /**
  119664. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119665. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119666. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119667. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119668. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119669. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119670. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119671. */
  119672. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119673. /**
  119674. * Returns the string "AnimationGroup"
  119675. * @returns "AnimationGroup"
  119676. */
  119677. getClassName(): string;
  119678. /**
  119679. * Creates a detailled string about the object
  119680. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119681. * @returns a string representing the object
  119682. */
  119683. toString(fullDetails?: boolean): string;
  119684. }
  119685. }
  119686. declare module BABYLON {
  119687. /**
  119688. * Define an interface for all classes that will hold resources
  119689. */
  119690. export interface IDisposable {
  119691. /**
  119692. * Releases all held resources
  119693. */
  119694. dispose(): void;
  119695. }
  119696. /** Interface defining initialization parameters for Scene class */
  119697. export interface SceneOptions {
  119698. /**
  119699. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119700. * It will improve performance when the number of geometries becomes important.
  119701. */
  119702. useGeometryUniqueIdsMap?: boolean;
  119703. /**
  119704. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119705. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119706. */
  119707. useMaterialMeshMap?: boolean;
  119708. /**
  119709. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119710. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119711. */
  119712. useClonedMeshMap?: boolean;
  119713. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119714. virtual?: boolean;
  119715. }
  119716. /**
  119717. * Represents a scene to be rendered by the engine.
  119718. * @see https://doc.babylonjs.com/features/scene
  119719. */
  119720. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119721. /** The fog is deactivated */
  119722. static readonly FOGMODE_NONE: number;
  119723. /** The fog density is following an exponential function */
  119724. static readonly FOGMODE_EXP: number;
  119725. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119726. static readonly FOGMODE_EXP2: number;
  119727. /** The fog density is following a linear function. */
  119728. static readonly FOGMODE_LINEAR: number;
  119729. /**
  119730. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119731. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119732. */
  119733. static MinDeltaTime: number;
  119734. /**
  119735. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119736. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119737. */
  119738. static MaxDeltaTime: number;
  119739. /**
  119740. * Factory used to create the default material.
  119741. * @param name The name of the material to create
  119742. * @param scene The scene to create the material for
  119743. * @returns The default material
  119744. */
  119745. static DefaultMaterialFactory(scene: Scene): Material;
  119746. /**
  119747. * Factory used to create the a collision coordinator.
  119748. * @returns The collision coordinator
  119749. */
  119750. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119751. /** @hidden */
  119752. _inputManager: InputManager;
  119753. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119754. cameraToUseForPointers: Nullable<Camera>;
  119755. /** @hidden */
  119756. readonly _isScene: boolean;
  119757. /** @hidden */
  119758. _blockEntityCollection: boolean;
  119759. /**
  119760. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119761. */
  119762. autoClear: boolean;
  119763. /**
  119764. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119765. */
  119766. autoClearDepthAndStencil: boolean;
  119767. /**
  119768. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119769. */
  119770. clearColor: Color4;
  119771. /**
  119772. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119773. */
  119774. ambientColor: Color3;
  119775. /**
  119776. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119777. * It should only be one of the following (if not the default embedded one):
  119778. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119779. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119780. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119781. * The material properties need to be setup according to the type of texture in use.
  119782. */
  119783. environmentBRDFTexture: BaseTexture;
  119784. /**
  119785. * Texture used in all pbr material as the reflection texture.
  119786. * As in the majority of the scene they are the same (exception for multi room and so on),
  119787. * this is easier to reference from here than from all the materials.
  119788. */
  119789. get environmentTexture(): Nullable<BaseTexture>;
  119790. /**
  119791. * Texture used in all pbr material as the reflection texture.
  119792. * As in the majority of the scene they are the same (exception for multi room and so on),
  119793. * this is easier to set here than in all the materials.
  119794. */
  119795. set environmentTexture(value: Nullable<BaseTexture>);
  119796. /** @hidden */
  119797. protected _environmentIntensity: number;
  119798. /**
  119799. * Intensity of the environment in all pbr material.
  119800. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119801. * As in the majority of the scene they are the same (exception for multi room and so on),
  119802. * this is easier to reference from here than from all the materials.
  119803. */
  119804. get environmentIntensity(): number;
  119805. /**
  119806. * Intensity of the environment in all pbr material.
  119807. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119808. * As in the majority of the scene they are the same (exception for multi room and so on),
  119809. * this is easier to set here than in all the materials.
  119810. */
  119811. set environmentIntensity(value: number);
  119812. /** @hidden */
  119813. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119814. /**
  119815. * Default image processing configuration used either in the rendering
  119816. * Forward main pass or through the imageProcessingPostProcess if present.
  119817. * As in the majority of the scene they are the same (exception for multi camera),
  119818. * this is easier to reference from here than from all the materials and post process.
  119819. *
  119820. * No setter as we it is a shared configuration, you can set the values instead.
  119821. */
  119822. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119823. private _forceWireframe;
  119824. /**
  119825. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119826. */
  119827. set forceWireframe(value: boolean);
  119828. get forceWireframe(): boolean;
  119829. private _skipFrustumClipping;
  119830. /**
  119831. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119832. */
  119833. set skipFrustumClipping(value: boolean);
  119834. get skipFrustumClipping(): boolean;
  119835. private _forcePointsCloud;
  119836. /**
  119837. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119838. */
  119839. set forcePointsCloud(value: boolean);
  119840. get forcePointsCloud(): boolean;
  119841. /**
  119842. * Gets or sets the active clipplane 1
  119843. */
  119844. clipPlane: Nullable<Plane>;
  119845. /**
  119846. * Gets or sets the active clipplane 2
  119847. */
  119848. clipPlane2: Nullable<Plane>;
  119849. /**
  119850. * Gets or sets the active clipplane 3
  119851. */
  119852. clipPlane3: Nullable<Plane>;
  119853. /**
  119854. * Gets or sets the active clipplane 4
  119855. */
  119856. clipPlane4: Nullable<Plane>;
  119857. /**
  119858. * Gets or sets the active clipplane 5
  119859. */
  119860. clipPlane5: Nullable<Plane>;
  119861. /**
  119862. * Gets or sets the active clipplane 6
  119863. */
  119864. clipPlane6: Nullable<Plane>;
  119865. /**
  119866. * Gets or sets a boolean indicating if animations are enabled
  119867. */
  119868. animationsEnabled: boolean;
  119869. private _animationPropertiesOverride;
  119870. /**
  119871. * Gets or sets the animation properties override
  119872. */
  119873. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119874. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119875. /**
  119876. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119877. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119878. */
  119879. useConstantAnimationDeltaTime: boolean;
  119880. /**
  119881. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119882. * Please note that it requires to run a ray cast through the scene on every frame
  119883. */
  119884. constantlyUpdateMeshUnderPointer: boolean;
  119885. /**
  119886. * Defines the HTML cursor to use when hovering over interactive elements
  119887. */
  119888. hoverCursor: string;
  119889. /**
  119890. * Defines the HTML default cursor to use (empty by default)
  119891. */
  119892. defaultCursor: string;
  119893. /**
  119894. * Defines whether cursors are handled by the scene.
  119895. */
  119896. doNotHandleCursors: boolean;
  119897. /**
  119898. * This is used to call preventDefault() on pointer down
  119899. * in order to block unwanted artifacts like system double clicks
  119900. */
  119901. preventDefaultOnPointerDown: boolean;
  119902. /**
  119903. * This is used to call preventDefault() on pointer up
  119904. * in order to block unwanted artifacts like system double clicks
  119905. */
  119906. preventDefaultOnPointerUp: boolean;
  119907. /**
  119908. * Gets or sets user defined metadata
  119909. */
  119910. metadata: any;
  119911. /**
  119912. * For internal use only. Please do not use.
  119913. */
  119914. reservedDataStore: any;
  119915. /**
  119916. * Gets the name of the plugin used to load this scene (null by default)
  119917. */
  119918. loadingPluginName: string;
  119919. /**
  119920. * Use this array to add regular expressions used to disable offline support for specific urls
  119921. */
  119922. disableOfflineSupportExceptionRules: RegExp[];
  119923. /**
  119924. * An event triggered when the scene is disposed.
  119925. */
  119926. onDisposeObservable: Observable<Scene>;
  119927. private _onDisposeObserver;
  119928. /** Sets a function to be executed when this scene is disposed. */
  119929. set onDispose(callback: () => void);
  119930. /**
  119931. * An event triggered before rendering the scene (right after animations and physics)
  119932. */
  119933. onBeforeRenderObservable: Observable<Scene>;
  119934. private _onBeforeRenderObserver;
  119935. /** Sets a function to be executed before rendering this scene */
  119936. set beforeRender(callback: Nullable<() => void>);
  119937. /**
  119938. * An event triggered after rendering the scene
  119939. */
  119940. onAfterRenderObservable: Observable<Scene>;
  119941. /**
  119942. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119943. */
  119944. onAfterRenderCameraObservable: Observable<Camera>;
  119945. private _onAfterRenderObserver;
  119946. /** Sets a function to be executed after rendering this scene */
  119947. set afterRender(callback: Nullable<() => void>);
  119948. /**
  119949. * An event triggered before animating the scene
  119950. */
  119951. onBeforeAnimationsObservable: Observable<Scene>;
  119952. /**
  119953. * An event triggered after animations processing
  119954. */
  119955. onAfterAnimationsObservable: Observable<Scene>;
  119956. /**
  119957. * An event triggered before draw calls are ready to be sent
  119958. */
  119959. onBeforeDrawPhaseObservable: Observable<Scene>;
  119960. /**
  119961. * An event triggered after draw calls have been sent
  119962. */
  119963. onAfterDrawPhaseObservable: Observable<Scene>;
  119964. /**
  119965. * An event triggered when the scene is ready
  119966. */
  119967. onReadyObservable: Observable<Scene>;
  119968. /**
  119969. * An event triggered before rendering a camera
  119970. */
  119971. onBeforeCameraRenderObservable: Observable<Camera>;
  119972. private _onBeforeCameraRenderObserver;
  119973. /** Sets a function to be executed before rendering a camera*/
  119974. set beforeCameraRender(callback: () => void);
  119975. /**
  119976. * An event triggered after rendering a camera
  119977. */
  119978. onAfterCameraRenderObservable: Observable<Camera>;
  119979. private _onAfterCameraRenderObserver;
  119980. /** Sets a function to be executed after rendering a camera*/
  119981. set afterCameraRender(callback: () => void);
  119982. /**
  119983. * An event triggered when active meshes evaluation is about to start
  119984. */
  119985. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119986. /**
  119987. * An event triggered when active meshes evaluation is done
  119988. */
  119989. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119990. /**
  119991. * An event triggered when particles rendering is about to start
  119992. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119993. */
  119994. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119995. /**
  119996. * An event triggered when particles rendering is done
  119997. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119998. */
  119999. onAfterParticlesRenderingObservable: Observable<Scene>;
  120000. /**
  120001. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  120002. */
  120003. onDataLoadedObservable: Observable<Scene>;
  120004. /**
  120005. * An event triggered when a camera is created
  120006. */
  120007. onNewCameraAddedObservable: Observable<Camera>;
  120008. /**
  120009. * An event triggered when a camera is removed
  120010. */
  120011. onCameraRemovedObservable: Observable<Camera>;
  120012. /**
  120013. * An event triggered when a light is created
  120014. */
  120015. onNewLightAddedObservable: Observable<Light>;
  120016. /**
  120017. * An event triggered when a light is removed
  120018. */
  120019. onLightRemovedObservable: Observable<Light>;
  120020. /**
  120021. * An event triggered when a geometry is created
  120022. */
  120023. onNewGeometryAddedObservable: Observable<Geometry>;
  120024. /**
  120025. * An event triggered when a geometry is removed
  120026. */
  120027. onGeometryRemovedObservable: Observable<Geometry>;
  120028. /**
  120029. * An event triggered when a transform node is created
  120030. */
  120031. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120032. /**
  120033. * An event triggered when a transform node is removed
  120034. */
  120035. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120036. /**
  120037. * An event triggered when a mesh is created
  120038. */
  120039. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120040. /**
  120041. * An event triggered when a mesh is removed
  120042. */
  120043. onMeshRemovedObservable: Observable<AbstractMesh>;
  120044. /**
  120045. * An event triggered when a skeleton is created
  120046. */
  120047. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120048. /**
  120049. * An event triggered when a skeleton is removed
  120050. */
  120051. onSkeletonRemovedObservable: Observable<Skeleton>;
  120052. /**
  120053. * An event triggered when a material is created
  120054. */
  120055. onNewMaterialAddedObservable: Observable<Material>;
  120056. /**
  120057. * An event triggered when a material is removed
  120058. */
  120059. onMaterialRemovedObservable: Observable<Material>;
  120060. /**
  120061. * An event triggered when a texture is created
  120062. */
  120063. onNewTextureAddedObservable: Observable<BaseTexture>;
  120064. /**
  120065. * An event triggered when a texture is removed
  120066. */
  120067. onTextureRemovedObservable: Observable<BaseTexture>;
  120068. /**
  120069. * An event triggered when render targets are about to be rendered
  120070. * Can happen multiple times per frame.
  120071. */
  120072. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120073. /**
  120074. * An event triggered when render targets were rendered.
  120075. * Can happen multiple times per frame.
  120076. */
  120077. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120078. /**
  120079. * An event triggered before calculating deterministic simulation step
  120080. */
  120081. onBeforeStepObservable: Observable<Scene>;
  120082. /**
  120083. * An event triggered after calculating deterministic simulation step
  120084. */
  120085. onAfterStepObservable: Observable<Scene>;
  120086. /**
  120087. * An event triggered when the activeCamera property is updated
  120088. */
  120089. onActiveCameraChanged: Observable<Scene>;
  120090. /**
  120091. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120092. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120093. * 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)
  120094. */
  120095. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120096. /**
  120097. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120098. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120099. * 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)
  120100. */
  120101. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120102. /**
  120103. * This Observable will when a mesh has been imported into the scene.
  120104. */
  120105. onMeshImportedObservable: Observable<AbstractMesh>;
  120106. /**
  120107. * This Observable will when an animation file has been imported into the scene.
  120108. */
  120109. onAnimationFileImportedObservable: Observable<Scene>;
  120110. /**
  120111. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120112. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120113. */
  120114. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120115. /** @hidden */
  120116. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120117. /**
  120118. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120119. */
  120120. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120121. /**
  120122. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120123. */
  120124. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120125. /**
  120126. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120127. */
  120128. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120129. /** Callback called when a pointer move is detected */
  120130. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120131. /** Callback called when a pointer down is detected */
  120132. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120133. /** Callback called when a pointer up is detected */
  120134. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120135. /** Callback called when a pointer pick is detected */
  120136. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120137. /**
  120138. * 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).
  120139. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120140. */
  120141. onPrePointerObservable: Observable<PointerInfoPre>;
  120142. /**
  120143. * Observable event triggered each time an input event is received from the rendering canvas
  120144. */
  120145. onPointerObservable: Observable<PointerInfo>;
  120146. /**
  120147. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120148. */
  120149. get unTranslatedPointer(): Vector2;
  120150. /**
  120151. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120152. */
  120153. static get DragMovementThreshold(): number;
  120154. static set DragMovementThreshold(value: number);
  120155. /**
  120156. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120157. */
  120158. static get LongPressDelay(): number;
  120159. static set LongPressDelay(value: number);
  120160. /**
  120161. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120162. */
  120163. static get DoubleClickDelay(): number;
  120164. static set DoubleClickDelay(value: number);
  120165. /** If you need to check double click without raising a single click at first click, enable this flag */
  120166. static get ExclusiveDoubleClickMode(): boolean;
  120167. static set ExclusiveDoubleClickMode(value: boolean);
  120168. /** @hidden */
  120169. _mirroredCameraPosition: Nullable<Vector3>;
  120170. /**
  120171. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120172. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120173. */
  120174. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120175. /**
  120176. * Observable event triggered each time an keyboard event is received from the hosting window
  120177. */
  120178. onKeyboardObservable: Observable<KeyboardInfo>;
  120179. private _useRightHandedSystem;
  120180. /**
  120181. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120182. */
  120183. set useRightHandedSystem(value: boolean);
  120184. get useRightHandedSystem(): boolean;
  120185. private _timeAccumulator;
  120186. private _currentStepId;
  120187. private _currentInternalStep;
  120188. /**
  120189. * Sets the step Id used by deterministic lock step
  120190. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120191. * @param newStepId defines the step Id
  120192. */
  120193. setStepId(newStepId: number): void;
  120194. /**
  120195. * Gets the step Id used by deterministic lock step
  120196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120197. * @returns the step Id
  120198. */
  120199. getStepId(): number;
  120200. /**
  120201. * Gets the internal step used by deterministic lock step
  120202. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120203. * @returns the internal step
  120204. */
  120205. getInternalStep(): number;
  120206. private _fogEnabled;
  120207. /**
  120208. * Gets or sets a boolean indicating if fog is enabled on this scene
  120209. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120210. * (Default is true)
  120211. */
  120212. set fogEnabled(value: boolean);
  120213. get fogEnabled(): boolean;
  120214. private _fogMode;
  120215. /**
  120216. * Gets or sets the fog mode to use
  120217. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120218. * | mode | value |
  120219. * | --- | --- |
  120220. * | FOGMODE_NONE | 0 |
  120221. * | FOGMODE_EXP | 1 |
  120222. * | FOGMODE_EXP2 | 2 |
  120223. * | FOGMODE_LINEAR | 3 |
  120224. */
  120225. set fogMode(value: number);
  120226. get fogMode(): number;
  120227. /**
  120228. * Gets or sets the fog color to use
  120229. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120230. * (Default is Color3(0.2, 0.2, 0.3))
  120231. */
  120232. fogColor: Color3;
  120233. /**
  120234. * Gets or sets the fog density to use
  120235. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120236. * (Default is 0.1)
  120237. */
  120238. fogDensity: number;
  120239. /**
  120240. * Gets or sets the fog start distance to use
  120241. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120242. * (Default is 0)
  120243. */
  120244. fogStart: number;
  120245. /**
  120246. * Gets or sets the fog end distance to use
  120247. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120248. * (Default is 1000)
  120249. */
  120250. fogEnd: number;
  120251. /**
  120252. * Flag indicating that the frame buffer binding is handled by another component
  120253. */
  120254. prePass: boolean;
  120255. private _shadowsEnabled;
  120256. /**
  120257. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120258. */
  120259. set shadowsEnabled(value: boolean);
  120260. get shadowsEnabled(): boolean;
  120261. private _lightsEnabled;
  120262. /**
  120263. * Gets or sets a boolean indicating if lights are enabled on this scene
  120264. */
  120265. set lightsEnabled(value: boolean);
  120266. get lightsEnabled(): boolean;
  120267. /** All of the active cameras added to this scene. */
  120268. activeCameras: Camera[];
  120269. /** @hidden */
  120270. _activeCamera: Nullable<Camera>;
  120271. /** Gets or sets the current active camera */
  120272. get activeCamera(): Nullable<Camera>;
  120273. set activeCamera(value: Nullable<Camera>);
  120274. private _defaultMaterial;
  120275. /** The default material used on meshes when no material is affected */
  120276. get defaultMaterial(): Material;
  120277. /** The default material used on meshes when no material is affected */
  120278. set defaultMaterial(value: Material);
  120279. private _texturesEnabled;
  120280. /**
  120281. * Gets or sets a boolean indicating if textures are enabled on this scene
  120282. */
  120283. set texturesEnabled(value: boolean);
  120284. get texturesEnabled(): boolean;
  120285. /**
  120286. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120287. */
  120288. physicsEnabled: boolean;
  120289. /**
  120290. * Gets or sets a boolean indicating if particles are enabled on this scene
  120291. */
  120292. particlesEnabled: boolean;
  120293. /**
  120294. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120295. */
  120296. spritesEnabled: boolean;
  120297. private _skeletonsEnabled;
  120298. /**
  120299. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120300. */
  120301. set skeletonsEnabled(value: boolean);
  120302. get skeletonsEnabled(): boolean;
  120303. /**
  120304. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120305. */
  120306. lensFlaresEnabled: boolean;
  120307. /**
  120308. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120309. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120310. */
  120311. collisionsEnabled: boolean;
  120312. private _collisionCoordinator;
  120313. /** @hidden */
  120314. get collisionCoordinator(): ICollisionCoordinator;
  120315. /**
  120316. * Defines the gravity applied to this scene (used only for collisions)
  120317. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120318. */
  120319. gravity: Vector3;
  120320. /**
  120321. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120322. */
  120323. postProcessesEnabled: boolean;
  120324. /**
  120325. * Gets the current postprocess manager
  120326. */
  120327. postProcessManager: PostProcessManager;
  120328. /**
  120329. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120330. */
  120331. renderTargetsEnabled: boolean;
  120332. /**
  120333. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120334. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120335. */
  120336. dumpNextRenderTargets: boolean;
  120337. /**
  120338. * The list of user defined render targets added to the scene
  120339. */
  120340. customRenderTargets: RenderTargetTexture[];
  120341. /**
  120342. * Defines if texture loading must be delayed
  120343. * If true, textures will only be loaded when they need to be rendered
  120344. */
  120345. useDelayedTextureLoading: boolean;
  120346. /**
  120347. * Gets the list of meshes imported to the scene through SceneLoader
  120348. */
  120349. importedMeshesFiles: String[];
  120350. /**
  120351. * Gets or sets a boolean indicating if probes are enabled on this scene
  120352. */
  120353. probesEnabled: boolean;
  120354. /**
  120355. * Gets or sets the current offline provider to use to store scene data
  120356. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120357. */
  120358. offlineProvider: IOfflineProvider;
  120359. /**
  120360. * Gets or sets the action manager associated with the scene
  120361. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120362. */
  120363. actionManager: AbstractActionManager;
  120364. private _meshesForIntersections;
  120365. /**
  120366. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120367. */
  120368. proceduralTexturesEnabled: boolean;
  120369. private _engine;
  120370. private _totalVertices;
  120371. /** @hidden */
  120372. _activeIndices: PerfCounter;
  120373. /** @hidden */
  120374. _activeParticles: PerfCounter;
  120375. /** @hidden */
  120376. _activeBones: PerfCounter;
  120377. private _animationRatio;
  120378. /** @hidden */
  120379. _animationTimeLast: number;
  120380. /** @hidden */
  120381. _animationTime: number;
  120382. /**
  120383. * Gets or sets a general scale for animation speed
  120384. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120385. */
  120386. animationTimeScale: number;
  120387. /** @hidden */
  120388. _cachedMaterial: Nullable<Material>;
  120389. /** @hidden */
  120390. _cachedEffect: Nullable<Effect>;
  120391. /** @hidden */
  120392. _cachedVisibility: Nullable<number>;
  120393. private _renderId;
  120394. private _frameId;
  120395. private _executeWhenReadyTimeoutId;
  120396. private _intermediateRendering;
  120397. private _viewUpdateFlag;
  120398. private _projectionUpdateFlag;
  120399. /** @hidden */
  120400. _toBeDisposed: Nullable<IDisposable>[];
  120401. private _activeRequests;
  120402. /** @hidden */
  120403. _pendingData: any[];
  120404. private _isDisposed;
  120405. /**
  120406. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120407. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120408. */
  120409. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120410. private _activeMeshes;
  120411. private _processedMaterials;
  120412. private _renderTargets;
  120413. /** @hidden */
  120414. _activeParticleSystems: SmartArray<IParticleSystem>;
  120415. private _activeSkeletons;
  120416. private _softwareSkinnedMeshes;
  120417. private _renderingManager;
  120418. /** @hidden */
  120419. _activeAnimatables: Animatable[];
  120420. private _transformMatrix;
  120421. private _sceneUbo;
  120422. /** @hidden */
  120423. _viewMatrix: Matrix;
  120424. private _projectionMatrix;
  120425. /** @hidden */
  120426. _forcedViewPosition: Nullable<Vector3>;
  120427. /** @hidden */
  120428. _frustumPlanes: Plane[];
  120429. /**
  120430. * Gets the list of frustum planes (built from the active camera)
  120431. */
  120432. get frustumPlanes(): Plane[];
  120433. /**
  120434. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120435. * This is useful if there are more lights that the maximum simulteanous authorized
  120436. */
  120437. requireLightSorting: boolean;
  120438. /** @hidden */
  120439. readonly useMaterialMeshMap: boolean;
  120440. /** @hidden */
  120441. readonly useClonedMeshMap: boolean;
  120442. private _externalData;
  120443. private _uid;
  120444. /**
  120445. * @hidden
  120446. * Backing store of defined scene components.
  120447. */
  120448. _components: ISceneComponent[];
  120449. /**
  120450. * @hidden
  120451. * Backing store of defined scene components.
  120452. */
  120453. _serializableComponents: ISceneSerializableComponent[];
  120454. /**
  120455. * List of components to register on the next registration step.
  120456. */
  120457. private _transientComponents;
  120458. /**
  120459. * Registers the transient components if needed.
  120460. */
  120461. private _registerTransientComponents;
  120462. /**
  120463. * @hidden
  120464. * Add a component to the scene.
  120465. * Note that the ccomponent could be registered on th next frame if this is called after
  120466. * the register component stage.
  120467. * @param component Defines the component to add to the scene
  120468. */
  120469. _addComponent(component: ISceneComponent): void;
  120470. /**
  120471. * @hidden
  120472. * Gets a component from the scene.
  120473. * @param name defines the name of the component to retrieve
  120474. * @returns the component or null if not present
  120475. */
  120476. _getComponent(name: string): Nullable<ISceneComponent>;
  120477. /**
  120478. * @hidden
  120479. * Defines the actions happening before camera updates.
  120480. */
  120481. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120482. /**
  120483. * @hidden
  120484. * Defines the actions happening before clear the canvas.
  120485. */
  120486. _beforeClearStage: Stage<SimpleStageAction>;
  120487. /**
  120488. * @hidden
  120489. * Defines the actions when collecting render targets for the frame.
  120490. */
  120491. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120492. /**
  120493. * @hidden
  120494. * Defines the actions happening for one camera in the frame.
  120495. */
  120496. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120497. /**
  120498. * @hidden
  120499. * Defines the actions happening during the per mesh ready checks.
  120500. */
  120501. _isReadyForMeshStage: Stage<MeshStageAction>;
  120502. /**
  120503. * @hidden
  120504. * Defines the actions happening before evaluate active mesh checks.
  120505. */
  120506. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120507. /**
  120508. * @hidden
  120509. * Defines the actions happening during the evaluate sub mesh checks.
  120510. */
  120511. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120512. /**
  120513. * @hidden
  120514. * Defines the actions happening during the active mesh stage.
  120515. */
  120516. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120517. /**
  120518. * @hidden
  120519. * Defines the actions happening during the per camera render target step.
  120520. */
  120521. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120522. /**
  120523. * @hidden
  120524. * Defines the actions happening just before the active camera is drawing.
  120525. */
  120526. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120527. /**
  120528. * @hidden
  120529. * Defines the actions happening just before a render target is drawing.
  120530. */
  120531. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120532. /**
  120533. * @hidden
  120534. * Defines the actions happening just before a rendering group is drawing.
  120535. */
  120536. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120537. /**
  120538. * @hidden
  120539. * Defines the actions happening just before a mesh is drawing.
  120540. */
  120541. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120542. /**
  120543. * @hidden
  120544. * Defines the actions happening just after a mesh has been drawn.
  120545. */
  120546. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120547. /**
  120548. * @hidden
  120549. * Defines the actions happening just after a rendering group has been drawn.
  120550. */
  120551. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120552. /**
  120553. * @hidden
  120554. * Defines the actions happening just after the active camera has been drawn.
  120555. */
  120556. _afterCameraDrawStage: Stage<CameraStageAction>;
  120557. /**
  120558. * @hidden
  120559. * Defines the actions happening just after a render target has been drawn.
  120560. */
  120561. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120562. /**
  120563. * @hidden
  120564. * Defines the actions happening just after rendering all cameras and computing intersections.
  120565. */
  120566. _afterRenderStage: Stage<SimpleStageAction>;
  120567. /**
  120568. * @hidden
  120569. * Defines the actions happening when a pointer move event happens.
  120570. */
  120571. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120572. /**
  120573. * @hidden
  120574. * Defines the actions happening when a pointer down event happens.
  120575. */
  120576. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120577. /**
  120578. * @hidden
  120579. * Defines the actions happening when a pointer up event happens.
  120580. */
  120581. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120582. /**
  120583. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120584. */
  120585. private geometriesByUniqueId;
  120586. /**
  120587. * Creates a new Scene
  120588. * @param engine defines the engine to use to render this scene
  120589. * @param options defines the scene options
  120590. */
  120591. constructor(engine: Engine, options?: SceneOptions);
  120592. /**
  120593. * Gets a string identifying the name of the class
  120594. * @returns "Scene" string
  120595. */
  120596. getClassName(): string;
  120597. private _defaultMeshCandidates;
  120598. /**
  120599. * @hidden
  120600. */
  120601. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120602. private _defaultSubMeshCandidates;
  120603. /**
  120604. * @hidden
  120605. */
  120606. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120607. /**
  120608. * Sets the default candidate providers for the scene.
  120609. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120610. * and getCollidingSubMeshCandidates to their default function
  120611. */
  120612. setDefaultCandidateProviders(): void;
  120613. /**
  120614. * Gets the mesh that is currently under the pointer
  120615. */
  120616. get meshUnderPointer(): Nullable<AbstractMesh>;
  120617. /**
  120618. * Gets or sets the current on-screen X position of the pointer
  120619. */
  120620. get pointerX(): number;
  120621. set pointerX(value: number);
  120622. /**
  120623. * Gets or sets the current on-screen Y position of the pointer
  120624. */
  120625. get pointerY(): number;
  120626. set pointerY(value: number);
  120627. /**
  120628. * Gets the cached material (ie. the latest rendered one)
  120629. * @returns the cached material
  120630. */
  120631. getCachedMaterial(): Nullable<Material>;
  120632. /**
  120633. * Gets the cached effect (ie. the latest rendered one)
  120634. * @returns the cached effect
  120635. */
  120636. getCachedEffect(): Nullable<Effect>;
  120637. /**
  120638. * Gets the cached visibility state (ie. the latest rendered one)
  120639. * @returns the cached visibility state
  120640. */
  120641. getCachedVisibility(): Nullable<number>;
  120642. /**
  120643. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120644. * @param material defines the current material
  120645. * @param effect defines the current effect
  120646. * @param visibility defines the current visibility state
  120647. * @returns true if one parameter is not cached
  120648. */
  120649. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120650. /**
  120651. * Gets the engine associated with the scene
  120652. * @returns an Engine
  120653. */
  120654. getEngine(): Engine;
  120655. /**
  120656. * Gets the total number of vertices rendered per frame
  120657. * @returns the total number of vertices rendered per frame
  120658. */
  120659. getTotalVertices(): number;
  120660. /**
  120661. * Gets the performance counter for total vertices
  120662. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120663. */
  120664. get totalVerticesPerfCounter(): PerfCounter;
  120665. /**
  120666. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120667. * @returns the total number of active indices rendered per frame
  120668. */
  120669. getActiveIndices(): number;
  120670. /**
  120671. * Gets the performance counter for active indices
  120672. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120673. */
  120674. get totalActiveIndicesPerfCounter(): PerfCounter;
  120675. /**
  120676. * Gets the total number of active particles rendered per frame
  120677. * @returns the total number of active particles rendered per frame
  120678. */
  120679. getActiveParticles(): number;
  120680. /**
  120681. * Gets the performance counter for active particles
  120682. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120683. */
  120684. get activeParticlesPerfCounter(): PerfCounter;
  120685. /**
  120686. * Gets the total number of active bones rendered per frame
  120687. * @returns the total number of active bones rendered per frame
  120688. */
  120689. getActiveBones(): number;
  120690. /**
  120691. * Gets the performance counter for active bones
  120692. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120693. */
  120694. get activeBonesPerfCounter(): PerfCounter;
  120695. /**
  120696. * Gets the array of active meshes
  120697. * @returns an array of AbstractMesh
  120698. */
  120699. getActiveMeshes(): SmartArray<AbstractMesh>;
  120700. /**
  120701. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120702. * @returns a number
  120703. */
  120704. getAnimationRatio(): number;
  120705. /**
  120706. * Gets an unique Id for the current render phase
  120707. * @returns a number
  120708. */
  120709. getRenderId(): number;
  120710. /**
  120711. * Gets an unique Id for the current frame
  120712. * @returns a number
  120713. */
  120714. getFrameId(): number;
  120715. /** Call this function if you want to manually increment the render Id*/
  120716. incrementRenderId(): void;
  120717. private _createUbo;
  120718. /**
  120719. * Use this method to simulate a pointer move on a mesh
  120720. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120721. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120722. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120723. * @returns the current scene
  120724. */
  120725. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120726. /**
  120727. * Use this method to simulate a pointer down on a mesh
  120728. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120729. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120730. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120731. * @returns the current scene
  120732. */
  120733. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120734. /**
  120735. * Use this method to simulate a pointer up on a mesh
  120736. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120737. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120738. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120739. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120740. * @returns the current scene
  120741. */
  120742. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120743. /**
  120744. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120745. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120746. * @returns true if the pointer was captured
  120747. */
  120748. isPointerCaptured(pointerId?: number): boolean;
  120749. /**
  120750. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120751. * @param attachUp defines if you want to attach events to pointerup
  120752. * @param attachDown defines if you want to attach events to pointerdown
  120753. * @param attachMove defines if you want to attach events to pointermove
  120754. */
  120755. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120756. /** Detaches all event handlers*/
  120757. detachControl(): void;
  120758. /**
  120759. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120760. * Delay loaded resources are not taking in account
  120761. * @return true if all required resources are ready
  120762. */
  120763. isReady(): boolean;
  120764. /** Resets all cached information relative to material (including effect and visibility) */
  120765. resetCachedMaterial(): void;
  120766. /**
  120767. * Registers a function to be called before every frame render
  120768. * @param func defines the function to register
  120769. */
  120770. registerBeforeRender(func: () => void): void;
  120771. /**
  120772. * Unregisters a function called before every frame render
  120773. * @param func defines the function to unregister
  120774. */
  120775. unregisterBeforeRender(func: () => void): void;
  120776. /**
  120777. * Registers a function to be called after every frame render
  120778. * @param func defines the function to register
  120779. */
  120780. registerAfterRender(func: () => void): void;
  120781. /**
  120782. * Unregisters a function called after every frame render
  120783. * @param func defines the function to unregister
  120784. */
  120785. unregisterAfterRender(func: () => void): void;
  120786. private _executeOnceBeforeRender;
  120787. /**
  120788. * The provided function will run before render once and will be disposed afterwards.
  120789. * A timeout delay can be provided so that the function will be executed in N ms.
  120790. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120791. * @param func The function to be executed.
  120792. * @param timeout optional delay in ms
  120793. */
  120794. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120795. /** @hidden */
  120796. _addPendingData(data: any): void;
  120797. /** @hidden */
  120798. _removePendingData(data: any): void;
  120799. /**
  120800. * Returns the number of items waiting to be loaded
  120801. * @returns the number of items waiting to be loaded
  120802. */
  120803. getWaitingItemsCount(): number;
  120804. /**
  120805. * Returns a boolean indicating if the scene is still loading data
  120806. */
  120807. get isLoading(): boolean;
  120808. /**
  120809. * Registers a function to be executed when the scene is ready
  120810. * @param {Function} func - the function to be executed
  120811. */
  120812. executeWhenReady(func: () => void): void;
  120813. /**
  120814. * Returns a promise that resolves when the scene is ready
  120815. * @returns A promise that resolves when the scene is ready
  120816. */
  120817. whenReadyAsync(): Promise<void>;
  120818. /** @hidden */
  120819. _checkIsReady(): void;
  120820. /**
  120821. * Gets all animatable attached to the scene
  120822. */
  120823. get animatables(): Animatable[];
  120824. /**
  120825. * Resets the last animation time frame.
  120826. * Useful to override when animations start running when loading a scene for the first time.
  120827. */
  120828. resetLastAnimationTimeFrame(): void;
  120829. /**
  120830. * Gets the current view matrix
  120831. * @returns a Matrix
  120832. */
  120833. getViewMatrix(): Matrix;
  120834. /**
  120835. * Gets the current projection matrix
  120836. * @returns a Matrix
  120837. */
  120838. getProjectionMatrix(): Matrix;
  120839. /**
  120840. * Gets the current transform matrix
  120841. * @returns a Matrix made of View * Projection
  120842. */
  120843. getTransformMatrix(): Matrix;
  120844. /**
  120845. * Sets the current transform matrix
  120846. * @param viewL defines the View matrix to use
  120847. * @param projectionL defines the Projection matrix to use
  120848. * @param viewR defines the right View matrix to use (if provided)
  120849. * @param projectionR defines the right Projection matrix to use (if provided)
  120850. */
  120851. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120852. /**
  120853. * Gets the uniform buffer used to store scene data
  120854. * @returns a UniformBuffer
  120855. */
  120856. getSceneUniformBuffer(): UniformBuffer;
  120857. /**
  120858. * Gets an unique (relatively to the current scene) Id
  120859. * @returns an unique number for the scene
  120860. */
  120861. getUniqueId(): number;
  120862. /**
  120863. * Add a mesh to the list of scene's meshes
  120864. * @param newMesh defines the mesh to add
  120865. * @param recursive if all child meshes should also be added to the scene
  120866. */
  120867. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120868. /**
  120869. * Remove a mesh for the list of scene's meshes
  120870. * @param toRemove defines the mesh to remove
  120871. * @param recursive if all child meshes should also be removed from the scene
  120872. * @returns the index where the mesh was in the mesh list
  120873. */
  120874. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120875. /**
  120876. * Add a transform node to the list of scene's transform nodes
  120877. * @param newTransformNode defines the transform node to add
  120878. */
  120879. addTransformNode(newTransformNode: TransformNode): void;
  120880. /**
  120881. * Remove a transform node for the list of scene's transform nodes
  120882. * @param toRemove defines the transform node to remove
  120883. * @returns the index where the transform node was in the transform node list
  120884. */
  120885. removeTransformNode(toRemove: TransformNode): number;
  120886. /**
  120887. * Remove a skeleton for the list of scene's skeletons
  120888. * @param toRemove defines the skeleton to remove
  120889. * @returns the index where the skeleton was in the skeleton list
  120890. */
  120891. removeSkeleton(toRemove: Skeleton): number;
  120892. /**
  120893. * Remove a morph target for the list of scene's morph targets
  120894. * @param toRemove defines the morph target to remove
  120895. * @returns the index where the morph target was in the morph target list
  120896. */
  120897. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120898. /**
  120899. * Remove a light for the list of scene's lights
  120900. * @param toRemove defines the light to remove
  120901. * @returns the index where the light was in the light list
  120902. */
  120903. removeLight(toRemove: Light): number;
  120904. /**
  120905. * Remove a camera for the list of scene's cameras
  120906. * @param toRemove defines the camera to remove
  120907. * @returns the index where the camera was in the camera list
  120908. */
  120909. removeCamera(toRemove: Camera): number;
  120910. /**
  120911. * Remove a particle system for the list of scene's particle systems
  120912. * @param toRemove defines the particle system to remove
  120913. * @returns the index where the particle system was in the particle system list
  120914. */
  120915. removeParticleSystem(toRemove: IParticleSystem): number;
  120916. /**
  120917. * Remove a animation for the list of scene's animations
  120918. * @param toRemove defines the animation to remove
  120919. * @returns the index where the animation was in the animation list
  120920. */
  120921. removeAnimation(toRemove: Animation): number;
  120922. /**
  120923. * Will stop the animation of the given target
  120924. * @param target - the target
  120925. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120926. * @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)
  120927. */
  120928. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120929. /**
  120930. * Removes the given animation group from this scene.
  120931. * @param toRemove The animation group to remove
  120932. * @returns The index of the removed animation group
  120933. */
  120934. removeAnimationGroup(toRemove: AnimationGroup): number;
  120935. /**
  120936. * Removes the given multi-material from this scene.
  120937. * @param toRemove The multi-material to remove
  120938. * @returns The index of the removed multi-material
  120939. */
  120940. removeMultiMaterial(toRemove: MultiMaterial): number;
  120941. /**
  120942. * Removes the given material from this scene.
  120943. * @param toRemove The material to remove
  120944. * @returns The index of the removed material
  120945. */
  120946. removeMaterial(toRemove: Material): number;
  120947. /**
  120948. * Removes the given action manager from this scene.
  120949. * @param toRemove The action manager to remove
  120950. * @returns The index of the removed action manager
  120951. */
  120952. removeActionManager(toRemove: AbstractActionManager): number;
  120953. /**
  120954. * Removes the given texture from this scene.
  120955. * @param toRemove The texture to remove
  120956. * @returns The index of the removed texture
  120957. */
  120958. removeTexture(toRemove: BaseTexture): number;
  120959. /**
  120960. * Adds the given light to this scene
  120961. * @param newLight The light to add
  120962. */
  120963. addLight(newLight: Light): void;
  120964. /**
  120965. * Sorts the list list based on light priorities
  120966. */
  120967. sortLightsByPriority(): void;
  120968. /**
  120969. * Adds the given camera to this scene
  120970. * @param newCamera The camera to add
  120971. */
  120972. addCamera(newCamera: Camera): void;
  120973. /**
  120974. * Adds the given skeleton to this scene
  120975. * @param newSkeleton The skeleton to add
  120976. */
  120977. addSkeleton(newSkeleton: Skeleton): void;
  120978. /**
  120979. * Adds the given particle system to this scene
  120980. * @param newParticleSystem The particle system to add
  120981. */
  120982. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120983. /**
  120984. * Adds the given animation to this scene
  120985. * @param newAnimation The animation to add
  120986. */
  120987. addAnimation(newAnimation: Animation): void;
  120988. /**
  120989. * Adds the given animation group to this scene.
  120990. * @param newAnimationGroup The animation group to add
  120991. */
  120992. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120993. /**
  120994. * Adds the given multi-material to this scene
  120995. * @param newMultiMaterial The multi-material to add
  120996. */
  120997. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120998. /**
  120999. * Adds the given material to this scene
  121000. * @param newMaterial The material to add
  121001. */
  121002. addMaterial(newMaterial: Material): void;
  121003. /**
  121004. * Adds the given morph target to this scene
  121005. * @param newMorphTargetManager The morph target to add
  121006. */
  121007. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121008. /**
  121009. * Adds the given geometry to this scene
  121010. * @param newGeometry The geometry to add
  121011. */
  121012. addGeometry(newGeometry: Geometry): void;
  121013. /**
  121014. * Adds the given action manager to this scene
  121015. * @param newActionManager The action manager to add
  121016. */
  121017. addActionManager(newActionManager: AbstractActionManager): void;
  121018. /**
  121019. * Adds the given texture to this scene.
  121020. * @param newTexture The texture to add
  121021. */
  121022. addTexture(newTexture: BaseTexture): void;
  121023. /**
  121024. * Switch active camera
  121025. * @param newCamera defines the new active camera
  121026. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121027. */
  121028. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121029. /**
  121030. * sets the active camera of the scene using its ID
  121031. * @param id defines the camera's ID
  121032. * @return the new active camera or null if none found.
  121033. */
  121034. setActiveCameraByID(id: string): Nullable<Camera>;
  121035. /**
  121036. * sets the active camera of the scene using its name
  121037. * @param name defines the camera's name
  121038. * @returns the new active camera or null if none found.
  121039. */
  121040. setActiveCameraByName(name: string): Nullable<Camera>;
  121041. /**
  121042. * get an animation group using its name
  121043. * @param name defines the material's name
  121044. * @return the animation group or null if none found.
  121045. */
  121046. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121047. /**
  121048. * Get a material using its unique id
  121049. * @param uniqueId defines the material's unique id
  121050. * @return the material or null if none found.
  121051. */
  121052. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121053. /**
  121054. * get a material using its id
  121055. * @param id defines the material's ID
  121056. * @return the material or null if none found.
  121057. */
  121058. getMaterialByID(id: string): Nullable<Material>;
  121059. /**
  121060. * Gets a the last added material using a given id
  121061. * @param id defines the material's ID
  121062. * @return the last material with the given id or null if none found.
  121063. */
  121064. getLastMaterialByID(id: string): Nullable<Material>;
  121065. /**
  121066. * Gets a material using its name
  121067. * @param name defines the material's name
  121068. * @return the material or null if none found.
  121069. */
  121070. getMaterialByName(name: string): Nullable<Material>;
  121071. /**
  121072. * Get a texture using its unique id
  121073. * @param uniqueId defines the texture's unique id
  121074. * @return the texture or null if none found.
  121075. */
  121076. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121077. /**
  121078. * Gets a camera using its id
  121079. * @param id defines the id to look for
  121080. * @returns the camera or null if not found
  121081. */
  121082. getCameraByID(id: string): Nullable<Camera>;
  121083. /**
  121084. * Gets a camera using its unique id
  121085. * @param uniqueId defines the unique id to look for
  121086. * @returns the camera or null if not found
  121087. */
  121088. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121089. /**
  121090. * Gets a camera using its name
  121091. * @param name defines the camera's name
  121092. * @return the camera or null if none found.
  121093. */
  121094. getCameraByName(name: string): Nullable<Camera>;
  121095. /**
  121096. * Gets a bone using its id
  121097. * @param id defines the bone's id
  121098. * @return the bone or null if not found
  121099. */
  121100. getBoneByID(id: string): Nullable<Bone>;
  121101. /**
  121102. * Gets a bone using its id
  121103. * @param name defines the bone's name
  121104. * @return the bone or null if not found
  121105. */
  121106. getBoneByName(name: string): Nullable<Bone>;
  121107. /**
  121108. * Gets a light node using its name
  121109. * @param name defines the the light's name
  121110. * @return the light or null if none found.
  121111. */
  121112. getLightByName(name: string): Nullable<Light>;
  121113. /**
  121114. * Gets a light node using its id
  121115. * @param id defines the light's id
  121116. * @return the light or null if none found.
  121117. */
  121118. getLightByID(id: string): Nullable<Light>;
  121119. /**
  121120. * Gets a light node using its scene-generated unique ID
  121121. * @param uniqueId defines the light's unique id
  121122. * @return the light or null if none found.
  121123. */
  121124. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121125. /**
  121126. * Gets a particle system by id
  121127. * @param id defines the particle system id
  121128. * @return the corresponding system or null if none found
  121129. */
  121130. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121131. /**
  121132. * Gets a geometry using its ID
  121133. * @param id defines the geometry's id
  121134. * @return the geometry or null if none found.
  121135. */
  121136. getGeometryByID(id: string): Nullable<Geometry>;
  121137. private _getGeometryByUniqueID;
  121138. /**
  121139. * Add a new geometry to this scene
  121140. * @param geometry defines the geometry to be added to the scene.
  121141. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121142. * @return a boolean defining if the geometry was added or not
  121143. */
  121144. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121145. /**
  121146. * Removes an existing geometry
  121147. * @param geometry defines the geometry to be removed from the scene
  121148. * @return a boolean defining if the geometry was removed or not
  121149. */
  121150. removeGeometry(geometry: Geometry): boolean;
  121151. /**
  121152. * Gets the list of geometries attached to the scene
  121153. * @returns an array of Geometry
  121154. */
  121155. getGeometries(): Geometry[];
  121156. /**
  121157. * Gets the first added mesh found of a given ID
  121158. * @param id defines the id to search for
  121159. * @return the mesh found or null if not found at all
  121160. */
  121161. getMeshByID(id: string): Nullable<AbstractMesh>;
  121162. /**
  121163. * Gets a list of meshes using their id
  121164. * @param id defines the id to search for
  121165. * @returns a list of meshes
  121166. */
  121167. getMeshesByID(id: string): Array<AbstractMesh>;
  121168. /**
  121169. * Gets the first added transform node found of a given ID
  121170. * @param id defines the id to search for
  121171. * @return the found transform node or null if not found at all.
  121172. */
  121173. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121174. /**
  121175. * Gets a transform node with its auto-generated unique id
  121176. * @param uniqueId efines the unique id to search for
  121177. * @return the found transform node or null if not found at all.
  121178. */
  121179. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121180. /**
  121181. * Gets a list of transform nodes using their id
  121182. * @param id defines the id to search for
  121183. * @returns a list of transform nodes
  121184. */
  121185. getTransformNodesByID(id: string): Array<TransformNode>;
  121186. /**
  121187. * Gets a mesh with its auto-generated unique id
  121188. * @param uniqueId defines the unique id to search for
  121189. * @return the found mesh or null if not found at all.
  121190. */
  121191. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121192. /**
  121193. * Gets a the last added mesh using a given id
  121194. * @param id defines the id to search for
  121195. * @return the found mesh or null if not found at all.
  121196. */
  121197. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121198. /**
  121199. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121200. * @param id defines the id to search for
  121201. * @return the found node or null if not found at all
  121202. */
  121203. getLastEntryByID(id: string): Nullable<Node>;
  121204. /**
  121205. * Gets a node (Mesh, Camera, Light) using a given id
  121206. * @param id defines the id to search for
  121207. * @return the found node or null if not found at all
  121208. */
  121209. getNodeByID(id: string): Nullable<Node>;
  121210. /**
  121211. * Gets a node (Mesh, Camera, Light) using a given name
  121212. * @param name defines the name to search for
  121213. * @return the found node or null if not found at all.
  121214. */
  121215. getNodeByName(name: string): Nullable<Node>;
  121216. /**
  121217. * Gets a mesh using a given name
  121218. * @param name defines the name to search for
  121219. * @return the found mesh or null if not found at all.
  121220. */
  121221. getMeshByName(name: string): Nullable<AbstractMesh>;
  121222. /**
  121223. * Gets a transform node using a given name
  121224. * @param name defines the name to search for
  121225. * @return the found transform node or null if not found at all.
  121226. */
  121227. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121228. /**
  121229. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121230. * @param id defines the id to search for
  121231. * @return the found skeleton or null if not found at all.
  121232. */
  121233. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121234. /**
  121235. * Gets a skeleton using a given auto generated unique id
  121236. * @param uniqueId defines the unique id to search for
  121237. * @return the found skeleton or null if not found at all.
  121238. */
  121239. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121240. /**
  121241. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121242. * @param id defines the id to search for
  121243. * @return the found skeleton or null if not found at all.
  121244. */
  121245. getSkeletonById(id: string): Nullable<Skeleton>;
  121246. /**
  121247. * Gets a skeleton using a given name
  121248. * @param name defines the name to search for
  121249. * @return the found skeleton or null if not found at all.
  121250. */
  121251. getSkeletonByName(name: string): Nullable<Skeleton>;
  121252. /**
  121253. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121254. * @param id defines the id to search for
  121255. * @return the found morph target manager or null if not found at all.
  121256. */
  121257. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121258. /**
  121259. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121260. * @param id defines the id to search for
  121261. * @return the found morph target or null if not found at all.
  121262. */
  121263. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121264. /**
  121265. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121266. * @param name defines the name to search for
  121267. * @return the found morph target or null if not found at all.
  121268. */
  121269. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121270. /**
  121271. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121272. * @param name defines the name to search for
  121273. * @return the found post process or null if not found at all.
  121274. */
  121275. getPostProcessByName(name: string): Nullable<PostProcess>;
  121276. /**
  121277. * Gets a boolean indicating if the given mesh is active
  121278. * @param mesh defines the mesh to look for
  121279. * @returns true if the mesh is in the active list
  121280. */
  121281. isActiveMesh(mesh: AbstractMesh): boolean;
  121282. /**
  121283. * Return a unique id as a string which can serve as an identifier for the scene
  121284. */
  121285. get uid(): string;
  121286. /**
  121287. * Add an externaly attached data from its key.
  121288. * This method call will fail and return false, if such key already exists.
  121289. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121290. * @param key the unique key that identifies the data
  121291. * @param data the data object to associate to the key for this Engine instance
  121292. * @return true if no such key were already present and the data was added successfully, false otherwise
  121293. */
  121294. addExternalData<T>(key: string, data: T): boolean;
  121295. /**
  121296. * Get an externaly attached data from its key
  121297. * @param key the unique key that identifies the data
  121298. * @return the associated data, if present (can be null), or undefined if not present
  121299. */
  121300. getExternalData<T>(key: string): Nullable<T>;
  121301. /**
  121302. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121303. * @param key the unique key that identifies the data
  121304. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121305. * @return the associated data, can be null if the factory returned null.
  121306. */
  121307. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121308. /**
  121309. * Remove an externaly attached data from the Engine instance
  121310. * @param key the unique key that identifies the data
  121311. * @return true if the data was successfully removed, false if it doesn't exist
  121312. */
  121313. removeExternalData(key: string): boolean;
  121314. private _evaluateSubMesh;
  121315. /**
  121316. * Clear the processed materials smart array preventing retention point in material dispose.
  121317. */
  121318. freeProcessedMaterials(): void;
  121319. private _preventFreeActiveMeshesAndRenderingGroups;
  121320. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121321. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121322. * when disposing several meshes in a row or a hierarchy of meshes.
  121323. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121324. */
  121325. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121326. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121327. /**
  121328. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121329. */
  121330. freeActiveMeshes(): void;
  121331. /**
  121332. * Clear the info related to rendering groups preventing retention points during dispose.
  121333. */
  121334. freeRenderingGroups(): void;
  121335. /** @hidden */
  121336. _isInIntermediateRendering(): boolean;
  121337. /**
  121338. * Lambda returning the list of potentially active meshes.
  121339. */
  121340. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121341. /**
  121342. * Lambda returning the list of potentially active sub meshes.
  121343. */
  121344. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121345. /**
  121346. * Lambda returning the list of potentially intersecting sub meshes.
  121347. */
  121348. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121349. /**
  121350. * Lambda returning the list of potentially colliding sub meshes.
  121351. */
  121352. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121353. private _activeMeshesFrozen;
  121354. private _skipEvaluateActiveMeshesCompletely;
  121355. /**
  121356. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121357. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121358. * @returns the current scene
  121359. */
  121360. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121361. /**
  121362. * Use this function to restart evaluating active meshes on every frame
  121363. * @returns the current scene
  121364. */
  121365. unfreezeActiveMeshes(): Scene;
  121366. private _evaluateActiveMeshes;
  121367. private _activeMesh;
  121368. /**
  121369. * Update the transform matrix to update from the current active camera
  121370. * @param force defines a boolean used to force the update even if cache is up to date
  121371. */
  121372. updateTransformMatrix(force?: boolean): void;
  121373. private _bindFrameBuffer;
  121374. /** @hidden */
  121375. _allowPostProcessClearColor: boolean;
  121376. /** @hidden */
  121377. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121378. private _processSubCameras;
  121379. private _checkIntersections;
  121380. /** @hidden */
  121381. _advancePhysicsEngineStep(step: number): void;
  121382. /**
  121383. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121384. */
  121385. getDeterministicFrameTime: () => number;
  121386. /** @hidden */
  121387. _animate(): void;
  121388. /** Execute all animations (for a frame) */
  121389. animate(): void;
  121390. /**
  121391. * Render the scene
  121392. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121393. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121394. */
  121395. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121396. /**
  121397. * Freeze all materials
  121398. * A frozen material will not be updatable but should be faster to render
  121399. */
  121400. freezeMaterials(): void;
  121401. /**
  121402. * Unfreeze all materials
  121403. * A frozen material will not be updatable but should be faster to render
  121404. */
  121405. unfreezeMaterials(): void;
  121406. /**
  121407. * Releases all held ressources
  121408. */
  121409. dispose(): void;
  121410. /**
  121411. * Gets if the scene is already disposed
  121412. */
  121413. get isDisposed(): boolean;
  121414. /**
  121415. * Call this function to reduce memory footprint of the scene.
  121416. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121417. */
  121418. clearCachedVertexData(): void;
  121419. /**
  121420. * This function will remove the local cached buffer data from texture.
  121421. * It will save memory but will prevent the texture from being rebuilt
  121422. */
  121423. cleanCachedTextureBuffer(): void;
  121424. /**
  121425. * Get the world extend vectors with an optional filter
  121426. *
  121427. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121428. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121429. */
  121430. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121431. min: Vector3;
  121432. max: Vector3;
  121433. };
  121434. /**
  121435. * Creates a ray that can be used to pick in the scene
  121436. * @param x defines the x coordinate of the origin (on-screen)
  121437. * @param y defines the y coordinate of the origin (on-screen)
  121438. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121439. * @param camera defines the camera to use for the picking
  121440. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121441. * @returns a Ray
  121442. */
  121443. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121444. /**
  121445. * Creates a ray that can be used to pick in the scene
  121446. * @param x defines the x coordinate of the origin (on-screen)
  121447. * @param y defines the y coordinate of the origin (on-screen)
  121448. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121449. * @param result defines the ray where to store the picking ray
  121450. * @param camera defines the camera to use for the picking
  121451. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121452. * @returns the current scene
  121453. */
  121454. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121455. /**
  121456. * Creates a ray that can be used to pick in the scene
  121457. * @param x defines the x coordinate of the origin (on-screen)
  121458. * @param y defines the y coordinate of the origin (on-screen)
  121459. * @param camera defines the camera to use for the picking
  121460. * @returns a Ray
  121461. */
  121462. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121463. /**
  121464. * Creates a ray that can be used to pick in the scene
  121465. * @param x defines the x coordinate of the origin (on-screen)
  121466. * @param y defines the y coordinate of the origin (on-screen)
  121467. * @param result defines the ray where to store the picking ray
  121468. * @param camera defines the camera to use for the picking
  121469. * @returns the current scene
  121470. */
  121471. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121472. /** Launch a ray to try to pick a mesh in the scene
  121473. * @param x position on screen
  121474. * @param y position on screen
  121475. * @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
  121476. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121477. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121479. * @returns a PickingInfo
  121480. */
  121481. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121482. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121483. * @param x position on screen
  121484. * @param y position on screen
  121485. * @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
  121486. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121487. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121488. * @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)
  121489. */
  121490. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121491. /** Use the given ray to pick a mesh in the scene
  121492. * @param ray The ray to use to pick meshes
  121493. * @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
  121494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121496. * @returns a PickingInfo
  121497. */
  121498. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121499. /**
  121500. * Launch a ray to try to pick a mesh in the scene
  121501. * @param x X position on screen
  121502. * @param y Y position on screen
  121503. * @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
  121504. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121505. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121506. * @returns an array of PickingInfo
  121507. */
  121508. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121509. /**
  121510. * Launch a ray to try to pick a mesh in the scene
  121511. * @param ray Ray to use
  121512. * @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
  121513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121514. * @returns an array of PickingInfo
  121515. */
  121516. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121517. /**
  121518. * Force the value of meshUnderPointer
  121519. * @param mesh defines the mesh to use
  121520. * @param pointerId optional pointer id when using more than one pointer
  121521. */
  121522. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121523. /**
  121524. * Gets the mesh under the pointer
  121525. * @returns a Mesh or null if no mesh is under the pointer
  121526. */
  121527. getPointerOverMesh(): Nullable<AbstractMesh>;
  121528. /** @hidden */
  121529. _rebuildGeometries(): void;
  121530. /** @hidden */
  121531. _rebuildTextures(): void;
  121532. private _getByTags;
  121533. /**
  121534. * Get a list of meshes by tags
  121535. * @param tagsQuery defines the tags query to use
  121536. * @param forEach defines a predicate used to filter results
  121537. * @returns an array of Mesh
  121538. */
  121539. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121540. /**
  121541. * Get a list of cameras by tags
  121542. * @param tagsQuery defines the tags query to use
  121543. * @param forEach defines a predicate used to filter results
  121544. * @returns an array of Camera
  121545. */
  121546. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121547. /**
  121548. * Get a list of lights by tags
  121549. * @param tagsQuery defines the tags query to use
  121550. * @param forEach defines a predicate used to filter results
  121551. * @returns an array of Light
  121552. */
  121553. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121554. /**
  121555. * Get a list of materials by tags
  121556. * @param tagsQuery defines the tags query to use
  121557. * @param forEach defines a predicate used to filter results
  121558. * @returns an array of Material
  121559. */
  121560. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121561. /**
  121562. * Get a list of transform nodes by tags
  121563. * @param tagsQuery defines the tags query to use
  121564. * @param forEach defines a predicate used to filter results
  121565. * @returns an array of TransformNode
  121566. */
  121567. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121568. /**
  121569. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121570. * This allowed control for front to back rendering or reversly depending of the special needs.
  121571. *
  121572. * @param renderingGroupId The rendering group id corresponding to its index
  121573. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121574. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121575. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121576. */
  121577. 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;
  121578. /**
  121579. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121580. *
  121581. * @param renderingGroupId The rendering group id corresponding to its index
  121582. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121583. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121584. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121585. */
  121586. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121587. /**
  121588. * Gets the current auto clear configuration for one rendering group of the rendering
  121589. * manager.
  121590. * @param index the rendering group index to get the information for
  121591. * @returns The auto clear setup for the requested rendering group
  121592. */
  121593. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121594. private _blockMaterialDirtyMechanism;
  121595. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121596. get blockMaterialDirtyMechanism(): boolean;
  121597. set blockMaterialDirtyMechanism(value: boolean);
  121598. /**
  121599. * Will flag all materials as dirty to trigger new shader compilation
  121600. * @param flag defines the flag used to specify which material part must be marked as dirty
  121601. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121602. */
  121603. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121604. /** @hidden */
  121605. _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;
  121606. /** @hidden */
  121607. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121608. /** @hidden */
  121609. _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;
  121610. /** @hidden */
  121611. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121612. /** @hidden */
  121613. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121614. /** @hidden */
  121615. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121616. }
  121617. }
  121618. declare module BABYLON {
  121619. /**
  121620. * Set of assets to keep when moving a scene into an asset container.
  121621. */
  121622. export class KeepAssets extends AbstractScene {
  121623. }
  121624. /**
  121625. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121626. */
  121627. export class InstantiatedEntries {
  121628. /**
  121629. * List of new root nodes (eg. nodes with no parent)
  121630. */
  121631. rootNodes: TransformNode[];
  121632. /**
  121633. * List of new skeletons
  121634. */
  121635. skeletons: Skeleton[];
  121636. /**
  121637. * List of new animation groups
  121638. */
  121639. animationGroups: AnimationGroup[];
  121640. }
  121641. /**
  121642. * Container with a set of assets that can be added or removed from a scene.
  121643. */
  121644. export class AssetContainer extends AbstractScene {
  121645. private _wasAddedToScene;
  121646. /**
  121647. * The scene the AssetContainer belongs to.
  121648. */
  121649. scene: Scene;
  121650. /**
  121651. * Instantiates an AssetContainer.
  121652. * @param scene The scene the AssetContainer belongs to.
  121653. */
  121654. constructor(scene: Scene);
  121655. /**
  121656. * Instantiate or clone all meshes and add the new ones to the scene.
  121657. * Skeletons and animation groups will all be cloned
  121658. * @param nameFunction defines an optional function used to get new names for clones
  121659. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121660. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121661. */
  121662. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121663. /**
  121664. * Adds all the assets from the container to the scene.
  121665. */
  121666. addAllToScene(): void;
  121667. /**
  121668. * Removes all the assets in the container from the scene
  121669. */
  121670. removeAllFromScene(): void;
  121671. /**
  121672. * Disposes all the assets in the container
  121673. */
  121674. dispose(): void;
  121675. private _moveAssets;
  121676. /**
  121677. * Removes all the assets contained in the scene and adds them to the container.
  121678. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121679. */
  121680. moveAllFromScene(keepAssets?: KeepAssets): void;
  121681. /**
  121682. * 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.
  121683. * @returns the root mesh
  121684. */
  121685. createRootMesh(): Mesh;
  121686. /**
  121687. * Merge animations (direct and animation groups) from this asset container into a scene
  121688. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121689. * @param animatables set of animatables to retarget to a node from the scene
  121690. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121691. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121692. */
  121693. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121694. }
  121695. }
  121696. declare module BABYLON {
  121697. /**
  121698. * Defines how the parser contract is defined.
  121699. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121700. */
  121701. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121702. /**
  121703. * Defines how the individual parser contract is defined.
  121704. * These parser can parse an individual asset
  121705. */
  121706. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121707. /**
  121708. * Base class of the scene acting as a container for the different elements composing a scene.
  121709. * This class is dynamically extended by the different components of the scene increasing
  121710. * flexibility and reducing coupling
  121711. */
  121712. export abstract class AbstractScene {
  121713. /**
  121714. * Stores the list of available parsers in the application.
  121715. */
  121716. private static _BabylonFileParsers;
  121717. /**
  121718. * Stores the list of available individual parsers in the application.
  121719. */
  121720. private static _IndividualBabylonFileParsers;
  121721. /**
  121722. * Adds a parser in the list of available ones
  121723. * @param name Defines the name of the parser
  121724. * @param parser Defines the parser to add
  121725. */
  121726. static AddParser(name: string, parser: BabylonFileParser): void;
  121727. /**
  121728. * Gets a general parser from the list of avaialble ones
  121729. * @param name Defines the name of the parser
  121730. * @returns the requested parser or null
  121731. */
  121732. static GetParser(name: string): Nullable<BabylonFileParser>;
  121733. /**
  121734. * Adds n individual parser in the list of available ones
  121735. * @param name Defines the name of the parser
  121736. * @param parser Defines the parser to add
  121737. */
  121738. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121739. /**
  121740. * Gets an individual parser from the list of avaialble ones
  121741. * @param name Defines the name of the parser
  121742. * @returns the requested parser or null
  121743. */
  121744. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121745. /**
  121746. * Parser json data and populate both a scene and its associated container object
  121747. * @param jsonData Defines the data to parse
  121748. * @param scene Defines the scene to parse the data for
  121749. * @param container Defines the container attached to the parsing sequence
  121750. * @param rootUrl Defines the root url of the data
  121751. */
  121752. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121753. /**
  121754. * Gets the list of root nodes (ie. nodes with no parent)
  121755. */
  121756. rootNodes: Node[];
  121757. /** All of the cameras added to this scene
  121758. * @see https://doc.babylonjs.com/babylon101/cameras
  121759. */
  121760. cameras: Camera[];
  121761. /**
  121762. * All of the lights added to this scene
  121763. * @see https://doc.babylonjs.com/babylon101/lights
  121764. */
  121765. lights: Light[];
  121766. /**
  121767. * All of the (abstract) meshes added to this scene
  121768. */
  121769. meshes: AbstractMesh[];
  121770. /**
  121771. * The list of skeletons added to the scene
  121772. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121773. */
  121774. skeletons: Skeleton[];
  121775. /**
  121776. * All of the particle systems added to this scene
  121777. * @see https://doc.babylonjs.com/babylon101/particles
  121778. */
  121779. particleSystems: IParticleSystem[];
  121780. /**
  121781. * Gets a list of Animations associated with the scene
  121782. */
  121783. animations: Animation[];
  121784. /**
  121785. * All of the animation groups added to this scene
  121786. * @see https://doc.babylonjs.com/how_to/group
  121787. */
  121788. animationGroups: AnimationGroup[];
  121789. /**
  121790. * All of the multi-materials added to this scene
  121791. * @see https://doc.babylonjs.com/how_to/multi_materials
  121792. */
  121793. multiMaterials: MultiMaterial[];
  121794. /**
  121795. * All of the materials added to this scene
  121796. * In the context of a Scene, it is not supposed to be modified manually.
  121797. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121798. * Note also that the order of the Material within the array is not significant and might change.
  121799. * @see https://doc.babylonjs.com/babylon101/materials
  121800. */
  121801. materials: Material[];
  121802. /**
  121803. * The list of morph target managers added to the scene
  121804. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121805. */
  121806. morphTargetManagers: MorphTargetManager[];
  121807. /**
  121808. * The list of geometries used in the scene.
  121809. */
  121810. geometries: Geometry[];
  121811. /**
  121812. * All of the tranform nodes added to this scene
  121813. * In the context of a Scene, it is not supposed to be modified manually.
  121814. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121815. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121816. * @see https://doc.babylonjs.com/how_to/transformnode
  121817. */
  121818. transformNodes: TransformNode[];
  121819. /**
  121820. * ActionManagers available on the scene.
  121821. */
  121822. actionManagers: AbstractActionManager[];
  121823. /**
  121824. * Textures to keep.
  121825. */
  121826. textures: BaseTexture[];
  121827. /** @hidden */
  121828. protected _environmentTexture: Nullable<BaseTexture>;
  121829. /**
  121830. * Texture used in all pbr material as the reflection texture.
  121831. * As in the majority of the scene they are the same (exception for multi room and so on),
  121832. * this is easier to reference from here than from all the materials.
  121833. */
  121834. get environmentTexture(): Nullable<BaseTexture>;
  121835. set environmentTexture(value: Nullable<BaseTexture>);
  121836. /**
  121837. * The list of postprocesses added to the scene
  121838. */
  121839. postProcesses: PostProcess[];
  121840. /**
  121841. * @returns all meshes, lights, cameras, transformNodes and bones
  121842. */
  121843. getNodes(): Array<Node>;
  121844. }
  121845. }
  121846. declare module BABYLON {
  121847. /**
  121848. * Interface used to define options for Sound class
  121849. */
  121850. export interface ISoundOptions {
  121851. /**
  121852. * Does the sound autoplay once loaded.
  121853. */
  121854. autoplay?: boolean;
  121855. /**
  121856. * Does the sound loop after it finishes playing once.
  121857. */
  121858. loop?: boolean;
  121859. /**
  121860. * Sound's volume
  121861. */
  121862. volume?: number;
  121863. /**
  121864. * Is it a spatial sound?
  121865. */
  121866. spatialSound?: boolean;
  121867. /**
  121868. * Maximum distance to hear that sound
  121869. */
  121870. maxDistance?: number;
  121871. /**
  121872. * Uses user defined attenuation function
  121873. */
  121874. useCustomAttenuation?: boolean;
  121875. /**
  121876. * Define the roll off factor of spatial sounds.
  121877. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121878. */
  121879. rolloffFactor?: number;
  121880. /**
  121881. * Define the reference distance the sound should be heard perfectly.
  121882. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121883. */
  121884. refDistance?: number;
  121885. /**
  121886. * Define the distance attenuation model the sound will follow.
  121887. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121888. */
  121889. distanceModel?: string;
  121890. /**
  121891. * Defines the playback speed (1 by default)
  121892. */
  121893. playbackRate?: number;
  121894. /**
  121895. * Defines if the sound is from a streaming source
  121896. */
  121897. streaming?: boolean;
  121898. /**
  121899. * Defines an optional length (in seconds) inside the sound file
  121900. */
  121901. length?: number;
  121902. /**
  121903. * Defines an optional offset (in seconds) inside the sound file
  121904. */
  121905. offset?: number;
  121906. /**
  121907. * If true, URLs will not be required to state the audio file codec to use.
  121908. */
  121909. skipCodecCheck?: boolean;
  121910. }
  121911. /**
  121912. * Defines a sound that can be played in the application.
  121913. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121915. */
  121916. export class Sound {
  121917. /**
  121918. * The name of the sound in the scene.
  121919. */
  121920. name: string;
  121921. /**
  121922. * Does the sound autoplay once loaded.
  121923. */
  121924. autoplay: boolean;
  121925. /**
  121926. * Does the sound loop after it finishes playing once.
  121927. */
  121928. loop: boolean;
  121929. /**
  121930. * Does the sound use a custom attenuation curve to simulate the falloff
  121931. * happening when the source gets further away from the camera.
  121932. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121933. */
  121934. useCustomAttenuation: boolean;
  121935. /**
  121936. * The sound track id this sound belongs to.
  121937. */
  121938. soundTrackId: number;
  121939. /**
  121940. * Is this sound currently played.
  121941. */
  121942. isPlaying: boolean;
  121943. /**
  121944. * Is this sound currently paused.
  121945. */
  121946. isPaused: boolean;
  121947. /**
  121948. * Does this sound enables spatial sound.
  121949. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121950. */
  121951. spatialSound: boolean;
  121952. /**
  121953. * Define the reference distance the sound should be heard perfectly.
  121954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121955. */
  121956. refDistance: number;
  121957. /**
  121958. * Define the roll off factor of spatial sounds.
  121959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121960. */
  121961. rolloffFactor: number;
  121962. /**
  121963. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121965. */
  121966. maxDistance: number;
  121967. /**
  121968. * Define the distance attenuation model the sound will follow.
  121969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121970. */
  121971. distanceModel: string;
  121972. /**
  121973. * @hidden
  121974. * Back Compat
  121975. **/
  121976. onended: () => any;
  121977. /**
  121978. * Gets or sets an object used to store user defined information for the sound.
  121979. */
  121980. metadata: any;
  121981. /**
  121982. * Observable event when the current playing sound finishes.
  121983. */
  121984. onEndedObservable: Observable<Sound>;
  121985. private _panningModel;
  121986. private _playbackRate;
  121987. private _streaming;
  121988. private _startTime;
  121989. private _startOffset;
  121990. private _position;
  121991. /** @hidden */
  121992. _positionInEmitterSpace: boolean;
  121993. private _localDirection;
  121994. private _volume;
  121995. private _isReadyToPlay;
  121996. private _isDirectional;
  121997. private _readyToPlayCallback;
  121998. private _audioBuffer;
  121999. private _soundSource;
  122000. private _streamingSource;
  122001. private _soundPanner;
  122002. private _soundGain;
  122003. private _inputAudioNode;
  122004. private _outputAudioNode;
  122005. private _coneInnerAngle;
  122006. private _coneOuterAngle;
  122007. private _coneOuterGain;
  122008. private _scene;
  122009. private _connectedTransformNode;
  122010. private _customAttenuationFunction;
  122011. private _registerFunc;
  122012. private _isOutputConnected;
  122013. private _htmlAudioElement;
  122014. private _urlType;
  122015. private _length?;
  122016. private _offset?;
  122017. /** @hidden */
  122018. static _SceneComponentInitialization: (scene: Scene) => void;
  122019. /**
  122020. * Create a sound and attach it to a scene
  122021. * @param name Name of your sound
  122022. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122023. * @param scene defines the scene the sound belongs to
  122024. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122025. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122026. */
  122027. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122028. /**
  122029. * Release the sound and its associated resources
  122030. */
  122031. dispose(): void;
  122032. /**
  122033. * Gets if the sounds is ready to be played or not.
  122034. * @returns true if ready, otherwise false
  122035. */
  122036. isReady(): boolean;
  122037. private _soundLoaded;
  122038. /**
  122039. * Sets the data of the sound from an audiobuffer
  122040. * @param audioBuffer The audioBuffer containing the data
  122041. */
  122042. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122043. /**
  122044. * Updates the current sounds options such as maxdistance, loop...
  122045. * @param options A JSON object containing values named as the object properties
  122046. */
  122047. updateOptions(options: ISoundOptions): void;
  122048. private _createSpatialParameters;
  122049. private _updateSpatialParameters;
  122050. /**
  122051. * Switch the panning model to HRTF:
  122052. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122053. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122054. */
  122055. switchPanningModelToHRTF(): void;
  122056. /**
  122057. * Switch the panning model to Equal Power:
  122058. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122059. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122060. */
  122061. switchPanningModelToEqualPower(): void;
  122062. private _switchPanningModel;
  122063. /**
  122064. * Connect this sound to a sound track audio node like gain...
  122065. * @param soundTrackAudioNode the sound track audio node to connect to
  122066. */
  122067. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122068. /**
  122069. * Transform this sound into a directional source
  122070. * @param coneInnerAngle Size of the inner cone in degree
  122071. * @param coneOuterAngle Size of the outer cone in degree
  122072. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122073. */
  122074. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122075. /**
  122076. * Gets or sets the inner angle for the directional cone.
  122077. */
  122078. get directionalConeInnerAngle(): number;
  122079. /**
  122080. * Gets or sets the inner angle for the directional cone.
  122081. */
  122082. set directionalConeInnerAngle(value: number);
  122083. /**
  122084. * Gets or sets the outer angle for the directional cone.
  122085. */
  122086. get directionalConeOuterAngle(): number;
  122087. /**
  122088. * Gets or sets the outer angle for the directional cone.
  122089. */
  122090. set directionalConeOuterAngle(value: number);
  122091. /**
  122092. * Sets the position of the emitter if spatial sound is enabled
  122093. * @param newPosition Defines the new posisiton
  122094. */
  122095. setPosition(newPosition: Vector3): void;
  122096. /**
  122097. * Sets the local direction of the emitter if spatial sound is enabled
  122098. * @param newLocalDirection Defines the new local direction
  122099. */
  122100. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122101. private _updateDirection;
  122102. /** @hidden */
  122103. updateDistanceFromListener(): void;
  122104. /**
  122105. * Sets a new custom attenuation function for the sound.
  122106. * @param callback Defines the function used for the attenuation
  122107. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122108. */
  122109. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122110. /**
  122111. * Play the sound
  122112. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122113. * @param offset (optional) Start the sound at a specific time in seconds
  122114. * @param length (optional) Sound duration (in seconds)
  122115. */
  122116. play(time?: number, offset?: number, length?: number): void;
  122117. private _onended;
  122118. /**
  122119. * Stop the sound
  122120. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122121. */
  122122. stop(time?: number): void;
  122123. /**
  122124. * Put the sound in pause
  122125. */
  122126. pause(): void;
  122127. /**
  122128. * Sets a dedicated volume for this sounds
  122129. * @param newVolume Define the new volume of the sound
  122130. * @param time Define time for gradual change to new volume
  122131. */
  122132. setVolume(newVolume: number, time?: number): void;
  122133. /**
  122134. * Set the sound play back rate
  122135. * @param newPlaybackRate Define the playback rate the sound should be played at
  122136. */
  122137. setPlaybackRate(newPlaybackRate: number): void;
  122138. /**
  122139. * Gets the volume of the sound.
  122140. * @returns the volume of the sound
  122141. */
  122142. getVolume(): number;
  122143. /**
  122144. * Attach the sound to a dedicated mesh
  122145. * @param transformNode The transform node to connect the sound with
  122146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122147. */
  122148. attachToMesh(transformNode: TransformNode): void;
  122149. /**
  122150. * Detach the sound from the previously attached mesh
  122151. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122152. */
  122153. detachFromMesh(): void;
  122154. private _onRegisterAfterWorldMatrixUpdate;
  122155. /**
  122156. * Clone the current sound in the scene.
  122157. * @returns the new sound clone
  122158. */
  122159. clone(): Nullable<Sound>;
  122160. /**
  122161. * Gets the current underlying audio buffer containing the data
  122162. * @returns the audio buffer
  122163. */
  122164. getAudioBuffer(): Nullable<AudioBuffer>;
  122165. /**
  122166. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122167. * @returns the source node
  122168. */
  122169. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122170. /**
  122171. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122172. * @returns the gain node
  122173. */
  122174. getSoundGain(): Nullable<GainNode>;
  122175. /**
  122176. * Serializes the Sound in a JSON representation
  122177. * @returns the JSON representation of the sound
  122178. */
  122179. serialize(): any;
  122180. /**
  122181. * Parse a JSON representation of a sound to innstantiate in a given scene
  122182. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122183. * @param scene Define the scene the new parsed sound should be created in
  122184. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122185. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122186. * @returns the newly parsed sound
  122187. */
  122188. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122189. }
  122190. }
  122191. declare module BABYLON {
  122192. /**
  122193. * This defines an action helpful to play a defined sound on a triggered action.
  122194. */
  122195. export class PlaySoundAction extends Action {
  122196. private _sound;
  122197. /**
  122198. * Instantiate the action
  122199. * @param triggerOptions defines the trigger options
  122200. * @param sound defines the sound to play
  122201. * @param condition defines the trigger related conditions
  122202. */
  122203. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122204. /** @hidden */
  122205. _prepare(): void;
  122206. /**
  122207. * Execute the action and play the sound.
  122208. */
  122209. execute(): void;
  122210. /**
  122211. * Serializes the actions and its related information.
  122212. * @param parent defines the object to serialize in
  122213. * @returns the serialized object
  122214. */
  122215. serialize(parent: any): any;
  122216. }
  122217. /**
  122218. * This defines an action helpful to stop a defined sound on a triggered action.
  122219. */
  122220. export class StopSoundAction extends Action {
  122221. private _sound;
  122222. /**
  122223. * Instantiate the action
  122224. * @param triggerOptions defines the trigger options
  122225. * @param sound defines the sound to stop
  122226. * @param condition defines the trigger related conditions
  122227. */
  122228. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122229. /** @hidden */
  122230. _prepare(): void;
  122231. /**
  122232. * Execute the action and stop the sound.
  122233. */
  122234. execute(): void;
  122235. /**
  122236. * Serializes the actions and its related information.
  122237. * @param parent defines the object to serialize in
  122238. * @returns the serialized object
  122239. */
  122240. serialize(parent: any): any;
  122241. }
  122242. }
  122243. declare module BABYLON {
  122244. /**
  122245. * This defines an action responsible to change the value of a property
  122246. * by interpolating between its current value and the newly set one once triggered.
  122247. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122248. */
  122249. export class InterpolateValueAction extends Action {
  122250. /**
  122251. * Defines the path of the property where the value should be interpolated
  122252. */
  122253. propertyPath: string;
  122254. /**
  122255. * Defines the target value at the end of the interpolation.
  122256. */
  122257. value: any;
  122258. /**
  122259. * Defines the time it will take for the property to interpolate to the value.
  122260. */
  122261. duration: number;
  122262. /**
  122263. * Defines if the other scene animations should be stopped when the action has been triggered
  122264. */
  122265. stopOtherAnimations?: boolean;
  122266. /**
  122267. * Defines a callback raised once the interpolation animation has been done.
  122268. */
  122269. onInterpolationDone?: () => void;
  122270. /**
  122271. * Observable triggered once the interpolation animation has been done.
  122272. */
  122273. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122274. private _target;
  122275. private _effectiveTarget;
  122276. private _property;
  122277. /**
  122278. * Instantiate the action
  122279. * @param triggerOptions defines the trigger options
  122280. * @param target defines the object containing the value to interpolate
  122281. * @param propertyPath defines the path to the property in the target object
  122282. * @param value defines the target value at the end of the interpolation
  122283. * @param duration deines the time it will take for the property to interpolate to the value.
  122284. * @param condition defines the trigger related conditions
  122285. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122286. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122287. */
  122288. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122289. /** @hidden */
  122290. _prepare(): void;
  122291. /**
  122292. * Execute the action starts the value interpolation.
  122293. */
  122294. execute(): void;
  122295. /**
  122296. * Serializes the actions and its related information.
  122297. * @param parent defines the object to serialize in
  122298. * @returns the serialized object
  122299. */
  122300. serialize(parent: any): any;
  122301. }
  122302. }
  122303. declare module BABYLON {
  122304. /**
  122305. * Options allowed during the creation of a sound track.
  122306. */
  122307. export interface ISoundTrackOptions {
  122308. /**
  122309. * The volume the sound track should take during creation
  122310. */
  122311. volume?: number;
  122312. /**
  122313. * Define if the sound track is the main sound track of the scene
  122314. */
  122315. mainTrack?: boolean;
  122316. }
  122317. /**
  122318. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122319. * It will be also used in a future release to apply effects on a specific track.
  122320. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122321. */
  122322. export class SoundTrack {
  122323. /**
  122324. * The unique identifier of the sound track in the scene.
  122325. */
  122326. id: number;
  122327. /**
  122328. * The list of sounds included in the sound track.
  122329. */
  122330. soundCollection: Array<Sound>;
  122331. private _outputAudioNode;
  122332. private _scene;
  122333. private _connectedAnalyser;
  122334. private _options;
  122335. private _isInitialized;
  122336. /**
  122337. * Creates a new sound track.
  122338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122339. * @param scene Define the scene the sound track belongs to
  122340. * @param options
  122341. */
  122342. constructor(scene: Scene, options?: ISoundTrackOptions);
  122343. private _initializeSoundTrackAudioGraph;
  122344. /**
  122345. * Release the sound track and its associated resources
  122346. */
  122347. dispose(): void;
  122348. /**
  122349. * Adds a sound to this sound track
  122350. * @param sound define the cound to add
  122351. * @ignoreNaming
  122352. */
  122353. AddSound(sound: Sound): void;
  122354. /**
  122355. * Removes a sound to this sound track
  122356. * @param sound define the cound to remove
  122357. * @ignoreNaming
  122358. */
  122359. RemoveSound(sound: Sound): void;
  122360. /**
  122361. * Set a global volume for the full sound track.
  122362. * @param newVolume Define the new volume of the sound track
  122363. */
  122364. setVolume(newVolume: number): void;
  122365. /**
  122366. * Switch the panning model to HRTF:
  122367. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122368. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122369. */
  122370. switchPanningModelToHRTF(): void;
  122371. /**
  122372. * Switch the panning model to Equal Power:
  122373. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122374. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122375. */
  122376. switchPanningModelToEqualPower(): void;
  122377. /**
  122378. * Connect the sound track to an audio analyser allowing some amazing
  122379. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122381. * @param analyser The analyser to connect to the engine
  122382. */
  122383. connectToAnalyser(analyser: Analyser): void;
  122384. }
  122385. }
  122386. declare module BABYLON {
  122387. interface AbstractScene {
  122388. /**
  122389. * The list of sounds used in the scene.
  122390. */
  122391. sounds: Nullable<Array<Sound>>;
  122392. }
  122393. interface Scene {
  122394. /**
  122395. * @hidden
  122396. * Backing field
  122397. */
  122398. _mainSoundTrack: SoundTrack;
  122399. /**
  122400. * The main sound track played by the scene.
  122401. * It cotains your primary collection of sounds.
  122402. */
  122403. mainSoundTrack: SoundTrack;
  122404. /**
  122405. * The list of sound tracks added to the scene
  122406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122407. */
  122408. soundTracks: Nullable<Array<SoundTrack>>;
  122409. /**
  122410. * Gets a sound using a given name
  122411. * @param name defines the name to search for
  122412. * @return the found sound or null if not found at all.
  122413. */
  122414. getSoundByName(name: string): Nullable<Sound>;
  122415. /**
  122416. * Gets or sets if audio support is enabled
  122417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122418. */
  122419. audioEnabled: boolean;
  122420. /**
  122421. * Gets or sets if audio will be output to headphones
  122422. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122423. */
  122424. headphone: boolean;
  122425. /**
  122426. * Gets or sets custom audio listener position provider
  122427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122428. */
  122429. audioListenerPositionProvider: Nullable<() => Vector3>;
  122430. /**
  122431. * Gets or sets a refresh rate when using 3D audio positioning
  122432. */
  122433. audioPositioningRefreshRate: number;
  122434. }
  122435. /**
  122436. * Defines the sound scene component responsible to manage any sounds
  122437. * in a given scene.
  122438. */
  122439. export class AudioSceneComponent implements ISceneSerializableComponent {
  122440. private static _CameraDirectionLH;
  122441. private static _CameraDirectionRH;
  122442. /**
  122443. * The component name helpfull to identify the component in the list of scene components.
  122444. */
  122445. readonly name: string;
  122446. /**
  122447. * The scene the component belongs to.
  122448. */
  122449. scene: Scene;
  122450. private _audioEnabled;
  122451. /**
  122452. * Gets whether audio is enabled or not.
  122453. * Please use related enable/disable method to switch state.
  122454. */
  122455. get audioEnabled(): boolean;
  122456. private _headphone;
  122457. /**
  122458. * Gets whether audio is outputing to headphone or not.
  122459. * Please use the according Switch methods to change output.
  122460. */
  122461. get headphone(): boolean;
  122462. /**
  122463. * Gets or sets a refresh rate when using 3D audio positioning
  122464. */
  122465. audioPositioningRefreshRate: number;
  122466. private _audioListenerPositionProvider;
  122467. /**
  122468. * Gets the current audio listener position provider
  122469. */
  122470. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122471. /**
  122472. * Sets a custom listener position for all sounds in the scene
  122473. * By default, this is the position of the first active camera
  122474. */
  122475. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122476. /**
  122477. * Creates a new instance of the component for the given scene
  122478. * @param scene Defines the scene to register the component in
  122479. */
  122480. constructor(scene: Scene);
  122481. /**
  122482. * Registers the component in a given scene
  122483. */
  122484. register(): void;
  122485. /**
  122486. * Rebuilds the elements related to this component in case of
  122487. * context lost for instance.
  122488. */
  122489. rebuild(): void;
  122490. /**
  122491. * Serializes the component data to the specified json object
  122492. * @param serializationObject The object to serialize to
  122493. */
  122494. serialize(serializationObject: any): void;
  122495. /**
  122496. * Adds all the elements from the container to the scene
  122497. * @param container the container holding the elements
  122498. */
  122499. addFromContainer(container: AbstractScene): void;
  122500. /**
  122501. * Removes all the elements in the container from the scene
  122502. * @param container contains the elements to remove
  122503. * @param dispose if the removed element should be disposed (default: false)
  122504. */
  122505. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122506. /**
  122507. * Disposes the component and the associated ressources.
  122508. */
  122509. dispose(): void;
  122510. /**
  122511. * Disables audio in the associated scene.
  122512. */
  122513. disableAudio(): void;
  122514. /**
  122515. * Enables audio in the associated scene.
  122516. */
  122517. enableAudio(): void;
  122518. /**
  122519. * Switch audio to headphone output.
  122520. */
  122521. switchAudioModeForHeadphones(): void;
  122522. /**
  122523. * Switch audio to normal speakers.
  122524. */
  122525. switchAudioModeForNormalSpeakers(): void;
  122526. private _cachedCameraDirection;
  122527. private _cachedCameraPosition;
  122528. private _lastCheck;
  122529. private _afterRender;
  122530. }
  122531. }
  122532. declare module BABYLON {
  122533. /**
  122534. * Wraps one or more Sound objects and selects one with random weight for playback.
  122535. */
  122536. export class WeightedSound {
  122537. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122538. loop: boolean;
  122539. private _coneInnerAngle;
  122540. private _coneOuterAngle;
  122541. private _volume;
  122542. /** A Sound is currently playing. */
  122543. isPlaying: boolean;
  122544. /** A Sound is currently paused. */
  122545. isPaused: boolean;
  122546. private _sounds;
  122547. private _weights;
  122548. private _currentIndex?;
  122549. /**
  122550. * Creates a new WeightedSound from the list of sounds given.
  122551. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122552. * @param sounds Array of Sounds that will be selected from.
  122553. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122554. */
  122555. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122556. /**
  122557. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122558. */
  122559. get directionalConeInnerAngle(): number;
  122560. /**
  122561. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122562. */
  122563. set directionalConeInnerAngle(value: number);
  122564. /**
  122565. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122566. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122567. */
  122568. get directionalConeOuterAngle(): number;
  122569. /**
  122570. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122571. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122572. */
  122573. set directionalConeOuterAngle(value: number);
  122574. /**
  122575. * Playback volume.
  122576. */
  122577. get volume(): number;
  122578. /**
  122579. * Playback volume.
  122580. */
  122581. set volume(value: number);
  122582. private _onended;
  122583. /**
  122584. * Suspend playback
  122585. */
  122586. pause(): void;
  122587. /**
  122588. * Stop playback
  122589. */
  122590. stop(): void;
  122591. /**
  122592. * Start playback.
  122593. * @param startOffset Position the clip head at a specific time in seconds.
  122594. */
  122595. play(startOffset?: number): void;
  122596. }
  122597. }
  122598. declare module BABYLON {
  122599. /**
  122600. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122601. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122602. */
  122603. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122604. /**
  122605. * Gets the name of the behavior.
  122606. */
  122607. get name(): string;
  122608. /**
  122609. * The easing function used by animations
  122610. */
  122611. static EasingFunction: BackEase;
  122612. /**
  122613. * The easing mode used by animations
  122614. */
  122615. static EasingMode: number;
  122616. /**
  122617. * The duration of the animation, in milliseconds
  122618. */
  122619. transitionDuration: number;
  122620. /**
  122621. * Length of the distance animated by the transition when lower radius is reached
  122622. */
  122623. lowerRadiusTransitionRange: number;
  122624. /**
  122625. * Length of the distance animated by the transition when upper radius is reached
  122626. */
  122627. upperRadiusTransitionRange: number;
  122628. private _autoTransitionRange;
  122629. /**
  122630. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122631. */
  122632. get autoTransitionRange(): boolean;
  122633. /**
  122634. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122635. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122636. */
  122637. set autoTransitionRange(value: boolean);
  122638. private _attachedCamera;
  122639. private _onAfterCheckInputsObserver;
  122640. private _onMeshTargetChangedObserver;
  122641. /**
  122642. * Initializes the behavior.
  122643. */
  122644. init(): void;
  122645. /**
  122646. * Attaches the behavior to its arc rotate camera.
  122647. * @param camera Defines the camera to attach the behavior to
  122648. */
  122649. attach(camera: ArcRotateCamera): void;
  122650. /**
  122651. * Detaches the behavior from its current arc rotate camera.
  122652. */
  122653. detach(): void;
  122654. private _radiusIsAnimating;
  122655. private _radiusBounceTransition;
  122656. private _animatables;
  122657. private _cachedWheelPrecision;
  122658. /**
  122659. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122660. * @param radiusLimit The limit to check against.
  122661. * @return Bool to indicate if at limit.
  122662. */
  122663. private _isRadiusAtLimit;
  122664. /**
  122665. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122666. * @param radiusDelta The delta by which to animate to. Can be negative.
  122667. */
  122668. private _applyBoundRadiusAnimation;
  122669. /**
  122670. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122671. */
  122672. protected _clearAnimationLocks(): void;
  122673. /**
  122674. * Stops and removes all animations that have been applied to the camera
  122675. */
  122676. stopAllAnimations(): void;
  122677. }
  122678. }
  122679. declare module BABYLON {
  122680. /**
  122681. * 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.
  122682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122683. */
  122684. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122685. /**
  122686. * Gets the name of the behavior.
  122687. */
  122688. get name(): string;
  122689. private _mode;
  122690. private _radiusScale;
  122691. private _positionScale;
  122692. private _defaultElevation;
  122693. private _elevationReturnTime;
  122694. private _elevationReturnWaitTime;
  122695. private _zoomStopsAnimation;
  122696. private _framingTime;
  122697. /**
  122698. * The easing function used by animations
  122699. */
  122700. static EasingFunction: ExponentialEase;
  122701. /**
  122702. * The easing mode used by animations
  122703. */
  122704. static EasingMode: number;
  122705. /**
  122706. * Sets the current mode used by the behavior
  122707. */
  122708. set mode(mode: number);
  122709. /**
  122710. * Gets current mode used by the behavior.
  122711. */
  122712. get mode(): number;
  122713. /**
  122714. * Sets the scale applied to the radius (1 by default)
  122715. */
  122716. set radiusScale(radius: number);
  122717. /**
  122718. * Gets the scale applied to the radius
  122719. */
  122720. get radiusScale(): number;
  122721. /**
  122722. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122723. */
  122724. set positionScale(scale: number);
  122725. /**
  122726. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122727. */
  122728. get positionScale(): number;
  122729. /**
  122730. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122731. * behaviour is triggered, in radians.
  122732. */
  122733. set defaultElevation(elevation: number);
  122734. /**
  122735. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122736. * behaviour is triggered, in radians.
  122737. */
  122738. get defaultElevation(): number;
  122739. /**
  122740. * Sets the time (in milliseconds) taken to return to the default beta position.
  122741. * Negative value indicates camera should not return to default.
  122742. */
  122743. set elevationReturnTime(speed: number);
  122744. /**
  122745. * Gets the time (in milliseconds) taken to return to the default beta position.
  122746. * Negative value indicates camera should not return to default.
  122747. */
  122748. get elevationReturnTime(): number;
  122749. /**
  122750. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122751. */
  122752. set elevationReturnWaitTime(time: number);
  122753. /**
  122754. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122755. */
  122756. get elevationReturnWaitTime(): number;
  122757. /**
  122758. * Sets the flag that indicates if user zooming should stop animation.
  122759. */
  122760. set zoomStopsAnimation(flag: boolean);
  122761. /**
  122762. * Gets the flag that indicates if user zooming should stop animation.
  122763. */
  122764. get zoomStopsAnimation(): boolean;
  122765. /**
  122766. * Sets the transition time when framing the mesh, in milliseconds
  122767. */
  122768. set framingTime(time: number);
  122769. /**
  122770. * Gets the transition time when framing the mesh, in milliseconds
  122771. */
  122772. get framingTime(): number;
  122773. /**
  122774. * Define if the behavior should automatically change the configured
  122775. * camera limits and sensibilities.
  122776. */
  122777. autoCorrectCameraLimitsAndSensibility: boolean;
  122778. private _onPrePointerObservableObserver;
  122779. private _onAfterCheckInputsObserver;
  122780. private _onMeshTargetChangedObserver;
  122781. private _attachedCamera;
  122782. private _isPointerDown;
  122783. private _lastInteractionTime;
  122784. /**
  122785. * Initializes the behavior.
  122786. */
  122787. init(): void;
  122788. /**
  122789. * Attaches the behavior to its arc rotate camera.
  122790. * @param camera Defines the camera to attach the behavior to
  122791. */
  122792. attach(camera: ArcRotateCamera): void;
  122793. /**
  122794. * Detaches the behavior from its current arc rotate camera.
  122795. */
  122796. detach(): void;
  122797. private _animatables;
  122798. private _betaIsAnimating;
  122799. private _betaTransition;
  122800. private _radiusTransition;
  122801. private _vectorTransition;
  122802. /**
  122803. * Targets the given mesh and updates zoom level accordingly.
  122804. * @param mesh The mesh to target.
  122805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122807. */
  122808. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122809. /**
  122810. * Targets the given mesh with its children and updates zoom level accordingly.
  122811. * @param mesh The mesh to target.
  122812. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122813. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122814. */
  122815. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122816. /**
  122817. * Targets the given meshes with their children and updates zoom level accordingly.
  122818. * @param meshes The mesh to target.
  122819. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122820. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122821. */
  122822. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122823. /**
  122824. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122825. * @param minimumWorld Determines the smaller position of the bounding box extend
  122826. * @param maximumWorld Determines the bigger position of the bounding box extend
  122827. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122828. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122829. */
  122830. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122831. /**
  122832. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122833. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122834. * frustum width.
  122835. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122836. * to fully enclose the mesh in the viewing frustum.
  122837. */
  122838. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122839. /**
  122840. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122841. * is automatically returned to its default position (expected to be above ground plane).
  122842. */
  122843. private _maintainCameraAboveGround;
  122844. /**
  122845. * Returns the frustum slope based on the canvas ratio and camera FOV
  122846. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122847. */
  122848. private _getFrustumSlope;
  122849. /**
  122850. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122851. */
  122852. private _clearAnimationLocks;
  122853. /**
  122854. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122855. */
  122856. private _applyUserInteraction;
  122857. /**
  122858. * Stops and removes all animations that have been applied to the camera
  122859. */
  122860. stopAllAnimations(): void;
  122861. /**
  122862. * Gets a value indicating if the user is moving the camera
  122863. */
  122864. get isUserIsMoving(): boolean;
  122865. /**
  122866. * The camera can move all the way towards the mesh.
  122867. */
  122868. static IgnoreBoundsSizeMode: number;
  122869. /**
  122870. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122871. */
  122872. static FitFrustumSidesMode: number;
  122873. }
  122874. }
  122875. declare module BABYLON {
  122876. /**
  122877. * Base class for Camera Pointer Inputs.
  122878. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122879. * for example usage.
  122880. */
  122881. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122882. /**
  122883. * Defines the camera the input is attached to.
  122884. */
  122885. abstract camera: Camera;
  122886. /**
  122887. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122888. */
  122889. protected _altKey: boolean;
  122890. protected _ctrlKey: boolean;
  122891. protected _metaKey: boolean;
  122892. protected _shiftKey: boolean;
  122893. /**
  122894. * Which mouse buttons were pressed at time of last mouse event.
  122895. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122896. */
  122897. protected _buttonsPressed: number;
  122898. /**
  122899. * Defines the buttons associated with the input to handle camera move.
  122900. */
  122901. buttons: number[];
  122902. /**
  122903. * Attach the input controls to a specific dom element to get the input from.
  122904. * @param element Defines the element the controls should be listened from
  122905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122906. */
  122907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122908. /**
  122909. * Detach the current controls from the specified dom element.
  122910. * @param element Defines the element to stop listening the inputs from
  122911. */
  122912. detachControl(element: Nullable<HTMLElement>): void;
  122913. /**
  122914. * Gets the class name of the current input.
  122915. * @returns the class name
  122916. */
  122917. getClassName(): string;
  122918. /**
  122919. * Get the friendly name associated with the input class.
  122920. * @returns the input friendly name
  122921. */
  122922. getSimpleName(): string;
  122923. /**
  122924. * Called on pointer POINTERDOUBLETAP event.
  122925. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122926. */
  122927. protected onDoubleTap(type: string): void;
  122928. /**
  122929. * Called on pointer POINTERMOVE event if only a single touch is active.
  122930. * Override this method to provide functionality.
  122931. */
  122932. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122933. /**
  122934. * Called on pointer POINTERMOVE event if multiple touches are active.
  122935. * Override this method to provide functionality.
  122936. */
  122937. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122938. /**
  122939. * Called on JS contextmenu event.
  122940. * Override this method to provide functionality.
  122941. */
  122942. protected onContextMenu(evt: PointerEvent): void;
  122943. /**
  122944. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122945. * press.
  122946. * Override this method to provide functionality.
  122947. */
  122948. protected onButtonDown(evt: PointerEvent): void;
  122949. /**
  122950. * Called each time a new POINTERUP event occurs. Ie, for each button
  122951. * release.
  122952. * Override this method to provide functionality.
  122953. */
  122954. protected onButtonUp(evt: PointerEvent): void;
  122955. /**
  122956. * Called when window becomes inactive.
  122957. * Override this method to provide functionality.
  122958. */
  122959. protected onLostFocus(): void;
  122960. private _pointerInput;
  122961. private _observer;
  122962. private _onLostFocus;
  122963. private pointA;
  122964. private pointB;
  122965. }
  122966. }
  122967. declare module BABYLON {
  122968. /**
  122969. * Manage the pointers inputs to control an arc rotate camera.
  122970. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122971. */
  122972. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122973. /**
  122974. * Defines the camera the input is attached to.
  122975. */
  122976. camera: ArcRotateCamera;
  122977. /**
  122978. * Gets the class name of the current input.
  122979. * @returns the class name
  122980. */
  122981. getClassName(): string;
  122982. /**
  122983. * Defines the buttons associated with the input to handle camera move.
  122984. */
  122985. buttons: number[];
  122986. /**
  122987. * Defines the pointer angular sensibility along the X axis or how fast is
  122988. * the camera rotating.
  122989. */
  122990. angularSensibilityX: number;
  122991. /**
  122992. * Defines the pointer angular sensibility along the Y axis or how fast is
  122993. * the camera rotating.
  122994. */
  122995. angularSensibilityY: number;
  122996. /**
  122997. * Defines the pointer pinch precision or how fast is the camera zooming.
  122998. */
  122999. pinchPrecision: number;
  123000. /**
  123001. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123002. * from 0.
  123003. * It defines the percentage of current camera.radius to use as delta when
  123004. * pinch zoom is used.
  123005. */
  123006. pinchDeltaPercentage: number;
  123007. /**
  123008. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123009. * that any object in the plane at the camera's target point will scale
  123010. * perfectly with finger motion.
  123011. * Overrides pinchDeltaPercentage and pinchPrecision.
  123012. */
  123013. useNaturalPinchZoom: boolean;
  123014. /**
  123015. * Defines the pointer panning sensibility or how fast is the camera moving.
  123016. */
  123017. panningSensibility: number;
  123018. /**
  123019. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123020. */
  123021. multiTouchPanning: boolean;
  123022. /**
  123023. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123024. * zoom (pinch) through multitouch.
  123025. */
  123026. multiTouchPanAndZoom: boolean;
  123027. /**
  123028. * Revers pinch action direction.
  123029. */
  123030. pinchInwards: boolean;
  123031. private _isPanClick;
  123032. private _twoFingerActivityCount;
  123033. private _isPinching;
  123034. /**
  123035. * Called on pointer POINTERMOVE event if only a single touch is active.
  123036. */
  123037. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123038. /**
  123039. * Called on pointer POINTERDOUBLETAP event.
  123040. */
  123041. protected onDoubleTap(type: string): void;
  123042. /**
  123043. * Called on pointer POINTERMOVE event if multiple touches are active.
  123044. */
  123045. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123046. /**
  123047. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123048. * press.
  123049. */
  123050. protected onButtonDown(evt: PointerEvent): void;
  123051. /**
  123052. * Called each time a new POINTERUP event occurs. Ie, for each button
  123053. * release.
  123054. */
  123055. protected onButtonUp(evt: PointerEvent): void;
  123056. /**
  123057. * Called when window becomes inactive.
  123058. */
  123059. protected onLostFocus(): void;
  123060. }
  123061. }
  123062. declare module BABYLON {
  123063. /**
  123064. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123065. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123066. */
  123067. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123068. /**
  123069. * Defines the camera the input is attached to.
  123070. */
  123071. camera: ArcRotateCamera;
  123072. /**
  123073. * Defines the list of key codes associated with the up action (increase alpha)
  123074. */
  123075. keysUp: number[];
  123076. /**
  123077. * Defines the list of key codes associated with the down action (decrease alpha)
  123078. */
  123079. keysDown: number[];
  123080. /**
  123081. * Defines the list of key codes associated with the left action (increase beta)
  123082. */
  123083. keysLeft: number[];
  123084. /**
  123085. * Defines the list of key codes associated with the right action (decrease beta)
  123086. */
  123087. keysRight: number[];
  123088. /**
  123089. * Defines the list of key codes associated with the reset action.
  123090. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123091. */
  123092. keysReset: number[];
  123093. /**
  123094. * Defines the panning sensibility of the inputs.
  123095. * (How fast is the camera panning)
  123096. */
  123097. panningSensibility: number;
  123098. /**
  123099. * Defines the zooming sensibility of the inputs.
  123100. * (How fast is the camera zooming)
  123101. */
  123102. zoomingSensibility: number;
  123103. /**
  123104. * Defines whether maintaining the alt key down switch the movement mode from
  123105. * orientation to zoom.
  123106. */
  123107. useAltToZoom: boolean;
  123108. /**
  123109. * Rotation speed of the camera
  123110. */
  123111. angularSpeed: number;
  123112. private _keys;
  123113. private _ctrlPressed;
  123114. private _altPressed;
  123115. private _onCanvasBlurObserver;
  123116. private _onKeyboardObserver;
  123117. private _engine;
  123118. private _scene;
  123119. /**
  123120. * Attach the input controls to a specific dom element to get the input from.
  123121. * @param element Defines the element the controls should be listened from
  123122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123123. */
  123124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123125. /**
  123126. * Detach the current controls from the specified dom element.
  123127. * @param element Defines the element to stop listening the inputs from
  123128. */
  123129. detachControl(element: Nullable<HTMLElement>): void;
  123130. /**
  123131. * Update the current camera state depending on the inputs that have been used this frame.
  123132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123133. */
  123134. checkInputs(): void;
  123135. /**
  123136. * Gets the class name of the current intput.
  123137. * @returns the class name
  123138. */
  123139. getClassName(): string;
  123140. /**
  123141. * Get the friendly name associated with the input class.
  123142. * @returns the input friendly name
  123143. */
  123144. getSimpleName(): string;
  123145. }
  123146. }
  123147. declare module BABYLON {
  123148. /**
  123149. * Manage the mouse wheel inputs to control an arc rotate camera.
  123150. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123151. */
  123152. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123153. /**
  123154. * Defines the camera the input is attached to.
  123155. */
  123156. camera: ArcRotateCamera;
  123157. /**
  123158. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123159. */
  123160. wheelPrecision: number;
  123161. /**
  123162. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123163. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123164. */
  123165. wheelDeltaPercentage: number;
  123166. private _wheel;
  123167. private _observer;
  123168. private computeDeltaFromMouseWheelLegacyEvent;
  123169. /**
  123170. * Attach the input controls to a specific dom element to get the input from.
  123171. * @param element Defines the element the controls should be listened from
  123172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123173. */
  123174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123175. /**
  123176. * Detach the current controls from the specified dom element.
  123177. * @param element Defines the element to stop listening the inputs from
  123178. */
  123179. detachControl(element: Nullable<HTMLElement>): void;
  123180. /**
  123181. * Gets the class name of the current intput.
  123182. * @returns the class name
  123183. */
  123184. getClassName(): string;
  123185. /**
  123186. * Get the friendly name associated with the input class.
  123187. * @returns the input friendly name
  123188. */
  123189. getSimpleName(): string;
  123190. }
  123191. }
  123192. declare module BABYLON {
  123193. /**
  123194. * Default Inputs manager for the ArcRotateCamera.
  123195. * It groups all the default supported inputs for ease of use.
  123196. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123197. */
  123198. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123199. /**
  123200. * Instantiates a new ArcRotateCameraInputsManager.
  123201. * @param camera Defines the camera the inputs belong to
  123202. */
  123203. constructor(camera: ArcRotateCamera);
  123204. /**
  123205. * Add mouse wheel input support to the input manager.
  123206. * @returns the current input manager
  123207. */
  123208. addMouseWheel(): ArcRotateCameraInputsManager;
  123209. /**
  123210. * Add pointers input support to the input manager.
  123211. * @returns the current input manager
  123212. */
  123213. addPointers(): ArcRotateCameraInputsManager;
  123214. /**
  123215. * Add keyboard input support to the input manager.
  123216. * @returns the current input manager
  123217. */
  123218. addKeyboard(): ArcRotateCameraInputsManager;
  123219. }
  123220. }
  123221. declare module BABYLON {
  123222. /**
  123223. * This represents an orbital type of camera.
  123224. *
  123225. * 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.
  123226. * 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.
  123227. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123228. */
  123229. export class ArcRotateCamera extends TargetCamera {
  123230. /**
  123231. * Defines the rotation angle of the camera along the longitudinal axis.
  123232. */
  123233. alpha: number;
  123234. /**
  123235. * Defines the rotation angle of the camera along the latitudinal axis.
  123236. */
  123237. beta: number;
  123238. /**
  123239. * Defines the radius of the camera from it s target point.
  123240. */
  123241. radius: number;
  123242. protected _target: Vector3;
  123243. protected _targetHost: Nullable<AbstractMesh>;
  123244. /**
  123245. * Defines the target point of the camera.
  123246. * The camera looks towards it form the radius distance.
  123247. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123248. */
  123249. get target(): Vector3;
  123250. set target(value: Vector3);
  123251. /**
  123252. * Define the current local position of the camera in the scene
  123253. */
  123254. get position(): Vector3;
  123255. set position(newPosition: Vector3);
  123256. protected _upToYMatrix: Matrix;
  123257. protected _YToUpMatrix: Matrix;
  123258. /**
  123259. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123260. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123261. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123262. */
  123263. set upVector(vec: Vector3);
  123264. get upVector(): Vector3;
  123265. /**
  123266. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123267. */
  123268. setMatUp(): void;
  123269. /**
  123270. * Current inertia value on the longitudinal axis.
  123271. * The bigger this number the longer it will take for the camera to stop.
  123272. */
  123273. inertialAlphaOffset: number;
  123274. /**
  123275. * Current inertia value on the latitudinal axis.
  123276. * The bigger this number the longer it will take for the camera to stop.
  123277. */
  123278. inertialBetaOffset: number;
  123279. /**
  123280. * Current inertia value on the radius axis.
  123281. * The bigger this number the longer it will take for the camera to stop.
  123282. */
  123283. inertialRadiusOffset: number;
  123284. /**
  123285. * Minimum allowed angle on the longitudinal axis.
  123286. * This can help limiting how the Camera is able to move in the scene.
  123287. */
  123288. lowerAlphaLimit: Nullable<number>;
  123289. /**
  123290. * Maximum allowed angle on the longitudinal axis.
  123291. * This can help limiting how the Camera is able to move in the scene.
  123292. */
  123293. upperAlphaLimit: Nullable<number>;
  123294. /**
  123295. * Minimum allowed angle on the latitudinal axis.
  123296. * This can help limiting how the Camera is able to move in the scene.
  123297. */
  123298. lowerBetaLimit: number;
  123299. /**
  123300. * Maximum allowed angle on the latitudinal axis.
  123301. * This can help limiting how the Camera is able to move in the scene.
  123302. */
  123303. upperBetaLimit: number;
  123304. /**
  123305. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123306. * This can help limiting how the Camera is able to move in the scene.
  123307. */
  123308. lowerRadiusLimit: Nullable<number>;
  123309. /**
  123310. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123311. * This can help limiting how the Camera is able to move in the scene.
  123312. */
  123313. upperRadiusLimit: Nullable<number>;
  123314. /**
  123315. * Defines the current inertia value used during panning of the camera along the X axis.
  123316. */
  123317. inertialPanningX: number;
  123318. /**
  123319. * Defines the current inertia value used during panning of the camera along the Y axis.
  123320. */
  123321. inertialPanningY: number;
  123322. /**
  123323. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123324. * Basically if your fingers moves away from more than this distance you will be considered
  123325. * in pinch mode.
  123326. */
  123327. pinchToPanMaxDistance: number;
  123328. /**
  123329. * Defines the maximum distance the camera can pan.
  123330. * This could help keeping the cammera always in your scene.
  123331. */
  123332. panningDistanceLimit: Nullable<number>;
  123333. /**
  123334. * Defines the target of the camera before paning.
  123335. */
  123336. panningOriginTarget: Vector3;
  123337. /**
  123338. * Defines the value of the inertia used during panning.
  123339. * 0 would mean stop inertia and one would mean no decelleration at all.
  123340. */
  123341. panningInertia: number;
  123342. /**
  123343. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123344. */
  123345. get angularSensibilityX(): number;
  123346. set angularSensibilityX(value: number);
  123347. /**
  123348. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123349. */
  123350. get angularSensibilityY(): number;
  123351. set angularSensibilityY(value: number);
  123352. /**
  123353. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123354. */
  123355. get pinchPrecision(): number;
  123356. set pinchPrecision(value: number);
  123357. /**
  123358. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123359. * It will be used instead of pinchDeltaPrecision if different from 0.
  123360. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123361. */
  123362. get pinchDeltaPercentage(): number;
  123363. set pinchDeltaPercentage(value: number);
  123364. /**
  123365. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123366. * and pinch delta percentage.
  123367. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123368. * that any object in the plane at the camera's target point will scale
  123369. * perfectly with finger motion.
  123370. */
  123371. get useNaturalPinchZoom(): boolean;
  123372. set useNaturalPinchZoom(value: boolean);
  123373. /**
  123374. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123375. */
  123376. get panningSensibility(): number;
  123377. set panningSensibility(value: number);
  123378. /**
  123379. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123380. */
  123381. get keysUp(): number[];
  123382. set keysUp(value: number[]);
  123383. /**
  123384. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123385. */
  123386. get keysDown(): number[];
  123387. set keysDown(value: number[]);
  123388. /**
  123389. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123390. */
  123391. get keysLeft(): number[];
  123392. set keysLeft(value: number[]);
  123393. /**
  123394. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123395. */
  123396. get keysRight(): number[];
  123397. set keysRight(value: number[]);
  123398. /**
  123399. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123400. */
  123401. get wheelPrecision(): number;
  123402. set wheelPrecision(value: number);
  123403. /**
  123404. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123405. * It will be used instead of pinchDeltaPrecision if different from 0.
  123406. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123407. */
  123408. get wheelDeltaPercentage(): number;
  123409. set wheelDeltaPercentage(value: number);
  123410. /**
  123411. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123412. */
  123413. zoomOnFactor: number;
  123414. /**
  123415. * Defines a screen offset for the camera position.
  123416. */
  123417. targetScreenOffset: Vector2;
  123418. /**
  123419. * Allows the camera to be completely reversed.
  123420. * If false the camera can not arrive upside down.
  123421. */
  123422. allowUpsideDown: boolean;
  123423. /**
  123424. * Define if double tap/click is used to restore the previously saved state of the camera.
  123425. */
  123426. useInputToRestoreState: boolean;
  123427. /** @hidden */
  123428. _viewMatrix: Matrix;
  123429. /** @hidden */
  123430. _useCtrlForPanning: boolean;
  123431. /** @hidden */
  123432. _panningMouseButton: number;
  123433. /**
  123434. * Defines the input associated to the camera.
  123435. */
  123436. inputs: ArcRotateCameraInputsManager;
  123437. /** @hidden */
  123438. _reset: () => void;
  123439. /**
  123440. * Defines the allowed panning axis.
  123441. */
  123442. panningAxis: Vector3;
  123443. protected _localDirection: Vector3;
  123444. protected _transformedDirection: Vector3;
  123445. private _bouncingBehavior;
  123446. /**
  123447. * Gets the bouncing behavior of the camera if it has been enabled.
  123448. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123449. */
  123450. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123451. /**
  123452. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123453. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123454. */
  123455. get useBouncingBehavior(): boolean;
  123456. set useBouncingBehavior(value: boolean);
  123457. private _framingBehavior;
  123458. /**
  123459. * Gets the framing behavior of the camera if it has been enabled.
  123460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123461. */
  123462. get framingBehavior(): Nullable<FramingBehavior>;
  123463. /**
  123464. * Defines if the framing behavior of the camera is enabled on the camera.
  123465. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123466. */
  123467. get useFramingBehavior(): boolean;
  123468. set useFramingBehavior(value: boolean);
  123469. private _autoRotationBehavior;
  123470. /**
  123471. * Gets the auto rotation behavior of the camera if it has been enabled.
  123472. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123473. */
  123474. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123475. /**
  123476. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123477. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123478. */
  123479. get useAutoRotationBehavior(): boolean;
  123480. set useAutoRotationBehavior(value: boolean);
  123481. /**
  123482. * Observable triggered when the mesh target has been changed on the camera.
  123483. */
  123484. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123485. /**
  123486. * Event raised when the camera is colliding with a mesh.
  123487. */
  123488. onCollide: (collidedMesh: AbstractMesh) => void;
  123489. /**
  123490. * Defines whether the camera should check collision with the objects oh the scene.
  123491. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123492. */
  123493. checkCollisions: boolean;
  123494. /**
  123495. * Defines the collision radius of the camera.
  123496. * This simulates a sphere around the camera.
  123497. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123498. */
  123499. collisionRadius: Vector3;
  123500. protected _collider: Collider;
  123501. protected _previousPosition: Vector3;
  123502. protected _collisionVelocity: Vector3;
  123503. protected _newPosition: Vector3;
  123504. protected _previousAlpha: number;
  123505. protected _previousBeta: number;
  123506. protected _previousRadius: number;
  123507. protected _collisionTriggered: boolean;
  123508. protected _targetBoundingCenter: Nullable<Vector3>;
  123509. private _computationVector;
  123510. /**
  123511. * Instantiates a new ArcRotateCamera in a given scene
  123512. * @param name Defines the name of the camera
  123513. * @param alpha Defines the camera rotation along the logitudinal axis
  123514. * @param beta Defines the camera rotation along the latitudinal axis
  123515. * @param radius Defines the camera distance from its target
  123516. * @param target Defines the camera target
  123517. * @param scene Defines the scene the camera belongs to
  123518. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123519. */
  123520. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123521. /** @hidden */
  123522. _initCache(): void;
  123523. /** @hidden */
  123524. _updateCache(ignoreParentClass?: boolean): void;
  123525. protected _getTargetPosition(): Vector3;
  123526. private _storedAlpha;
  123527. private _storedBeta;
  123528. private _storedRadius;
  123529. private _storedTarget;
  123530. private _storedTargetScreenOffset;
  123531. /**
  123532. * Stores the current state of the camera (alpha, beta, radius and target)
  123533. * @returns the camera itself
  123534. */
  123535. storeState(): Camera;
  123536. /**
  123537. * @hidden
  123538. * Restored camera state. You must call storeState() first
  123539. */
  123540. _restoreStateValues(): boolean;
  123541. /** @hidden */
  123542. _isSynchronizedViewMatrix(): boolean;
  123543. /**
  123544. * Attached controls to the current camera.
  123545. * @param element Defines the element the controls should be listened from
  123546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123547. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123548. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123549. */
  123550. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123551. /**
  123552. * Detach the current controls from the camera.
  123553. * The camera will stop reacting to inputs.
  123554. * @param element Defines the element to stop listening the inputs from
  123555. */
  123556. detachControl(element: HTMLElement): void;
  123557. /** @hidden */
  123558. _checkInputs(): void;
  123559. protected _checkLimits(): void;
  123560. /**
  123561. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123562. */
  123563. rebuildAnglesAndRadius(): void;
  123564. /**
  123565. * Use a position to define the current camera related information like alpha, beta and radius
  123566. * @param position Defines the position to set the camera at
  123567. */
  123568. setPosition(position: Vector3): void;
  123569. /**
  123570. * Defines the target the camera should look at.
  123571. * This will automatically adapt alpha beta and radius to fit within the new target.
  123572. * @param target Defines the new target as a Vector or a mesh
  123573. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123574. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123575. */
  123576. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123577. /** @hidden */
  123578. _getViewMatrix(): Matrix;
  123579. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123580. /**
  123581. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123582. * @param meshes Defines the mesh to zoom on
  123583. * @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)
  123584. */
  123585. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123586. /**
  123587. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123588. * The target will be changed but the radius
  123589. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123590. * @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)
  123591. */
  123592. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123593. min: Vector3;
  123594. max: Vector3;
  123595. distance: number;
  123596. }, doNotUpdateMaxZ?: boolean): void;
  123597. /**
  123598. * @override
  123599. * Override Camera.createRigCamera
  123600. */
  123601. createRigCamera(name: string, cameraIndex: number): Camera;
  123602. /**
  123603. * @hidden
  123604. * @override
  123605. * Override Camera._updateRigCameras
  123606. */
  123607. _updateRigCameras(): void;
  123608. /**
  123609. * Destroy the camera and release the current resources hold by it.
  123610. */
  123611. dispose(): void;
  123612. /**
  123613. * Gets the current object class name.
  123614. * @return the class name
  123615. */
  123616. getClassName(): string;
  123617. }
  123618. }
  123619. declare module BABYLON {
  123620. /**
  123621. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123622. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123623. */
  123624. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123625. /**
  123626. * Gets the name of the behavior.
  123627. */
  123628. get name(): string;
  123629. private _zoomStopsAnimation;
  123630. private _idleRotationSpeed;
  123631. private _idleRotationWaitTime;
  123632. private _idleRotationSpinupTime;
  123633. /**
  123634. * Sets the flag that indicates if user zooming should stop animation.
  123635. */
  123636. set zoomStopsAnimation(flag: boolean);
  123637. /**
  123638. * Gets the flag that indicates if user zooming should stop animation.
  123639. */
  123640. get zoomStopsAnimation(): boolean;
  123641. /**
  123642. * Sets the default speed at which the camera rotates around the model.
  123643. */
  123644. set idleRotationSpeed(speed: number);
  123645. /**
  123646. * Gets the default speed at which the camera rotates around the model.
  123647. */
  123648. get idleRotationSpeed(): number;
  123649. /**
  123650. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123651. */
  123652. set idleRotationWaitTime(time: number);
  123653. /**
  123654. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123655. */
  123656. get idleRotationWaitTime(): number;
  123657. /**
  123658. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123659. */
  123660. set idleRotationSpinupTime(time: number);
  123661. /**
  123662. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123663. */
  123664. get idleRotationSpinupTime(): number;
  123665. /**
  123666. * Gets a value indicating if the camera is currently rotating because of this behavior
  123667. */
  123668. get rotationInProgress(): boolean;
  123669. private _onPrePointerObservableObserver;
  123670. private _onAfterCheckInputsObserver;
  123671. private _attachedCamera;
  123672. private _isPointerDown;
  123673. private _lastFrameTime;
  123674. private _lastInteractionTime;
  123675. private _cameraRotationSpeed;
  123676. /**
  123677. * Initializes the behavior.
  123678. */
  123679. init(): void;
  123680. /**
  123681. * Attaches the behavior to its arc rotate camera.
  123682. * @param camera Defines the camera to attach the behavior to
  123683. */
  123684. attach(camera: ArcRotateCamera): void;
  123685. /**
  123686. * Detaches the behavior from its current arc rotate camera.
  123687. */
  123688. detach(): void;
  123689. /**
  123690. * Returns true if user is scrolling.
  123691. * @return true if user is scrolling.
  123692. */
  123693. private _userIsZooming;
  123694. private _lastFrameRadius;
  123695. private _shouldAnimationStopForInteraction;
  123696. /**
  123697. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123698. */
  123699. private _applyUserInteraction;
  123700. private _userIsMoving;
  123701. }
  123702. }
  123703. declare module BABYLON {
  123704. /**
  123705. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123706. */
  123707. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123708. private ui;
  123709. /**
  123710. * The name of the behavior
  123711. */
  123712. name: string;
  123713. /**
  123714. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123715. */
  123716. distanceAwayFromFace: number;
  123717. /**
  123718. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123719. */
  123720. distanceAwayFromBottomOfFace: number;
  123721. private _faceVectors;
  123722. private _target;
  123723. private _scene;
  123724. private _onRenderObserver;
  123725. private _tmpMatrix;
  123726. private _tmpVector;
  123727. /**
  123728. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123729. * @param ui The transform node that should be attched to the mesh
  123730. */
  123731. constructor(ui: TransformNode);
  123732. /**
  123733. * Initializes the behavior
  123734. */
  123735. init(): void;
  123736. private _closestFace;
  123737. private _zeroVector;
  123738. private _lookAtTmpMatrix;
  123739. private _lookAtToRef;
  123740. /**
  123741. * Attaches the AttachToBoxBehavior to the passed in mesh
  123742. * @param target The mesh that the specified node will be attached to
  123743. */
  123744. attach(target: Mesh): void;
  123745. /**
  123746. * Detaches the behavior from the mesh
  123747. */
  123748. detach(): void;
  123749. }
  123750. }
  123751. declare module BABYLON {
  123752. /**
  123753. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123754. */
  123755. export class FadeInOutBehavior implements Behavior<Mesh> {
  123756. /**
  123757. * Time in milliseconds to delay before fading in (Default: 0)
  123758. */
  123759. delay: number;
  123760. /**
  123761. * Time in milliseconds for the mesh to fade in (Default: 300)
  123762. */
  123763. fadeInTime: number;
  123764. private _millisecondsPerFrame;
  123765. private _hovered;
  123766. private _hoverValue;
  123767. private _ownerNode;
  123768. /**
  123769. * Instatiates the FadeInOutBehavior
  123770. */
  123771. constructor();
  123772. /**
  123773. * The name of the behavior
  123774. */
  123775. get name(): string;
  123776. /**
  123777. * Initializes the behavior
  123778. */
  123779. init(): void;
  123780. /**
  123781. * Attaches the fade behavior on the passed in mesh
  123782. * @param ownerNode The mesh that will be faded in/out once attached
  123783. */
  123784. attach(ownerNode: Mesh): void;
  123785. /**
  123786. * Detaches the behavior from the mesh
  123787. */
  123788. detach(): void;
  123789. /**
  123790. * Triggers the mesh to begin fading in or out
  123791. * @param value if the object should fade in or out (true to fade in)
  123792. */
  123793. fadeIn(value: boolean): void;
  123794. private _update;
  123795. private _setAllVisibility;
  123796. }
  123797. }
  123798. declare module BABYLON {
  123799. /**
  123800. * Class containing a set of static utilities functions for managing Pivots
  123801. * @hidden
  123802. */
  123803. export class PivotTools {
  123804. private static _PivotCached;
  123805. private static _OldPivotPoint;
  123806. private static _PivotTranslation;
  123807. private static _PivotTmpVector;
  123808. private static _PivotPostMultiplyPivotMatrix;
  123809. /** @hidden */
  123810. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123811. /** @hidden */
  123812. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123813. }
  123814. }
  123815. declare module BABYLON {
  123816. /**
  123817. * Class containing static functions to help procedurally build meshes
  123818. */
  123819. export class PlaneBuilder {
  123820. /**
  123821. * Creates a plane mesh
  123822. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123823. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123824. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123828. * @param name defines the name of the mesh
  123829. * @param options defines the options used to create the mesh
  123830. * @param scene defines the hosting scene
  123831. * @returns the plane mesh
  123832. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123833. */
  123834. static CreatePlane(name: string, options: {
  123835. size?: number;
  123836. width?: number;
  123837. height?: number;
  123838. sideOrientation?: number;
  123839. frontUVs?: Vector4;
  123840. backUVs?: Vector4;
  123841. updatable?: boolean;
  123842. sourcePlane?: Plane;
  123843. }, scene?: Nullable<Scene>): Mesh;
  123844. }
  123845. }
  123846. declare module BABYLON {
  123847. /**
  123848. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123849. */
  123850. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123851. private static _AnyMouseID;
  123852. /**
  123853. * Abstract mesh the behavior is set on
  123854. */
  123855. attachedNode: AbstractMesh;
  123856. private _dragPlane;
  123857. private _scene;
  123858. private _pointerObserver;
  123859. private _beforeRenderObserver;
  123860. private static _planeScene;
  123861. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123862. /**
  123863. * 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)
  123864. */
  123865. maxDragAngle: number;
  123866. /**
  123867. * @hidden
  123868. */
  123869. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123870. /**
  123871. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123872. */
  123873. currentDraggingPointerID: number;
  123874. /**
  123875. * The last position where the pointer hit the drag plane in world space
  123876. */
  123877. lastDragPosition: Vector3;
  123878. /**
  123879. * If the behavior is currently in a dragging state
  123880. */
  123881. dragging: boolean;
  123882. /**
  123883. * 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)
  123884. */
  123885. dragDeltaRatio: number;
  123886. /**
  123887. * If the drag plane orientation should be updated during the dragging (Default: true)
  123888. */
  123889. updateDragPlane: boolean;
  123890. private _debugMode;
  123891. private _moving;
  123892. /**
  123893. * Fires each time the attached mesh is dragged with the pointer
  123894. * * delta between last drag position and current drag position in world space
  123895. * * dragDistance along the drag axis
  123896. * * dragPlaneNormal normal of the current drag plane used during the drag
  123897. * * dragPlanePoint in world space where the drag intersects the drag plane
  123898. */
  123899. onDragObservable: Observable<{
  123900. delta: Vector3;
  123901. dragPlanePoint: Vector3;
  123902. dragPlaneNormal: Vector3;
  123903. dragDistance: number;
  123904. pointerId: number;
  123905. }>;
  123906. /**
  123907. * Fires each time a drag begins (eg. mouse down on mesh)
  123908. */
  123909. onDragStartObservable: Observable<{
  123910. dragPlanePoint: Vector3;
  123911. pointerId: number;
  123912. }>;
  123913. /**
  123914. * Fires each time a drag ends (eg. mouse release after drag)
  123915. */
  123916. onDragEndObservable: Observable<{
  123917. dragPlanePoint: Vector3;
  123918. pointerId: number;
  123919. }>;
  123920. /**
  123921. * If the attached mesh should be moved when dragged
  123922. */
  123923. moveAttached: boolean;
  123924. /**
  123925. * If the drag behavior will react to drag events (Default: true)
  123926. */
  123927. enabled: boolean;
  123928. /**
  123929. * If pointer events should start and release the drag (Default: true)
  123930. */
  123931. startAndReleaseDragOnPointerEvents: boolean;
  123932. /**
  123933. * If camera controls should be detached during the drag
  123934. */
  123935. detachCameraControls: boolean;
  123936. /**
  123937. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123938. */
  123939. useObjectOrientationForDragging: boolean;
  123940. private _options;
  123941. /**
  123942. * Gets the options used by the behavior
  123943. */
  123944. get options(): {
  123945. dragAxis?: Vector3;
  123946. dragPlaneNormal?: Vector3;
  123947. };
  123948. /**
  123949. * Sets the options used by the behavior
  123950. */
  123951. set options(options: {
  123952. dragAxis?: Vector3;
  123953. dragPlaneNormal?: Vector3;
  123954. });
  123955. /**
  123956. * Creates a pointer drag behavior that can be attached to a mesh
  123957. * @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)
  123958. */
  123959. constructor(options?: {
  123960. dragAxis?: Vector3;
  123961. dragPlaneNormal?: Vector3;
  123962. });
  123963. /**
  123964. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123965. */
  123966. validateDrag: (targetPosition: Vector3) => boolean;
  123967. /**
  123968. * The name of the behavior
  123969. */
  123970. get name(): string;
  123971. /**
  123972. * Initializes the behavior
  123973. */
  123974. init(): void;
  123975. private _tmpVector;
  123976. private _alternatePickedPoint;
  123977. private _worldDragAxis;
  123978. private _targetPosition;
  123979. private _attachedElement;
  123980. /**
  123981. * Attaches the drag behavior the passed in mesh
  123982. * @param ownerNode The mesh that will be dragged around once attached
  123983. * @param predicate Predicate to use for pick filtering
  123984. */
  123985. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123986. /**
  123987. * Force relase the drag action by code.
  123988. */
  123989. releaseDrag(): void;
  123990. private _startDragRay;
  123991. private _lastPointerRay;
  123992. /**
  123993. * Simulates the start of a pointer drag event on the behavior
  123994. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123995. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123996. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123997. */
  123998. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123999. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124000. private _dragDelta;
  124001. protected _moveDrag(ray: Ray): void;
  124002. private _pickWithRayOnDragPlane;
  124003. private _pointA;
  124004. private _pointC;
  124005. private _localAxis;
  124006. private _lookAt;
  124007. private _updateDragPlanePosition;
  124008. /**
  124009. * Detaches the behavior from the mesh
  124010. */
  124011. detach(): void;
  124012. }
  124013. }
  124014. declare module BABYLON {
  124015. /**
  124016. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124017. */
  124018. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124019. private _dragBehaviorA;
  124020. private _dragBehaviorB;
  124021. private _startDistance;
  124022. private _initialScale;
  124023. private _targetScale;
  124024. private _ownerNode;
  124025. private _sceneRenderObserver;
  124026. /**
  124027. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124028. */
  124029. constructor();
  124030. /**
  124031. * The name of the behavior
  124032. */
  124033. get name(): string;
  124034. /**
  124035. * Initializes the behavior
  124036. */
  124037. init(): void;
  124038. private _getCurrentDistance;
  124039. /**
  124040. * Attaches the scale behavior the passed in mesh
  124041. * @param ownerNode The mesh that will be scaled around once attached
  124042. */
  124043. attach(ownerNode: Mesh): void;
  124044. /**
  124045. * Detaches the behavior from the mesh
  124046. */
  124047. detach(): void;
  124048. }
  124049. }
  124050. declare module BABYLON {
  124051. /**
  124052. * 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
  124053. */
  124054. export class SixDofDragBehavior implements Behavior<Mesh> {
  124055. private static _virtualScene;
  124056. private _ownerNode;
  124057. private _sceneRenderObserver;
  124058. private _scene;
  124059. private _targetPosition;
  124060. private _virtualOriginMesh;
  124061. private _virtualDragMesh;
  124062. private _pointerObserver;
  124063. private _moving;
  124064. private _startingOrientation;
  124065. private _attachedElement;
  124066. /**
  124067. * 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)
  124068. */
  124069. private zDragFactor;
  124070. /**
  124071. * If the object should rotate to face the drag origin
  124072. */
  124073. rotateDraggedObject: boolean;
  124074. /**
  124075. * If the behavior is currently in a dragging state
  124076. */
  124077. dragging: boolean;
  124078. /**
  124079. * 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)
  124080. */
  124081. dragDeltaRatio: number;
  124082. /**
  124083. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124084. */
  124085. currentDraggingPointerID: number;
  124086. /**
  124087. * If camera controls should be detached during the drag
  124088. */
  124089. detachCameraControls: boolean;
  124090. /**
  124091. * Fires each time a drag starts
  124092. */
  124093. onDragStartObservable: Observable<{}>;
  124094. /**
  124095. * Fires each time a drag ends (eg. mouse release after drag)
  124096. */
  124097. onDragEndObservable: Observable<{}>;
  124098. /**
  124099. * 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
  124100. */
  124101. constructor();
  124102. /**
  124103. * The name of the behavior
  124104. */
  124105. get name(): string;
  124106. /**
  124107. * Initializes the behavior
  124108. */
  124109. init(): void;
  124110. /**
  124111. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124112. */
  124113. private get _pointerCamera();
  124114. /**
  124115. * Attaches the scale behavior the passed in mesh
  124116. * @param ownerNode The mesh that will be scaled around once attached
  124117. */
  124118. attach(ownerNode: Mesh): void;
  124119. /**
  124120. * Detaches the behavior from the mesh
  124121. */
  124122. detach(): void;
  124123. }
  124124. }
  124125. declare module BABYLON {
  124126. /**
  124127. * Class used to apply inverse kinematics to bones
  124128. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124129. */
  124130. export class BoneIKController {
  124131. private static _tmpVecs;
  124132. private static _tmpQuat;
  124133. private static _tmpMats;
  124134. /**
  124135. * Gets or sets the target mesh
  124136. */
  124137. targetMesh: AbstractMesh;
  124138. /** Gets or sets the mesh used as pole */
  124139. poleTargetMesh: AbstractMesh;
  124140. /**
  124141. * Gets or sets the bone used as pole
  124142. */
  124143. poleTargetBone: Nullable<Bone>;
  124144. /**
  124145. * Gets or sets the target position
  124146. */
  124147. targetPosition: Vector3;
  124148. /**
  124149. * Gets or sets the pole target position
  124150. */
  124151. poleTargetPosition: Vector3;
  124152. /**
  124153. * Gets or sets the pole target local offset
  124154. */
  124155. poleTargetLocalOffset: Vector3;
  124156. /**
  124157. * Gets or sets the pole angle
  124158. */
  124159. poleAngle: number;
  124160. /**
  124161. * Gets or sets the mesh associated with the controller
  124162. */
  124163. mesh: AbstractMesh;
  124164. /**
  124165. * 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)
  124166. */
  124167. slerpAmount: number;
  124168. private _bone1Quat;
  124169. private _bone1Mat;
  124170. private _bone2Ang;
  124171. private _bone1;
  124172. private _bone2;
  124173. private _bone1Length;
  124174. private _bone2Length;
  124175. private _maxAngle;
  124176. private _maxReach;
  124177. private _rightHandedSystem;
  124178. private _bendAxis;
  124179. private _slerping;
  124180. private _adjustRoll;
  124181. /**
  124182. * Gets or sets maximum allowed angle
  124183. */
  124184. get maxAngle(): number;
  124185. set maxAngle(value: number);
  124186. /**
  124187. * Creates a new BoneIKController
  124188. * @param mesh defines the mesh to control
  124189. * @param bone defines the bone to control
  124190. * @param options defines options to set up the controller
  124191. */
  124192. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124193. targetMesh?: AbstractMesh;
  124194. poleTargetMesh?: AbstractMesh;
  124195. poleTargetBone?: Bone;
  124196. poleTargetLocalOffset?: Vector3;
  124197. poleAngle?: number;
  124198. bendAxis?: Vector3;
  124199. maxAngle?: number;
  124200. slerpAmount?: number;
  124201. });
  124202. private _setMaxAngle;
  124203. /**
  124204. * Force the controller to update the bones
  124205. */
  124206. update(): void;
  124207. }
  124208. }
  124209. declare module BABYLON {
  124210. /**
  124211. * Class used to make a bone look toward a point in space
  124212. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124213. */
  124214. export class BoneLookController {
  124215. private static _tmpVecs;
  124216. private static _tmpQuat;
  124217. private static _tmpMats;
  124218. /**
  124219. * The target Vector3 that the bone will look at
  124220. */
  124221. target: Vector3;
  124222. /**
  124223. * The mesh that the bone is attached to
  124224. */
  124225. mesh: AbstractMesh;
  124226. /**
  124227. * The bone that will be looking to the target
  124228. */
  124229. bone: Bone;
  124230. /**
  124231. * The up axis of the coordinate system that is used when the bone is rotated
  124232. */
  124233. upAxis: Vector3;
  124234. /**
  124235. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124236. */
  124237. upAxisSpace: Space;
  124238. /**
  124239. * Used to make an adjustment to the yaw of the bone
  124240. */
  124241. adjustYaw: number;
  124242. /**
  124243. * Used to make an adjustment to the pitch of the bone
  124244. */
  124245. adjustPitch: number;
  124246. /**
  124247. * Used to make an adjustment to the roll of the bone
  124248. */
  124249. adjustRoll: number;
  124250. /**
  124251. * 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)
  124252. */
  124253. slerpAmount: number;
  124254. private _minYaw;
  124255. private _maxYaw;
  124256. private _minPitch;
  124257. private _maxPitch;
  124258. private _minYawSin;
  124259. private _minYawCos;
  124260. private _maxYawSin;
  124261. private _maxYawCos;
  124262. private _midYawConstraint;
  124263. private _minPitchTan;
  124264. private _maxPitchTan;
  124265. private _boneQuat;
  124266. private _slerping;
  124267. private _transformYawPitch;
  124268. private _transformYawPitchInv;
  124269. private _firstFrameSkipped;
  124270. private _yawRange;
  124271. private _fowardAxis;
  124272. /**
  124273. * Gets or sets the minimum yaw angle that the bone can look to
  124274. */
  124275. get minYaw(): number;
  124276. set minYaw(value: number);
  124277. /**
  124278. * Gets or sets the maximum yaw angle that the bone can look to
  124279. */
  124280. get maxYaw(): number;
  124281. set maxYaw(value: number);
  124282. /**
  124283. * Gets or sets the minimum pitch angle that the bone can look to
  124284. */
  124285. get minPitch(): number;
  124286. set minPitch(value: number);
  124287. /**
  124288. * Gets or sets the maximum pitch angle that the bone can look to
  124289. */
  124290. get maxPitch(): number;
  124291. set maxPitch(value: number);
  124292. /**
  124293. * Create a BoneLookController
  124294. * @param mesh the mesh that the bone belongs to
  124295. * @param bone the bone that will be looking to the target
  124296. * @param target the target Vector3 to look at
  124297. * @param options optional settings:
  124298. * * maxYaw: the maximum angle the bone will yaw to
  124299. * * minYaw: the minimum angle the bone will yaw to
  124300. * * maxPitch: the maximum angle the bone will pitch to
  124301. * * minPitch: the minimum angle the bone will yaw to
  124302. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124303. * * upAxis: the up axis of the coordinate system
  124304. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124305. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124306. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124307. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124308. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124309. * * adjustRoll: used to make an adjustment to the roll of the bone
  124310. **/
  124311. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124312. maxYaw?: number;
  124313. minYaw?: number;
  124314. maxPitch?: number;
  124315. minPitch?: number;
  124316. slerpAmount?: number;
  124317. upAxis?: Vector3;
  124318. upAxisSpace?: Space;
  124319. yawAxis?: Vector3;
  124320. pitchAxis?: Vector3;
  124321. adjustYaw?: number;
  124322. adjustPitch?: number;
  124323. adjustRoll?: number;
  124324. });
  124325. /**
  124326. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124327. */
  124328. update(): void;
  124329. private _getAngleDiff;
  124330. private _getAngleBetween;
  124331. private _isAngleBetween;
  124332. }
  124333. }
  124334. declare module BABYLON {
  124335. /**
  124336. * Manage the gamepad inputs to control an arc rotate camera.
  124337. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124338. */
  124339. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124340. /**
  124341. * Defines the camera the input is attached to.
  124342. */
  124343. camera: ArcRotateCamera;
  124344. /**
  124345. * Defines the gamepad the input is gathering event from.
  124346. */
  124347. gamepad: Nullable<Gamepad>;
  124348. /**
  124349. * Defines the gamepad rotation sensiblity.
  124350. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124351. */
  124352. gamepadRotationSensibility: number;
  124353. /**
  124354. * Defines the gamepad move sensiblity.
  124355. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124356. */
  124357. gamepadMoveSensibility: number;
  124358. private _yAxisScale;
  124359. /**
  124360. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124361. */
  124362. get invertYAxis(): boolean;
  124363. set invertYAxis(value: boolean);
  124364. private _onGamepadConnectedObserver;
  124365. private _onGamepadDisconnectedObserver;
  124366. /**
  124367. * Attach the input controls to a specific dom element to get the input from.
  124368. * @param element Defines the element the controls should be listened from
  124369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124370. */
  124371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124372. /**
  124373. * Detach the current controls from the specified dom element.
  124374. * @param element Defines the element to stop listening the inputs from
  124375. */
  124376. detachControl(element: Nullable<HTMLElement>): void;
  124377. /**
  124378. * Update the current camera state depending on the inputs that have been used this frame.
  124379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124380. */
  124381. checkInputs(): void;
  124382. /**
  124383. * Gets the class name of the current intput.
  124384. * @returns the class name
  124385. */
  124386. getClassName(): string;
  124387. /**
  124388. * Get the friendly name associated with the input class.
  124389. * @returns the input friendly name
  124390. */
  124391. getSimpleName(): string;
  124392. }
  124393. }
  124394. declare module BABYLON {
  124395. interface ArcRotateCameraInputsManager {
  124396. /**
  124397. * Add orientation input support to the input manager.
  124398. * @returns the current input manager
  124399. */
  124400. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124401. }
  124402. /**
  124403. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124404. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124405. */
  124406. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124407. /**
  124408. * Defines the camera the input is attached to.
  124409. */
  124410. camera: ArcRotateCamera;
  124411. /**
  124412. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124413. */
  124414. alphaCorrection: number;
  124415. /**
  124416. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124417. */
  124418. gammaCorrection: number;
  124419. private _alpha;
  124420. private _gamma;
  124421. private _dirty;
  124422. private _deviceOrientationHandler;
  124423. /**
  124424. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124425. */
  124426. constructor();
  124427. /**
  124428. * Attach the input controls to a specific dom element to get the input from.
  124429. * @param element Defines the element the controls should be listened from
  124430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124431. */
  124432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124433. /** @hidden */
  124434. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124435. /**
  124436. * Update the current camera state depending on the inputs that have been used this frame.
  124437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124438. */
  124439. checkInputs(): void;
  124440. /**
  124441. * Detach the current controls from the specified dom element.
  124442. * @param element Defines the element to stop listening the inputs from
  124443. */
  124444. detachControl(element: Nullable<HTMLElement>): void;
  124445. /**
  124446. * Gets the class name of the current intput.
  124447. * @returns the class name
  124448. */
  124449. getClassName(): string;
  124450. /**
  124451. * Get the friendly name associated with the input class.
  124452. * @returns the input friendly name
  124453. */
  124454. getSimpleName(): string;
  124455. }
  124456. }
  124457. declare module BABYLON {
  124458. /**
  124459. * Listen to mouse events to control the camera.
  124460. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124461. */
  124462. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124463. /**
  124464. * Defines the camera the input is attached to.
  124465. */
  124466. camera: FlyCamera;
  124467. /**
  124468. * Defines if touch is enabled. (Default is true.)
  124469. */
  124470. touchEnabled: boolean;
  124471. /**
  124472. * Defines the buttons associated with the input to handle camera rotation.
  124473. */
  124474. buttons: number[];
  124475. /**
  124476. * Assign buttons for Yaw control.
  124477. */
  124478. buttonsYaw: number[];
  124479. /**
  124480. * Assign buttons for Pitch control.
  124481. */
  124482. buttonsPitch: number[];
  124483. /**
  124484. * Assign buttons for Roll control.
  124485. */
  124486. buttonsRoll: number[];
  124487. /**
  124488. * Detect if any button is being pressed while mouse is moved.
  124489. * -1 = Mouse locked.
  124490. * 0 = Left button.
  124491. * 1 = Middle Button.
  124492. * 2 = Right Button.
  124493. */
  124494. activeButton: number;
  124495. /**
  124496. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124497. * Higher values reduce its sensitivity.
  124498. */
  124499. angularSensibility: number;
  124500. private _mousemoveCallback;
  124501. private _observer;
  124502. private _rollObserver;
  124503. private previousPosition;
  124504. private noPreventDefault;
  124505. private element;
  124506. /**
  124507. * Listen to mouse events to control the camera.
  124508. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124509. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124510. */
  124511. constructor(touchEnabled?: boolean);
  124512. /**
  124513. * Attach the mouse control to the HTML DOM element.
  124514. * @param element Defines the element that listens to the input events.
  124515. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124516. */
  124517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124518. /**
  124519. * Detach the current controls from the specified dom element.
  124520. * @param element Defines the element to stop listening the inputs from
  124521. */
  124522. detachControl(element: Nullable<HTMLElement>): void;
  124523. /**
  124524. * Gets the class name of the current input.
  124525. * @returns the class name.
  124526. */
  124527. getClassName(): string;
  124528. /**
  124529. * Get the friendly name associated with the input class.
  124530. * @returns the input's friendly name.
  124531. */
  124532. getSimpleName(): string;
  124533. private _pointerInput;
  124534. private _onMouseMove;
  124535. /**
  124536. * Rotate camera by mouse offset.
  124537. */
  124538. private rotateCamera;
  124539. }
  124540. }
  124541. declare module BABYLON {
  124542. /**
  124543. * Default Inputs manager for the FlyCamera.
  124544. * It groups all the default supported inputs for ease of use.
  124545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124546. */
  124547. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124548. /**
  124549. * Instantiates a new FlyCameraInputsManager.
  124550. * @param camera Defines the camera the inputs belong to.
  124551. */
  124552. constructor(camera: FlyCamera);
  124553. /**
  124554. * Add keyboard input support to the input manager.
  124555. * @returns the new FlyCameraKeyboardMoveInput().
  124556. */
  124557. addKeyboard(): FlyCameraInputsManager;
  124558. /**
  124559. * Add mouse input support to the input manager.
  124560. * @param touchEnabled Enable touch screen support.
  124561. * @returns the new FlyCameraMouseInput().
  124562. */
  124563. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124564. }
  124565. }
  124566. declare module BABYLON {
  124567. /**
  124568. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124569. * such as in a 3D Space Shooter or a Flight Simulator.
  124570. */
  124571. export class FlyCamera extends TargetCamera {
  124572. /**
  124573. * Define the collision ellipsoid of the camera.
  124574. * This is helpful for simulating a camera body, like a player's body.
  124575. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124576. */
  124577. ellipsoid: Vector3;
  124578. /**
  124579. * Define an offset for the position of the ellipsoid around the camera.
  124580. * This can be helpful if the camera is attached away from the player's body center,
  124581. * such as at its head.
  124582. */
  124583. ellipsoidOffset: Vector3;
  124584. /**
  124585. * Enable or disable collisions of the camera with the rest of the scene objects.
  124586. */
  124587. checkCollisions: boolean;
  124588. /**
  124589. * Enable or disable gravity on the camera.
  124590. */
  124591. applyGravity: boolean;
  124592. /**
  124593. * Define the current direction the camera is moving to.
  124594. */
  124595. cameraDirection: Vector3;
  124596. /**
  124597. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124598. * This overrides and empties cameraRotation.
  124599. */
  124600. rotationQuaternion: Quaternion;
  124601. /**
  124602. * Track Roll to maintain the wanted Rolling when looking around.
  124603. */
  124604. _trackRoll: number;
  124605. /**
  124606. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124607. */
  124608. rollCorrect: number;
  124609. /**
  124610. * Mimic a banked turn, Rolling the camera when Yawing.
  124611. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124612. */
  124613. bankedTurn: boolean;
  124614. /**
  124615. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124616. */
  124617. bankedTurnLimit: number;
  124618. /**
  124619. * Value of 0 disables the banked Roll.
  124620. * Value of 1 is equal to the Yaw angle in radians.
  124621. */
  124622. bankedTurnMultiplier: number;
  124623. /**
  124624. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124625. */
  124626. inputs: FlyCameraInputsManager;
  124627. /**
  124628. * Gets the input sensibility for mouse input.
  124629. * Higher values reduce sensitivity.
  124630. */
  124631. get angularSensibility(): number;
  124632. /**
  124633. * Sets the input sensibility for a mouse input.
  124634. * Higher values reduce sensitivity.
  124635. */
  124636. set angularSensibility(value: number);
  124637. /**
  124638. * Get the keys for camera movement forward.
  124639. */
  124640. get keysForward(): number[];
  124641. /**
  124642. * Set the keys for camera movement forward.
  124643. */
  124644. set keysForward(value: number[]);
  124645. /**
  124646. * Get the keys for camera movement backward.
  124647. */
  124648. get keysBackward(): number[];
  124649. set keysBackward(value: number[]);
  124650. /**
  124651. * Get the keys for camera movement up.
  124652. */
  124653. get keysUp(): number[];
  124654. /**
  124655. * Set the keys for camera movement up.
  124656. */
  124657. set keysUp(value: number[]);
  124658. /**
  124659. * Get the keys for camera movement down.
  124660. */
  124661. get keysDown(): number[];
  124662. /**
  124663. * Set the keys for camera movement down.
  124664. */
  124665. set keysDown(value: number[]);
  124666. /**
  124667. * Get the keys for camera movement left.
  124668. */
  124669. get keysLeft(): number[];
  124670. /**
  124671. * Set the keys for camera movement left.
  124672. */
  124673. set keysLeft(value: number[]);
  124674. /**
  124675. * Set the keys for camera movement right.
  124676. */
  124677. get keysRight(): number[];
  124678. /**
  124679. * Set the keys for camera movement right.
  124680. */
  124681. set keysRight(value: number[]);
  124682. /**
  124683. * Event raised when the camera collides with a mesh in the scene.
  124684. */
  124685. onCollide: (collidedMesh: AbstractMesh) => void;
  124686. private _collider;
  124687. private _needMoveForGravity;
  124688. private _oldPosition;
  124689. private _diffPosition;
  124690. private _newPosition;
  124691. /** @hidden */
  124692. _localDirection: Vector3;
  124693. /** @hidden */
  124694. _transformedDirection: Vector3;
  124695. /**
  124696. * Instantiates a FlyCamera.
  124697. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124698. * such as in a 3D Space Shooter or a Flight Simulator.
  124699. * @param name Define the name of the camera in the scene.
  124700. * @param position Define the starting position of the camera in the scene.
  124701. * @param scene Define the scene the camera belongs to.
  124702. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124703. */
  124704. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124705. /**
  124706. * Attach a control to the HTML DOM element.
  124707. * @param element Defines the element that listens to the input events.
  124708. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124709. */
  124710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124711. /**
  124712. * Detach a control from the HTML DOM element.
  124713. * The camera will stop reacting to that input.
  124714. * @param element Defines the element that listens to the input events.
  124715. */
  124716. detachControl(element: HTMLElement): void;
  124717. private _collisionMask;
  124718. /**
  124719. * Get the mask that the camera ignores in collision events.
  124720. */
  124721. get collisionMask(): number;
  124722. /**
  124723. * Set the mask that the camera ignores in collision events.
  124724. */
  124725. set collisionMask(mask: number);
  124726. /** @hidden */
  124727. _collideWithWorld(displacement: Vector3): void;
  124728. /** @hidden */
  124729. private _onCollisionPositionChange;
  124730. /** @hidden */
  124731. _checkInputs(): void;
  124732. /** @hidden */
  124733. _decideIfNeedsToMove(): boolean;
  124734. /** @hidden */
  124735. _updatePosition(): void;
  124736. /**
  124737. * Restore the Roll to its target value at the rate specified.
  124738. * @param rate - Higher means slower restoring.
  124739. * @hidden
  124740. */
  124741. restoreRoll(rate: number): void;
  124742. /**
  124743. * Destroy the camera and release the current resources held by it.
  124744. */
  124745. dispose(): void;
  124746. /**
  124747. * Get the current object class name.
  124748. * @returns the class name.
  124749. */
  124750. getClassName(): string;
  124751. }
  124752. }
  124753. declare module BABYLON {
  124754. /**
  124755. * Listen to keyboard events to control the camera.
  124756. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124757. */
  124758. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124759. /**
  124760. * Defines the camera the input is attached to.
  124761. */
  124762. camera: FlyCamera;
  124763. /**
  124764. * The list of keyboard keys used to control the forward move of the camera.
  124765. */
  124766. keysForward: number[];
  124767. /**
  124768. * The list of keyboard keys used to control the backward move of the camera.
  124769. */
  124770. keysBackward: number[];
  124771. /**
  124772. * The list of keyboard keys used to control the forward move of the camera.
  124773. */
  124774. keysUp: number[];
  124775. /**
  124776. * The list of keyboard keys used to control the backward move of the camera.
  124777. */
  124778. keysDown: number[];
  124779. /**
  124780. * The list of keyboard keys used to control the right strafe move of the camera.
  124781. */
  124782. keysRight: number[];
  124783. /**
  124784. * The list of keyboard keys used to control the left strafe move of the camera.
  124785. */
  124786. keysLeft: number[];
  124787. private _keys;
  124788. private _onCanvasBlurObserver;
  124789. private _onKeyboardObserver;
  124790. private _engine;
  124791. private _scene;
  124792. /**
  124793. * Attach the input controls to a specific dom element to get the input from.
  124794. * @param element Defines the element the controls should be listened from
  124795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124796. */
  124797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124798. /**
  124799. * Detach the current controls from the specified dom element.
  124800. * @param element Defines the element to stop listening the inputs from
  124801. */
  124802. detachControl(element: Nullable<HTMLElement>): void;
  124803. /**
  124804. * Gets the class name of the current intput.
  124805. * @returns the class name
  124806. */
  124807. getClassName(): string;
  124808. /** @hidden */
  124809. _onLostFocus(e: FocusEvent): void;
  124810. /**
  124811. * Get the friendly name associated with the input class.
  124812. * @returns the input friendly name
  124813. */
  124814. getSimpleName(): string;
  124815. /**
  124816. * Update the current camera state depending on the inputs that have been used this frame.
  124817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124818. */
  124819. checkInputs(): void;
  124820. }
  124821. }
  124822. declare module BABYLON {
  124823. /**
  124824. * Manage the mouse wheel inputs to control a follow camera.
  124825. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124826. */
  124827. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124828. /**
  124829. * Defines the camera the input is attached to.
  124830. */
  124831. camera: FollowCamera;
  124832. /**
  124833. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124834. */
  124835. axisControlRadius: boolean;
  124836. /**
  124837. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124838. */
  124839. axisControlHeight: boolean;
  124840. /**
  124841. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124842. */
  124843. axisControlRotation: boolean;
  124844. /**
  124845. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124846. * relation to mouseWheel events.
  124847. */
  124848. wheelPrecision: number;
  124849. /**
  124850. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124851. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124852. */
  124853. wheelDeltaPercentage: number;
  124854. private _wheel;
  124855. private _observer;
  124856. /**
  124857. * Attach the input controls to a specific dom element to get the input from.
  124858. * @param element Defines the element the controls should be listened from
  124859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124860. */
  124861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124862. /**
  124863. * Detach the current controls from the specified dom element.
  124864. * @param element Defines the element to stop listening the inputs from
  124865. */
  124866. detachControl(element: Nullable<HTMLElement>): void;
  124867. /**
  124868. * Gets the class name of the current intput.
  124869. * @returns the class name
  124870. */
  124871. getClassName(): string;
  124872. /**
  124873. * Get the friendly name associated with the input class.
  124874. * @returns the input friendly name
  124875. */
  124876. getSimpleName(): string;
  124877. }
  124878. }
  124879. declare module BABYLON {
  124880. /**
  124881. * Manage the pointers inputs to control an follow camera.
  124882. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124883. */
  124884. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124885. /**
  124886. * Defines the camera the input is attached to.
  124887. */
  124888. camera: FollowCamera;
  124889. /**
  124890. * Gets the class name of the current input.
  124891. * @returns the class name
  124892. */
  124893. getClassName(): string;
  124894. /**
  124895. * Defines the pointer angular sensibility along the X axis or how fast is
  124896. * the camera rotating.
  124897. * A negative number will reverse the axis direction.
  124898. */
  124899. angularSensibilityX: number;
  124900. /**
  124901. * Defines the pointer angular sensibility along the Y axis or how fast is
  124902. * the camera rotating.
  124903. * A negative number will reverse the axis direction.
  124904. */
  124905. angularSensibilityY: number;
  124906. /**
  124907. * Defines the pointer pinch precision or how fast is the camera zooming.
  124908. * A negative number will reverse the axis direction.
  124909. */
  124910. pinchPrecision: number;
  124911. /**
  124912. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124913. * from 0.
  124914. * It defines the percentage of current camera.radius to use as delta when
  124915. * pinch zoom is used.
  124916. */
  124917. pinchDeltaPercentage: number;
  124918. /**
  124919. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124920. */
  124921. axisXControlRadius: boolean;
  124922. /**
  124923. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124924. */
  124925. axisXControlHeight: boolean;
  124926. /**
  124927. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124928. */
  124929. axisXControlRotation: boolean;
  124930. /**
  124931. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124932. */
  124933. axisYControlRadius: boolean;
  124934. /**
  124935. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124936. */
  124937. axisYControlHeight: boolean;
  124938. /**
  124939. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124940. */
  124941. axisYControlRotation: boolean;
  124942. /**
  124943. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124944. */
  124945. axisPinchControlRadius: boolean;
  124946. /**
  124947. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124948. */
  124949. axisPinchControlHeight: boolean;
  124950. /**
  124951. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124952. */
  124953. axisPinchControlRotation: boolean;
  124954. /**
  124955. * Log error messages if basic misconfiguration has occurred.
  124956. */
  124957. warningEnable: boolean;
  124958. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124959. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124960. private _warningCounter;
  124961. private _warning;
  124962. }
  124963. }
  124964. declare module BABYLON {
  124965. /**
  124966. * Default Inputs manager for the FollowCamera.
  124967. * It groups all the default supported inputs for ease of use.
  124968. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124969. */
  124970. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124971. /**
  124972. * Instantiates a new FollowCameraInputsManager.
  124973. * @param camera Defines the camera the inputs belong to
  124974. */
  124975. constructor(camera: FollowCamera);
  124976. /**
  124977. * Add keyboard input support to the input manager.
  124978. * @returns the current input manager
  124979. */
  124980. addKeyboard(): FollowCameraInputsManager;
  124981. /**
  124982. * Add mouse wheel input support to the input manager.
  124983. * @returns the current input manager
  124984. */
  124985. addMouseWheel(): FollowCameraInputsManager;
  124986. /**
  124987. * Add pointers input support to the input manager.
  124988. * @returns the current input manager
  124989. */
  124990. addPointers(): FollowCameraInputsManager;
  124991. /**
  124992. * Add orientation input support to the input manager.
  124993. * @returns the current input manager
  124994. */
  124995. addVRDeviceOrientation(): FollowCameraInputsManager;
  124996. }
  124997. }
  124998. declare module BABYLON {
  124999. /**
  125000. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  125001. * an arc rotate version arcFollowCamera are available.
  125002. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125003. */
  125004. export class FollowCamera extends TargetCamera {
  125005. /**
  125006. * Distance the follow camera should follow an object at
  125007. */
  125008. radius: number;
  125009. /**
  125010. * Minimum allowed distance of the camera to the axis of rotation
  125011. * (The camera can not get closer).
  125012. * This can help limiting how the Camera is able to move in the scene.
  125013. */
  125014. lowerRadiusLimit: Nullable<number>;
  125015. /**
  125016. * Maximum allowed distance of the camera to the axis of rotation
  125017. * (The camera can not get further).
  125018. * This can help limiting how the Camera is able to move in the scene.
  125019. */
  125020. upperRadiusLimit: Nullable<number>;
  125021. /**
  125022. * Define a rotation offset between the camera and the object it follows
  125023. */
  125024. rotationOffset: number;
  125025. /**
  125026. * Minimum allowed angle to camera position relative to target object.
  125027. * This can help limiting how the Camera is able to move in the scene.
  125028. */
  125029. lowerRotationOffsetLimit: Nullable<number>;
  125030. /**
  125031. * Maximum allowed angle to camera position relative to target object.
  125032. * This can help limiting how the Camera is able to move in the scene.
  125033. */
  125034. upperRotationOffsetLimit: Nullable<number>;
  125035. /**
  125036. * Define a height offset between the camera and the object it follows.
  125037. * It can help following an object from the top (like a car chaing a plane)
  125038. */
  125039. heightOffset: number;
  125040. /**
  125041. * Minimum allowed height of camera position relative to target object.
  125042. * This can help limiting how the Camera is able to move in the scene.
  125043. */
  125044. lowerHeightOffsetLimit: Nullable<number>;
  125045. /**
  125046. * Maximum allowed height of camera position relative to target object.
  125047. * This can help limiting how the Camera is able to move in the scene.
  125048. */
  125049. upperHeightOffsetLimit: Nullable<number>;
  125050. /**
  125051. * Define how fast the camera can accelerate to follow it s target.
  125052. */
  125053. cameraAcceleration: number;
  125054. /**
  125055. * Define the speed limit of the camera following an object.
  125056. */
  125057. maxCameraSpeed: number;
  125058. /**
  125059. * Define the target of the camera.
  125060. */
  125061. lockedTarget: Nullable<AbstractMesh>;
  125062. /**
  125063. * Defines the input associated with the camera.
  125064. */
  125065. inputs: FollowCameraInputsManager;
  125066. /**
  125067. * Instantiates the follow camera.
  125068. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125069. * @param name Define the name of the camera in the scene
  125070. * @param position Define the position of the camera
  125071. * @param scene Define the scene the camera belong to
  125072. * @param lockedTarget Define the target of the camera
  125073. */
  125074. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125075. private _follow;
  125076. /**
  125077. * Attached controls to the current camera.
  125078. * @param element Defines the element the controls should be listened from
  125079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125080. */
  125081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125082. /**
  125083. * Detach the current controls from the camera.
  125084. * The camera will stop reacting to inputs.
  125085. * @param element Defines the element to stop listening the inputs from
  125086. */
  125087. detachControl(element: HTMLElement): void;
  125088. /** @hidden */
  125089. _checkInputs(): void;
  125090. private _checkLimits;
  125091. /**
  125092. * Gets the camera class name.
  125093. * @returns the class name
  125094. */
  125095. getClassName(): string;
  125096. }
  125097. /**
  125098. * Arc Rotate version of the follow camera.
  125099. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125100. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125101. */
  125102. export class ArcFollowCamera extends TargetCamera {
  125103. /** The longitudinal angle of the camera */
  125104. alpha: number;
  125105. /** The latitudinal angle of the camera */
  125106. beta: number;
  125107. /** The radius of the camera from its target */
  125108. radius: number;
  125109. private _cartesianCoordinates;
  125110. /** Define the camera target (the mesh it should follow) */
  125111. private _meshTarget;
  125112. /**
  125113. * Instantiates a new ArcFollowCamera
  125114. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125115. * @param name Define the name of the camera
  125116. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125117. * @param beta Define the rotation angle of the camera around the elevation axis
  125118. * @param radius Define the radius of the camera from its target point
  125119. * @param target Define the target of the camera
  125120. * @param scene Define the scene the camera belongs to
  125121. */
  125122. constructor(name: string,
  125123. /** The longitudinal angle of the camera */
  125124. alpha: number,
  125125. /** The latitudinal angle of the camera */
  125126. beta: number,
  125127. /** The radius of the camera from its target */
  125128. radius: number,
  125129. /** Define the camera target (the mesh it should follow) */
  125130. target: Nullable<AbstractMesh>, scene: Scene);
  125131. private _follow;
  125132. /** @hidden */
  125133. _checkInputs(): void;
  125134. /**
  125135. * Returns the class name of the object.
  125136. * It is mostly used internally for serialization purposes.
  125137. */
  125138. getClassName(): string;
  125139. }
  125140. }
  125141. declare module BABYLON {
  125142. /**
  125143. * Manage the keyboard inputs to control the movement of a follow camera.
  125144. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125145. */
  125146. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125147. /**
  125148. * Defines the camera the input is attached to.
  125149. */
  125150. camera: FollowCamera;
  125151. /**
  125152. * Defines the list of key codes associated with the up action (increase heightOffset)
  125153. */
  125154. keysHeightOffsetIncr: number[];
  125155. /**
  125156. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125157. */
  125158. keysHeightOffsetDecr: number[];
  125159. /**
  125160. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125161. */
  125162. keysHeightOffsetModifierAlt: boolean;
  125163. /**
  125164. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125165. */
  125166. keysHeightOffsetModifierCtrl: boolean;
  125167. /**
  125168. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125169. */
  125170. keysHeightOffsetModifierShift: boolean;
  125171. /**
  125172. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125173. */
  125174. keysRotationOffsetIncr: number[];
  125175. /**
  125176. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125177. */
  125178. keysRotationOffsetDecr: number[];
  125179. /**
  125180. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125181. */
  125182. keysRotationOffsetModifierAlt: boolean;
  125183. /**
  125184. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125185. */
  125186. keysRotationOffsetModifierCtrl: boolean;
  125187. /**
  125188. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125189. */
  125190. keysRotationOffsetModifierShift: boolean;
  125191. /**
  125192. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125193. */
  125194. keysRadiusIncr: number[];
  125195. /**
  125196. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125197. */
  125198. keysRadiusDecr: number[];
  125199. /**
  125200. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125201. */
  125202. keysRadiusModifierAlt: boolean;
  125203. /**
  125204. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125205. */
  125206. keysRadiusModifierCtrl: boolean;
  125207. /**
  125208. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125209. */
  125210. keysRadiusModifierShift: boolean;
  125211. /**
  125212. * Defines the rate of change of heightOffset.
  125213. */
  125214. heightSensibility: number;
  125215. /**
  125216. * Defines the rate of change of rotationOffset.
  125217. */
  125218. rotationSensibility: number;
  125219. /**
  125220. * Defines the rate of change of radius.
  125221. */
  125222. radiusSensibility: number;
  125223. private _keys;
  125224. private _ctrlPressed;
  125225. private _altPressed;
  125226. private _shiftPressed;
  125227. private _onCanvasBlurObserver;
  125228. private _onKeyboardObserver;
  125229. private _engine;
  125230. private _scene;
  125231. /**
  125232. * Attach the input controls to a specific dom element to get the input from.
  125233. * @param element Defines the element the controls should be listened from
  125234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125235. */
  125236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125237. /**
  125238. * Detach the current controls from the specified dom element.
  125239. * @param element Defines the element to stop listening the inputs from
  125240. */
  125241. detachControl(element: Nullable<HTMLElement>): void;
  125242. /**
  125243. * Update the current camera state depending on the inputs that have been used this frame.
  125244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125245. */
  125246. checkInputs(): void;
  125247. /**
  125248. * Gets the class name of the current input.
  125249. * @returns the class name
  125250. */
  125251. getClassName(): string;
  125252. /**
  125253. * Get the friendly name associated with the input class.
  125254. * @returns the input friendly name
  125255. */
  125256. getSimpleName(): string;
  125257. /**
  125258. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125259. * allow modification of the heightOffset value.
  125260. */
  125261. private _modifierHeightOffset;
  125262. /**
  125263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125264. * allow modification of the rotationOffset value.
  125265. */
  125266. private _modifierRotationOffset;
  125267. /**
  125268. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125269. * allow modification of the radius value.
  125270. */
  125271. private _modifierRadius;
  125272. }
  125273. }
  125274. declare module BABYLON {
  125275. interface FreeCameraInputsManager {
  125276. /**
  125277. * @hidden
  125278. */
  125279. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125280. /**
  125281. * Add orientation input support to the input manager.
  125282. * @returns the current input manager
  125283. */
  125284. addDeviceOrientation(): FreeCameraInputsManager;
  125285. }
  125286. /**
  125287. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125288. * Screen rotation is taken into account.
  125289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125290. */
  125291. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125292. private _camera;
  125293. private _screenOrientationAngle;
  125294. private _constantTranform;
  125295. private _screenQuaternion;
  125296. private _alpha;
  125297. private _beta;
  125298. private _gamma;
  125299. /**
  125300. * Can be used to detect if a device orientation sensor is available on a device
  125301. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125302. * @returns a promise that will resolve on orientation change
  125303. */
  125304. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125305. /**
  125306. * @hidden
  125307. */
  125308. _onDeviceOrientationChangedObservable: Observable<void>;
  125309. /**
  125310. * Instantiates a new input
  125311. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125312. */
  125313. constructor();
  125314. /**
  125315. * Define the camera controlled by the input.
  125316. */
  125317. get camera(): FreeCamera;
  125318. set camera(camera: FreeCamera);
  125319. /**
  125320. * Attach the input controls to a specific dom element to get the input from.
  125321. * @param element Defines the element the controls should be listened from
  125322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125323. */
  125324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125325. private _orientationChanged;
  125326. private _deviceOrientation;
  125327. /**
  125328. * Detach the current controls from the specified dom element.
  125329. * @param element Defines the element to stop listening the inputs from
  125330. */
  125331. detachControl(element: Nullable<HTMLElement>): void;
  125332. /**
  125333. * Update the current camera state depending on the inputs that have been used this frame.
  125334. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125335. */
  125336. checkInputs(): void;
  125337. /**
  125338. * Gets the class name of the current intput.
  125339. * @returns the class name
  125340. */
  125341. getClassName(): string;
  125342. /**
  125343. * Get the friendly name associated with the input class.
  125344. * @returns the input friendly name
  125345. */
  125346. getSimpleName(): string;
  125347. }
  125348. }
  125349. declare module BABYLON {
  125350. /**
  125351. * Manage the gamepad inputs to control a free camera.
  125352. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125353. */
  125354. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125355. /**
  125356. * Define the camera the input is attached to.
  125357. */
  125358. camera: FreeCamera;
  125359. /**
  125360. * Define the Gamepad controlling the input
  125361. */
  125362. gamepad: Nullable<Gamepad>;
  125363. /**
  125364. * Defines the gamepad rotation sensiblity.
  125365. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125366. */
  125367. gamepadAngularSensibility: number;
  125368. /**
  125369. * Defines the gamepad move sensiblity.
  125370. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125371. */
  125372. gamepadMoveSensibility: number;
  125373. private _yAxisScale;
  125374. /**
  125375. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125376. */
  125377. get invertYAxis(): boolean;
  125378. set invertYAxis(value: boolean);
  125379. private _onGamepadConnectedObserver;
  125380. private _onGamepadDisconnectedObserver;
  125381. private _cameraTransform;
  125382. private _deltaTransform;
  125383. private _vector3;
  125384. private _vector2;
  125385. /**
  125386. * Attach the input controls to a specific dom element to get the input from.
  125387. * @param element Defines the element the controls should be listened from
  125388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125389. */
  125390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125391. /**
  125392. * Detach the current controls from the specified dom element.
  125393. * @param element Defines the element to stop listening the inputs from
  125394. */
  125395. detachControl(element: Nullable<HTMLElement>): void;
  125396. /**
  125397. * Update the current camera state depending on the inputs that have been used this frame.
  125398. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125399. */
  125400. checkInputs(): void;
  125401. /**
  125402. * Gets the class name of the current intput.
  125403. * @returns the class name
  125404. */
  125405. getClassName(): string;
  125406. /**
  125407. * Get the friendly name associated with the input class.
  125408. * @returns the input friendly name
  125409. */
  125410. getSimpleName(): string;
  125411. }
  125412. }
  125413. declare module BABYLON {
  125414. /**
  125415. * Defines the potential axis of a Joystick
  125416. */
  125417. export enum JoystickAxis {
  125418. /** X axis */
  125419. X = 0,
  125420. /** Y axis */
  125421. Y = 1,
  125422. /** Z axis */
  125423. Z = 2
  125424. }
  125425. /**
  125426. * Represents the different customization options available
  125427. * for VirtualJoystick
  125428. */
  125429. interface VirtualJoystickCustomizations {
  125430. /**
  125431. * Size of the joystick's puck
  125432. */
  125433. puckSize: number;
  125434. /**
  125435. * Size of the joystick's container
  125436. */
  125437. containerSize: number;
  125438. /**
  125439. * Color of the joystick && puck
  125440. */
  125441. color: string;
  125442. /**
  125443. * Image URL for the joystick's puck
  125444. */
  125445. puckImage?: string;
  125446. /**
  125447. * Image URL for the joystick's container
  125448. */
  125449. containerImage?: string;
  125450. /**
  125451. * Defines the unmoving position of the joystick container
  125452. */
  125453. position?: {
  125454. x: number;
  125455. y: number;
  125456. };
  125457. /**
  125458. * Defines whether or not the joystick container is always visible
  125459. */
  125460. alwaysVisible: boolean;
  125461. /**
  125462. * Defines whether or not to limit the movement of the puck to the joystick's container
  125463. */
  125464. limitToContainer: boolean;
  125465. }
  125466. /**
  125467. * Class used to define virtual joystick (used in touch mode)
  125468. */
  125469. export class VirtualJoystick {
  125470. /**
  125471. * Gets or sets a boolean indicating that left and right values must be inverted
  125472. */
  125473. reverseLeftRight: boolean;
  125474. /**
  125475. * Gets or sets a boolean indicating that up and down values must be inverted
  125476. */
  125477. reverseUpDown: boolean;
  125478. /**
  125479. * Gets the offset value for the position (ie. the change of the position value)
  125480. */
  125481. deltaPosition: Vector3;
  125482. /**
  125483. * Gets a boolean indicating if the virtual joystick was pressed
  125484. */
  125485. pressed: boolean;
  125486. /**
  125487. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125488. */
  125489. static Canvas: Nullable<HTMLCanvasElement>;
  125490. /**
  125491. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125492. */
  125493. limitToContainer: boolean;
  125494. private static _globalJoystickIndex;
  125495. private static _alwaysVisibleSticks;
  125496. private static vjCanvasContext;
  125497. private static vjCanvasWidth;
  125498. private static vjCanvasHeight;
  125499. private static halfWidth;
  125500. private static _GetDefaultOptions;
  125501. private _action;
  125502. private _axisTargetedByLeftAndRight;
  125503. private _axisTargetedByUpAndDown;
  125504. private _joystickSensibility;
  125505. private _inversedSensibility;
  125506. private _joystickPointerID;
  125507. private _joystickColor;
  125508. private _joystickPointerPos;
  125509. private _joystickPreviousPointerPos;
  125510. private _joystickPointerStartPos;
  125511. private _deltaJoystickVector;
  125512. private _leftJoystick;
  125513. private _touches;
  125514. private _joystickPosition;
  125515. private _alwaysVisible;
  125516. private _puckImage;
  125517. private _containerImage;
  125518. private _joystickPuckSize;
  125519. private _joystickContainerSize;
  125520. private _clearPuckSize;
  125521. private _clearContainerSize;
  125522. private _clearPuckSizeOffset;
  125523. private _clearContainerSizeOffset;
  125524. private _onPointerDownHandlerRef;
  125525. private _onPointerMoveHandlerRef;
  125526. private _onPointerUpHandlerRef;
  125527. private _onResize;
  125528. /**
  125529. * Creates a new virtual joystick
  125530. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125531. * @param customizations Defines the options we want to customize the VirtualJoystick
  125532. */
  125533. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125534. /**
  125535. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125536. * @param newJoystickSensibility defines the new sensibility
  125537. */
  125538. setJoystickSensibility(newJoystickSensibility: number): void;
  125539. private _onPointerDown;
  125540. private _onPointerMove;
  125541. private _onPointerUp;
  125542. /**
  125543. * Change the color of the virtual joystick
  125544. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125545. */
  125546. setJoystickColor(newColor: string): void;
  125547. /**
  125548. * Size of the joystick's container
  125549. */
  125550. set containerSize(newSize: number);
  125551. get containerSize(): number;
  125552. /**
  125553. * Size of the joystick's puck
  125554. */
  125555. set puckSize(newSize: number);
  125556. get puckSize(): number;
  125557. /**
  125558. * Clears the set position of the joystick
  125559. */
  125560. clearPosition(): void;
  125561. /**
  125562. * Defines whether or not the joystick container is always visible
  125563. */
  125564. set alwaysVisible(value: boolean);
  125565. get alwaysVisible(): boolean;
  125566. /**
  125567. * Sets the constant position of the Joystick container
  125568. * @param x X axis coordinate
  125569. * @param y Y axis coordinate
  125570. */
  125571. setPosition(x: number, y: number): void;
  125572. /**
  125573. * Defines a callback to call when the joystick is touched
  125574. * @param action defines the callback
  125575. */
  125576. setActionOnTouch(action: () => any): void;
  125577. /**
  125578. * Defines which axis you'd like to control for left & right
  125579. * @param axis defines the axis to use
  125580. */
  125581. setAxisForLeftRight(axis: JoystickAxis): void;
  125582. /**
  125583. * Defines which axis you'd like to control for up & down
  125584. * @param axis defines the axis to use
  125585. */
  125586. setAxisForUpDown(axis: JoystickAxis): void;
  125587. /**
  125588. * Clears the canvas from the previous puck / container draw
  125589. */
  125590. private _clearPreviousDraw;
  125591. /**
  125592. * Loads `urlPath` to be used for the container's image
  125593. * @param urlPath defines the urlPath of an image to use
  125594. */
  125595. setContainerImage(urlPath: string): void;
  125596. /**
  125597. * Loads `urlPath` to be used for the puck's image
  125598. * @param urlPath defines the urlPath of an image to use
  125599. */
  125600. setPuckImage(urlPath: string): void;
  125601. /**
  125602. * Draws the Virtual Joystick's container
  125603. */
  125604. private _drawContainer;
  125605. /**
  125606. * Draws the Virtual Joystick's puck
  125607. */
  125608. private _drawPuck;
  125609. private _drawVirtualJoystick;
  125610. /**
  125611. * Release internal HTML canvas
  125612. */
  125613. releaseCanvas(): void;
  125614. }
  125615. }
  125616. declare module BABYLON {
  125617. interface FreeCameraInputsManager {
  125618. /**
  125619. * Add virtual joystick input support to the input manager.
  125620. * @returns the current input manager
  125621. */
  125622. addVirtualJoystick(): FreeCameraInputsManager;
  125623. }
  125624. /**
  125625. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125626. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125627. */
  125628. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125629. /**
  125630. * Defines the camera the input is attached to.
  125631. */
  125632. camera: FreeCamera;
  125633. private _leftjoystick;
  125634. private _rightjoystick;
  125635. /**
  125636. * Gets the left stick of the virtual joystick.
  125637. * @returns The virtual Joystick
  125638. */
  125639. getLeftJoystick(): VirtualJoystick;
  125640. /**
  125641. * Gets the right stick of the virtual joystick.
  125642. * @returns The virtual Joystick
  125643. */
  125644. getRightJoystick(): VirtualJoystick;
  125645. /**
  125646. * Update the current camera state depending on the inputs that have been used this frame.
  125647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125648. */
  125649. checkInputs(): void;
  125650. /**
  125651. * Attach the input controls to a specific dom element to get the input from.
  125652. * @param element Defines the element the controls should be listened from
  125653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125654. */
  125655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125656. /**
  125657. * Detach the current controls from the specified dom element.
  125658. * @param element Defines the element to stop listening the inputs from
  125659. */
  125660. detachControl(element: Nullable<HTMLElement>): void;
  125661. /**
  125662. * Gets the class name of the current intput.
  125663. * @returns the class name
  125664. */
  125665. getClassName(): string;
  125666. /**
  125667. * Get the friendly name associated with the input class.
  125668. * @returns the input friendly name
  125669. */
  125670. getSimpleName(): string;
  125671. }
  125672. }
  125673. declare module BABYLON {
  125674. /**
  125675. * This represents a FPS type of camera controlled by touch.
  125676. * This is like a universal camera minus the Gamepad controls.
  125677. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125678. */
  125679. export class TouchCamera extends FreeCamera {
  125680. /**
  125681. * Defines the touch sensibility for rotation.
  125682. * The higher the faster.
  125683. */
  125684. get touchAngularSensibility(): number;
  125685. set touchAngularSensibility(value: number);
  125686. /**
  125687. * Defines the touch sensibility for move.
  125688. * The higher the faster.
  125689. */
  125690. get touchMoveSensibility(): number;
  125691. set touchMoveSensibility(value: number);
  125692. /**
  125693. * Instantiates a new touch camera.
  125694. * This represents a FPS type of camera controlled by touch.
  125695. * This is like a universal camera minus the Gamepad controls.
  125696. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125697. * @param name Define the name of the camera in the scene
  125698. * @param position Define the start position of the camera in the scene
  125699. * @param scene Define the scene the camera belongs to
  125700. */
  125701. constructor(name: string, position: Vector3, scene: Scene);
  125702. /**
  125703. * Gets the current object class name.
  125704. * @return the class name
  125705. */
  125706. getClassName(): string;
  125707. /** @hidden */
  125708. _setupInputs(): void;
  125709. }
  125710. }
  125711. declare module BABYLON {
  125712. /**
  125713. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125714. * being tilted forward or back and left or right.
  125715. */
  125716. export class DeviceOrientationCamera extends FreeCamera {
  125717. private _initialQuaternion;
  125718. private _quaternionCache;
  125719. private _tmpDragQuaternion;
  125720. private _disablePointerInputWhenUsingDeviceOrientation;
  125721. /**
  125722. * Creates a new device orientation camera
  125723. * @param name The name of the camera
  125724. * @param position The start position camera
  125725. * @param scene The scene the camera belongs to
  125726. */
  125727. constructor(name: string, position: Vector3, scene: Scene);
  125728. /**
  125729. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125730. */
  125731. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125732. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125733. private _dragFactor;
  125734. /**
  125735. * Enabled turning on the y axis when the orientation sensor is active
  125736. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125737. */
  125738. enableHorizontalDragging(dragFactor?: number): void;
  125739. /**
  125740. * Gets the current instance class name ("DeviceOrientationCamera").
  125741. * This helps avoiding instanceof at run time.
  125742. * @returns the class name
  125743. */
  125744. getClassName(): string;
  125745. /**
  125746. * @hidden
  125747. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125748. */
  125749. _checkInputs(): void;
  125750. /**
  125751. * Reset the camera to its default orientation on the specified axis only.
  125752. * @param axis The axis to reset
  125753. */
  125754. resetToCurrentRotation(axis?: Axis): void;
  125755. }
  125756. }
  125757. declare module BABYLON {
  125758. /**
  125759. * Defines supported buttons for XBox360 compatible gamepads
  125760. */
  125761. export enum Xbox360Button {
  125762. /** A */
  125763. A = 0,
  125764. /** B */
  125765. B = 1,
  125766. /** X */
  125767. X = 2,
  125768. /** Y */
  125769. Y = 3,
  125770. /** Left button */
  125771. LB = 4,
  125772. /** Right button */
  125773. RB = 5,
  125774. /** Back */
  125775. Back = 8,
  125776. /** Start */
  125777. Start = 9,
  125778. /** Left stick */
  125779. LeftStick = 10,
  125780. /** Right stick */
  125781. RightStick = 11
  125782. }
  125783. /** Defines values for XBox360 DPad */
  125784. export enum Xbox360Dpad {
  125785. /** Up */
  125786. Up = 12,
  125787. /** Down */
  125788. Down = 13,
  125789. /** Left */
  125790. Left = 14,
  125791. /** Right */
  125792. Right = 15
  125793. }
  125794. /**
  125795. * Defines a XBox360 gamepad
  125796. */
  125797. export class Xbox360Pad extends Gamepad {
  125798. private _leftTrigger;
  125799. private _rightTrigger;
  125800. private _onlefttriggerchanged;
  125801. private _onrighttriggerchanged;
  125802. private _onbuttondown;
  125803. private _onbuttonup;
  125804. private _ondpaddown;
  125805. private _ondpadup;
  125806. /** Observable raised when a button is pressed */
  125807. onButtonDownObservable: Observable<Xbox360Button>;
  125808. /** Observable raised when a button is released */
  125809. onButtonUpObservable: Observable<Xbox360Button>;
  125810. /** Observable raised when a pad is pressed */
  125811. onPadDownObservable: Observable<Xbox360Dpad>;
  125812. /** Observable raised when a pad is released */
  125813. onPadUpObservable: Observable<Xbox360Dpad>;
  125814. private _buttonA;
  125815. private _buttonB;
  125816. private _buttonX;
  125817. private _buttonY;
  125818. private _buttonBack;
  125819. private _buttonStart;
  125820. private _buttonLB;
  125821. private _buttonRB;
  125822. private _buttonLeftStick;
  125823. private _buttonRightStick;
  125824. private _dPadUp;
  125825. private _dPadDown;
  125826. private _dPadLeft;
  125827. private _dPadRight;
  125828. private _isXboxOnePad;
  125829. /**
  125830. * Creates a new XBox360 gamepad object
  125831. * @param id defines the id of this gamepad
  125832. * @param index defines its index
  125833. * @param gamepad defines the internal HTML gamepad object
  125834. * @param xboxOne defines if it is a XBox One gamepad
  125835. */
  125836. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125837. /**
  125838. * Defines the callback to call when left trigger is pressed
  125839. * @param callback defines the callback to use
  125840. */
  125841. onlefttriggerchanged(callback: (value: number) => void): void;
  125842. /**
  125843. * Defines the callback to call when right trigger is pressed
  125844. * @param callback defines the callback to use
  125845. */
  125846. onrighttriggerchanged(callback: (value: number) => void): void;
  125847. /**
  125848. * Gets the left trigger value
  125849. */
  125850. get leftTrigger(): number;
  125851. /**
  125852. * Sets the left trigger value
  125853. */
  125854. set leftTrigger(newValue: number);
  125855. /**
  125856. * Gets the right trigger value
  125857. */
  125858. get rightTrigger(): number;
  125859. /**
  125860. * Sets the right trigger value
  125861. */
  125862. set rightTrigger(newValue: number);
  125863. /**
  125864. * Defines the callback to call when a button is pressed
  125865. * @param callback defines the callback to use
  125866. */
  125867. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125868. /**
  125869. * Defines the callback to call when a button is released
  125870. * @param callback defines the callback to use
  125871. */
  125872. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125873. /**
  125874. * Defines the callback to call when a pad is pressed
  125875. * @param callback defines the callback to use
  125876. */
  125877. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125878. /**
  125879. * Defines the callback to call when a pad is released
  125880. * @param callback defines the callback to use
  125881. */
  125882. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125883. private _setButtonValue;
  125884. private _setDPadValue;
  125885. /**
  125886. * Gets the value of the `A` button
  125887. */
  125888. get buttonA(): number;
  125889. /**
  125890. * Sets the value of the `A` button
  125891. */
  125892. set buttonA(value: number);
  125893. /**
  125894. * Gets the value of the `B` button
  125895. */
  125896. get buttonB(): number;
  125897. /**
  125898. * Sets the value of the `B` button
  125899. */
  125900. set buttonB(value: number);
  125901. /**
  125902. * Gets the value of the `X` button
  125903. */
  125904. get buttonX(): number;
  125905. /**
  125906. * Sets the value of the `X` button
  125907. */
  125908. set buttonX(value: number);
  125909. /**
  125910. * Gets the value of the `Y` button
  125911. */
  125912. get buttonY(): number;
  125913. /**
  125914. * Sets the value of the `Y` button
  125915. */
  125916. set buttonY(value: number);
  125917. /**
  125918. * Gets the value of the `Start` button
  125919. */
  125920. get buttonStart(): number;
  125921. /**
  125922. * Sets the value of the `Start` button
  125923. */
  125924. set buttonStart(value: number);
  125925. /**
  125926. * Gets the value of the `Back` button
  125927. */
  125928. get buttonBack(): number;
  125929. /**
  125930. * Sets the value of the `Back` button
  125931. */
  125932. set buttonBack(value: number);
  125933. /**
  125934. * Gets the value of the `Left` button
  125935. */
  125936. get buttonLB(): number;
  125937. /**
  125938. * Sets the value of the `Left` button
  125939. */
  125940. set buttonLB(value: number);
  125941. /**
  125942. * Gets the value of the `Right` button
  125943. */
  125944. get buttonRB(): number;
  125945. /**
  125946. * Sets the value of the `Right` button
  125947. */
  125948. set buttonRB(value: number);
  125949. /**
  125950. * Gets the value of the Left joystick
  125951. */
  125952. get buttonLeftStick(): number;
  125953. /**
  125954. * Sets the value of the Left joystick
  125955. */
  125956. set buttonLeftStick(value: number);
  125957. /**
  125958. * Gets the value of the Right joystick
  125959. */
  125960. get buttonRightStick(): number;
  125961. /**
  125962. * Sets the value of the Right joystick
  125963. */
  125964. set buttonRightStick(value: number);
  125965. /**
  125966. * Gets the value of D-pad up
  125967. */
  125968. get dPadUp(): number;
  125969. /**
  125970. * Sets the value of D-pad up
  125971. */
  125972. set dPadUp(value: number);
  125973. /**
  125974. * Gets the value of D-pad down
  125975. */
  125976. get dPadDown(): number;
  125977. /**
  125978. * Sets the value of D-pad down
  125979. */
  125980. set dPadDown(value: number);
  125981. /**
  125982. * Gets the value of D-pad left
  125983. */
  125984. get dPadLeft(): number;
  125985. /**
  125986. * Sets the value of D-pad left
  125987. */
  125988. set dPadLeft(value: number);
  125989. /**
  125990. * Gets the value of D-pad right
  125991. */
  125992. get dPadRight(): number;
  125993. /**
  125994. * Sets the value of D-pad right
  125995. */
  125996. set dPadRight(value: number);
  125997. /**
  125998. * Force the gamepad to synchronize with device values
  125999. */
  126000. update(): void;
  126001. /**
  126002. * Disposes the gamepad
  126003. */
  126004. dispose(): void;
  126005. }
  126006. }
  126007. declare module BABYLON {
  126008. /**
  126009. * Defines supported buttons for DualShock compatible gamepads
  126010. */
  126011. export enum DualShockButton {
  126012. /** Cross */
  126013. Cross = 0,
  126014. /** Circle */
  126015. Circle = 1,
  126016. /** Square */
  126017. Square = 2,
  126018. /** Triangle */
  126019. Triangle = 3,
  126020. /** L1 */
  126021. L1 = 4,
  126022. /** R1 */
  126023. R1 = 5,
  126024. /** Share */
  126025. Share = 8,
  126026. /** Options */
  126027. Options = 9,
  126028. /** Left stick */
  126029. LeftStick = 10,
  126030. /** Right stick */
  126031. RightStick = 11
  126032. }
  126033. /** Defines values for DualShock DPad */
  126034. export enum DualShockDpad {
  126035. /** Up */
  126036. Up = 12,
  126037. /** Down */
  126038. Down = 13,
  126039. /** Left */
  126040. Left = 14,
  126041. /** Right */
  126042. Right = 15
  126043. }
  126044. /**
  126045. * Defines a DualShock gamepad
  126046. */
  126047. export class DualShockPad extends Gamepad {
  126048. private _leftTrigger;
  126049. private _rightTrigger;
  126050. private _onlefttriggerchanged;
  126051. private _onrighttriggerchanged;
  126052. private _onbuttondown;
  126053. private _onbuttonup;
  126054. private _ondpaddown;
  126055. private _ondpadup;
  126056. /** Observable raised when a button is pressed */
  126057. onButtonDownObservable: Observable<DualShockButton>;
  126058. /** Observable raised when a button is released */
  126059. onButtonUpObservable: Observable<DualShockButton>;
  126060. /** Observable raised when a pad is pressed */
  126061. onPadDownObservable: Observable<DualShockDpad>;
  126062. /** Observable raised when a pad is released */
  126063. onPadUpObservable: Observable<DualShockDpad>;
  126064. private _buttonCross;
  126065. private _buttonCircle;
  126066. private _buttonSquare;
  126067. private _buttonTriangle;
  126068. private _buttonShare;
  126069. private _buttonOptions;
  126070. private _buttonL1;
  126071. private _buttonR1;
  126072. private _buttonLeftStick;
  126073. private _buttonRightStick;
  126074. private _dPadUp;
  126075. private _dPadDown;
  126076. private _dPadLeft;
  126077. private _dPadRight;
  126078. /**
  126079. * Creates a new DualShock gamepad object
  126080. * @param id defines the id of this gamepad
  126081. * @param index defines its index
  126082. * @param gamepad defines the internal HTML gamepad object
  126083. */
  126084. constructor(id: string, index: number, gamepad: any);
  126085. /**
  126086. * Defines the callback to call when left trigger is pressed
  126087. * @param callback defines the callback to use
  126088. */
  126089. onlefttriggerchanged(callback: (value: number) => void): void;
  126090. /**
  126091. * Defines the callback to call when right trigger is pressed
  126092. * @param callback defines the callback to use
  126093. */
  126094. onrighttriggerchanged(callback: (value: number) => void): void;
  126095. /**
  126096. * Gets the left trigger value
  126097. */
  126098. get leftTrigger(): number;
  126099. /**
  126100. * Sets the left trigger value
  126101. */
  126102. set leftTrigger(newValue: number);
  126103. /**
  126104. * Gets the right trigger value
  126105. */
  126106. get rightTrigger(): number;
  126107. /**
  126108. * Sets the right trigger value
  126109. */
  126110. set rightTrigger(newValue: number);
  126111. /**
  126112. * Defines the callback to call when a button is pressed
  126113. * @param callback defines the callback to use
  126114. */
  126115. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126116. /**
  126117. * Defines the callback to call when a button is released
  126118. * @param callback defines the callback to use
  126119. */
  126120. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126121. /**
  126122. * Defines the callback to call when a pad is pressed
  126123. * @param callback defines the callback to use
  126124. */
  126125. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126126. /**
  126127. * Defines the callback to call when a pad is released
  126128. * @param callback defines the callback to use
  126129. */
  126130. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126131. private _setButtonValue;
  126132. private _setDPadValue;
  126133. /**
  126134. * Gets the value of the `Cross` button
  126135. */
  126136. get buttonCross(): number;
  126137. /**
  126138. * Sets the value of the `Cross` button
  126139. */
  126140. set buttonCross(value: number);
  126141. /**
  126142. * Gets the value of the `Circle` button
  126143. */
  126144. get buttonCircle(): number;
  126145. /**
  126146. * Sets the value of the `Circle` button
  126147. */
  126148. set buttonCircle(value: number);
  126149. /**
  126150. * Gets the value of the `Square` button
  126151. */
  126152. get buttonSquare(): number;
  126153. /**
  126154. * Sets the value of the `Square` button
  126155. */
  126156. set buttonSquare(value: number);
  126157. /**
  126158. * Gets the value of the `Triangle` button
  126159. */
  126160. get buttonTriangle(): number;
  126161. /**
  126162. * Sets the value of the `Triangle` button
  126163. */
  126164. set buttonTriangle(value: number);
  126165. /**
  126166. * Gets the value of the `Options` button
  126167. */
  126168. get buttonOptions(): number;
  126169. /**
  126170. * Sets the value of the `Options` button
  126171. */
  126172. set buttonOptions(value: number);
  126173. /**
  126174. * Gets the value of the `Share` button
  126175. */
  126176. get buttonShare(): number;
  126177. /**
  126178. * Sets the value of the `Share` button
  126179. */
  126180. set buttonShare(value: number);
  126181. /**
  126182. * Gets the value of the `L1` button
  126183. */
  126184. get buttonL1(): number;
  126185. /**
  126186. * Sets the value of the `L1` button
  126187. */
  126188. set buttonL1(value: number);
  126189. /**
  126190. * Gets the value of the `R1` button
  126191. */
  126192. get buttonR1(): number;
  126193. /**
  126194. * Sets the value of the `R1` button
  126195. */
  126196. set buttonR1(value: number);
  126197. /**
  126198. * Gets the value of the Left joystick
  126199. */
  126200. get buttonLeftStick(): number;
  126201. /**
  126202. * Sets the value of the Left joystick
  126203. */
  126204. set buttonLeftStick(value: number);
  126205. /**
  126206. * Gets the value of the Right joystick
  126207. */
  126208. get buttonRightStick(): number;
  126209. /**
  126210. * Sets the value of the Right joystick
  126211. */
  126212. set buttonRightStick(value: number);
  126213. /**
  126214. * Gets the value of D-pad up
  126215. */
  126216. get dPadUp(): number;
  126217. /**
  126218. * Sets the value of D-pad up
  126219. */
  126220. set dPadUp(value: number);
  126221. /**
  126222. * Gets the value of D-pad down
  126223. */
  126224. get dPadDown(): number;
  126225. /**
  126226. * Sets the value of D-pad down
  126227. */
  126228. set dPadDown(value: number);
  126229. /**
  126230. * Gets the value of D-pad left
  126231. */
  126232. get dPadLeft(): number;
  126233. /**
  126234. * Sets the value of D-pad left
  126235. */
  126236. set dPadLeft(value: number);
  126237. /**
  126238. * Gets the value of D-pad right
  126239. */
  126240. get dPadRight(): number;
  126241. /**
  126242. * Sets the value of D-pad right
  126243. */
  126244. set dPadRight(value: number);
  126245. /**
  126246. * Force the gamepad to synchronize with device values
  126247. */
  126248. update(): void;
  126249. /**
  126250. * Disposes the gamepad
  126251. */
  126252. dispose(): void;
  126253. }
  126254. }
  126255. declare module BABYLON {
  126256. /**
  126257. * Manager for handling gamepads
  126258. */
  126259. export class GamepadManager {
  126260. private _scene?;
  126261. private _babylonGamepads;
  126262. private _oneGamepadConnected;
  126263. /** @hidden */
  126264. _isMonitoring: boolean;
  126265. private _gamepadEventSupported;
  126266. private _gamepadSupport?;
  126267. /**
  126268. * observable to be triggered when the gamepad controller has been connected
  126269. */
  126270. onGamepadConnectedObservable: Observable<Gamepad>;
  126271. /**
  126272. * observable to be triggered when the gamepad controller has been disconnected
  126273. */
  126274. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126275. private _onGamepadConnectedEvent;
  126276. private _onGamepadDisconnectedEvent;
  126277. /**
  126278. * Initializes the gamepad manager
  126279. * @param _scene BabylonJS scene
  126280. */
  126281. constructor(_scene?: Scene | undefined);
  126282. /**
  126283. * The gamepads in the game pad manager
  126284. */
  126285. get gamepads(): Gamepad[];
  126286. /**
  126287. * Get the gamepad controllers based on type
  126288. * @param type The type of gamepad controller
  126289. * @returns Nullable gamepad
  126290. */
  126291. getGamepadByType(type?: number): Nullable<Gamepad>;
  126292. /**
  126293. * Disposes the gamepad manager
  126294. */
  126295. dispose(): void;
  126296. private _addNewGamepad;
  126297. private _startMonitoringGamepads;
  126298. private _stopMonitoringGamepads;
  126299. /** @hidden */
  126300. _checkGamepadsStatus(): void;
  126301. private _updateGamepadObjects;
  126302. }
  126303. }
  126304. declare module BABYLON {
  126305. interface Scene {
  126306. /** @hidden */
  126307. _gamepadManager: Nullable<GamepadManager>;
  126308. /**
  126309. * Gets the gamepad manager associated with the scene
  126310. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126311. */
  126312. gamepadManager: GamepadManager;
  126313. }
  126314. /**
  126315. * Interface representing a free camera inputs manager
  126316. */
  126317. interface FreeCameraInputsManager {
  126318. /**
  126319. * Adds gamepad input support to the FreeCameraInputsManager.
  126320. * @returns the FreeCameraInputsManager
  126321. */
  126322. addGamepad(): FreeCameraInputsManager;
  126323. }
  126324. /**
  126325. * Interface representing an arc rotate camera inputs manager
  126326. */
  126327. interface ArcRotateCameraInputsManager {
  126328. /**
  126329. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126330. * @returns the camera inputs manager
  126331. */
  126332. addGamepad(): ArcRotateCameraInputsManager;
  126333. }
  126334. /**
  126335. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126336. */
  126337. export class GamepadSystemSceneComponent implements ISceneComponent {
  126338. /**
  126339. * The component name helpfull to identify the component in the list of scene components.
  126340. */
  126341. readonly name: string;
  126342. /**
  126343. * The scene the component belongs to.
  126344. */
  126345. scene: Scene;
  126346. /**
  126347. * Creates a new instance of the component for the given scene
  126348. * @param scene Defines the scene to register the component in
  126349. */
  126350. constructor(scene: Scene);
  126351. /**
  126352. * Registers the component in a given scene
  126353. */
  126354. register(): void;
  126355. /**
  126356. * Rebuilds the elements related to this component in case of
  126357. * context lost for instance.
  126358. */
  126359. rebuild(): void;
  126360. /**
  126361. * Disposes the component and the associated ressources
  126362. */
  126363. dispose(): void;
  126364. private _beforeCameraUpdate;
  126365. }
  126366. }
  126367. declare module BABYLON {
  126368. /**
  126369. * 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,
  126370. * which still works and will still be found in many Playgrounds.
  126371. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126372. */
  126373. export class UniversalCamera extends TouchCamera {
  126374. /**
  126375. * Defines the gamepad rotation sensiblity.
  126376. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126377. */
  126378. get gamepadAngularSensibility(): number;
  126379. set gamepadAngularSensibility(value: number);
  126380. /**
  126381. * Defines the gamepad move sensiblity.
  126382. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126383. */
  126384. get gamepadMoveSensibility(): number;
  126385. set gamepadMoveSensibility(value: number);
  126386. /**
  126387. * 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,
  126388. * which still works and will still be found in many Playgrounds.
  126389. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126390. * @param name Define the name of the camera in the scene
  126391. * @param position Define the start position of the camera in the scene
  126392. * @param scene Define the scene the camera belongs to
  126393. */
  126394. constructor(name: string, position: Vector3, scene: Scene);
  126395. /**
  126396. * Gets the current object class name.
  126397. * @return the class name
  126398. */
  126399. getClassName(): string;
  126400. }
  126401. }
  126402. declare module BABYLON {
  126403. /**
  126404. * This represents a FPS type of camera. This is only here for back compat purpose.
  126405. * Please use the UniversalCamera instead as both are identical.
  126406. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126407. */
  126408. export class GamepadCamera extends UniversalCamera {
  126409. /**
  126410. * Instantiates a new Gamepad Camera
  126411. * This represents a FPS type of camera. This is only here for back compat purpose.
  126412. * Please use the UniversalCamera instead as both are identical.
  126413. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126414. * @param name Define the name of the camera in the scene
  126415. * @param position Define the start position of the camera in the scene
  126416. * @param scene Define the scene the camera belongs to
  126417. */
  126418. constructor(name: string, position: Vector3, scene: Scene);
  126419. /**
  126420. * Gets the current object class name.
  126421. * @return the class name
  126422. */
  126423. getClassName(): string;
  126424. }
  126425. }
  126426. declare module BABYLON {
  126427. /** @hidden */
  126428. export var passPixelShader: {
  126429. name: string;
  126430. shader: string;
  126431. };
  126432. }
  126433. declare module BABYLON {
  126434. /** @hidden */
  126435. export var passCubePixelShader: {
  126436. name: string;
  126437. shader: string;
  126438. };
  126439. }
  126440. declare module BABYLON {
  126441. /**
  126442. * PassPostProcess which produces an output the same as it's input
  126443. */
  126444. export class PassPostProcess extends PostProcess {
  126445. /**
  126446. * Gets a string identifying the name of the class
  126447. * @returns "PassPostProcess" string
  126448. */
  126449. getClassName(): string;
  126450. /**
  126451. * Creates the PassPostProcess
  126452. * @param name The name of the effect.
  126453. * @param options The required width/height ratio to downsize to before computing the render pass.
  126454. * @param camera The camera to apply the render pass to.
  126455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126456. * @param engine The engine which the post process will be applied. (default: current engine)
  126457. * @param reusable If the post process can be reused on the same frame. (default: false)
  126458. * @param textureType The type of texture to be used when performing the post processing.
  126459. * @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)
  126460. */
  126461. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126462. /** @hidden */
  126463. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126464. }
  126465. /**
  126466. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126467. */
  126468. export class PassCubePostProcess extends PostProcess {
  126469. private _face;
  126470. /**
  126471. * Gets or sets the cube face to display.
  126472. * * 0 is +X
  126473. * * 1 is -X
  126474. * * 2 is +Y
  126475. * * 3 is -Y
  126476. * * 4 is +Z
  126477. * * 5 is -Z
  126478. */
  126479. get face(): number;
  126480. set face(value: number);
  126481. /**
  126482. * Gets a string identifying the name of the class
  126483. * @returns "PassCubePostProcess" string
  126484. */
  126485. getClassName(): string;
  126486. /**
  126487. * Creates the PassCubePostProcess
  126488. * @param name The name of the effect.
  126489. * @param options The required width/height ratio to downsize to before computing the render pass.
  126490. * @param camera The camera to apply the render pass to.
  126491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126492. * @param engine The engine which the post process will be applied. (default: current engine)
  126493. * @param reusable If the post process can be reused on the same frame. (default: false)
  126494. * @param textureType The type of texture to be used when performing the post processing.
  126495. * @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)
  126496. */
  126497. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126498. /** @hidden */
  126499. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126500. }
  126501. }
  126502. declare module BABYLON {
  126503. /** @hidden */
  126504. export var anaglyphPixelShader: {
  126505. name: string;
  126506. shader: string;
  126507. };
  126508. }
  126509. declare module BABYLON {
  126510. /**
  126511. * Postprocess used to generate anaglyphic rendering
  126512. */
  126513. export class AnaglyphPostProcess extends PostProcess {
  126514. private _passedProcess;
  126515. /**
  126516. * Gets a string identifying the name of the class
  126517. * @returns "AnaglyphPostProcess" string
  126518. */
  126519. getClassName(): string;
  126520. /**
  126521. * Creates a new AnaglyphPostProcess
  126522. * @param name defines postprocess name
  126523. * @param options defines creation options or target ratio scale
  126524. * @param rigCameras defines cameras using this postprocess
  126525. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126526. * @param engine defines hosting engine
  126527. * @param reusable defines if the postprocess will be reused multiple times per frame
  126528. */
  126529. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126530. }
  126531. }
  126532. declare module BABYLON {
  126533. /**
  126534. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126535. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126536. */
  126537. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126538. /**
  126539. * Creates a new AnaglyphArcRotateCamera
  126540. * @param name defines camera name
  126541. * @param alpha defines alpha angle (in radians)
  126542. * @param beta defines beta angle (in radians)
  126543. * @param radius defines radius
  126544. * @param target defines camera target
  126545. * @param interaxialDistance defines distance between each color axis
  126546. * @param scene defines the hosting scene
  126547. */
  126548. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126549. /**
  126550. * Gets camera class name
  126551. * @returns AnaglyphArcRotateCamera
  126552. */
  126553. getClassName(): string;
  126554. }
  126555. }
  126556. declare module BABYLON {
  126557. /**
  126558. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126559. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126560. */
  126561. export class AnaglyphFreeCamera extends FreeCamera {
  126562. /**
  126563. * Creates a new AnaglyphFreeCamera
  126564. * @param name defines camera name
  126565. * @param position defines initial position
  126566. * @param interaxialDistance defines distance between each color axis
  126567. * @param scene defines the hosting scene
  126568. */
  126569. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126570. /**
  126571. * Gets camera class name
  126572. * @returns AnaglyphFreeCamera
  126573. */
  126574. getClassName(): string;
  126575. }
  126576. }
  126577. declare module BABYLON {
  126578. /**
  126579. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126580. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126581. */
  126582. export class AnaglyphGamepadCamera extends GamepadCamera {
  126583. /**
  126584. * Creates a new AnaglyphGamepadCamera
  126585. * @param name defines camera name
  126586. * @param position defines initial position
  126587. * @param interaxialDistance defines distance between each color axis
  126588. * @param scene defines the hosting scene
  126589. */
  126590. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126591. /**
  126592. * Gets camera class name
  126593. * @returns AnaglyphGamepadCamera
  126594. */
  126595. getClassName(): string;
  126596. }
  126597. }
  126598. declare module BABYLON {
  126599. /**
  126600. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126601. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126602. */
  126603. export class AnaglyphUniversalCamera extends UniversalCamera {
  126604. /**
  126605. * Creates a new AnaglyphUniversalCamera
  126606. * @param name defines camera name
  126607. * @param position defines initial position
  126608. * @param interaxialDistance defines distance between each color axis
  126609. * @param scene defines the hosting scene
  126610. */
  126611. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126612. /**
  126613. * Gets camera class name
  126614. * @returns AnaglyphUniversalCamera
  126615. */
  126616. getClassName(): string;
  126617. }
  126618. }
  126619. declare module BABYLON {
  126620. /**
  126621. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126622. * @see https://doc.babylonjs.com/features/cameras
  126623. */
  126624. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126625. /**
  126626. * Creates a new StereoscopicArcRotateCamera
  126627. * @param name defines camera name
  126628. * @param alpha defines alpha angle (in radians)
  126629. * @param beta defines beta angle (in radians)
  126630. * @param radius defines radius
  126631. * @param target defines camera target
  126632. * @param interaxialDistance defines distance between each color axis
  126633. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126634. * @param scene defines the hosting scene
  126635. */
  126636. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126637. /**
  126638. * Gets camera class name
  126639. * @returns StereoscopicArcRotateCamera
  126640. */
  126641. getClassName(): string;
  126642. }
  126643. }
  126644. declare module BABYLON {
  126645. /**
  126646. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126647. * @see https://doc.babylonjs.com/features/cameras
  126648. */
  126649. export class StereoscopicFreeCamera extends FreeCamera {
  126650. /**
  126651. * Creates a new StereoscopicFreeCamera
  126652. * @param name defines camera name
  126653. * @param position defines initial position
  126654. * @param interaxialDistance defines distance between each color axis
  126655. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126656. * @param scene defines the hosting scene
  126657. */
  126658. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126659. /**
  126660. * Gets camera class name
  126661. * @returns StereoscopicFreeCamera
  126662. */
  126663. getClassName(): string;
  126664. }
  126665. }
  126666. declare module BABYLON {
  126667. /**
  126668. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126669. * @see https://doc.babylonjs.com/features/cameras
  126670. */
  126671. export class StereoscopicGamepadCamera extends GamepadCamera {
  126672. /**
  126673. * Creates a new StereoscopicGamepadCamera
  126674. * @param name defines camera name
  126675. * @param position defines initial position
  126676. * @param interaxialDistance defines distance between each color axis
  126677. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126678. * @param scene defines the hosting scene
  126679. */
  126680. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126681. /**
  126682. * Gets camera class name
  126683. * @returns StereoscopicGamepadCamera
  126684. */
  126685. getClassName(): string;
  126686. }
  126687. }
  126688. declare module BABYLON {
  126689. /**
  126690. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126691. * @see https://doc.babylonjs.com/features/cameras
  126692. */
  126693. export class StereoscopicUniversalCamera extends UniversalCamera {
  126694. /**
  126695. * Creates a new StereoscopicUniversalCamera
  126696. * @param name defines camera name
  126697. * @param position defines initial position
  126698. * @param interaxialDistance defines distance between each color axis
  126699. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126700. * @param scene defines the hosting scene
  126701. */
  126702. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126703. /**
  126704. * Gets camera class name
  126705. * @returns StereoscopicUniversalCamera
  126706. */
  126707. getClassName(): string;
  126708. }
  126709. }
  126710. declare module BABYLON {
  126711. /**
  126712. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126713. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126714. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126715. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126716. */
  126717. export class VirtualJoysticksCamera extends FreeCamera {
  126718. /**
  126719. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126720. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126721. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126722. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126723. * @param name Define the name of the camera in the scene
  126724. * @param position Define the start position of the camera in the scene
  126725. * @param scene Define the scene the camera belongs to
  126726. */
  126727. constructor(name: string, position: Vector3, scene: Scene);
  126728. /**
  126729. * Gets the current object class name.
  126730. * @return the class name
  126731. */
  126732. getClassName(): string;
  126733. }
  126734. }
  126735. declare module BABYLON {
  126736. /**
  126737. * This represents all the required metrics to create a VR camera.
  126738. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126739. */
  126740. export class VRCameraMetrics {
  126741. /**
  126742. * Define the horizontal resolution off the screen.
  126743. */
  126744. hResolution: number;
  126745. /**
  126746. * Define the vertical resolution off the screen.
  126747. */
  126748. vResolution: number;
  126749. /**
  126750. * Define the horizontal screen size.
  126751. */
  126752. hScreenSize: number;
  126753. /**
  126754. * Define the vertical screen size.
  126755. */
  126756. vScreenSize: number;
  126757. /**
  126758. * Define the vertical screen center position.
  126759. */
  126760. vScreenCenter: number;
  126761. /**
  126762. * Define the distance of the eyes to the screen.
  126763. */
  126764. eyeToScreenDistance: number;
  126765. /**
  126766. * Define the distance between both lenses
  126767. */
  126768. lensSeparationDistance: number;
  126769. /**
  126770. * Define the distance between both viewer's eyes.
  126771. */
  126772. interpupillaryDistance: number;
  126773. /**
  126774. * Define the distortion factor of the VR postprocess.
  126775. * Please, touch with care.
  126776. */
  126777. distortionK: number[];
  126778. /**
  126779. * Define the chromatic aberration correction factors for the VR post process.
  126780. */
  126781. chromaAbCorrection: number[];
  126782. /**
  126783. * Define the scale factor of the post process.
  126784. * The smaller the better but the slower.
  126785. */
  126786. postProcessScaleFactor: number;
  126787. /**
  126788. * Define an offset for the lens center.
  126789. */
  126790. lensCenterOffset: number;
  126791. /**
  126792. * Define if the current vr camera should compensate the distortion of the lense or not.
  126793. */
  126794. compensateDistortion: boolean;
  126795. /**
  126796. * Defines if multiview should be enabled when rendering (Default: false)
  126797. */
  126798. multiviewEnabled: boolean;
  126799. /**
  126800. * Gets the rendering aspect ratio based on the provided resolutions.
  126801. */
  126802. get aspectRatio(): number;
  126803. /**
  126804. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126805. */
  126806. get aspectRatioFov(): number;
  126807. /**
  126808. * @hidden
  126809. */
  126810. get leftHMatrix(): Matrix;
  126811. /**
  126812. * @hidden
  126813. */
  126814. get rightHMatrix(): Matrix;
  126815. /**
  126816. * @hidden
  126817. */
  126818. get leftPreViewMatrix(): Matrix;
  126819. /**
  126820. * @hidden
  126821. */
  126822. get rightPreViewMatrix(): Matrix;
  126823. /**
  126824. * Get the default VRMetrics based on the most generic setup.
  126825. * @returns the default vr metrics
  126826. */
  126827. static GetDefault(): VRCameraMetrics;
  126828. }
  126829. }
  126830. declare module BABYLON {
  126831. /** @hidden */
  126832. export var vrDistortionCorrectionPixelShader: {
  126833. name: string;
  126834. shader: string;
  126835. };
  126836. }
  126837. declare module BABYLON {
  126838. /**
  126839. * VRDistortionCorrectionPostProcess used for mobile VR
  126840. */
  126841. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126842. private _isRightEye;
  126843. private _distortionFactors;
  126844. private _postProcessScaleFactor;
  126845. private _lensCenterOffset;
  126846. private _scaleIn;
  126847. private _scaleFactor;
  126848. private _lensCenter;
  126849. /**
  126850. * Gets a string identifying the name of the class
  126851. * @returns "VRDistortionCorrectionPostProcess" string
  126852. */
  126853. getClassName(): string;
  126854. /**
  126855. * Initializes the VRDistortionCorrectionPostProcess
  126856. * @param name The name of the effect.
  126857. * @param camera The camera to apply the render pass to.
  126858. * @param isRightEye If this is for the right eye distortion
  126859. * @param vrMetrics All the required metrics for the VR camera
  126860. */
  126861. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126862. }
  126863. }
  126864. declare module BABYLON {
  126865. /**
  126866. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126867. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126868. */
  126869. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126870. /**
  126871. * Creates a new VRDeviceOrientationArcRotateCamera
  126872. * @param name defines camera name
  126873. * @param alpha defines the camera rotation along the logitudinal axis
  126874. * @param beta defines the camera rotation along the latitudinal axis
  126875. * @param radius defines the camera distance from its target
  126876. * @param target defines the camera target
  126877. * @param scene defines the scene the camera belongs to
  126878. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126879. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126880. */
  126881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126882. /**
  126883. * Gets camera class name
  126884. * @returns VRDeviceOrientationArcRotateCamera
  126885. */
  126886. getClassName(): string;
  126887. }
  126888. }
  126889. declare module BABYLON {
  126890. /**
  126891. * Camera used to simulate VR rendering (based on FreeCamera)
  126892. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126893. */
  126894. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126895. /**
  126896. * Creates a new VRDeviceOrientationFreeCamera
  126897. * @param name defines camera name
  126898. * @param position defines the start position of the camera
  126899. * @param scene defines the scene the camera belongs to
  126900. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126901. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126902. */
  126903. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126904. /**
  126905. * Gets camera class name
  126906. * @returns VRDeviceOrientationFreeCamera
  126907. */
  126908. getClassName(): string;
  126909. }
  126910. }
  126911. declare module BABYLON {
  126912. /**
  126913. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126914. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126915. */
  126916. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126917. /**
  126918. * Creates a new VRDeviceOrientationGamepadCamera
  126919. * @param name defines camera name
  126920. * @param position defines the start position of the camera
  126921. * @param scene defines the scene the camera belongs to
  126922. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126923. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126924. */
  126925. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126926. /**
  126927. * Gets camera class name
  126928. * @returns VRDeviceOrientationGamepadCamera
  126929. */
  126930. getClassName(): string;
  126931. }
  126932. }
  126933. declare module BABYLON {
  126934. /**
  126935. * A class extending Texture allowing drawing on a texture
  126936. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126937. */
  126938. export class DynamicTexture extends Texture {
  126939. private _generateMipMaps;
  126940. private _canvas;
  126941. private _context;
  126942. /**
  126943. * Creates a DynamicTexture
  126944. * @param name defines the name of the texture
  126945. * @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
  126946. * @param scene defines the scene where you want the texture
  126947. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126948. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126949. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126950. */
  126951. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126952. /**
  126953. * Get the current class name of the texture useful for serialization or dynamic coding.
  126954. * @returns "DynamicTexture"
  126955. */
  126956. getClassName(): string;
  126957. /**
  126958. * Gets the current state of canRescale
  126959. */
  126960. get canRescale(): boolean;
  126961. private _recreate;
  126962. /**
  126963. * Scales the texture
  126964. * @param ratio the scale factor to apply to both width and height
  126965. */
  126966. scale(ratio: number): void;
  126967. /**
  126968. * Resizes the texture
  126969. * @param width the new width
  126970. * @param height the new height
  126971. */
  126972. scaleTo(width: number, height: number): void;
  126973. /**
  126974. * Gets the context of the canvas used by the texture
  126975. * @returns the canvas context of the dynamic texture
  126976. */
  126977. getContext(): CanvasRenderingContext2D;
  126978. /**
  126979. * Clears the texture
  126980. */
  126981. clear(): void;
  126982. /**
  126983. * Updates the texture
  126984. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126985. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126986. */
  126987. update(invertY?: boolean, premulAlpha?: boolean): void;
  126988. /**
  126989. * Draws text onto the texture
  126990. * @param text defines the text to be drawn
  126991. * @param x defines the placement of the text from the left
  126992. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126993. * @param font defines the font to be used with font-style, font-size, font-name
  126994. * @param color defines the color used for the text
  126995. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126996. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126997. * @param update defines whether texture is immediately update (default is true)
  126998. */
  126999. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  127000. /**
  127001. * Clones the texture
  127002. * @returns the clone of the texture.
  127003. */
  127004. clone(): DynamicTexture;
  127005. /**
  127006. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127007. * @returns a serialized dynamic texture object
  127008. */
  127009. serialize(): any;
  127010. private _IsCanvasElement;
  127011. /** @hidden */
  127012. _rebuild(): void;
  127013. }
  127014. }
  127015. declare module BABYLON {
  127016. /**
  127017. * Class containing static functions to help procedurally build meshes
  127018. */
  127019. export class GroundBuilder {
  127020. /**
  127021. * Creates a ground mesh
  127022. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127023. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127025. * @param name defines the name of the mesh
  127026. * @param options defines the options used to create the mesh
  127027. * @param scene defines the hosting scene
  127028. * @returns the ground mesh
  127029. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127030. */
  127031. static CreateGround(name: string, options: {
  127032. width?: number;
  127033. height?: number;
  127034. subdivisions?: number;
  127035. subdivisionsX?: number;
  127036. subdivisionsY?: number;
  127037. updatable?: boolean;
  127038. }, scene: any): Mesh;
  127039. /**
  127040. * Creates a tiled ground mesh
  127041. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127042. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127043. * * 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
  127044. * * 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
  127045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127046. * @param name defines the name of the mesh
  127047. * @param options defines the options used to create the mesh
  127048. * @param scene defines the hosting scene
  127049. * @returns the tiled ground mesh
  127050. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127051. */
  127052. static CreateTiledGround(name: string, options: {
  127053. xmin: number;
  127054. zmin: number;
  127055. xmax: number;
  127056. zmax: number;
  127057. subdivisions?: {
  127058. w: number;
  127059. h: number;
  127060. };
  127061. precision?: {
  127062. w: number;
  127063. h: number;
  127064. };
  127065. updatable?: boolean;
  127066. }, scene?: Nullable<Scene>): Mesh;
  127067. /**
  127068. * Creates a ground mesh from a height map
  127069. * * The parameter `url` sets the URL of the height map image resource.
  127070. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127071. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127072. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127073. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127074. * * 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.
  127075. * * 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).
  127076. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127078. * @param name defines the name of the mesh
  127079. * @param url defines the url to the height map
  127080. * @param options defines the options used to create the mesh
  127081. * @param scene defines the hosting scene
  127082. * @returns the ground mesh
  127083. * @see https://doc.babylonjs.com/babylon101/height_map
  127084. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127085. */
  127086. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127087. width?: number;
  127088. height?: number;
  127089. subdivisions?: number;
  127090. minHeight?: number;
  127091. maxHeight?: number;
  127092. colorFilter?: Color3;
  127093. alphaFilter?: number;
  127094. updatable?: boolean;
  127095. onReady?: (mesh: GroundMesh) => void;
  127096. }, scene?: Nullable<Scene>): GroundMesh;
  127097. }
  127098. }
  127099. declare module BABYLON {
  127100. /**
  127101. * Class containing static functions to help procedurally build meshes
  127102. */
  127103. export class TorusBuilder {
  127104. /**
  127105. * Creates a torus mesh
  127106. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127107. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127108. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127112. * @param name defines the name of the mesh
  127113. * @param options defines the options used to create the mesh
  127114. * @param scene defines the hosting scene
  127115. * @returns the torus mesh
  127116. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127117. */
  127118. static CreateTorus(name: string, options: {
  127119. diameter?: number;
  127120. thickness?: number;
  127121. tessellation?: number;
  127122. updatable?: boolean;
  127123. sideOrientation?: number;
  127124. frontUVs?: Vector4;
  127125. backUVs?: Vector4;
  127126. }, scene: any): Mesh;
  127127. }
  127128. }
  127129. declare module BABYLON {
  127130. /**
  127131. * Class containing static functions to help procedurally build meshes
  127132. */
  127133. export class CylinderBuilder {
  127134. /**
  127135. * Creates a cylinder or a cone mesh
  127136. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127137. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127138. * * 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.
  127139. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127140. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127141. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127142. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127143. * * 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).
  127144. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127145. * * 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).
  127146. * * 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
  127147. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127148. * * 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
  127149. * * 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.
  127150. * * If `enclose` is false, a ring surface is one element.
  127151. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127152. * * 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
  127153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127156. * @param name defines the name of the mesh
  127157. * @param options defines the options used to create the mesh
  127158. * @param scene defines the hosting scene
  127159. * @returns the cylinder mesh
  127160. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127161. */
  127162. static CreateCylinder(name: string, options: {
  127163. height?: number;
  127164. diameterTop?: number;
  127165. diameterBottom?: number;
  127166. diameter?: number;
  127167. tessellation?: number;
  127168. subdivisions?: number;
  127169. arc?: number;
  127170. faceColors?: Color4[];
  127171. faceUV?: Vector4[];
  127172. updatable?: boolean;
  127173. hasRings?: boolean;
  127174. enclose?: boolean;
  127175. cap?: number;
  127176. sideOrientation?: number;
  127177. frontUVs?: Vector4;
  127178. backUVs?: Vector4;
  127179. }, scene: any): Mesh;
  127180. }
  127181. }
  127182. declare module BABYLON {
  127183. /**
  127184. * States of the webXR experience
  127185. */
  127186. export enum WebXRState {
  127187. /**
  127188. * Transitioning to being in XR mode
  127189. */
  127190. ENTERING_XR = 0,
  127191. /**
  127192. * Transitioning to non XR mode
  127193. */
  127194. EXITING_XR = 1,
  127195. /**
  127196. * In XR mode and presenting
  127197. */
  127198. IN_XR = 2,
  127199. /**
  127200. * Not entered XR mode
  127201. */
  127202. NOT_IN_XR = 3
  127203. }
  127204. /**
  127205. * Abstraction of the XR render target
  127206. */
  127207. export interface WebXRRenderTarget extends IDisposable {
  127208. /**
  127209. * xrpresent context of the canvas which can be used to display/mirror xr content
  127210. */
  127211. canvasContext: WebGLRenderingContext;
  127212. /**
  127213. * xr layer for the canvas
  127214. */
  127215. xrLayer: Nullable<XRWebGLLayer>;
  127216. /**
  127217. * Initializes the xr layer for the session
  127218. * @param xrSession xr session
  127219. * @returns a promise that will resolve once the XR Layer has been created
  127220. */
  127221. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127222. }
  127223. }
  127224. declare module BABYLON {
  127225. /**
  127226. * COnfiguration object for WebXR output canvas
  127227. */
  127228. export class WebXRManagedOutputCanvasOptions {
  127229. /**
  127230. * An optional canvas in case you wish to create it yourself and provide it here.
  127231. * If not provided, a new canvas will be created
  127232. */
  127233. canvasElement?: HTMLCanvasElement;
  127234. /**
  127235. * Options for this XR Layer output
  127236. */
  127237. canvasOptions?: XRWebGLLayerOptions;
  127238. /**
  127239. * CSS styling for a newly created canvas (if not provided)
  127240. */
  127241. newCanvasCssStyle?: string;
  127242. /**
  127243. * Get the default values of the configuration object
  127244. * @param engine defines the engine to use (can be null)
  127245. * @returns default values of this configuration object
  127246. */
  127247. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127248. }
  127249. /**
  127250. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127251. */
  127252. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127253. private _options;
  127254. private _canvas;
  127255. private _engine;
  127256. private _originalCanvasSize;
  127257. /**
  127258. * Rendering context of the canvas which can be used to display/mirror xr content
  127259. */
  127260. canvasContext: WebGLRenderingContext;
  127261. /**
  127262. * xr layer for the canvas
  127263. */
  127264. xrLayer: Nullable<XRWebGLLayer>;
  127265. /**
  127266. * Obseervers registered here will be triggered when the xr layer was initialized
  127267. */
  127268. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127269. /**
  127270. * Initializes the canvas to be added/removed upon entering/exiting xr
  127271. * @param _xrSessionManager The XR Session manager
  127272. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127273. */
  127274. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127275. /**
  127276. * Disposes of the object
  127277. */
  127278. dispose(): void;
  127279. /**
  127280. * Initializes the xr layer for the session
  127281. * @param xrSession xr session
  127282. * @returns a promise that will resolve once the XR Layer has been created
  127283. */
  127284. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127285. private _addCanvas;
  127286. private _removeCanvas;
  127287. private _setCanvasSize;
  127288. private _setManagedOutputCanvas;
  127289. }
  127290. }
  127291. declare module BABYLON {
  127292. /**
  127293. * Manages an XRSession to work with Babylon's engine
  127294. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127295. */
  127296. export class WebXRSessionManager implements IDisposable {
  127297. /** The scene which the session should be created for */
  127298. scene: Scene;
  127299. private _referenceSpace;
  127300. private _rttProvider;
  127301. private _sessionEnded;
  127302. private _xrNavigator;
  127303. private baseLayer;
  127304. /**
  127305. * The base reference space from which the session started. good if you want to reset your
  127306. * reference space
  127307. */
  127308. baseReferenceSpace: XRReferenceSpace;
  127309. /**
  127310. * Current XR frame
  127311. */
  127312. currentFrame: Nullable<XRFrame>;
  127313. /** WebXR timestamp updated every frame */
  127314. currentTimestamp: number;
  127315. /**
  127316. * Used just in case of a failure to initialize an immersive session.
  127317. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127318. */
  127319. defaultHeightCompensation: number;
  127320. /**
  127321. * Fires every time a new xrFrame arrives which can be used to update the camera
  127322. */
  127323. onXRFrameObservable: Observable<XRFrame>;
  127324. /**
  127325. * Fires when the reference space changed
  127326. */
  127327. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127328. /**
  127329. * Fires when the xr session is ended either by the device or manually done
  127330. */
  127331. onXRSessionEnded: Observable<any>;
  127332. /**
  127333. * Fires when the xr session is ended either by the device or manually done
  127334. */
  127335. onXRSessionInit: Observable<XRSession>;
  127336. /**
  127337. * Underlying xr session
  127338. */
  127339. session: XRSession;
  127340. /**
  127341. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127342. * or get the offset the player is currently at.
  127343. */
  127344. viewerReferenceSpace: XRReferenceSpace;
  127345. /**
  127346. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127347. * @param scene The scene which the session should be created for
  127348. */
  127349. constructor(
  127350. /** The scene which the session should be created for */
  127351. scene: Scene);
  127352. /**
  127353. * The current reference space used in this session. This reference space can constantly change!
  127354. * It is mainly used to offset the camera's position.
  127355. */
  127356. get referenceSpace(): XRReferenceSpace;
  127357. /**
  127358. * Set a new reference space and triggers the observable
  127359. */
  127360. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127361. /**
  127362. * Disposes of the session manager
  127363. */
  127364. dispose(): void;
  127365. /**
  127366. * Stops the xrSession and restores the render loop
  127367. * @returns Promise which resolves after it exits XR
  127368. */
  127369. exitXRAsync(): Promise<void>;
  127370. /**
  127371. * Gets the correct render target texture to be rendered this frame for this eye
  127372. * @param eye the eye for which to get the render target
  127373. * @returns the render target for the specified eye
  127374. */
  127375. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127376. /**
  127377. * Creates a WebXRRenderTarget object for the XR session
  127378. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127379. * @param options optional options to provide when creating a new render target
  127380. * @returns a WebXR render target to which the session can render
  127381. */
  127382. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127383. /**
  127384. * Initializes the manager
  127385. * After initialization enterXR can be called to start an XR session
  127386. * @returns Promise which resolves after it is initialized
  127387. */
  127388. initializeAsync(): Promise<void>;
  127389. /**
  127390. * Initializes an xr session
  127391. * @param xrSessionMode mode to initialize
  127392. * @param xrSessionInit defines optional and required values to pass to the session builder
  127393. * @returns a promise which will resolve once the session has been initialized
  127394. */
  127395. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127396. /**
  127397. * Checks if a session would be supported for the creation options specified
  127398. * @param sessionMode session mode to check if supported eg. immersive-vr
  127399. * @returns A Promise that resolves to true if supported and false if not
  127400. */
  127401. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127402. /**
  127403. * Resets the reference space to the one started the session
  127404. */
  127405. resetReferenceSpace(): void;
  127406. /**
  127407. * Starts rendering to the xr layer
  127408. */
  127409. runXRRenderLoop(): void;
  127410. /**
  127411. * Sets the reference space on the xr session
  127412. * @param referenceSpaceType space to set
  127413. * @returns a promise that will resolve once the reference space has been set
  127414. */
  127415. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127416. /**
  127417. * Updates the render state of the session
  127418. * @param state state to set
  127419. * @returns a promise that resolves once the render state has been updated
  127420. */
  127421. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127422. /**
  127423. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127424. * @param sessionMode defines the session to test
  127425. * @returns a promise with boolean as final value
  127426. */
  127427. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127428. private _createRenderTargetTexture;
  127429. }
  127430. }
  127431. declare module BABYLON {
  127432. /**
  127433. * WebXR Camera which holds the views for the xrSession
  127434. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127435. */
  127436. export class WebXRCamera extends FreeCamera {
  127437. private _xrSessionManager;
  127438. private _firstFrame;
  127439. private _referenceQuaternion;
  127440. private _referencedPosition;
  127441. private _xrInvPositionCache;
  127442. private _xrInvQuaternionCache;
  127443. /**
  127444. * Observable raised before camera teleportation
  127445. */
  127446. onBeforeCameraTeleport: Observable<Vector3>;
  127447. /**
  127448. * Observable raised after camera teleportation
  127449. */
  127450. onAfterCameraTeleport: Observable<Vector3>;
  127451. /**
  127452. * Should position compensation execute on first frame.
  127453. * This is used when copying the position from a native (non XR) camera
  127454. */
  127455. compensateOnFirstFrame: boolean;
  127456. /**
  127457. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127458. * @param name the name of the camera
  127459. * @param scene the scene to add the camera to
  127460. * @param _xrSessionManager a constructed xr session manager
  127461. */
  127462. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127463. /**
  127464. * Return the user's height, unrelated to the current ground.
  127465. * This will be the y position of this camera, when ground level is 0.
  127466. */
  127467. get realWorldHeight(): number;
  127468. /** @hidden */
  127469. _updateForDualEyeDebugging(): void;
  127470. /**
  127471. * Sets this camera's transformation based on a non-vr camera
  127472. * @param otherCamera the non-vr camera to copy the transformation from
  127473. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127474. */
  127475. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127476. /**
  127477. * Gets the current instance class name ("WebXRCamera").
  127478. * @returns the class name
  127479. */
  127480. getClassName(): string;
  127481. private _rotate180;
  127482. private _updateFromXRSession;
  127483. private _updateNumberOfRigCameras;
  127484. private _updateReferenceSpace;
  127485. private _updateReferenceSpaceOffset;
  127486. }
  127487. }
  127488. declare module BABYLON {
  127489. /**
  127490. * Defining the interface required for a (webxr) feature
  127491. */
  127492. export interface IWebXRFeature extends IDisposable {
  127493. /**
  127494. * Is this feature attached
  127495. */
  127496. attached: boolean;
  127497. /**
  127498. * Should auto-attach be disabled?
  127499. */
  127500. disableAutoAttach: boolean;
  127501. /**
  127502. * Attach the feature to the session
  127503. * Will usually be called by the features manager
  127504. *
  127505. * @param force should attachment be forced (even when already attached)
  127506. * @returns true if successful.
  127507. */
  127508. attach(force?: boolean): boolean;
  127509. /**
  127510. * Detach the feature from the session
  127511. * Will usually be called by the features manager
  127512. *
  127513. * @returns true if successful.
  127514. */
  127515. detach(): boolean;
  127516. /**
  127517. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127518. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127519. *
  127520. * @returns whether or not the feature is compatible in this environment
  127521. */
  127522. isCompatible(): boolean;
  127523. /**
  127524. * Was this feature disposed;
  127525. */
  127526. isDisposed: boolean;
  127527. /**
  127528. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127529. */
  127530. xrNativeFeatureName?: string;
  127531. /**
  127532. * A list of (Babylon WebXR) features this feature depends on
  127533. */
  127534. dependsOn?: string[];
  127535. }
  127536. /**
  127537. * A list of the currently available features without referencing them
  127538. */
  127539. export class WebXRFeatureName {
  127540. /**
  127541. * The name of the anchor system feature
  127542. */
  127543. static readonly ANCHOR_SYSTEM: string;
  127544. /**
  127545. * The name of the background remover feature
  127546. */
  127547. static readonly BACKGROUND_REMOVER: string;
  127548. /**
  127549. * The name of the hit test feature
  127550. */
  127551. static readonly HIT_TEST: string;
  127552. /**
  127553. * physics impostors for xr controllers feature
  127554. */
  127555. static readonly PHYSICS_CONTROLLERS: string;
  127556. /**
  127557. * The name of the plane detection feature
  127558. */
  127559. static readonly PLANE_DETECTION: string;
  127560. /**
  127561. * The name of the pointer selection feature
  127562. */
  127563. static readonly POINTER_SELECTION: string;
  127564. /**
  127565. * The name of the teleportation feature
  127566. */
  127567. static readonly TELEPORTATION: string;
  127568. /**
  127569. * The name of the feature points feature.
  127570. */
  127571. static readonly FEATURE_POINTS: string;
  127572. /**
  127573. * The name of the hand tracking feature.
  127574. */
  127575. static readonly HAND_TRACKING: string;
  127576. }
  127577. /**
  127578. * Defining the constructor of a feature. Used to register the modules.
  127579. */
  127580. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127581. /**
  127582. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127583. * It is mainly used in AR sessions.
  127584. *
  127585. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127586. */
  127587. export class WebXRFeaturesManager implements IDisposable {
  127588. private _xrSessionManager;
  127589. private static readonly _AvailableFeatures;
  127590. private _features;
  127591. /**
  127592. * constructs a new features manages.
  127593. *
  127594. * @param _xrSessionManager an instance of WebXRSessionManager
  127595. */
  127596. constructor(_xrSessionManager: WebXRSessionManager);
  127597. /**
  127598. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127599. * Mainly used internally.
  127600. *
  127601. * @param featureName the name of the feature to register
  127602. * @param constructorFunction the function used to construct the module
  127603. * @param version the (babylon) version of the module
  127604. * @param stable is that a stable version of this module
  127605. */
  127606. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127607. /**
  127608. * Returns a constructor of a specific feature.
  127609. *
  127610. * @param featureName the name of the feature to construct
  127611. * @param version the version of the feature to load
  127612. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127613. * @param options optional options provided to the module.
  127614. * @returns a function that, when called, will return a new instance of this feature
  127615. */
  127616. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127617. /**
  127618. * Can be used to return the list of features currently registered
  127619. *
  127620. * @returns an Array of available features
  127621. */
  127622. static GetAvailableFeatures(): string[];
  127623. /**
  127624. * Gets the versions available for a specific feature
  127625. * @param featureName the name of the feature
  127626. * @returns an array with the available versions
  127627. */
  127628. static GetAvailableVersions(featureName: string): string[];
  127629. /**
  127630. * Return the latest unstable version of this feature
  127631. * @param featureName the name of the feature to search
  127632. * @returns the version number. if not found will return -1
  127633. */
  127634. static GetLatestVersionOfFeature(featureName: string): number;
  127635. /**
  127636. * Return the latest stable version of this feature
  127637. * @param featureName the name of the feature to search
  127638. * @returns the version number. if not found will return -1
  127639. */
  127640. static GetStableVersionOfFeature(featureName: string): number;
  127641. /**
  127642. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127643. * Can be used during a session to start a feature
  127644. * @param featureName the name of feature to attach
  127645. */
  127646. attachFeature(featureName: string): void;
  127647. /**
  127648. * Can be used inside a session or when the session ends to detach a specific feature
  127649. * @param featureName the name of the feature to detach
  127650. */
  127651. detachFeature(featureName: string): void;
  127652. /**
  127653. * Used to disable an already-enabled feature
  127654. * The feature will be disposed and will be recreated once enabled.
  127655. * @param featureName the feature to disable
  127656. * @returns true if disable was successful
  127657. */
  127658. disableFeature(featureName: string | {
  127659. Name: string;
  127660. }): boolean;
  127661. /**
  127662. * dispose this features manager
  127663. */
  127664. dispose(): void;
  127665. /**
  127666. * 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.
  127667. * 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.
  127668. *
  127669. * @param featureName the name of the feature to load or the class of the feature
  127670. * @param version optional version to load. if not provided the latest version will be enabled
  127671. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127672. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127673. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127674. * @returns a new constructed feature or throws an error if feature not found.
  127675. */
  127676. enableFeature(featureName: string | {
  127677. Name: string;
  127678. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127679. /**
  127680. * get the implementation of an enabled feature.
  127681. * @param featureName the name of the feature to load
  127682. * @returns the feature class, if found
  127683. */
  127684. getEnabledFeature(featureName: string): IWebXRFeature;
  127685. /**
  127686. * Get the list of enabled features
  127687. * @returns an array of enabled features
  127688. */
  127689. getEnabledFeatures(): string[];
  127690. /**
  127691. * This function will exten the session creation configuration object with enabled features.
  127692. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127693. * according to the defined "required" variable, provided during enableFeature call
  127694. * @param xrSessionInit the xr Session init object to extend
  127695. *
  127696. * @returns an extended XRSessionInit object
  127697. */
  127698. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127699. }
  127700. }
  127701. declare module BABYLON {
  127702. /**
  127703. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127704. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127705. */
  127706. export class WebXRExperienceHelper implements IDisposable {
  127707. private scene;
  127708. private _nonVRCamera;
  127709. private _originalSceneAutoClear;
  127710. private _supported;
  127711. /**
  127712. * Camera used to render xr content
  127713. */
  127714. camera: WebXRCamera;
  127715. /** A features manager for this xr session */
  127716. featuresManager: WebXRFeaturesManager;
  127717. /**
  127718. * Observers registered here will be triggered after the camera's initial transformation is set
  127719. * This can be used to set a different ground level or an extra rotation.
  127720. *
  127721. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127722. * to the position set after this observable is done executing.
  127723. */
  127724. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127725. /**
  127726. * Fires when the state of the experience helper has changed
  127727. */
  127728. onStateChangedObservable: Observable<WebXRState>;
  127729. /** Session manager used to keep track of xr session */
  127730. sessionManager: WebXRSessionManager;
  127731. /**
  127732. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127733. */
  127734. state: WebXRState;
  127735. /**
  127736. * Creates a WebXRExperienceHelper
  127737. * @param scene The scene the helper should be created in
  127738. */
  127739. private constructor();
  127740. /**
  127741. * Creates the experience helper
  127742. * @param scene the scene to attach the experience helper to
  127743. * @returns a promise for the experience helper
  127744. */
  127745. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127746. /**
  127747. * Disposes of the experience helper
  127748. */
  127749. dispose(): void;
  127750. /**
  127751. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127752. * @param sessionMode options for the XR session
  127753. * @param referenceSpaceType frame of reference of the XR session
  127754. * @param renderTarget the output canvas that will be used to enter XR mode
  127755. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127756. * @returns promise that resolves after xr mode has entered
  127757. */
  127758. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127759. /**
  127760. * Exits XR mode and returns the scene to its original state
  127761. * @returns promise that resolves after xr mode has exited
  127762. */
  127763. exitXRAsync(): Promise<void>;
  127764. private _nonXRToXRCamera;
  127765. private _setState;
  127766. }
  127767. }
  127768. declare module BABYLON {
  127769. /**
  127770. * X-Y values for axes in WebXR
  127771. */
  127772. export interface IWebXRMotionControllerAxesValue {
  127773. /**
  127774. * The value of the x axis
  127775. */
  127776. x: number;
  127777. /**
  127778. * The value of the y-axis
  127779. */
  127780. y: number;
  127781. }
  127782. /**
  127783. * changed / previous values for the values of this component
  127784. */
  127785. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127786. /**
  127787. * current (this frame) value
  127788. */
  127789. current: T;
  127790. /**
  127791. * previous (last change) value
  127792. */
  127793. previous: T;
  127794. }
  127795. /**
  127796. * Represents changes in the component between current frame and last values recorded
  127797. */
  127798. export interface IWebXRMotionControllerComponentChanges {
  127799. /**
  127800. * will be populated with previous and current values if axes changed
  127801. */
  127802. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127803. /**
  127804. * will be populated with previous and current values if pressed changed
  127805. */
  127806. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127807. /**
  127808. * will be populated with previous and current values if touched changed
  127809. */
  127810. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127811. /**
  127812. * will be populated with previous and current values if value changed
  127813. */
  127814. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127815. }
  127816. /**
  127817. * This class represents a single component (for example button or thumbstick) of a motion controller
  127818. */
  127819. export class WebXRControllerComponent implements IDisposable {
  127820. /**
  127821. * the id of this component
  127822. */
  127823. id: string;
  127824. /**
  127825. * the type of the component
  127826. */
  127827. type: MotionControllerComponentType;
  127828. private _buttonIndex;
  127829. private _axesIndices;
  127830. private _axes;
  127831. private _changes;
  127832. private _currentValue;
  127833. private _hasChanges;
  127834. private _pressed;
  127835. private _touched;
  127836. /**
  127837. * button component type
  127838. */
  127839. static BUTTON_TYPE: MotionControllerComponentType;
  127840. /**
  127841. * squeeze component type
  127842. */
  127843. static SQUEEZE_TYPE: MotionControllerComponentType;
  127844. /**
  127845. * Thumbstick component type
  127846. */
  127847. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127848. /**
  127849. * Touchpad component type
  127850. */
  127851. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127852. /**
  127853. * trigger component type
  127854. */
  127855. static TRIGGER_TYPE: MotionControllerComponentType;
  127856. /**
  127857. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127858. * the axes data changes
  127859. */
  127860. onAxisValueChangedObservable: Observable<{
  127861. x: number;
  127862. y: number;
  127863. }>;
  127864. /**
  127865. * Observers registered here will be triggered when the state of a button changes
  127866. * State change is either pressed / touched / value
  127867. */
  127868. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127869. /**
  127870. * Creates a new component for a motion controller.
  127871. * It is created by the motion controller itself
  127872. *
  127873. * @param id the id of this component
  127874. * @param type the type of the component
  127875. * @param _buttonIndex index in the buttons array of the gamepad
  127876. * @param _axesIndices indices of the values in the axes array of the gamepad
  127877. */
  127878. constructor(
  127879. /**
  127880. * the id of this component
  127881. */
  127882. id: string,
  127883. /**
  127884. * the type of the component
  127885. */
  127886. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127887. /**
  127888. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127889. */
  127890. get axes(): IWebXRMotionControllerAxesValue;
  127891. /**
  127892. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127893. */
  127894. get changes(): IWebXRMotionControllerComponentChanges;
  127895. /**
  127896. * Return whether or not the component changed the last frame
  127897. */
  127898. get hasChanges(): boolean;
  127899. /**
  127900. * is the button currently pressed
  127901. */
  127902. get pressed(): boolean;
  127903. /**
  127904. * is the button currently touched
  127905. */
  127906. get touched(): boolean;
  127907. /**
  127908. * Get the current value of this component
  127909. */
  127910. get value(): number;
  127911. /**
  127912. * Dispose this component
  127913. */
  127914. dispose(): void;
  127915. /**
  127916. * Are there axes correlating to this component
  127917. * @return true is axes data is available
  127918. */
  127919. isAxes(): boolean;
  127920. /**
  127921. * Is this component a button (hence - pressable)
  127922. * @returns true if can be pressed
  127923. */
  127924. isButton(): boolean;
  127925. /**
  127926. * update this component using the gamepad object it is in. Called on every frame
  127927. * @param nativeController the native gamepad controller object
  127928. */
  127929. update(nativeController: IMinimalMotionControllerObject): void;
  127930. }
  127931. }
  127932. declare module BABYLON {
  127933. /**
  127934. * Interface used to represent data loading progression
  127935. */
  127936. export interface ISceneLoaderProgressEvent {
  127937. /**
  127938. * Defines if data length to load can be evaluated
  127939. */
  127940. readonly lengthComputable: boolean;
  127941. /**
  127942. * Defines the loaded data length
  127943. */
  127944. readonly loaded: number;
  127945. /**
  127946. * Defines the data length to load
  127947. */
  127948. readonly total: number;
  127949. }
  127950. /**
  127951. * Interface used by SceneLoader plugins to define supported file extensions
  127952. */
  127953. export interface ISceneLoaderPluginExtensions {
  127954. /**
  127955. * Defines the list of supported extensions
  127956. */
  127957. [extension: string]: {
  127958. isBinary: boolean;
  127959. };
  127960. }
  127961. /**
  127962. * Interface used by SceneLoader plugin factory
  127963. */
  127964. export interface ISceneLoaderPluginFactory {
  127965. /**
  127966. * Defines the name of the factory
  127967. */
  127968. name: string;
  127969. /**
  127970. * Function called to create a new plugin
  127971. * @return the new plugin
  127972. */
  127973. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127974. /**
  127975. * The callback that returns true if the data can be directly loaded.
  127976. * @param data string containing the file data
  127977. * @returns if the data can be loaded directly
  127978. */
  127979. canDirectLoad?(data: string): boolean;
  127980. }
  127981. /**
  127982. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127983. */
  127984. export interface ISceneLoaderPluginBase {
  127985. /**
  127986. * The friendly name of this plugin.
  127987. */
  127988. name: string;
  127989. /**
  127990. * The file extensions supported by this plugin.
  127991. */
  127992. extensions: string | ISceneLoaderPluginExtensions;
  127993. /**
  127994. * The callback called when loading from a url.
  127995. * @param scene scene loading this url
  127996. * @param url url to load
  127997. * @param onSuccess callback called when the file successfully loads
  127998. * @param onProgress callback called while file is loading (if the server supports this mode)
  127999. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128000. * @param onError callback called when the file fails to load
  128001. * @returns a file request object
  128002. */
  128003. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128004. /**
  128005. * The callback called when loading from a file object.
  128006. * @param scene scene loading this file
  128007. * @param file defines the file to load
  128008. * @param onSuccess defines the callback to call when data is loaded
  128009. * @param onProgress defines the callback to call during loading process
  128010. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128011. * @param onError defines the callback to call when an error occurs
  128012. * @returns a file request object
  128013. */
  128014. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128015. /**
  128016. * The callback that returns true if the data can be directly loaded.
  128017. * @param data string containing the file data
  128018. * @returns if the data can be loaded directly
  128019. */
  128020. canDirectLoad?(data: string): boolean;
  128021. /**
  128022. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128023. * @param scene scene loading this data
  128024. * @param data string containing the data
  128025. * @returns data to pass to the plugin
  128026. */
  128027. directLoad?(scene: Scene, data: string): any;
  128028. /**
  128029. * The callback that allows custom handling of the root url based on the response url.
  128030. * @param rootUrl the original root url
  128031. * @param responseURL the response url if available
  128032. * @returns the new root url
  128033. */
  128034. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128035. }
  128036. /**
  128037. * Interface used to define a SceneLoader plugin
  128038. */
  128039. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128040. /**
  128041. * Import meshes into a scene.
  128042. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128043. * @param scene The scene to import into
  128044. * @param data The data to import
  128045. * @param rootUrl The root url for scene and resources
  128046. * @param meshes The meshes array to import into
  128047. * @param particleSystems The particle systems array to import into
  128048. * @param skeletons The skeletons array to import into
  128049. * @param onError The callback when import fails
  128050. * @returns True if successful or false otherwise
  128051. */
  128052. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128053. /**
  128054. * Load into a scene.
  128055. * @param scene The scene to load into
  128056. * @param data The data to import
  128057. * @param rootUrl The root url for scene and resources
  128058. * @param onError The callback when import fails
  128059. * @returns True if successful or false otherwise
  128060. */
  128061. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128062. /**
  128063. * Load into an asset container.
  128064. * @param scene The scene to load into
  128065. * @param data The data to import
  128066. * @param rootUrl The root url for scene and resources
  128067. * @param onError The callback when import fails
  128068. * @returns The loaded asset container
  128069. */
  128070. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128071. }
  128072. /**
  128073. * Interface used to define an async SceneLoader plugin
  128074. */
  128075. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128076. /**
  128077. * Import meshes into a scene.
  128078. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128079. * @param scene The scene to import into
  128080. * @param data The data to import
  128081. * @param rootUrl The root url for scene and resources
  128082. * @param onProgress The callback when the load progresses
  128083. * @param fileName Defines the name of the file to load
  128084. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128085. */
  128086. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128087. meshes: AbstractMesh[];
  128088. particleSystems: IParticleSystem[];
  128089. skeletons: Skeleton[];
  128090. animationGroups: AnimationGroup[];
  128091. }>;
  128092. /**
  128093. * Load into a scene.
  128094. * @param scene The scene to load into
  128095. * @param data The data to import
  128096. * @param rootUrl The root url for scene and resources
  128097. * @param onProgress The callback when the load progresses
  128098. * @param fileName Defines the name of the file to load
  128099. * @returns Nothing
  128100. */
  128101. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128102. /**
  128103. * Load into an asset container.
  128104. * @param scene The scene to load into
  128105. * @param data The data to import
  128106. * @param rootUrl The root url for scene and resources
  128107. * @param onProgress The callback when the load progresses
  128108. * @param fileName Defines the name of the file to load
  128109. * @returns The loaded asset container
  128110. */
  128111. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128112. }
  128113. /**
  128114. * Mode that determines how to handle old animation groups before loading new ones.
  128115. */
  128116. export enum SceneLoaderAnimationGroupLoadingMode {
  128117. /**
  128118. * Reset all old animations to initial state then dispose them.
  128119. */
  128120. Clean = 0,
  128121. /**
  128122. * Stop all old animations.
  128123. */
  128124. Stop = 1,
  128125. /**
  128126. * Restart old animations from first frame.
  128127. */
  128128. Sync = 2,
  128129. /**
  128130. * Old animations remains untouched.
  128131. */
  128132. NoSync = 3
  128133. }
  128134. /**
  128135. * Defines a plugin registered by the SceneLoader
  128136. */
  128137. interface IRegisteredPlugin {
  128138. /**
  128139. * Defines the plugin to use
  128140. */
  128141. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128142. /**
  128143. * Defines if the plugin supports binary data
  128144. */
  128145. isBinary: boolean;
  128146. }
  128147. /**
  128148. * Class used to load scene from various file formats using registered plugins
  128149. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128150. */
  128151. export class SceneLoader {
  128152. /**
  128153. * No logging while loading
  128154. */
  128155. static readonly NO_LOGGING: number;
  128156. /**
  128157. * Minimal logging while loading
  128158. */
  128159. static readonly MINIMAL_LOGGING: number;
  128160. /**
  128161. * Summary logging while loading
  128162. */
  128163. static readonly SUMMARY_LOGGING: number;
  128164. /**
  128165. * Detailled logging while loading
  128166. */
  128167. static readonly DETAILED_LOGGING: number;
  128168. /**
  128169. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128170. */
  128171. static get ForceFullSceneLoadingForIncremental(): boolean;
  128172. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128173. /**
  128174. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128175. */
  128176. static get ShowLoadingScreen(): boolean;
  128177. static set ShowLoadingScreen(value: boolean);
  128178. /**
  128179. * Defines the current logging level (while loading the scene)
  128180. * @ignorenaming
  128181. */
  128182. static get loggingLevel(): number;
  128183. static set loggingLevel(value: number);
  128184. /**
  128185. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128186. */
  128187. static get CleanBoneMatrixWeights(): boolean;
  128188. static set CleanBoneMatrixWeights(value: boolean);
  128189. /**
  128190. * Event raised when a plugin is used to load a scene
  128191. */
  128192. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128193. private static _registeredPlugins;
  128194. private static _showingLoadingScreen;
  128195. /**
  128196. * Gets the default plugin (used to load Babylon files)
  128197. * @returns the .babylon plugin
  128198. */
  128199. static GetDefaultPlugin(): IRegisteredPlugin;
  128200. private static _GetPluginForExtension;
  128201. private static _GetPluginForDirectLoad;
  128202. private static _GetPluginForFilename;
  128203. private static _GetDirectLoad;
  128204. private static _LoadData;
  128205. private static _GetFileInfo;
  128206. /**
  128207. * Gets a plugin that can load the given extension
  128208. * @param extension defines the extension to load
  128209. * @returns a plugin or null if none works
  128210. */
  128211. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128212. /**
  128213. * Gets a boolean indicating that the given extension can be loaded
  128214. * @param extension defines the extension to load
  128215. * @returns true if the extension is supported
  128216. */
  128217. static IsPluginForExtensionAvailable(extension: string): boolean;
  128218. /**
  128219. * Adds a new plugin to the list of registered plugins
  128220. * @param plugin defines the plugin to add
  128221. */
  128222. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128223. /**
  128224. * Import meshes into a scene
  128225. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128226. * @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)
  128227. * @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)
  128228. * @param scene the instance of BABYLON.Scene to append to
  128229. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128230. * @param onProgress a callback with a progress event for each file being loaded
  128231. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128232. * @param pluginExtension the extension used to determine the plugin
  128233. * @returns The loaded plugin
  128234. */
  128235. 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>;
  128236. /**
  128237. * Import meshes into a scene
  128238. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128239. * @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)
  128240. * @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)
  128241. * @param scene the instance of BABYLON.Scene to append to
  128242. * @param onProgress a callback with a progress event for each file being loaded
  128243. * @param pluginExtension the extension used to determine the plugin
  128244. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128245. */
  128246. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128247. meshes: AbstractMesh[];
  128248. particleSystems: IParticleSystem[];
  128249. skeletons: Skeleton[];
  128250. animationGroups: AnimationGroup[];
  128251. }>;
  128252. /**
  128253. * Load a scene
  128254. * @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)
  128255. * @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)
  128256. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128257. * @param onSuccess a callback with the scene when import succeeds
  128258. * @param onProgress a callback with a progress event for each file being loaded
  128259. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128260. * @param pluginExtension the extension used to determine the plugin
  128261. * @returns The loaded plugin
  128262. */
  128263. 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>;
  128264. /**
  128265. * Load a scene
  128266. * @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)
  128267. * @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)
  128268. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128269. * @param onProgress a callback with a progress event for each file being loaded
  128270. * @param pluginExtension the extension used to determine the plugin
  128271. * @returns The loaded scene
  128272. */
  128273. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128274. /**
  128275. * Append a scene
  128276. * @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)
  128277. * @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)
  128278. * @param scene is the instance of BABYLON.Scene to append to
  128279. * @param onSuccess a callback with the scene when import succeeds
  128280. * @param onProgress a callback with a progress event for each file being loaded
  128281. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128282. * @param pluginExtension the extension used to determine the plugin
  128283. * @returns The loaded plugin
  128284. */
  128285. 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>;
  128286. /**
  128287. * Append a scene
  128288. * @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)
  128289. * @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)
  128290. * @param scene is the instance of BABYLON.Scene to append to
  128291. * @param onProgress a callback with a progress event for each file being loaded
  128292. * @param pluginExtension the extension used to determine the plugin
  128293. * @returns The given scene
  128294. */
  128295. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128296. /**
  128297. * Load a scene into an asset container
  128298. * @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)
  128299. * @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)
  128300. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128301. * @param onSuccess a callback with the scene when import succeeds
  128302. * @param onProgress a callback with a progress event for each file being loaded
  128303. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128304. * @param pluginExtension the extension used to determine the plugin
  128305. * @returns The loaded plugin
  128306. */
  128307. 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>;
  128308. /**
  128309. * Load a scene into an asset container
  128310. * @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)
  128311. * @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)
  128312. * @param scene is the instance of Scene to append to
  128313. * @param onProgress a callback with a progress event for each file being loaded
  128314. * @param pluginExtension the extension used to determine the plugin
  128315. * @returns The loaded asset container
  128316. */
  128317. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128318. /**
  128319. * Import animations from a file into a scene
  128320. * @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)
  128321. * @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)
  128322. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128323. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128324. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128325. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128326. * @param onSuccess a callback with the scene when import succeeds
  128327. * @param onProgress a callback with a progress event for each file being loaded
  128328. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128329. * @param pluginExtension the extension used to determine the plugin
  128330. */
  128331. 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;
  128332. /**
  128333. * Import animations from a file into a scene
  128334. * @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)
  128335. * @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)
  128336. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128337. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128338. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128339. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128340. * @param onSuccess a callback with the scene when import succeeds
  128341. * @param onProgress a callback with a progress event for each file being loaded
  128342. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128343. * @param pluginExtension the extension used to determine the plugin
  128344. * @returns the updated scene with imported animations
  128345. */
  128346. 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>;
  128347. }
  128348. }
  128349. declare module BABYLON {
  128350. /**
  128351. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128352. */
  128353. export type MotionControllerHandedness = "none" | "left" | "right";
  128354. /**
  128355. * The type of components available in motion controllers.
  128356. * This is not the name of the component.
  128357. */
  128358. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128359. /**
  128360. * The state of a controller component
  128361. */
  128362. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128363. /**
  128364. * The schema of motion controller layout.
  128365. * No object will be initialized using this interface
  128366. * This is used just to define the profile.
  128367. */
  128368. export interface IMotionControllerLayout {
  128369. /**
  128370. * Path to load the assets. Usually relative to the base path
  128371. */
  128372. assetPath: string;
  128373. /**
  128374. * Available components (unsorted)
  128375. */
  128376. components: {
  128377. /**
  128378. * A map of component Ids
  128379. */
  128380. [componentId: string]: {
  128381. /**
  128382. * The type of input the component outputs
  128383. */
  128384. type: MotionControllerComponentType;
  128385. /**
  128386. * The indices of this component in the gamepad object
  128387. */
  128388. gamepadIndices: {
  128389. /**
  128390. * Index of button
  128391. */
  128392. button?: number;
  128393. /**
  128394. * If available, index of x-axis
  128395. */
  128396. xAxis?: number;
  128397. /**
  128398. * If available, index of y-axis
  128399. */
  128400. yAxis?: number;
  128401. };
  128402. /**
  128403. * The mesh's root node name
  128404. */
  128405. rootNodeName: string;
  128406. /**
  128407. * Animation definitions for this model
  128408. */
  128409. visualResponses: {
  128410. [stateKey: string]: {
  128411. /**
  128412. * What property will be animated
  128413. */
  128414. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128415. /**
  128416. * What states influence this visual response
  128417. */
  128418. states: MotionControllerComponentStateType[];
  128419. /**
  128420. * Type of animation - movement or visibility
  128421. */
  128422. valueNodeProperty: "transform" | "visibility";
  128423. /**
  128424. * Base node name to move. Its position will be calculated according to the min and max nodes
  128425. */
  128426. valueNodeName?: string;
  128427. /**
  128428. * Minimum movement node
  128429. */
  128430. minNodeName?: string;
  128431. /**
  128432. * Max movement node
  128433. */
  128434. maxNodeName?: string;
  128435. };
  128436. };
  128437. /**
  128438. * If touch enabled, what is the name of node to display user feedback
  128439. */
  128440. touchPointNodeName?: string;
  128441. };
  128442. };
  128443. /**
  128444. * Is it xr standard mapping or not
  128445. */
  128446. gamepadMapping: "" | "xr-standard";
  128447. /**
  128448. * Base root node of this entire model
  128449. */
  128450. rootNodeName: string;
  128451. /**
  128452. * Defines the main button component id
  128453. */
  128454. selectComponentId: string;
  128455. }
  128456. /**
  128457. * A definition for the layout map in the input profile
  128458. */
  128459. export interface IMotionControllerLayoutMap {
  128460. /**
  128461. * Layouts with handedness type as a key
  128462. */
  128463. [handedness: string]: IMotionControllerLayout;
  128464. }
  128465. /**
  128466. * The XR Input profile schema
  128467. * Profiles can be found here:
  128468. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128469. */
  128470. export interface IMotionControllerProfile {
  128471. /**
  128472. * fallback profiles for this profileId
  128473. */
  128474. fallbackProfileIds: string[];
  128475. /**
  128476. * The layout map, with handedness as key
  128477. */
  128478. layouts: IMotionControllerLayoutMap;
  128479. /**
  128480. * The id of this profile
  128481. * correlates to the profile(s) in the xrInput.profiles array
  128482. */
  128483. profileId: string;
  128484. }
  128485. /**
  128486. * A helper-interface for the 3 meshes needed for controller button animation
  128487. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128488. */
  128489. export interface IMotionControllerButtonMeshMap {
  128490. /**
  128491. * the mesh that defines the pressed value mesh position.
  128492. * This is used to find the max-position of this button
  128493. */
  128494. pressedMesh: AbstractMesh;
  128495. /**
  128496. * the mesh that defines the unpressed value mesh position.
  128497. * This is used to find the min (or initial) position of this button
  128498. */
  128499. unpressedMesh: AbstractMesh;
  128500. /**
  128501. * The mesh that will be changed when value changes
  128502. */
  128503. valueMesh: AbstractMesh;
  128504. }
  128505. /**
  128506. * A helper-interface for the 3 meshes needed for controller axis animation.
  128507. * This will be expanded when touchpad animations are fully supported
  128508. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128509. */
  128510. export interface IMotionControllerMeshMap {
  128511. /**
  128512. * the mesh that defines the maximum value mesh position.
  128513. */
  128514. maxMesh?: AbstractMesh;
  128515. /**
  128516. * the mesh that defines the minimum value mesh position.
  128517. */
  128518. minMesh?: AbstractMesh;
  128519. /**
  128520. * The mesh that will be changed when axis value changes
  128521. */
  128522. valueMesh?: AbstractMesh;
  128523. }
  128524. /**
  128525. * The elements needed for change-detection of the gamepad objects in motion controllers
  128526. */
  128527. export interface IMinimalMotionControllerObject {
  128528. /**
  128529. * Available axes of this controller
  128530. */
  128531. axes: number[];
  128532. /**
  128533. * An array of available buttons
  128534. */
  128535. buttons: Array<{
  128536. /**
  128537. * Value of the button/trigger
  128538. */
  128539. value: number;
  128540. /**
  128541. * If the button/trigger is currently touched
  128542. */
  128543. touched: boolean;
  128544. /**
  128545. * If the button/trigger is currently pressed
  128546. */
  128547. pressed: boolean;
  128548. }>;
  128549. /**
  128550. * EXPERIMENTAL haptic support.
  128551. */
  128552. hapticActuators?: Array<{
  128553. pulse: (value: number, duration: number) => Promise<boolean>;
  128554. }>;
  128555. }
  128556. /**
  128557. * An Abstract Motion controller
  128558. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128559. * Each component has an observable to check for changes in value and state
  128560. */
  128561. export abstract class WebXRAbstractMotionController implements IDisposable {
  128562. protected scene: Scene;
  128563. protected layout: IMotionControllerLayout;
  128564. /**
  128565. * The gamepad object correlating to this controller
  128566. */
  128567. gamepadObject: IMinimalMotionControllerObject;
  128568. /**
  128569. * handedness (left/right/none) of this controller
  128570. */
  128571. handedness: MotionControllerHandedness;
  128572. private _initComponent;
  128573. private _modelReady;
  128574. /**
  128575. * A map of components (WebXRControllerComponent) in this motion controller
  128576. * Components have a ComponentType and can also have both button and axis definitions
  128577. */
  128578. readonly components: {
  128579. [id: string]: WebXRControllerComponent;
  128580. };
  128581. /**
  128582. * Disable the model's animation. Can be set at any time.
  128583. */
  128584. disableAnimation: boolean;
  128585. /**
  128586. * Observers registered here will be triggered when the model of this controller is done loading
  128587. */
  128588. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128589. /**
  128590. * The profile id of this motion controller
  128591. */
  128592. abstract profileId: string;
  128593. /**
  128594. * The root mesh of the model. It is null if the model was not yet initialized
  128595. */
  128596. rootMesh: Nullable<AbstractMesh>;
  128597. /**
  128598. * constructs a new abstract motion controller
  128599. * @param scene the scene to which the model of the controller will be added
  128600. * @param layout The profile layout to load
  128601. * @param gamepadObject The gamepad object correlating to this controller
  128602. * @param handedness handedness (left/right/none) of this controller
  128603. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128604. */
  128605. constructor(scene: Scene, layout: IMotionControllerLayout,
  128606. /**
  128607. * The gamepad object correlating to this controller
  128608. */
  128609. gamepadObject: IMinimalMotionControllerObject,
  128610. /**
  128611. * handedness (left/right/none) of this controller
  128612. */
  128613. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128614. /**
  128615. * Dispose this controller, the model mesh and all its components
  128616. */
  128617. dispose(): void;
  128618. /**
  128619. * Returns all components of specific type
  128620. * @param type the type to search for
  128621. * @return an array of components with this type
  128622. */
  128623. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128624. /**
  128625. * get a component based an its component id as defined in layout.components
  128626. * @param id the id of the component
  128627. * @returns the component correlates to the id or undefined if not found
  128628. */
  128629. getComponent(id: string): WebXRControllerComponent;
  128630. /**
  128631. * Get the list of components available in this motion controller
  128632. * @returns an array of strings correlating to available components
  128633. */
  128634. getComponentIds(): string[];
  128635. /**
  128636. * Get the first component of specific type
  128637. * @param type type of component to find
  128638. * @return a controller component or null if not found
  128639. */
  128640. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128641. /**
  128642. * Get the main (Select) component of this controller as defined in the layout
  128643. * @returns the main component of this controller
  128644. */
  128645. getMainComponent(): WebXRControllerComponent;
  128646. /**
  128647. * Loads the model correlating to this controller
  128648. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128649. * @returns A promise fulfilled with the result of the model loading
  128650. */
  128651. loadModel(): Promise<boolean>;
  128652. /**
  128653. * Update this model using the current XRFrame
  128654. * @param xrFrame the current xr frame to use and update the model
  128655. */
  128656. updateFromXRFrame(xrFrame: XRFrame): void;
  128657. /**
  128658. * Backwards compatibility due to a deeply-integrated typo
  128659. */
  128660. get handness(): XREye;
  128661. /**
  128662. * Pulse (vibrate) this controller
  128663. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128664. * Consecutive calls to this function will cancel the last pulse call
  128665. *
  128666. * @param value the strength of the pulse in 0.0...1.0 range
  128667. * @param duration Duration of the pulse in milliseconds
  128668. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128669. * @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
  128670. */
  128671. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128672. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128673. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128674. /**
  128675. * Moves the axis on the controller mesh based on its current state
  128676. * @param axis the index of the axis
  128677. * @param axisValue the value of the axis which determines the meshes new position
  128678. * @hidden
  128679. */
  128680. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128681. /**
  128682. * Update the model itself with the current frame data
  128683. * @param xrFrame the frame to use for updating the model mesh
  128684. */
  128685. protected updateModel(xrFrame: XRFrame): void;
  128686. /**
  128687. * Get the filename and path for this controller's model
  128688. * @returns a map of filename and path
  128689. */
  128690. protected abstract _getFilenameAndPath(): {
  128691. filename: string;
  128692. path: string;
  128693. };
  128694. /**
  128695. * This function is called before the mesh is loaded. It checks for loading constraints.
  128696. * For example, this function can check if the GLB loader is available
  128697. * If this function returns false, the generic controller will be loaded instead
  128698. * @returns Is the client ready to load the mesh
  128699. */
  128700. protected abstract _getModelLoadingConstraints(): boolean;
  128701. /**
  128702. * This function will be called after the model was successfully loaded and can be used
  128703. * for mesh transformations before it is available for the user
  128704. * @param meshes the loaded meshes
  128705. */
  128706. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128707. /**
  128708. * Set the root mesh for this controller. Important for the WebXR controller class
  128709. * @param meshes the loaded meshes
  128710. */
  128711. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128712. /**
  128713. * A function executed each frame that updates the mesh (if needed)
  128714. * @param xrFrame the current xrFrame
  128715. */
  128716. protected abstract _updateModel(xrFrame: XRFrame): void;
  128717. private _getGenericFilenameAndPath;
  128718. private _getGenericParentMesh;
  128719. }
  128720. }
  128721. declare module BABYLON {
  128722. /**
  128723. * A generic trigger-only motion controller for WebXR
  128724. */
  128725. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128726. /**
  128727. * Static version of the profile id of this controller
  128728. */
  128729. static ProfileId: string;
  128730. profileId: string;
  128731. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128732. protected _getFilenameAndPath(): {
  128733. filename: string;
  128734. path: string;
  128735. };
  128736. protected _getModelLoadingConstraints(): boolean;
  128737. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128738. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128739. protected _updateModel(): void;
  128740. }
  128741. }
  128742. declare module BABYLON {
  128743. /**
  128744. * Class containing static functions to help procedurally build meshes
  128745. */
  128746. export class SphereBuilder {
  128747. /**
  128748. * Creates a sphere mesh
  128749. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128750. * * 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`)
  128751. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128752. * * 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
  128753. * * 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)
  128754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128757. * @param name defines the name of the mesh
  128758. * @param options defines the options used to create the mesh
  128759. * @param scene defines the hosting scene
  128760. * @returns the sphere mesh
  128761. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128762. */
  128763. static CreateSphere(name: string, options: {
  128764. segments?: number;
  128765. diameter?: number;
  128766. diameterX?: number;
  128767. diameterY?: number;
  128768. diameterZ?: number;
  128769. arc?: number;
  128770. slice?: number;
  128771. sideOrientation?: number;
  128772. frontUVs?: Vector4;
  128773. backUVs?: Vector4;
  128774. updatable?: boolean;
  128775. }, scene?: Nullable<Scene>): Mesh;
  128776. }
  128777. }
  128778. declare module BABYLON {
  128779. /**
  128780. * A profiled motion controller has its profile loaded from an online repository.
  128781. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128782. */
  128783. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128784. private _repositoryUrl;
  128785. private _buttonMeshMapping;
  128786. private _touchDots;
  128787. /**
  128788. * The profile ID of this controller. Will be populated when the controller initializes.
  128789. */
  128790. profileId: string;
  128791. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128792. dispose(): void;
  128793. protected _getFilenameAndPath(): {
  128794. filename: string;
  128795. path: string;
  128796. };
  128797. protected _getModelLoadingConstraints(): boolean;
  128798. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128799. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128800. protected _updateModel(_xrFrame: XRFrame): void;
  128801. }
  128802. }
  128803. declare module BABYLON {
  128804. /**
  128805. * A construction function type to create a new controller based on an xrInput object
  128806. */
  128807. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128808. /**
  128809. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128810. *
  128811. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128812. * it should be replaced with auto-loaded controllers.
  128813. *
  128814. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128815. */
  128816. export class WebXRMotionControllerManager {
  128817. private static _AvailableControllers;
  128818. private static _Fallbacks;
  128819. private static _ProfileLoadingPromises;
  128820. private static _ProfilesList;
  128821. /**
  128822. * The base URL of the online controller repository. Can be changed at any time.
  128823. */
  128824. static BaseRepositoryUrl: string;
  128825. /**
  128826. * Which repository gets priority - local or online
  128827. */
  128828. static PrioritizeOnlineRepository: boolean;
  128829. /**
  128830. * Use the online repository, or use only locally-defined controllers
  128831. */
  128832. static UseOnlineRepository: boolean;
  128833. /**
  128834. * Clear the cache used for profile loading and reload when requested again
  128835. */
  128836. static ClearProfilesCache(): void;
  128837. /**
  128838. * Register the default fallbacks.
  128839. * This function is called automatically when this file is imported.
  128840. */
  128841. static DefaultFallbacks(): void;
  128842. /**
  128843. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128844. * @param profileId the profile to which a fallback needs to be found
  128845. * @return an array with corresponding fallback profiles
  128846. */
  128847. static FindFallbackWithProfileId(profileId: string): string[];
  128848. /**
  128849. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128850. * The order of search:
  128851. *
  128852. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128853. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128854. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128855. * 4) return the generic trigger controller if none were found
  128856. *
  128857. * @param xrInput the xrInput to which a new controller is initialized
  128858. * @param scene the scene to which the model will be added
  128859. * @param forceProfile force a certain profile for this controller
  128860. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128861. */
  128862. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128863. /**
  128864. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128865. *
  128866. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128867. *
  128868. * @param type the profile type to register
  128869. * @param constructFunction the function to be called when loading this profile
  128870. */
  128871. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128872. /**
  128873. * Register a fallback to a specific profile.
  128874. * @param profileId the profileId that will receive the fallbacks
  128875. * @param fallbacks A list of fallback profiles
  128876. */
  128877. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128878. /**
  128879. * Will update the list of profiles available in the repository
  128880. * @return a promise that resolves to a map of profiles available online
  128881. */
  128882. static UpdateProfilesList(): Promise<{
  128883. [profile: string]: string;
  128884. }>;
  128885. private static _LoadProfileFromRepository;
  128886. private static _LoadProfilesFromAvailableControllers;
  128887. }
  128888. }
  128889. declare module BABYLON {
  128890. /**
  128891. * Configuration options for the WebXR controller creation
  128892. */
  128893. export interface IWebXRControllerOptions {
  128894. /**
  128895. * Should the controller mesh be animated when a user interacts with it
  128896. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128897. */
  128898. disableMotionControllerAnimation?: boolean;
  128899. /**
  128900. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128901. */
  128902. doNotLoadControllerMesh?: boolean;
  128903. /**
  128904. * Force a specific controller type for this controller.
  128905. * This can be used when creating your own profile or when testing different controllers
  128906. */
  128907. forceControllerProfile?: string;
  128908. /**
  128909. * Defines a rendering group ID for meshes that will be loaded.
  128910. * This is for the default controllers only.
  128911. */
  128912. renderingGroupId?: number;
  128913. }
  128914. /**
  128915. * Represents an XR controller
  128916. */
  128917. export class WebXRInputSource {
  128918. private _scene;
  128919. /** The underlying input source for the controller */
  128920. inputSource: XRInputSource;
  128921. private _options;
  128922. private _tmpVector;
  128923. private _uniqueId;
  128924. private _disposed;
  128925. /**
  128926. * 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
  128927. */
  128928. grip?: AbstractMesh;
  128929. /**
  128930. * If available, this is the gamepad object related to this controller.
  128931. * Using this object it is possible to get click events and trackpad changes of the
  128932. * webxr controller that is currently being used.
  128933. */
  128934. motionController?: WebXRAbstractMotionController;
  128935. /**
  128936. * Event that fires when the controller is removed/disposed.
  128937. * The object provided as event data is this controller, after associated assets were disposed.
  128938. * uniqueId is still available.
  128939. */
  128940. onDisposeObservable: Observable<WebXRInputSource>;
  128941. /**
  128942. * Will be triggered when the mesh associated with the motion controller is done loading.
  128943. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128944. * A shortened version of controller -> motion controller -> on mesh loaded.
  128945. */
  128946. onMeshLoadedObservable: Observable<AbstractMesh>;
  128947. /**
  128948. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128949. */
  128950. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128951. /**
  128952. * Pointer which can be used to select objects or attach a visible laser to
  128953. */
  128954. pointer: AbstractMesh;
  128955. /**
  128956. * Creates the input source object
  128957. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128958. * @param _scene the scene which the controller should be associated to
  128959. * @param inputSource the underlying input source for the controller
  128960. * @param _options options for this controller creation
  128961. */
  128962. constructor(_scene: Scene,
  128963. /** The underlying input source for the controller */
  128964. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128965. /**
  128966. * Get this controllers unique id
  128967. */
  128968. get uniqueId(): string;
  128969. /**
  128970. * Disposes of the object
  128971. */
  128972. dispose(): void;
  128973. /**
  128974. * Gets a world space ray coming from the pointer or grip
  128975. * @param result the resulting ray
  128976. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128977. */
  128978. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128979. /**
  128980. * Updates the controller pose based on the given XRFrame
  128981. * @param xrFrame xr frame to update the pose with
  128982. * @param referenceSpace reference space to use
  128983. */
  128984. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128985. }
  128986. }
  128987. declare module BABYLON {
  128988. /**
  128989. * The schema for initialization options of the XR Input class
  128990. */
  128991. export interface IWebXRInputOptions {
  128992. /**
  128993. * If set to true no model will be automatically loaded
  128994. */
  128995. doNotLoadControllerMeshes?: boolean;
  128996. /**
  128997. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128998. * If not found, the xr input profile data will be used.
  128999. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  129000. */
  129001. forceInputProfile?: string;
  129002. /**
  129003. * Do not send a request to the controller repository to load the profile.
  129004. *
  129005. * Instead, use the controllers available in babylon itself.
  129006. */
  129007. disableOnlineControllerRepository?: boolean;
  129008. /**
  129009. * A custom URL for the controllers repository
  129010. */
  129011. customControllersRepositoryURL?: string;
  129012. /**
  129013. * Should the controller model's components not move according to the user input
  129014. */
  129015. disableControllerAnimation?: boolean;
  129016. /**
  129017. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129018. */
  129019. controllerOptions?: IWebXRControllerOptions;
  129020. }
  129021. /**
  129022. * XR input used to track XR inputs such as controllers/rays
  129023. */
  129024. export class WebXRInput implements IDisposable {
  129025. /**
  129026. * the xr session manager for this session
  129027. */
  129028. xrSessionManager: WebXRSessionManager;
  129029. /**
  129030. * the WebXR camera for this session. Mainly used for teleportation
  129031. */
  129032. xrCamera: WebXRCamera;
  129033. private readonly options;
  129034. /**
  129035. * XR controllers being tracked
  129036. */
  129037. controllers: Array<WebXRInputSource>;
  129038. private _frameObserver;
  129039. private _sessionEndedObserver;
  129040. private _sessionInitObserver;
  129041. /**
  129042. * Event when a controller has been connected/added
  129043. */
  129044. onControllerAddedObservable: Observable<WebXRInputSource>;
  129045. /**
  129046. * Event when a controller has been removed/disconnected
  129047. */
  129048. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129049. /**
  129050. * Initializes the WebXRInput
  129051. * @param xrSessionManager the xr session manager for this session
  129052. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129053. * @param options = initialization options for this xr input
  129054. */
  129055. constructor(
  129056. /**
  129057. * the xr session manager for this session
  129058. */
  129059. xrSessionManager: WebXRSessionManager,
  129060. /**
  129061. * the WebXR camera for this session. Mainly used for teleportation
  129062. */
  129063. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129064. private _onInputSourcesChange;
  129065. private _addAndRemoveControllers;
  129066. /**
  129067. * Disposes of the object
  129068. */
  129069. dispose(): void;
  129070. }
  129071. }
  129072. declare module BABYLON {
  129073. /**
  129074. * This is the base class for all WebXR features.
  129075. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129076. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129077. */
  129078. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129079. protected _xrSessionManager: WebXRSessionManager;
  129080. private _attached;
  129081. private _removeOnDetach;
  129082. /**
  129083. * Is this feature disposed?
  129084. */
  129085. isDisposed: boolean;
  129086. /**
  129087. * Should auto-attach be disabled?
  129088. */
  129089. disableAutoAttach: boolean;
  129090. /**
  129091. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129092. */
  129093. xrNativeFeatureName: string;
  129094. /**
  129095. * Construct a new (abstract) WebXR feature
  129096. * @param _xrSessionManager the xr session manager for this feature
  129097. */
  129098. constructor(_xrSessionManager: WebXRSessionManager);
  129099. /**
  129100. * Is this feature attached
  129101. */
  129102. get attached(): boolean;
  129103. /**
  129104. * attach this feature
  129105. *
  129106. * @param force should attachment be forced (even when already attached)
  129107. * @returns true if successful, false is failed or already attached
  129108. */
  129109. attach(force?: boolean): boolean;
  129110. /**
  129111. * detach this feature.
  129112. *
  129113. * @returns true if successful, false if failed or already detached
  129114. */
  129115. detach(): boolean;
  129116. /**
  129117. * Dispose this feature and all of the resources attached
  129118. */
  129119. dispose(): void;
  129120. /**
  129121. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129122. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129123. *
  129124. * @returns whether or not the feature is compatible in this environment
  129125. */
  129126. isCompatible(): boolean;
  129127. /**
  129128. * This is used to register callbacks that will automatically be removed when detach is called.
  129129. * @param observable the observable to which the observer will be attached
  129130. * @param callback the callback to register
  129131. */
  129132. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129133. /**
  129134. * Code in this function will be executed on each xrFrame received from the browser.
  129135. * This function will not execute after the feature is detached.
  129136. * @param _xrFrame the current frame
  129137. */
  129138. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129139. }
  129140. }
  129141. declare module BABYLON {
  129142. /**
  129143. * Renders a layer on top of an existing scene
  129144. */
  129145. export class UtilityLayerRenderer implements IDisposable {
  129146. /** the original scene that will be rendered on top of */
  129147. originalScene: Scene;
  129148. private _pointerCaptures;
  129149. private _lastPointerEvents;
  129150. private static _DefaultUtilityLayer;
  129151. private static _DefaultKeepDepthUtilityLayer;
  129152. private _sharedGizmoLight;
  129153. private _renderCamera;
  129154. /**
  129155. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129156. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129157. * @returns the camera that is used when rendering the utility layer
  129158. */
  129159. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129160. /**
  129161. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129162. * @param cam the camera that should be used when rendering the utility layer
  129163. */
  129164. setRenderCamera(cam: Nullable<Camera>): void;
  129165. /**
  129166. * @hidden
  129167. * Light which used by gizmos to get light shading
  129168. */
  129169. _getSharedGizmoLight(): HemisphericLight;
  129170. /**
  129171. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129172. */
  129173. pickUtilitySceneFirst: boolean;
  129174. /**
  129175. * 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)
  129176. */
  129177. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129178. /**
  129179. * 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)
  129180. */
  129181. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129182. /**
  129183. * The scene that is rendered on top of the original scene
  129184. */
  129185. utilityLayerScene: Scene;
  129186. /**
  129187. * If the utility layer should automatically be rendered on top of existing scene
  129188. */
  129189. shouldRender: boolean;
  129190. /**
  129191. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129192. */
  129193. onlyCheckPointerDownEvents: boolean;
  129194. /**
  129195. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129196. */
  129197. processAllEvents: boolean;
  129198. /**
  129199. * Observable raised when the pointer move from the utility layer scene to the main scene
  129200. */
  129201. onPointerOutObservable: Observable<number>;
  129202. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129203. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129204. private _afterRenderObserver;
  129205. private _sceneDisposeObserver;
  129206. private _originalPointerObserver;
  129207. /**
  129208. * Instantiates a UtilityLayerRenderer
  129209. * @param originalScene the original scene that will be rendered on top of
  129210. * @param handleEvents boolean indicating if the utility layer should handle events
  129211. */
  129212. constructor(
  129213. /** the original scene that will be rendered on top of */
  129214. originalScene: Scene, handleEvents?: boolean);
  129215. private _notifyObservers;
  129216. /**
  129217. * Renders the utility layers scene on top of the original scene
  129218. */
  129219. render(): void;
  129220. /**
  129221. * Disposes of the renderer
  129222. */
  129223. dispose(): void;
  129224. private _updateCamera;
  129225. }
  129226. }
  129227. declare module BABYLON {
  129228. /**
  129229. * Options interface for the pointer selection module
  129230. */
  129231. export interface IWebXRControllerPointerSelectionOptions {
  129232. /**
  129233. * if provided, this scene will be used to render meshes.
  129234. */
  129235. customUtilityLayerScene?: Scene;
  129236. /**
  129237. * 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)
  129238. * If not disabled, the last picked point will be used to execute a pointer up event
  129239. * If disabled, pointer up event will be triggered right after the pointer down event.
  129240. * Used in screen and gaze target ray mode only
  129241. */
  129242. disablePointerUpOnTouchOut: boolean;
  129243. /**
  129244. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129245. */
  129246. forceGazeMode: boolean;
  129247. /**
  129248. * 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
  129249. * to start a new countdown to the pointer down event.
  129250. * Defaults to 1.
  129251. */
  129252. gazeModePointerMovedFactor?: number;
  129253. /**
  129254. * Different button type to use instead of the main component
  129255. */
  129256. overrideButtonId?: string;
  129257. /**
  129258. * use this rendering group id for the meshes (optional)
  129259. */
  129260. renderingGroupId?: number;
  129261. /**
  129262. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129263. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129264. * 3000 means 3 seconds between pointing at something and selecting it
  129265. */
  129266. timeToSelect?: number;
  129267. /**
  129268. * Should meshes created here be added to a utility layer or the main scene
  129269. */
  129270. useUtilityLayer?: boolean;
  129271. /**
  129272. * Optional WebXR camera to be used for gaze selection
  129273. */
  129274. gazeCamera?: WebXRCamera;
  129275. /**
  129276. * the xr input to use with this pointer selection
  129277. */
  129278. xrInput: WebXRInput;
  129279. }
  129280. /**
  129281. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129282. */
  129283. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129284. private readonly _options;
  129285. private static _idCounter;
  129286. private _attachController;
  129287. private _controllers;
  129288. private _scene;
  129289. private _tmpVectorForPickCompare;
  129290. /**
  129291. * The module's name
  129292. */
  129293. static readonly Name: string;
  129294. /**
  129295. * The (Babylon) version of this module.
  129296. * This is an integer representing the implementation version.
  129297. * This number does not correspond to the WebXR specs version
  129298. */
  129299. static readonly Version: number;
  129300. /**
  129301. * Disable lighting on the laser pointer (so it will always be visible)
  129302. */
  129303. disablePointerLighting: boolean;
  129304. /**
  129305. * Disable lighting on the selection mesh (so it will always be visible)
  129306. */
  129307. disableSelectionMeshLighting: boolean;
  129308. /**
  129309. * Should the laser pointer be displayed
  129310. */
  129311. displayLaserPointer: boolean;
  129312. /**
  129313. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129314. */
  129315. displaySelectionMesh: boolean;
  129316. /**
  129317. * This color will be set to the laser pointer when selection is triggered
  129318. */
  129319. laserPointerPickedColor: Color3;
  129320. /**
  129321. * Default color of the laser pointer
  129322. */
  129323. laserPointerDefaultColor: Color3;
  129324. /**
  129325. * default color of the selection ring
  129326. */
  129327. selectionMeshDefaultColor: Color3;
  129328. /**
  129329. * This color will be applied to the selection ring when selection is triggered
  129330. */
  129331. selectionMeshPickedColor: Color3;
  129332. /**
  129333. * Optional filter to be used for ray selection. This predicate shares behavior with
  129334. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129335. */
  129336. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129337. /**
  129338. * constructs a new background remover module
  129339. * @param _xrSessionManager the session manager for this module
  129340. * @param _options read-only options to be used in this module
  129341. */
  129342. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129343. /**
  129344. * attach this feature
  129345. * Will usually be called by the features manager
  129346. *
  129347. * @returns true if successful.
  129348. */
  129349. attach(): boolean;
  129350. /**
  129351. * detach this feature.
  129352. * Will usually be called by the features manager
  129353. *
  129354. * @returns true if successful.
  129355. */
  129356. detach(): boolean;
  129357. /**
  129358. * Will get the mesh under a specific pointer.
  129359. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129360. * @param controllerId the controllerId to check
  129361. * @returns The mesh under pointer or null if no mesh is under the pointer
  129362. */
  129363. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129364. /**
  129365. * Get the xr controller that correlates to the pointer id in the pointer event
  129366. *
  129367. * @param id the pointer id to search for
  129368. * @returns the controller that correlates to this id or null if not found
  129369. */
  129370. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129371. protected _onXRFrame(_xrFrame: XRFrame): void;
  129372. private _attachGazeMode;
  129373. private _attachScreenRayMode;
  129374. private _attachTrackedPointerRayMode;
  129375. private _convertNormalToDirectionOfRay;
  129376. private _detachController;
  129377. private _generateNewMeshPair;
  129378. private _pickingMoved;
  129379. private _updatePointerDistance;
  129380. /** @hidden */
  129381. get lasterPointerDefaultColor(): Color3;
  129382. }
  129383. }
  129384. declare module BABYLON {
  129385. /**
  129386. * Button which can be used to enter a different mode of XR
  129387. */
  129388. export class WebXREnterExitUIButton {
  129389. /** button element */
  129390. element: HTMLElement;
  129391. /** XR initialization options for the button */
  129392. sessionMode: XRSessionMode;
  129393. /** Reference space type */
  129394. referenceSpaceType: XRReferenceSpaceType;
  129395. /**
  129396. * Creates a WebXREnterExitUIButton
  129397. * @param element button element
  129398. * @param sessionMode XR initialization session mode
  129399. * @param referenceSpaceType the type of reference space to be used
  129400. */
  129401. constructor(
  129402. /** button element */
  129403. element: HTMLElement,
  129404. /** XR initialization options for the button */
  129405. sessionMode: XRSessionMode,
  129406. /** Reference space type */
  129407. referenceSpaceType: XRReferenceSpaceType);
  129408. /**
  129409. * Extendable function which can be used to update the button's visuals when the state changes
  129410. * @param activeButton the current active button in the UI
  129411. */
  129412. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129413. }
  129414. /**
  129415. * Options to create the webXR UI
  129416. */
  129417. export class WebXREnterExitUIOptions {
  129418. /**
  129419. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129420. */
  129421. customButtons?: Array<WebXREnterExitUIButton>;
  129422. /**
  129423. * A reference space type to use when creating the default button.
  129424. * Default is local-floor
  129425. */
  129426. referenceSpaceType?: XRReferenceSpaceType;
  129427. /**
  129428. * Context to enter xr with
  129429. */
  129430. renderTarget?: Nullable<WebXRRenderTarget>;
  129431. /**
  129432. * A session mode to use when creating the default button.
  129433. * Default is immersive-vr
  129434. */
  129435. sessionMode?: XRSessionMode;
  129436. /**
  129437. * A list of optional features to init the session with
  129438. */
  129439. optionalFeatures?: string[];
  129440. /**
  129441. * A list of optional features to init the session with
  129442. */
  129443. requiredFeatures?: string[];
  129444. }
  129445. /**
  129446. * UI to allow the user to enter/exit XR mode
  129447. */
  129448. export class WebXREnterExitUI implements IDisposable {
  129449. private scene;
  129450. /** version of the options passed to this UI */
  129451. options: WebXREnterExitUIOptions;
  129452. private _activeButton;
  129453. private _buttons;
  129454. /**
  129455. * The HTML Div Element to which buttons are added.
  129456. */
  129457. readonly overlay: HTMLDivElement;
  129458. /**
  129459. * Fired every time the active button is changed.
  129460. *
  129461. * When xr is entered via a button that launches xr that button will be the callback parameter
  129462. *
  129463. * When exiting xr the callback parameter will be null)
  129464. */
  129465. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129466. /**
  129467. *
  129468. * @param scene babylon scene object to use
  129469. * @param options (read-only) version of the options passed to this UI
  129470. */
  129471. private constructor();
  129472. /**
  129473. * Creates UI to allow the user to enter/exit XR mode
  129474. * @param scene the scene to add the ui to
  129475. * @param helper the xr experience helper to enter/exit xr with
  129476. * @param options options to configure the UI
  129477. * @returns the created ui
  129478. */
  129479. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129480. /**
  129481. * Disposes of the XR UI component
  129482. */
  129483. dispose(): void;
  129484. private _updateButtons;
  129485. }
  129486. }
  129487. declare module BABYLON {
  129488. /**
  129489. * Class containing static functions to help procedurally build meshes
  129490. */
  129491. export class LinesBuilder {
  129492. /**
  129493. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129494. * * 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
  129495. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129496. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129497. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129498. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129499. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129500. * * 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
  129501. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129504. * @param name defines the name of the new line system
  129505. * @param options defines the options used to create the line system
  129506. * @param scene defines the hosting scene
  129507. * @returns a new line system mesh
  129508. */
  129509. static CreateLineSystem(name: string, options: {
  129510. lines: Vector3[][];
  129511. updatable?: boolean;
  129512. instance?: Nullable<LinesMesh>;
  129513. colors?: Nullable<Color4[][]>;
  129514. useVertexAlpha?: boolean;
  129515. }, scene: Nullable<Scene>): LinesMesh;
  129516. /**
  129517. * Creates a line mesh
  129518. * 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
  129519. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129520. * * The parameter `points` is an array successive Vector3
  129521. * * 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
  129522. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129523. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129524. * * When updating an instance, remember that only point positions can change, not the number of points
  129525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129527. * @param name defines the name of the new line system
  129528. * @param options defines the options used to create the line system
  129529. * @param scene defines the hosting scene
  129530. * @returns a new line mesh
  129531. */
  129532. static CreateLines(name: string, options: {
  129533. points: Vector3[];
  129534. updatable?: boolean;
  129535. instance?: Nullable<LinesMesh>;
  129536. colors?: Color4[];
  129537. useVertexAlpha?: boolean;
  129538. }, scene?: Nullable<Scene>): LinesMesh;
  129539. /**
  129540. * Creates a dashed line mesh
  129541. * * 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
  129542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129543. * * The parameter `points` is an array successive Vector3
  129544. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129545. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129546. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129547. * * 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
  129548. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129549. * * When updating an instance, remember that only point positions can change, not the number of points
  129550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129551. * @param name defines the name of the mesh
  129552. * @param options defines the options used to create the mesh
  129553. * @param scene defines the hosting scene
  129554. * @returns the dashed line mesh
  129555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129556. */
  129557. static CreateDashedLines(name: string, options: {
  129558. points: Vector3[];
  129559. dashSize?: number;
  129560. gapSize?: number;
  129561. dashNb?: number;
  129562. updatable?: boolean;
  129563. instance?: LinesMesh;
  129564. useVertexAlpha?: boolean;
  129565. }, scene?: Nullable<Scene>): LinesMesh;
  129566. }
  129567. }
  129568. declare module BABYLON {
  129569. /**
  129570. * Construction options for a timer
  129571. */
  129572. export interface ITimerOptions<T> {
  129573. /**
  129574. * Time-to-end
  129575. */
  129576. timeout: number;
  129577. /**
  129578. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129579. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129580. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129581. */
  129582. contextObservable: Observable<T>;
  129583. /**
  129584. * Optional parameters when adding an observer to the observable
  129585. */
  129586. observableParameters?: {
  129587. mask?: number;
  129588. insertFirst?: boolean;
  129589. scope?: any;
  129590. };
  129591. /**
  129592. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129593. */
  129594. breakCondition?: (data?: ITimerData<T>) => boolean;
  129595. /**
  129596. * Will be triggered when the time condition has met
  129597. */
  129598. onEnded?: (data: ITimerData<any>) => void;
  129599. /**
  129600. * Will be triggered when the break condition has met (prematurely ended)
  129601. */
  129602. onAborted?: (data: ITimerData<any>) => void;
  129603. /**
  129604. * Optional function to execute on each tick (or count)
  129605. */
  129606. onTick?: (data: ITimerData<any>) => void;
  129607. }
  129608. /**
  129609. * An interface defining the data sent by the timer
  129610. */
  129611. export interface ITimerData<T> {
  129612. /**
  129613. * When did it start
  129614. */
  129615. startTime: number;
  129616. /**
  129617. * Time now
  129618. */
  129619. currentTime: number;
  129620. /**
  129621. * Time passed since started
  129622. */
  129623. deltaTime: number;
  129624. /**
  129625. * How much is completed, in [0.0...1.0].
  129626. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129627. */
  129628. completeRate: number;
  129629. /**
  129630. * What the registered observable sent in the last count
  129631. */
  129632. payload: T;
  129633. }
  129634. /**
  129635. * The current state of the timer
  129636. */
  129637. export enum TimerState {
  129638. /**
  129639. * Timer initialized, not yet started
  129640. */
  129641. INIT = 0,
  129642. /**
  129643. * Timer started and counting
  129644. */
  129645. STARTED = 1,
  129646. /**
  129647. * Timer ended (whether aborted or time reached)
  129648. */
  129649. ENDED = 2
  129650. }
  129651. /**
  129652. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129653. *
  129654. * @param options options with which to initialize this timer
  129655. */
  129656. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129657. /**
  129658. * An advanced implementation of a timer class
  129659. */
  129660. export class AdvancedTimer<T = any> implements IDisposable {
  129661. /**
  129662. * Will notify each time the timer calculates the remaining time
  129663. */
  129664. onEachCountObservable: Observable<ITimerData<T>>;
  129665. /**
  129666. * Will trigger when the timer was aborted due to the break condition
  129667. */
  129668. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129669. /**
  129670. * Will trigger when the timer ended successfully
  129671. */
  129672. onTimerEndedObservable: Observable<ITimerData<T>>;
  129673. /**
  129674. * Will trigger when the timer state has changed
  129675. */
  129676. onStateChangedObservable: Observable<TimerState>;
  129677. private _observer;
  129678. private _contextObservable;
  129679. private _observableParameters;
  129680. private _startTime;
  129681. private _timer;
  129682. private _state;
  129683. private _breakCondition;
  129684. private _timeToEnd;
  129685. private _breakOnNextTick;
  129686. /**
  129687. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129688. * @param options construction options for this advanced timer
  129689. */
  129690. constructor(options: ITimerOptions<T>);
  129691. /**
  129692. * set a breaking condition for this timer. Default is to never break during count
  129693. * @param predicate the new break condition. Returns true to break, false otherwise
  129694. */
  129695. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129696. /**
  129697. * Reset ALL associated observables in this advanced timer
  129698. */
  129699. clearObservables(): void;
  129700. /**
  129701. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129702. *
  129703. * @param timeToEnd how much time to measure until timer ended
  129704. */
  129705. start(timeToEnd?: number): void;
  129706. /**
  129707. * Will force a stop on the next tick.
  129708. */
  129709. stop(): void;
  129710. /**
  129711. * Dispose this timer, clearing all resources
  129712. */
  129713. dispose(): void;
  129714. private _setState;
  129715. private _tick;
  129716. private _stop;
  129717. }
  129718. }
  129719. declare module BABYLON {
  129720. /**
  129721. * The options container for the teleportation module
  129722. */
  129723. export interface IWebXRTeleportationOptions {
  129724. /**
  129725. * if provided, this scene will be used to render meshes.
  129726. */
  129727. customUtilityLayerScene?: Scene;
  129728. /**
  129729. * Values to configure the default target mesh
  129730. */
  129731. defaultTargetMeshOptions?: {
  129732. /**
  129733. * Fill color of the teleportation area
  129734. */
  129735. teleportationFillColor?: string;
  129736. /**
  129737. * Border color for the teleportation area
  129738. */
  129739. teleportationBorderColor?: string;
  129740. /**
  129741. * Disable the mesh's animation sequence
  129742. */
  129743. disableAnimation?: boolean;
  129744. /**
  129745. * Disable lighting on the material or the ring and arrow
  129746. */
  129747. disableLighting?: boolean;
  129748. /**
  129749. * Override the default material of the torus and arrow
  129750. */
  129751. torusArrowMaterial?: Material;
  129752. };
  129753. /**
  129754. * A list of meshes to use as floor meshes.
  129755. * Meshes can be added and removed after initializing the feature using the
  129756. * addFloorMesh and removeFloorMesh functions
  129757. * If empty, rotation will still work
  129758. */
  129759. floorMeshes?: AbstractMesh[];
  129760. /**
  129761. * use this rendering group id for the meshes (optional)
  129762. */
  129763. renderingGroupId?: number;
  129764. /**
  129765. * Should teleportation move only to snap points
  129766. */
  129767. snapPointsOnly?: boolean;
  129768. /**
  129769. * An array of points to which the teleportation will snap to.
  129770. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129771. */
  129772. snapPositions?: Vector3[];
  129773. /**
  129774. * How close should the teleportation ray be in order to snap to position.
  129775. * Default to 0.8 units (meters)
  129776. */
  129777. snapToPositionRadius?: number;
  129778. /**
  129779. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129780. * If you want to support rotation, make sure your mesh has a direction indicator.
  129781. *
  129782. * When left untouched, the default mesh will be initialized.
  129783. */
  129784. teleportationTargetMesh?: AbstractMesh;
  129785. /**
  129786. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129787. */
  129788. timeToTeleport?: number;
  129789. /**
  129790. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129791. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129792. */
  129793. useMainComponentOnly?: boolean;
  129794. /**
  129795. * Should meshes created here be added to a utility layer or the main scene
  129796. */
  129797. useUtilityLayer?: boolean;
  129798. /**
  129799. * Babylon XR Input class for controller
  129800. */
  129801. xrInput: WebXRInput;
  129802. /**
  129803. * Meshes that the teleportation ray cannot go through
  129804. */
  129805. pickBlockerMeshes?: AbstractMesh[];
  129806. }
  129807. /**
  129808. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129809. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129810. * the input of the attached controllers.
  129811. */
  129812. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129813. private _options;
  129814. private _controllers;
  129815. private _currentTeleportationControllerId;
  129816. private _floorMeshes;
  129817. private _quadraticBezierCurve;
  129818. private _selectionFeature;
  129819. private _snapToPositions;
  129820. private _snappedToPoint;
  129821. private _teleportationRingMaterial?;
  129822. private _tmpRay;
  129823. private _tmpVector;
  129824. private _tmpQuaternion;
  129825. /**
  129826. * The module's name
  129827. */
  129828. static readonly Name: string;
  129829. /**
  129830. * The (Babylon) version of this module.
  129831. * This is an integer representing the implementation version.
  129832. * This number does not correspond to the webxr specs version
  129833. */
  129834. static readonly Version: number;
  129835. /**
  129836. * Is movement backwards enabled
  129837. */
  129838. backwardsMovementEnabled: boolean;
  129839. /**
  129840. * Distance to travel when moving backwards
  129841. */
  129842. backwardsTeleportationDistance: number;
  129843. /**
  129844. * The distance from the user to the inspection point in the direction of the controller
  129845. * A higher number will allow the user to move further
  129846. * defaults to 5 (meters, in xr units)
  129847. */
  129848. parabolicCheckRadius: number;
  129849. /**
  129850. * Should the module support parabolic ray on top of direct ray
  129851. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129852. * Very helpful when moving between floors / different heights
  129853. */
  129854. parabolicRayEnabled: boolean;
  129855. /**
  129856. * How much rotation should be applied when rotating right and left
  129857. */
  129858. rotationAngle: number;
  129859. /**
  129860. * Is rotation enabled when moving forward?
  129861. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129862. */
  129863. rotationEnabled: boolean;
  129864. /**
  129865. * constructs a new anchor system
  129866. * @param _xrSessionManager an instance of WebXRSessionManager
  129867. * @param _options configuration object for this feature
  129868. */
  129869. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129870. /**
  129871. * Get the snapPointsOnly flag
  129872. */
  129873. get snapPointsOnly(): boolean;
  129874. /**
  129875. * Sets the snapPointsOnly flag
  129876. * @param snapToPoints should teleportation be exclusively to snap points
  129877. */
  129878. set snapPointsOnly(snapToPoints: boolean);
  129879. /**
  129880. * Add a new mesh to the floor meshes array
  129881. * @param mesh the mesh to use as floor mesh
  129882. */
  129883. addFloorMesh(mesh: AbstractMesh): void;
  129884. /**
  129885. * Add a new snap-to point to fix teleportation to this position
  129886. * @param newSnapPoint The new Snap-To point
  129887. */
  129888. addSnapPoint(newSnapPoint: Vector3): void;
  129889. attach(): boolean;
  129890. detach(): boolean;
  129891. dispose(): void;
  129892. /**
  129893. * Remove a mesh from the floor meshes array
  129894. * @param mesh the mesh to remove
  129895. */
  129896. removeFloorMesh(mesh: AbstractMesh): void;
  129897. /**
  129898. * Remove a mesh from the floor meshes array using its name
  129899. * @param name the mesh name to remove
  129900. */
  129901. removeFloorMeshByName(name: string): void;
  129902. /**
  129903. * 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
  129904. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129905. * @returns was the point found and removed or not
  129906. */
  129907. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129908. /**
  129909. * This function sets a selection feature that will be disabled when
  129910. * the forward ray is shown and will be reattached when hidden.
  129911. * This is used to remove the selection rays when moving.
  129912. * @param selectionFeature the feature to disable when forward movement is enabled
  129913. */
  129914. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129915. protected _onXRFrame(_xrFrame: XRFrame): void;
  129916. private _attachController;
  129917. private _createDefaultTargetMesh;
  129918. private _detachController;
  129919. private _findClosestSnapPointWithRadius;
  129920. private _setTargetMeshPosition;
  129921. private _setTargetMeshVisibility;
  129922. private _showParabolicPath;
  129923. private _teleportForward;
  129924. }
  129925. }
  129926. declare module BABYLON {
  129927. /**
  129928. * Options for the default xr helper
  129929. */
  129930. export class WebXRDefaultExperienceOptions {
  129931. /**
  129932. * Enable or disable default UI to enter XR
  129933. */
  129934. disableDefaultUI?: boolean;
  129935. /**
  129936. * Should teleportation not initialize. defaults to false.
  129937. */
  129938. disableTeleportation?: boolean;
  129939. /**
  129940. * Floor meshes that will be used for teleport
  129941. */
  129942. floorMeshes?: Array<AbstractMesh>;
  129943. /**
  129944. * If set to true, the first frame will not be used to reset position
  129945. * The first frame is mainly used when copying transformation from the old camera
  129946. * Mainly used in AR
  129947. */
  129948. ignoreNativeCameraTransformation?: boolean;
  129949. /**
  129950. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129951. */
  129952. inputOptions?: IWebXRInputOptions;
  129953. /**
  129954. * optional configuration for the output canvas
  129955. */
  129956. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129957. /**
  129958. * optional UI options. This can be used among other to change session mode and reference space type
  129959. */
  129960. uiOptions?: WebXREnterExitUIOptions;
  129961. /**
  129962. * When loading teleportation and pointer select, use stable versions instead of latest.
  129963. */
  129964. useStablePlugins?: boolean;
  129965. /**
  129966. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129967. */
  129968. renderingGroupId?: number;
  129969. /**
  129970. * A list of optional features to init the session with
  129971. * If set to true, all features we support will be added
  129972. */
  129973. optionalFeatures?: boolean | string[];
  129974. }
  129975. /**
  129976. * Default experience which provides a similar setup to the previous webVRExperience
  129977. */
  129978. export class WebXRDefaultExperience {
  129979. /**
  129980. * Base experience
  129981. */
  129982. baseExperience: WebXRExperienceHelper;
  129983. /**
  129984. * Enables ui for entering/exiting xr
  129985. */
  129986. enterExitUI: WebXREnterExitUI;
  129987. /**
  129988. * Input experience extension
  129989. */
  129990. input: WebXRInput;
  129991. /**
  129992. * Enables laser pointer and selection
  129993. */
  129994. pointerSelection: WebXRControllerPointerSelection;
  129995. /**
  129996. * Default target xr should render to
  129997. */
  129998. renderTarget: WebXRRenderTarget;
  129999. /**
  130000. * Enables teleportation
  130001. */
  130002. teleportation: WebXRMotionControllerTeleportation;
  130003. private constructor();
  130004. /**
  130005. * Creates the default xr experience
  130006. * @param scene scene
  130007. * @param options options for basic configuration
  130008. * @returns resulting WebXRDefaultExperience
  130009. */
  130010. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130011. /**
  130012. * DIsposes of the experience helper
  130013. */
  130014. dispose(): void;
  130015. }
  130016. }
  130017. declare module BABYLON {
  130018. /**
  130019. * Options to modify the vr teleportation behavior.
  130020. */
  130021. export interface VRTeleportationOptions {
  130022. /**
  130023. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130024. */
  130025. floorMeshName?: string;
  130026. /**
  130027. * A list of meshes to be used as the teleportation floor. (default: empty)
  130028. */
  130029. floorMeshes?: Mesh[];
  130030. /**
  130031. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130032. */
  130033. teleportationMode?: number;
  130034. /**
  130035. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130036. */
  130037. teleportationTime?: number;
  130038. /**
  130039. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130040. */
  130041. teleportationSpeed?: number;
  130042. /**
  130043. * The easing function used in the animation or null for Linear. (default CircleEase)
  130044. */
  130045. easingFunction?: EasingFunction;
  130046. }
  130047. /**
  130048. * Options to modify the vr experience helper's behavior.
  130049. */
  130050. export interface VRExperienceHelperOptions extends WebVROptions {
  130051. /**
  130052. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130053. */
  130054. createDeviceOrientationCamera?: boolean;
  130055. /**
  130056. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130057. */
  130058. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130059. /**
  130060. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130061. */
  130062. laserToggle?: boolean;
  130063. /**
  130064. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130065. */
  130066. floorMeshes?: Mesh[];
  130067. /**
  130068. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130069. */
  130070. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130071. /**
  130072. * Defines if WebXR should be used instead of WebVR (if available)
  130073. */
  130074. useXR?: boolean;
  130075. }
  130076. /**
  130077. * Event containing information after VR has been entered
  130078. */
  130079. export class OnAfterEnteringVRObservableEvent {
  130080. /**
  130081. * If entering vr was successful
  130082. */
  130083. success: boolean;
  130084. }
  130085. /**
  130086. * Helps to quickly add VR support to an existing scene.
  130087. * See https://doc.babylonjs.com/how_to/webvr_helper
  130088. */
  130089. export class VRExperienceHelper {
  130090. /** Options to modify the vr experience helper's behavior. */
  130091. webVROptions: VRExperienceHelperOptions;
  130092. private _scene;
  130093. private _position;
  130094. private _btnVR;
  130095. private _btnVRDisplayed;
  130096. private _webVRsupported;
  130097. private _webVRready;
  130098. private _webVRrequesting;
  130099. private _webVRpresenting;
  130100. private _hasEnteredVR;
  130101. private _fullscreenVRpresenting;
  130102. private _inputElement;
  130103. private _webVRCamera;
  130104. private _vrDeviceOrientationCamera;
  130105. private _deviceOrientationCamera;
  130106. private _existingCamera;
  130107. private _onKeyDown;
  130108. private _onVrDisplayPresentChange;
  130109. private _onVRDisplayChanged;
  130110. private _onVRRequestPresentStart;
  130111. private _onVRRequestPresentComplete;
  130112. /**
  130113. * 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)
  130114. */
  130115. enableGazeEvenWhenNoPointerLock: boolean;
  130116. /**
  130117. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130118. */
  130119. exitVROnDoubleTap: boolean;
  130120. /**
  130121. * Observable raised right before entering VR.
  130122. */
  130123. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130124. /**
  130125. * Observable raised when entering VR has completed.
  130126. */
  130127. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130128. /**
  130129. * Observable raised when exiting VR.
  130130. */
  130131. onExitingVRObservable: Observable<VRExperienceHelper>;
  130132. /**
  130133. * Observable raised when controller mesh is loaded.
  130134. */
  130135. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130136. /** Return this.onEnteringVRObservable
  130137. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130138. */
  130139. get onEnteringVR(): Observable<VRExperienceHelper>;
  130140. /** Return this.onExitingVRObservable
  130141. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130142. */
  130143. get onExitingVR(): Observable<VRExperienceHelper>;
  130144. /** Return this.onControllerMeshLoadedObservable
  130145. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130146. */
  130147. get onControllerMeshLoaded(): Observable<WebVRController>;
  130148. private _rayLength;
  130149. private _useCustomVRButton;
  130150. private _teleportationRequested;
  130151. private _teleportActive;
  130152. private _floorMeshName;
  130153. private _floorMeshesCollection;
  130154. private _teleportationMode;
  130155. private _teleportationTime;
  130156. private _teleportationSpeed;
  130157. private _teleportationEasing;
  130158. private _rotationAllowed;
  130159. private _teleportBackwardsVector;
  130160. private _teleportationTarget;
  130161. private _isDefaultTeleportationTarget;
  130162. private _postProcessMove;
  130163. private _teleportationFillColor;
  130164. private _teleportationBorderColor;
  130165. private _rotationAngle;
  130166. private _haloCenter;
  130167. private _cameraGazer;
  130168. private _padSensibilityUp;
  130169. private _padSensibilityDown;
  130170. private _leftController;
  130171. private _rightController;
  130172. private _gazeColor;
  130173. private _laserColor;
  130174. private _pickedLaserColor;
  130175. private _pickedGazeColor;
  130176. /**
  130177. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130178. */
  130179. onNewMeshSelected: Observable<AbstractMesh>;
  130180. /**
  130181. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130182. * This observable will provide the mesh and the controller used to select the mesh
  130183. */
  130184. onMeshSelectedWithController: Observable<{
  130185. mesh: AbstractMesh;
  130186. controller: WebVRController;
  130187. }>;
  130188. /**
  130189. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130190. */
  130191. onNewMeshPicked: Observable<PickingInfo>;
  130192. private _circleEase;
  130193. /**
  130194. * Observable raised before camera teleportation
  130195. */
  130196. onBeforeCameraTeleport: Observable<Vector3>;
  130197. /**
  130198. * Observable raised after camera teleportation
  130199. */
  130200. onAfterCameraTeleport: Observable<Vector3>;
  130201. /**
  130202. * Observable raised when current selected mesh gets unselected
  130203. */
  130204. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130205. private _raySelectionPredicate;
  130206. /**
  130207. * To be optionaly changed by user to define custom ray selection
  130208. */
  130209. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130210. /**
  130211. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130212. */
  130213. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130214. /**
  130215. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130216. */
  130217. teleportationEnabled: boolean;
  130218. private _defaultHeight;
  130219. private _teleportationInitialized;
  130220. private _interactionsEnabled;
  130221. private _interactionsRequested;
  130222. private _displayGaze;
  130223. private _displayLaserPointer;
  130224. /**
  130225. * The mesh used to display where the user is going to teleport.
  130226. */
  130227. get teleportationTarget(): Mesh;
  130228. /**
  130229. * Sets the mesh to be used to display where the user is going to teleport.
  130230. */
  130231. set teleportationTarget(value: Mesh);
  130232. /**
  130233. * 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
  130234. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130235. * See https://doc.babylonjs.com/resources/baking_transformations
  130236. */
  130237. get gazeTrackerMesh(): Mesh;
  130238. set gazeTrackerMesh(value: Mesh);
  130239. /**
  130240. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130241. */
  130242. updateGazeTrackerScale: boolean;
  130243. /**
  130244. * If the gaze trackers color should be updated when selecting meshes
  130245. */
  130246. updateGazeTrackerColor: boolean;
  130247. /**
  130248. * If the controller laser color should be updated when selecting meshes
  130249. */
  130250. updateControllerLaserColor: boolean;
  130251. /**
  130252. * The gaze tracking mesh corresponding to the left controller
  130253. */
  130254. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130255. /**
  130256. * The gaze tracking mesh corresponding to the right controller
  130257. */
  130258. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130259. /**
  130260. * If the ray of the gaze should be displayed.
  130261. */
  130262. get displayGaze(): boolean;
  130263. /**
  130264. * Sets if the ray of the gaze should be displayed.
  130265. */
  130266. set displayGaze(value: boolean);
  130267. /**
  130268. * If the ray of the LaserPointer should be displayed.
  130269. */
  130270. get displayLaserPointer(): boolean;
  130271. /**
  130272. * Sets if the ray of the LaserPointer should be displayed.
  130273. */
  130274. set displayLaserPointer(value: boolean);
  130275. /**
  130276. * The deviceOrientationCamera used as the camera when not in VR.
  130277. */
  130278. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130279. /**
  130280. * Based on the current WebVR support, returns the current VR camera used.
  130281. */
  130282. get currentVRCamera(): Nullable<Camera>;
  130283. /**
  130284. * The webVRCamera which is used when in VR.
  130285. */
  130286. get webVRCamera(): WebVRFreeCamera;
  130287. /**
  130288. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130289. */
  130290. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130291. /**
  130292. * The html button that is used to trigger entering into VR.
  130293. */
  130294. get vrButton(): Nullable<HTMLButtonElement>;
  130295. private get _teleportationRequestInitiated();
  130296. /**
  130297. * Defines whether or not Pointer lock should be requested when switching to
  130298. * full screen.
  130299. */
  130300. requestPointerLockOnFullScreen: boolean;
  130301. /**
  130302. * If asking to force XR, this will be populated with the default xr experience
  130303. */
  130304. xr: WebXRDefaultExperience;
  130305. /**
  130306. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130307. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130308. */
  130309. xrTestDone: boolean;
  130310. /**
  130311. * Instantiates a VRExperienceHelper.
  130312. * Helps to quickly add VR support to an existing scene.
  130313. * @param scene The scene the VRExperienceHelper belongs to.
  130314. * @param webVROptions Options to modify the vr experience helper's behavior.
  130315. */
  130316. constructor(scene: Scene,
  130317. /** Options to modify the vr experience helper's behavior. */
  130318. webVROptions?: VRExperienceHelperOptions);
  130319. private completeVRInit;
  130320. private _onDefaultMeshLoaded;
  130321. private _onResize;
  130322. private _onFullscreenChange;
  130323. /**
  130324. * Gets a value indicating if we are currently in VR mode.
  130325. */
  130326. get isInVRMode(): boolean;
  130327. private onVrDisplayPresentChange;
  130328. private onVRDisplayChanged;
  130329. private moveButtonToBottomRight;
  130330. private displayVRButton;
  130331. private updateButtonVisibility;
  130332. private _cachedAngularSensibility;
  130333. /**
  130334. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130335. * Otherwise, will use the fullscreen API.
  130336. */
  130337. enterVR(): void;
  130338. /**
  130339. * Attempt to exit VR, or fullscreen.
  130340. */
  130341. exitVR(): void;
  130342. /**
  130343. * The position of the vr experience helper.
  130344. */
  130345. get position(): Vector3;
  130346. /**
  130347. * Sets the position of the vr experience helper.
  130348. */
  130349. set position(value: Vector3);
  130350. /**
  130351. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130352. */
  130353. enableInteractions(): void;
  130354. private get _noControllerIsActive();
  130355. private beforeRender;
  130356. private _isTeleportationFloor;
  130357. /**
  130358. * Adds a floor mesh to be used for teleportation.
  130359. * @param floorMesh the mesh to be used for teleportation.
  130360. */
  130361. addFloorMesh(floorMesh: Mesh): void;
  130362. /**
  130363. * Removes a floor mesh from being used for teleportation.
  130364. * @param floorMesh the mesh to be removed.
  130365. */
  130366. removeFloorMesh(floorMesh: Mesh): void;
  130367. /**
  130368. * Enables interactions and teleportation using the VR controllers and gaze.
  130369. * @param vrTeleportationOptions options to modify teleportation behavior.
  130370. */
  130371. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130372. private _onNewGamepadConnected;
  130373. private _tryEnableInteractionOnController;
  130374. private _onNewGamepadDisconnected;
  130375. private _enableInteractionOnController;
  130376. private _checkTeleportWithRay;
  130377. private _checkRotate;
  130378. private _checkTeleportBackwards;
  130379. private _enableTeleportationOnController;
  130380. private _createTeleportationCircles;
  130381. private _displayTeleportationTarget;
  130382. private _hideTeleportationTarget;
  130383. private _rotateCamera;
  130384. private _moveTeleportationSelectorTo;
  130385. private _workingVector;
  130386. private _workingQuaternion;
  130387. private _workingMatrix;
  130388. /**
  130389. * Time Constant Teleportation Mode
  130390. */
  130391. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130392. /**
  130393. * Speed Constant Teleportation Mode
  130394. */
  130395. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130396. /**
  130397. * Teleports the users feet to the desired location
  130398. * @param location The location where the user's feet should be placed
  130399. */
  130400. teleportCamera(location: Vector3): void;
  130401. private _convertNormalToDirectionOfRay;
  130402. private _castRayAndSelectObject;
  130403. private _notifySelectedMeshUnselected;
  130404. /**
  130405. * Permanently set new colors for the laser pointer
  130406. * @param color the new laser color
  130407. * @param pickedColor the new laser color when picked mesh detected
  130408. */
  130409. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130410. /**
  130411. * Set lighting enabled / disabled on the laser pointer of both controllers
  130412. * @param enabled should the lighting be enabled on the laser pointer
  130413. */
  130414. setLaserLightingState(enabled?: boolean): void;
  130415. /**
  130416. * Permanently set new colors for the gaze pointer
  130417. * @param color the new gaze color
  130418. * @param pickedColor the new gaze color when picked mesh detected
  130419. */
  130420. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130421. /**
  130422. * Sets the color of the laser ray from the vr controllers.
  130423. * @param color new color for the ray.
  130424. */
  130425. changeLaserColor(color: Color3): void;
  130426. /**
  130427. * Sets the color of the ray from the vr headsets gaze.
  130428. * @param color new color for the ray.
  130429. */
  130430. changeGazeColor(color: Color3): void;
  130431. /**
  130432. * Exits VR and disposes of the vr experience helper
  130433. */
  130434. dispose(): void;
  130435. /**
  130436. * Gets the name of the VRExperienceHelper class
  130437. * @returns "VRExperienceHelper"
  130438. */
  130439. getClassName(): string;
  130440. }
  130441. }
  130442. declare module BABYLON {
  130443. /**
  130444. * Contains an array of blocks representing the octree
  130445. */
  130446. export interface IOctreeContainer<T> {
  130447. /**
  130448. * Blocks within the octree
  130449. */
  130450. blocks: Array<OctreeBlock<T>>;
  130451. }
  130452. /**
  130453. * Class used to store a cell in an octree
  130454. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130455. */
  130456. export class OctreeBlock<T> {
  130457. /**
  130458. * Gets the content of the current block
  130459. */
  130460. entries: T[];
  130461. /**
  130462. * Gets the list of block children
  130463. */
  130464. blocks: Array<OctreeBlock<T>>;
  130465. private _depth;
  130466. private _maxDepth;
  130467. private _capacity;
  130468. private _minPoint;
  130469. private _maxPoint;
  130470. private _boundingVectors;
  130471. private _creationFunc;
  130472. /**
  130473. * Creates a new block
  130474. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130475. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130476. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130477. * @param depth defines the current depth of this block in the octree
  130478. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130479. * @param creationFunc defines a callback to call when an element is added to the block
  130480. */
  130481. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130482. /**
  130483. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130484. */
  130485. get capacity(): number;
  130486. /**
  130487. * Gets the minimum vector (in world space) of the block's bounding box
  130488. */
  130489. get minPoint(): Vector3;
  130490. /**
  130491. * Gets the maximum vector (in world space) of the block's bounding box
  130492. */
  130493. get maxPoint(): Vector3;
  130494. /**
  130495. * Add a new element to this block
  130496. * @param entry defines the element to add
  130497. */
  130498. addEntry(entry: T): void;
  130499. /**
  130500. * Remove an element from this block
  130501. * @param entry defines the element to remove
  130502. */
  130503. removeEntry(entry: T): void;
  130504. /**
  130505. * Add an array of elements to this block
  130506. * @param entries defines the array of elements to add
  130507. */
  130508. addEntries(entries: T[]): void;
  130509. /**
  130510. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130511. * @param frustumPlanes defines the frustum planes to test
  130512. * @param selection defines the array to store current content if selection is positive
  130513. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130514. */
  130515. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130516. /**
  130517. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130518. * @param sphereCenter defines the bounding sphere center
  130519. * @param sphereRadius defines the bounding sphere radius
  130520. * @param selection defines the array to store current content if selection is positive
  130521. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130522. */
  130523. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130524. /**
  130525. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130526. * @param ray defines the ray to test with
  130527. * @param selection defines the array to store current content if selection is positive
  130528. */
  130529. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130530. /**
  130531. * Subdivide the content into child blocks (this block will then be empty)
  130532. */
  130533. createInnerBlocks(): void;
  130534. /**
  130535. * @hidden
  130536. */
  130537. 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;
  130538. }
  130539. }
  130540. declare module BABYLON {
  130541. /**
  130542. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130543. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130544. */
  130545. export class Octree<T> {
  130546. /** 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.) */
  130547. maxDepth: number;
  130548. /**
  130549. * Blocks within the octree containing objects
  130550. */
  130551. blocks: Array<OctreeBlock<T>>;
  130552. /**
  130553. * Content stored in the octree
  130554. */
  130555. dynamicContent: T[];
  130556. private _maxBlockCapacity;
  130557. private _selectionContent;
  130558. private _creationFunc;
  130559. /**
  130560. * Creates a octree
  130561. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130562. * @param creationFunc function to be used to instatiate the octree
  130563. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130564. * @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.)
  130565. */
  130566. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130567. /** 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.) */
  130568. maxDepth?: number);
  130569. /**
  130570. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130571. * @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);
  130572. * @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);
  130573. * @param entries meshes to be added to the octree blocks
  130574. */
  130575. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130576. /**
  130577. * Adds a mesh to the octree
  130578. * @param entry Mesh to add to the octree
  130579. */
  130580. addMesh(entry: T): void;
  130581. /**
  130582. * Remove an element from the octree
  130583. * @param entry defines the element to remove
  130584. */
  130585. removeMesh(entry: T): void;
  130586. /**
  130587. * Selects an array of meshes within the frustum
  130588. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130589. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130590. * @returns array of meshes within the frustum
  130591. */
  130592. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130593. /**
  130594. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130595. * @param sphereCenter defines the bounding sphere center
  130596. * @param sphereRadius defines the bounding sphere radius
  130597. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130598. * @returns an array of objects that intersect the sphere
  130599. */
  130600. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130601. /**
  130602. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130603. * @param ray defines the ray to test with
  130604. * @returns array of intersected objects
  130605. */
  130606. intersectsRay(ray: Ray): SmartArray<T>;
  130607. /**
  130608. * Adds a mesh into the octree block if it intersects the block
  130609. */
  130610. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130611. /**
  130612. * Adds a submesh into the octree block if it intersects the block
  130613. */
  130614. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130615. }
  130616. }
  130617. declare module BABYLON {
  130618. interface Scene {
  130619. /**
  130620. * @hidden
  130621. * Backing Filed
  130622. */
  130623. _selectionOctree: Octree<AbstractMesh>;
  130624. /**
  130625. * Gets the octree used to boost mesh selection (picking)
  130626. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130627. */
  130628. selectionOctree: Octree<AbstractMesh>;
  130629. /**
  130630. * Creates or updates the octree used to boost selection (picking)
  130631. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130632. * @param maxCapacity defines the maximum capacity per leaf
  130633. * @param maxDepth defines the maximum depth of the octree
  130634. * @returns an octree of AbstractMesh
  130635. */
  130636. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130637. }
  130638. interface AbstractMesh {
  130639. /**
  130640. * @hidden
  130641. * Backing Field
  130642. */
  130643. _submeshesOctree: Octree<SubMesh>;
  130644. /**
  130645. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130646. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130647. * @param maxCapacity defines the maximum size of each block (64 by default)
  130648. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130649. * @returns the new octree
  130650. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130651. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130652. */
  130653. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130654. }
  130655. /**
  130656. * Defines the octree scene component responsible to manage any octrees
  130657. * in a given scene.
  130658. */
  130659. export class OctreeSceneComponent {
  130660. /**
  130661. * The component name help to identify the component in the list of scene components.
  130662. */
  130663. readonly name: string;
  130664. /**
  130665. * The scene the component belongs to.
  130666. */
  130667. scene: Scene;
  130668. /**
  130669. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130670. */
  130671. readonly checksIsEnabled: boolean;
  130672. /**
  130673. * Creates a new instance of the component for the given scene
  130674. * @param scene Defines the scene to register the component in
  130675. */
  130676. constructor(scene: Scene);
  130677. /**
  130678. * Registers the component in a given scene
  130679. */
  130680. register(): void;
  130681. /**
  130682. * Return the list of active meshes
  130683. * @returns the list of active meshes
  130684. */
  130685. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130686. /**
  130687. * Return the list of active sub meshes
  130688. * @param mesh The mesh to get the candidates sub meshes from
  130689. * @returns the list of active sub meshes
  130690. */
  130691. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130692. private _tempRay;
  130693. /**
  130694. * Return the list of sub meshes intersecting with a given local ray
  130695. * @param mesh defines the mesh to find the submesh for
  130696. * @param localRay defines the ray in local space
  130697. * @returns the list of intersecting sub meshes
  130698. */
  130699. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130700. /**
  130701. * Return the list of sub meshes colliding with a collider
  130702. * @param mesh defines the mesh to find the submesh for
  130703. * @param collider defines the collider to evaluate the collision against
  130704. * @returns the list of colliding sub meshes
  130705. */
  130706. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130707. /**
  130708. * Rebuilds the elements related to this component in case of
  130709. * context lost for instance.
  130710. */
  130711. rebuild(): void;
  130712. /**
  130713. * Disposes the component and the associated ressources.
  130714. */
  130715. dispose(): void;
  130716. }
  130717. }
  130718. declare module BABYLON {
  130719. /**
  130720. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130721. */
  130722. export class Gizmo implements IDisposable {
  130723. /** The utility layer the gizmo will be added to */
  130724. gizmoLayer: UtilityLayerRenderer;
  130725. /**
  130726. * The root mesh of the gizmo
  130727. */
  130728. _rootMesh: Mesh;
  130729. private _attachedMesh;
  130730. private _attachedNode;
  130731. /**
  130732. * Ratio for the scale of the gizmo (Default: 1)
  130733. */
  130734. protected _scaleRatio: number;
  130735. /**
  130736. * boolean updated by pointermove when a gizmo mesh is hovered
  130737. */
  130738. protected _isHovered: boolean;
  130739. /**
  130740. * Ratio for the scale of the gizmo (Default: 1)
  130741. */
  130742. set scaleRatio(value: number);
  130743. get scaleRatio(): number;
  130744. /**
  130745. * True when the mouse pointer is hovered a gizmo mesh
  130746. */
  130747. get isHovered(): boolean;
  130748. /**
  130749. * If a custom mesh has been set (Default: false)
  130750. */
  130751. protected _customMeshSet: boolean;
  130752. /**
  130753. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130754. * * When set, interactions will be enabled
  130755. */
  130756. get attachedMesh(): Nullable<AbstractMesh>;
  130757. set attachedMesh(value: Nullable<AbstractMesh>);
  130758. /**
  130759. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130760. * * When set, interactions will be enabled
  130761. */
  130762. get attachedNode(): Nullable<Node>;
  130763. set attachedNode(value: Nullable<Node>);
  130764. /**
  130765. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130766. * @param mesh The mesh to replace the default mesh of the gizmo
  130767. */
  130768. setCustomMesh(mesh: Mesh): void;
  130769. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130770. /**
  130771. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130772. */
  130773. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130774. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130775. /**
  130776. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130777. */
  130778. updateGizmoPositionToMatchAttachedMesh: boolean;
  130779. /**
  130780. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130781. */
  130782. updateScale: boolean;
  130783. protected _interactionsEnabled: boolean;
  130784. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130785. private _beforeRenderObserver;
  130786. private _tempQuaternion;
  130787. private _tempVector;
  130788. private _tempVector2;
  130789. private _tempMatrix1;
  130790. private _tempMatrix2;
  130791. private _rightHandtoLeftHandMatrix;
  130792. /**
  130793. * Creates a gizmo
  130794. * @param gizmoLayer The utility layer the gizmo will be added to
  130795. */
  130796. constructor(
  130797. /** The utility layer the gizmo will be added to */
  130798. gizmoLayer?: UtilityLayerRenderer);
  130799. /**
  130800. * Updates the gizmo to match the attached mesh's position/rotation
  130801. */
  130802. protected _update(): void;
  130803. /**
  130804. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130805. * @param value Node, TransformNode or mesh
  130806. */
  130807. protected _matrixChanged(): void;
  130808. /**
  130809. * Disposes of the gizmo
  130810. */
  130811. dispose(): void;
  130812. }
  130813. }
  130814. declare module BABYLON {
  130815. /**
  130816. * Single plane drag gizmo
  130817. */
  130818. export class PlaneDragGizmo extends Gizmo {
  130819. /**
  130820. * Drag behavior responsible for the gizmos dragging interactions
  130821. */
  130822. dragBehavior: PointerDragBehavior;
  130823. private _pointerObserver;
  130824. /**
  130825. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130826. */
  130827. snapDistance: number;
  130828. /**
  130829. * Event that fires each time the gizmo snaps to a new location.
  130830. * * snapDistance is the the change in distance
  130831. */
  130832. onSnapObservable: Observable<{
  130833. snapDistance: number;
  130834. }>;
  130835. private _plane;
  130836. private _coloredMaterial;
  130837. private _hoverMaterial;
  130838. private _isEnabled;
  130839. private _parent;
  130840. /** @hidden */
  130841. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130842. /** @hidden */
  130843. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130844. /**
  130845. * Creates a PlaneDragGizmo
  130846. * @param gizmoLayer The utility layer the gizmo will be added to
  130847. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130848. * @param color The color of the gizmo
  130849. */
  130850. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130851. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130852. /**
  130853. * If the gizmo is enabled
  130854. */
  130855. set isEnabled(value: boolean);
  130856. get isEnabled(): boolean;
  130857. /**
  130858. * Disposes of the gizmo
  130859. */
  130860. dispose(): void;
  130861. }
  130862. }
  130863. declare module BABYLON {
  130864. /**
  130865. * Gizmo that enables dragging a mesh along 3 axis
  130866. */
  130867. export class PositionGizmo extends Gizmo {
  130868. /**
  130869. * Internal gizmo used for interactions on the x axis
  130870. */
  130871. xGizmo: AxisDragGizmo;
  130872. /**
  130873. * Internal gizmo used for interactions on the y axis
  130874. */
  130875. yGizmo: AxisDragGizmo;
  130876. /**
  130877. * Internal gizmo used for interactions on the z axis
  130878. */
  130879. zGizmo: AxisDragGizmo;
  130880. /**
  130881. * Internal gizmo used for interactions on the yz plane
  130882. */
  130883. xPlaneGizmo: PlaneDragGizmo;
  130884. /**
  130885. * Internal gizmo used for interactions on the xz plane
  130886. */
  130887. yPlaneGizmo: PlaneDragGizmo;
  130888. /**
  130889. * Internal gizmo used for interactions on the xy plane
  130890. */
  130891. zPlaneGizmo: PlaneDragGizmo;
  130892. /**
  130893. * private variables
  130894. */
  130895. private _meshAttached;
  130896. private _nodeAttached;
  130897. private _snapDistance;
  130898. /** Fires an event when any of it's sub gizmos are dragged */
  130899. onDragStartObservable: Observable<unknown>;
  130900. /** Fires an event when any of it's sub gizmos are released from dragging */
  130901. onDragEndObservable: Observable<unknown>;
  130902. /**
  130903. * If set to true, planar drag is enabled
  130904. */
  130905. private _planarGizmoEnabled;
  130906. get attachedMesh(): Nullable<AbstractMesh>;
  130907. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130908. get attachedNode(): Nullable<Node>;
  130909. set attachedNode(node: Nullable<Node>);
  130910. /**
  130911. * True when the mouse pointer is hovering a gizmo mesh
  130912. */
  130913. get isHovered(): boolean;
  130914. /**
  130915. * Creates a PositionGizmo
  130916. * @param gizmoLayer The utility layer the gizmo will be added to
  130917. @param thickness display gizmo axis thickness
  130918. */
  130919. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130920. /**
  130921. * If the planar drag gizmo is enabled
  130922. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130923. */
  130924. set planarGizmoEnabled(value: boolean);
  130925. get planarGizmoEnabled(): boolean;
  130926. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130927. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130928. /**
  130929. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130930. */
  130931. set snapDistance(value: number);
  130932. get snapDistance(): number;
  130933. /**
  130934. * Ratio for the scale of the gizmo (Default: 1)
  130935. */
  130936. set scaleRatio(value: number);
  130937. get scaleRatio(): number;
  130938. /**
  130939. * Disposes of the gizmo
  130940. */
  130941. dispose(): void;
  130942. /**
  130943. * CustomMeshes are not supported by this gizmo
  130944. * @param mesh The mesh to replace the default mesh of the gizmo
  130945. */
  130946. setCustomMesh(mesh: Mesh): void;
  130947. }
  130948. }
  130949. declare module BABYLON {
  130950. /**
  130951. * Single axis drag gizmo
  130952. */
  130953. export class AxisDragGizmo extends Gizmo {
  130954. /**
  130955. * Drag behavior responsible for the gizmos dragging interactions
  130956. */
  130957. dragBehavior: PointerDragBehavior;
  130958. private _pointerObserver;
  130959. /**
  130960. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130961. */
  130962. snapDistance: number;
  130963. /**
  130964. * Event that fires each time the gizmo snaps to a new location.
  130965. * * snapDistance is the the change in distance
  130966. */
  130967. onSnapObservable: Observable<{
  130968. snapDistance: number;
  130969. }>;
  130970. private _isEnabled;
  130971. private _parent;
  130972. private _arrow;
  130973. private _coloredMaterial;
  130974. private _hoverMaterial;
  130975. /** @hidden */
  130976. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130977. /** @hidden */
  130978. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130979. /**
  130980. * Creates an AxisDragGizmo
  130981. * @param gizmoLayer The utility layer the gizmo will be added to
  130982. * @param dragAxis The axis which the gizmo will be able to drag on
  130983. * @param color The color of the gizmo
  130984. * @param thickness display gizmo axis thickness
  130985. */
  130986. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130987. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130988. /**
  130989. * If the gizmo is enabled
  130990. */
  130991. set isEnabled(value: boolean);
  130992. get isEnabled(): boolean;
  130993. /**
  130994. * Disposes of the gizmo
  130995. */
  130996. dispose(): void;
  130997. }
  130998. }
  130999. declare module BABYLON.Debug {
  131000. /**
  131001. * The Axes viewer will show 3 axes in a specific point in space
  131002. */
  131003. export class AxesViewer {
  131004. private _xAxis;
  131005. private _yAxis;
  131006. private _zAxis;
  131007. private _scaleLinesFactor;
  131008. private _instanced;
  131009. /**
  131010. * Gets the hosting scene
  131011. */
  131012. scene: Nullable<Scene>;
  131013. /**
  131014. * Gets or sets a number used to scale line length
  131015. */
  131016. scaleLines: number;
  131017. /** Gets the node hierarchy used to render x-axis */
  131018. get xAxis(): TransformNode;
  131019. /** Gets the node hierarchy used to render y-axis */
  131020. get yAxis(): TransformNode;
  131021. /** Gets the node hierarchy used to render z-axis */
  131022. get zAxis(): TransformNode;
  131023. /**
  131024. * Creates a new AxesViewer
  131025. * @param scene defines the hosting scene
  131026. * @param scaleLines defines a number used to scale line length (1 by default)
  131027. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131028. * @param xAxis defines the node hierarchy used to render the x-axis
  131029. * @param yAxis defines the node hierarchy used to render the y-axis
  131030. * @param zAxis defines the node hierarchy used to render the z-axis
  131031. */
  131032. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131033. /**
  131034. * Force the viewer to update
  131035. * @param position defines the position of the viewer
  131036. * @param xaxis defines the x axis of the viewer
  131037. * @param yaxis defines the y axis of the viewer
  131038. * @param zaxis defines the z axis of the viewer
  131039. */
  131040. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131041. /**
  131042. * Creates an instance of this axes viewer.
  131043. * @returns a new axes viewer with instanced meshes
  131044. */
  131045. createInstance(): AxesViewer;
  131046. /** Releases resources */
  131047. dispose(): void;
  131048. private static _SetRenderingGroupId;
  131049. }
  131050. }
  131051. declare module BABYLON.Debug {
  131052. /**
  131053. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131054. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131055. */
  131056. export class BoneAxesViewer extends AxesViewer {
  131057. /**
  131058. * Gets or sets the target mesh where to display the axes viewer
  131059. */
  131060. mesh: Nullable<Mesh>;
  131061. /**
  131062. * Gets or sets the target bone where to display the axes viewer
  131063. */
  131064. bone: Nullable<Bone>;
  131065. /** Gets current position */
  131066. pos: Vector3;
  131067. /** Gets direction of X axis */
  131068. xaxis: Vector3;
  131069. /** Gets direction of Y axis */
  131070. yaxis: Vector3;
  131071. /** Gets direction of Z axis */
  131072. zaxis: Vector3;
  131073. /**
  131074. * Creates a new BoneAxesViewer
  131075. * @param scene defines the hosting scene
  131076. * @param bone defines the target bone
  131077. * @param mesh defines the target mesh
  131078. * @param scaleLines defines a scaling factor for line length (1 by default)
  131079. */
  131080. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131081. /**
  131082. * Force the viewer to update
  131083. */
  131084. update(): void;
  131085. /** Releases resources */
  131086. dispose(): void;
  131087. }
  131088. }
  131089. declare module BABYLON {
  131090. /**
  131091. * Interface used to define scene explorer extensibility option
  131092. */
  131093. export interface IExplorerExtensibilityOption {
  131094. /**
  131095. * Define the option label
  131096. */
  131097. label: string;
  131098. /**
  131099. * Defines the action to execute on click
  131100. */
  131101. action: (entity: any) => void;
  131102. }
  131103. /**
  131104. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131105. */
  131106. export interface IExplorerExtensibilityGroup {
  131107. /**
  131108. * Defines a predicate to test if a given type mut be extended
  131109. */
  131110. predicate: (entity: any) => boolean;
  131111. /**
  131112. * Gets the list of options added to a type
  131113. */
  131114. entries: IExplorerExtensibilityOption[];
  131115. }
  131116. /**
  131117. * Interface used to define the options to use to create the Inspector
  131118. */
  131119. export interface IInspectorOptions {
  131120. /**
  131121. * Display in overlay mode (default: false)
  131122. */
  131123. overlay?: boolean;
  131124. /**
  131125. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131126. */
  131127. globalRoot?: HTMLElement;
  131128. /**
  131129. * Display the Scene explorer
  131130. */
  131131. showExplorer?: boolean;
  131132. /**
  131133. * Display the property inspector
  131134. */
  131135. showInspector?: boolean;
  131136. /**
  131137. * Display in embed mode (both panes on the right)
  131138. */
  131139. embedMode?: boolean;
  131140. /**
  131141. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131142. */
  131143. handleResize?: boolean;
  131144. /**
  131145. * Allow the panes to popup (default: true)
  131146. */
  131147. enablePopup?: boolean;
  131148. /**
  131149. * Allow the panes to be closed by users (default: true)
  131150. */
  131151. enableClose?: boolean;
  131152. /**
  131153. * Optional list of extensibility entries
  131154. */
  131155. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131156. /**
  131157. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131158. */
  131159. inspectorURL?: string;
  131160. /**
  131161. * Optional initial tab (default to DebugLayerTab.Properties)
  131162. */
  131163. initialTab?: DebugLayerTab;
  131164. }
  131165. interface Scene {
  131166. /**
  131167. * @hidden
  131168. * Backing field
  131169. */
  131170. _debugLayer: DebugLayer;
  131171. /**
  131172. * Gets the debug layer (aka Inspector) associated with the scene
  131173. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131174. */
  131175. debugLayer: DebugLayer;
  131176. }
  131177. /**
  131178. * Enum of inspector action tab
  131179. */
  131180. export enum DebugLayerTab {
  131181. /**
  131182. * Properties tag (default)
  131183. */
  131184. Properties = 0,
  131185. /**
  131186. * Debug tab
  131187. */
  131188. Debug = 1,
  131189. /**
  131190. * Statistics tab
  131191. */
  131192. Statistics = 2,
  131193. /**
  131194. * Tools tab
  131195. */
  131196. Tools = 3,
  131197. /**
  131198. * Settings tab
  131199. */
  131200. Settings = 4
  131201. }
  131202. /**
  131203. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131204. * what is happening in your scene
  131205. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131206. */
  131207. export class DebugLayer {
  131208. /**
  131209. * Define the url to get the inspector script from.
  131210. * By default it uses the babylonjs CDN.
  131211. * @ignoreNaming
  131212. */
  131213. static InspectorURL: string;
  131214. private _scene;
  131215. private BJSINSPECTOR;
  131216. private _onPropertyChangedObservable?;
  131217. /**
  131218. * Observable triggered when a property is changed through the inspector.
  131219. */
  131220. get onPropertyChangedObservable(): any;
  131221. /**
  131222. * Instantiates a new debug layer.
  131223. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131224. * what is happening in your scene
  131225. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131226. * @param scene Defines the scene to inspect
  131227. */
  131228. constructor(scene: Scene);
  131229. /** Creates the inspector window. */
  131230. private _createInspector;
  131231. /**
  131232. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131233. * @param entity defines the entity to select
  131234. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131235. */
  131236. select(entity: any, lineContainerTitles?: string | string[]): void;
  131237. /** Get the inspector from bundle or global */
  131238. private _getGlobalInspector;
  131239. /**
  131240. * Get if the inspector is visible or not.
  131241. * @returns true if visible otherwise, false
  131242. */
  131243. isVisible(): boolean;
  131244. /**
  131245. * Hide the inspector and close its window.
  131246. */
  131247. hide(): void;
  131248. /**
  131249. * Update the scene in the inspector
  131250. */
  131251. setAsActiveScene(): void;
  131252. /**
  131253. * Launch the debugLayer.
  131254. * @param config Define the configuration of the inspector
  131255. * @return a promise fulfilled when the debug layer is visible
  131256. */
  131257. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131258. }
  131259. }
  131260. declare module BABYLON {
  131261. /**
  131262. * Class containing static functions to help procedurally build meshes
  131263. */
  131264. export class BoxBuilder {
  131265. /**
  131266. * Creates a box mesh
  131267. * * The parameter `size` sets the size (float) of each box side (default 1)
  131268. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131269. * * 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)
  131270. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131274. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131275. * @param name defines the name of the mesh
  131276. * @param options defines the options used to create the mesh
  131277. * @param scene defines the hosting scene
  131278. * @returns the box mesh
  131279. */
  131280. static CreateBox(name: string, options: {
  131281. size?: number;
  131282. width?: number;
  131283. height?: number;
  131284. depth?: number;
  131285. faceUV?: Vector4[];
  131286. faceColors?: Color4[];
  131287. sideOrientation?: number;
  131288. frontUVs?: Vector4;
  131289. backUVs?: Vector4;
  131290. wrap?: boolean;
  131291. topBaseAt?: number;
  131292. bottomBaseAt?: number;
  131293. updatable?: boolean;
  131294. }, scene?: Nullable<Scene>): Mesh;
  131295. }
  131296. }
  131297. declare module BABYLON.Debug {
  131298. /**
  131299. * Used to show the physics impostor around the specific mesh
  131300. */
  131301. export class PhysicsViewer {
  131302. /** @hidden */
  131303. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131304. /** @hidden */
  131305. protected _meshes: Array<Nullable<AbstractMesh>>;
  131306. /** @hidden */
  131307. protected _scene: Nullable<Scene>;
  131308. /** @hidden */
  131309. protected _numMeshes: number;
  131310. /** @hidden */
  131311. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131312. private _renderFunction;
  131313. private _utilityLayer;
  131314. private _debugBoxMesh;
  131315. private _debugSphereMesh;
  131316. private _debugCylinderMesh;
  131317. private _debugMaterial;
  131318. private _debugMeshMeshes;
  131319. /**
  131320. * Creates a new PhysicsViewer
  131321. * @param scene defines the hosting scene
  131322. */
  131323. constructor(scene: Scene);
  131324. /** @hidden */
  131325. protected _updateDebugMeshes(): void;
  131326. /**
  131327. * Renders a specified physic impostor
  131328. * @param impostor defines the impostor to render
  131329. * @param targetMesh defines the mesh represented by the impostor
  131330. * @returns the new debug mesh used to render the impostor
  131331. */
  131332. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131333. /**
  131334. * Hides a specified physic impostor
  131335. * @param impostor defines the impostor to hide
  131336. */
  131337. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131338. private _getDebugMaterial;
  131339. private _getDebugBoxMesh;
  131340. private _getDebugSphereMesh;
  131341. private _getDebugCylinderMesh;
  131342. private _getDebugMeshMesh;
  131343. private _getDebugMesh;
  131344. /** Releases all resources */
  131345. dispose(): void;
  131346. }
  131347. }
  131348. declare module BABYLON {
  131349. /**
  131350. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131351. * in order to better appreciate the issue one might have.
  131352. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131353. */
  131354. export class RayHelper {
  131355. /**
  131356. * Defines the ray we are currently tryin to visualize.
  131357. */
  131358. ray: Nullable<Ray>;
  131359. private _renderPoints;
  131360. private _renderLine;
  131361. private _renderFunction;
  131362. private _scene;
  131363. private _onAfterRenderObserver;
  131364. private _onAfterStepObserver;
  131365. private _attachedToMesh;
  131366. private _meshSpaceDirection;
  131367. private _meshSpaceOrigin;
  131368. /**
  131369. * Helper function to create a colored helper in a scene in one line.
  131370. * @param ray Defines the ray we are currently tryin to visualize
  131371. * @param scene Defines the scene the ray is used in
  131372. * @param color Defines the color we want to see the ray in
  131373. * @returns The newly created ray helper.
  131374. */
  131375. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131376. /**
  131377. * Instantiate a new ray helper.
  131378. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131379. * in order to better appreciate the issue one might have.
  131380. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131381. * @param ray Defines the ray we are currently tryin to visualize
  131382. */
  131383. constructor(ray: Ray);
  131384. /**
  131385. * Shows the ray we are willing to debug.
  131386. * @param scene Defines the scene the ray needs to be rendered in
  131387. * @param color Defines the color the ray needs to be rendered in
  131388. */
  131389. show(scene: Scene, color?: Color3): void;
  131390. /**
  131391. * Hides the ray we are debugging.
  131392. */
  131393. hide(): void;
  131394. private _render;
  131395. /**
  131396. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131397. * @param mesh Defines the mesh we want the helper attached to
  131398. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131399. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131400. * @param length Defines the length of the ray
  131401. */
  131402. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131403. /**
  131404. * Detach the ray helper from the mesh it has previously been attached to.
  131405. */
  131406. detachFromMesh(): void;
  131407. private _updateToMesh;
  131408. /**
  131409. * Dispose the helper and release its associated resources.
  131410. */
  131411. dispose(): void;
  131412. }
  131413. }
  131414. declare module BABYLON {
  131415. /**
  131416. * Defines the options associated with the creation of a SkeletonViewer.
  131417. */
  131418. export interface ISkeletonViewerOptions {
  131419. /** Should the system pause animations before building the Viewer? */
  131420. pauseAnimations: boolean;
  131421. /** Should the system return the skeleton to rest before building? */
  131422. returnToRest: boolean;
  131423. /** public Display Mode of the Viewer */
  131424. displayMode: number;
  131425. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131426. displayOptions: ISkeletonViewerDisplayOptions;
  131427. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131428. computeBonesUsingShaders: boolean;
  131429. /** Flag ignore non weighted bones */
  131430. useAllBones: boolean;
  131431. }
  131432. /**
  131433. * Defines how to display the various bone meshes for the viewer.
  131434. */
  131435. export interface ISkeletonViewerDisplayOptions {
  131436. /** How far down to start tapering the bone spurs */
  131437. midStep?: number;
  131438. /** How big is the midStep? */
  131439. midStepFactor?: number;
  131440. /** Base for the Sphere Size */
  131441. sphereBaseSize?: number;
  131442. /** The ratio of the sphere to the longest bone in units */
  131443. sphereScaleUnit?: number;
  131444. /** Ratio for the Sphere Size */
  131445. sphereFactor?: number;
  131446. /** Whether to show local axes or not */
  131447. showLocalAxes?: boolean;
  131448. /** Length of each local axis */
  131449. localAxesSize?: number;
  131450. }
  131451. /**
  131452. * Defines the constructor options for the BoneWeight Shader.
  131453. */
  131454. export interface IBoneWeightShaderOptions {
  131455. /** Skeleton to Map */
  131456. skeleton: Skeleton;
  131457. /** Colors for Uninfluenced bones */
  131458. colorBase?: Color3;
  131459. /** Colors for 0.0-0.25 Weight bones */
  131460. colorZero?: Color3;
  131461. /** Color for 0.25-0.5 Weight Influence */
  131462. colorQuarter?: Color3;
  131463. /** Color for 0.5-0.75 Weight Influence */
  131464. colorHalf?: Color3;
  131465. /** Color for 0.75-1 Weight Influence */
  131466. colorFull?: Color3;
  131467. /** Color for Zero Weight Influence */
  131468. targetBoneIndex?: number;
  131469. }
  131470. /**
  131471. * Simple structure of the gradient steps for the Color Map.
  131472. */
  131473. export interface ISkeletonMapShaderColorMapKnot {
  131474. /** Color of the Knot */
  131475. color: Color3;
  131476. /** Location of the Knot */
  131477. location: number;
  131478. }
  131479. /**
  131480. * Defines the constructor options for the SkeletonMap Shader.
  131481. */
  131482. export interface ISkeletonMapShaderOptions {
  131483. /** Skeleton to Map */
  131484. skeleton: Skeleton;
  131485. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131486. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131487. }
  131488. }
  131489. declare module BABYLON {
  131490. /**
  131491. * Class containing static functions to help procedurally build meshes
  131492. */
  131493. export class RibbonBuilder {
  131494. /**
  131495. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131496. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131497. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131498. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131499. * * 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
  131500. * * 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
  131501. * * 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
  131502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131505. * * 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
  131506. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131507. * * 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
  131508. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131510. * @param name defines the name of the mesh
  131511. * @param options defines the options used to create the mesh
  131512. * @param scene defines the hosting scene
  131513. * @returns the ribbon mesh
  131514. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131516. */
  131517. static CreateRibbon(name: string, options: {
  131518. pathArray: Vector3[][];
  131519. closeArray?: boolean;
  131520. closePath?: boolean;
  131521. offset?: number;
  131522. updatable?: boolean;
  131523. sideOrientation?: number;
  131524. frontUVs?: Vector4;
  131525. backUVs?: Vector4;
  131526. instance?: Mesh;
  131527. invertUV?: boolean;
  131528. uvs?: Vector2[];
  131529. colors?: Color4[];
  131530. }, scene?: Nullable<Scene>): Mesh;
  131531. }
  131532. }
  131533. declare module BABYLON {
  131534. /**
  131535. * Class containing static functions to help procedurally build meshes
  131536. */
  131537. export class ShapeBuilder {
  131538. /**
  131539. * 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.
  131540. * * 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.
  131541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131542. * * 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.
  131543. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131544. * * 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
  131545. * * 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
  131546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131551. * @param name defines the name of the mesh
  131552. * @param options defines the options used to create the mesh
  131553. * @param scene defines the hosting scene
  131554. * @returns the extruded shape mesh
  131555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131557. */
  131558. static ExtrudeShape(name: string, options: {
  131559. shape: Vector3[];
  131560. path: Vector3[];
  131561. scale?: number;
  131562. rotation?: number;
  131563. cap?: number;
  131564. updatable?: boolean;
  131565. sideOrientation?: number;
  131566. frontUVs?: Vector4;
  131567. backUVs?: Vector4;
  131568. instance?: Mesh;
  131569. invertUV?: boolean;
  131570. }, scene?: Nullable<Scene>): Mesh;
  131571. /**
  131572. * Creates an custom extruded shape mesh.
  131573. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131574. * * 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.
  131575. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131576. * * 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
  131577. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131578. * * 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
  131579. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131580. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131581. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131582. * * 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
  131583. * * 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
  131584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131589. * @param name defines the name of the mesh
  131590. * @param options defines the options used to create the mesh
  131591. * @param scene defines the hosting scene
  131592. * @returns the custom extruded shape mesh
  131593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131596. */
  131597. static ExtrudeShapeCustom(name: string, options: {
  131598. shape: Vector3[];
  131599. path: Vector3[];
  131600. scaleFunction?: any;
  131601. rotationFunction?: any;
  131602. ribbonCloseArray?: boolean;
  131603. ribbonClosePath?: boolean;
  131604. cap?: number;
  131605. updatable?: boolean;
  131606. sideOrientation?: number;
  131607. frontUVs?: Vector4;
  131608. backUVs?: Vector4;
  131609. instance?: Mesh;
  131610. invertUV?: boolean;
  131611. }, scene?: Nullable<Scene>): Mesh;
  131612. private static _ExtrudeShapeGeneric;
  131613. }
  131614. }
  131615. declare module BABYLON.Debug {
  131616. /**
  131617. * Class used to render a debug view of a given skeleton
  131618. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131619. */
  131620. export class SkeletonViewer {
  131621. /** defines the skeleton to render */
  131622. skeleton: Skeleton;
  131623. /** defines the mesh attached to the skeleton */
  131624. mesh: AbstractMesh;
  131625. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131626. autoUpdateBonesMatrices: boolean;
  131627. /** defines the rendering group id to use with the viewer */
  131628. renderingGroupId: number;
  131629. /** is the options for the viewer */
  131630. options: Partial<ISkeletonViewerOptions>;
  131631. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131632. static readonly DISPLAY_LINES: number;
  131633. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131634. static readonly DISPLAY_SPHERES: number;
  131635. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131636. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131637. /** public static method to create a BoneWeight Shader
  131638. * @param options The constructor options
  131639. * @param scene The scene that the shader is scoped to
  131640. * @returns The created ShaderMaterial
  131641. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131642. */
  131643. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131644. /** public static method to create a BoneWeight Shader
  131645. * @param options The constructor options
  131646. * @param scene The scene that the shader is scoped to
  131647. * @returns The created ShaderMaterial
  131648. */
  131649. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131650. /** private static method to create a BoneWeight Shader
  131651. * @param size The size of the buffer to create (usually the bone count)
  131652. * @param colorMap The gradient data to generate
  131653. * @param scene The scene that the shader is scoped to
  131654. * @returns an Array of floats from the color gradient values
  131655. */
  131656. private static _CreateBoneMapColorBuffer;
  131657. /** If SkeletonViewer scene scope. */
  131658. private _scene;
  131659. /** Gets or sets the color used to render the skeleton */
  131660. color: Color3;
  131661. /** Array of the points of the skeleton fo the line view. */
  131662. private _debugLines;
  131663. /** The SkeletonViewers Mesh. */
  131664. private _debugMesh;
  131665. /** The local axes Meshes. */
  131666. private _localAxes;
  131667. /** If SkeletonViewer is enabled. */
  131668. private _isEnabled;
  131669. /** If SkeletonViewer is ready. */
  131670. private _ready;
  131671. /** SkeletonViewer render observable. */
  131672. private _obs;
  131673. /** The Utility Layer to render the gizmos in. */
  131674. private _utilityLayer;
  131675. private _boneIndices;
  131676. /** Gets the Scene. */
  131677. get scene(): Scene;
  131678. /** Gets the utilityLayer. */
  131679. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131680. /** Checks Ready Status. */
  131681. get isReady(): Boolean;
  131682. /** Sets Ready Status. */
  131683. set ready(value: boolean);
  131684. /** Gets the debugMesh */
  131685. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131686. /** Sets the debugMesh */
  131687. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131688. /** Gets the displayMode */
  131689. get displayMode(): number;
  131690. /** Sets the displayMode */
  131691. set displayMode(value: number);
  131692. /**
  131693. * Creates a new SkeletonViewer
  131694. * @param skeleton defines the skeleton to render
  131695. * @param mesh defines the mesh attached to the skeleton
  131696. * @param scene defines the hosting scene
  131697. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131698. * @param renderingGroupId defines the rendering group id to use with the viewer
  131699. * @param options All of the extra constructor options for the SkeletonViewer
  131700. */
  131701. constructor(
  131702. /** defines the skeleton to render */
  131703. skeleton: Skeleton,
  131704. /** defines the mesh attached to the skeleton */
  131705. mesh: AbstractMesh,
  131706. /** The Scene scope*/
  131707. scene: Scene,
  131708. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131709. autoUpdateBonesMatrices?: boolean,
  131710. /** defines the rendering group id to use with the viewer */
  131711. renderingGroupId?: number,
  131712. /** is the options for the viewer */
  131713. options?: Partial<ISkeletonViewerOptions>);
  131714. /** The Dynamic bindings for the update functions */
  131715. private _bindObs;
  131716. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131717. update(): void;
  131718. /** Gets or sets a boolean indicating if the viewer is enabled */
  131719. set isEnabled(value: boolean);
  131720. get isEnabled(): boolean;
  131721. private _getBonePosition;
  131722. private _getLinesForBonesWithLength;
  131723. private _getLinesForBonesNoLength;
  131724. /** function to revert the mesh and scene back to the initial state. */
  131725. private _revert;
  131726. private getAbsoluteRestPose;
  131727. /** function to build and bind sphere joint points and spur bone representations. */
  131728. private _buildSpheresAndSpurs;
  131729. private _buildLocalAxes;
  131730. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131731. private _displayLinesUpdate;
  131732. /** Changes the displayMode of the skeleton viewer
  131733. * @param mode The displayMode numerical value
  131734. */
  131735. changeDisplayMode(mode: number): void;
  131736. /** Sets a display option of the skeleton viewer
  131737. *
  131738. * | Option | Type | Default | Description |
  131739. * | --------------- | ------- | ------- | ----------- |
  131740. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131741. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131742. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131743. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131744. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  131745. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  131746. *
  131747. * @param option String of the option name
  131748. * @param value The numerical option value
  131749. */
  131750. changeDisplayOptions(option: string, value: number): void;
  131751. /** Release associated resources */
  131752. dispose(): void;
  131753. }
  131754. }
  131755. declare module BABYLON {
  131756. /**
  131757. * Enum for Device Types
  131758. */
  131759. export enum DeviceType {
  131760. /** Generic */
  131761. Generic = 0,
  131762. /** Keyboard */
  131763. Keyboard = 1,
  131764. /** Mouse */
  131765. Mouse = 2,
  131766. /** Touch Pointers */
  131767. Touch = 3,
  131768. /** PS4 Dual Shock */
  131769. DualShock = 4,
  131770. /** Xbox */
  131771. Xbox = 5,
  131772. /** Switch Controller */
  131773. Switch = 6
  131774. }
  131775. /**
  131776. * Enum for All Pointers (Touch/Mouse)
  131777. */
  131778. export enum PointerInput {
  131779. /** Horizontal Axis */
  131780. Horizontal = 0,
  131781. /** Vertical Axis */
  131782. Vertical = 1,
  131783. /** Left Click or Touch */
  131784. LeftClick = 2,
  131785. /** Middle Click */
  131786. MiddleClick = 3,
  131787. /** Right Click */
  131788. RightClick = 4,
  131789. /** Browser Back */
  131790. BrowserBack = 5,
  131791. /** Browser Forward */
  131792. BrowserForward = 6
  131793. }
  131794. /**
  131795. * Enum for Dual Shock Gamepad
  131796. */
  131797. export enum DualShockInput {
  131798. /** Cross */
  131799. Cross = 0,
  131800. /** Circle */
  131801. Circle = 1,
  131802. /** Square */
  131803. Square = 2,
  131804. /** Triangle */
  131805. Triangle = 3,
  131806. /** L1 */
  131807. L1 = 4,
  131808. /** R1 */
  131809. R1 = 5,
  131810. /** L2 */
  131811. L2 = 6,
  131812. /** R2 */
  131813. R2 = 7,
  131814. /** Share */
  131815. Share = 8,
  131816. /** Options */
  131817. Options = 9,
  131818. /** L3 */
  131819. L3 = 10,
  131820. /** R3 */
  131821. R3 = 11,
  131822. /** DPadUp */
  131823. DPadUp = 12,
  131824. /** DPadDown */
  131825. DPadDown = 13,
  131826. /** DPadLeft */
  131827. DPadLeft = 14,
  131828. /** DRight */
  131829. DPadRight = 15,
  131830. /** Home */
  131831. Home = 16,
  131832. /** TouchPad */
  131833. TouchPad = 17,
  131834. /** LStickXAxis */
  131835. LStickXAxis = 18,
  131836. /** LStickYAxis */
  131837. LStickYAxis = 19,
  131838. /** RStickXAxis */
  131839. RStickXAxis = 20,
  131840. /** RStickYAxis */
  131841. RStickYAxis = 21
  131842. }
  131843. /**
  131844. * Enum for Xbox Gamepad
  131845. */
  131846. export enum XboxInput {
  131847. /** A */
  131848. A = 0,
  131849. /** B */
  131850. B = 1,
  131851. /** X */
  131852. X = 2,
  131853. /** Y */
  131854. Y = 3,
  131855. /** LB */
  131856. LB = 4,
  131857. /** RB */
  131858. RB = 5,
  131859. /** LT */
  131860. LT = 6,
  131861. /** RT */
  131862. RT = 7,
  131863. /** Back */
  131864. Back = 8,
  131865. /** Start */
  131866. Start = 9,
  131867. /** LS */
  131868. LS = 10,
  131869. /** RS */
  131870. RS = 11,
  131871. /** DPadUp */
  131872. DPadUp = 12,
  131873. /** DPadDown */
  131874. DPadDown = 13,
  131875. /** DPadLeft */
  131876. DPadLeft = 14,
  131877. /** DRight */
  131878. DPadRight = 15,
  131879. /** Home */
  131880. Home = 16,
  131881. /** LStickXAxis */
  131882. LStickXAxis = 17,
  131883. /** LStickYAxis */
  131884. LStickYAxis = 18,
  131885. /** RStickXAxis */
  131886. RStickXAxis = 19,
  131887. /** RStickYAxis */
  131888. RStickYAxis = 20
  131889. }
  131890. /**
  131891. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131892. */
  131893. export enum SwitchInput {
  131894. /** B */
  131895. B = 0,
  131896. /** A */
  131897. A = 1,
  131898. /** Y */
  131899. Y = 2,
  131900. /** X */
  131901. X = 3,
  131902. /** L */
  131903. L = 4,
  131904. /** R */
  131905. R = 5,
  131906. /** ZL */
  131907. ZL = 6,
  131908. /** ZR */
  131909. ZR = 7,
  131910. /** Minus */
  131911. Minus = 8,
  131912. /** Plus */
  131913. Plus = 9,
  131914. /** LS */
  131915. LS = 10,
  131916. /** RS */
  131917. RS = 11,
  131918. /** DPadUp */
  131919. DPadUp = 12,
  131920. /** DPadDown */
  131921. DPadDown = 13,
  131922. /** DPadLeft */
  131923. DPadLeft = 14,
  131924. /** DRight */
  131925. DPadRight = 15,
  131926. /** Home */
  131927. Home = 16,
  131928. /** Capture */
  131929. Capture = 17,
  131930. /** LStickXAxis */
  131931. LStickXAxis = 18,
  131932. /** LStickYAxis */
  131933. LStickYAxis = 19,
  131934. /** RStickXAxis */
  131935. RStickXAxis = 20,
  131936. /** RStickYAxis */
  131937. RStickYAxis = 21
  131938. }
  131939. }
  131940. declare module BABYLON {
  131941. /**
  131942. * This class will take all inputs from Keyboard, Pointer, and
  131943. * any Gamepads and provide a polling system that all devices
  131944. * will use. This class assumes that there will only be one
  131945. * pointer device and one keyboard.
  131946. */
  131947. export class DeviceInputSystem implements IDisposable {
  131948. /**
  131949. * Callback to be triggered when a device is connected
  131950. */
  131951. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131952. /**
  131953. * Callback to be triggered when a device is disconnected
  131954. */
  131955. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131956. /**
  131957. * Callback to be triggered when event driven input is updated
  131958. */
  131959. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131960. private _inputs;
  131961. private _gamepads;
  131962. private _keyboardActive;
  131963. private _pointerActive;
  131964. private _elementToAttachTo;
  131965. private _keyboardDownEvent;
  131966. private _keyboardUpEvent;
  131967. private _pointerMoveEvent;
  131968. private _pointerDownEvent;
  131969. private _pointerUpEvent;
  131970. private _gamepadConnectedEvent;
  131971. private _gamepadDisconnectedEvent;
  131972. private static _MAX_KEYCODES;
  131973. private static _MAX_POINTER_INPUTS;
  131974. private constructor();
  131975. /**
  131976. * Creates a new DeviceInputSystem instance
  131977. * @param engine Engine to pull input element from
  131978. * @returns The new instance
  131979. */
  131980. static Create(engine: Engine): DeviceInputSystem;
  131981. /**
  131982. * Checks for current device input value, given an id and input index
  131983. * @param deviceName Id of connected device
  131984. * @param inputIndex Index of device input
  131985. * @returns Current value of input
  131986. */
  131987. /**
  131988. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131989. * @param deviceType Enum specifiying device type
  131990. * @param deviceSlot "Slot" or index that device is referenced in
  131991. * @param inputIndex Id of input to be checked
  131992. * @returns Current value of input
  131993. */
  131994. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131995. /**
  131996. * Dispose of all the eventlisteners
  131997. */
  131998. dispose(): void;
  131999. /**
  132000. * Add device and inputs to device array
  132001. * @param deviceType Enum specifiying device type
  132002. * @param deviceSlot "Slot" or index that device is referenced in
  132003. * @param numberOfInputs Number of input entries to create for given device
  132004. */
  132005. private _registerDevice;
  132006. /**
  132007. * Given a specific device name, remove that device from the device map
  132008. * @param deviceType Enum specifiying device type
  132009. * @param deviceSlot "Slot" or index that device is referenced in
  132010. */
  132011. private _unregisterDevice;
  132012. /**
  132013. * Handle all actions that come from keyboard interaction
  132014. */
  132015. private _handleKeyActions;
  132016. /**
  132017. * Handle all actions that come from pointer interaction
  132018. */
  132019. private _handlePointerActions;
  132020. /**
  132021. * Handle all actions that come from gamepad interaction
  132022. */
  132023. private _handleGamepadActions;
  132024. /**
  132025. * Update all non-event based devices with each frame
  132026. * @param deviceType Enum specifiying device type
  132027. * @param deviceSlot "Slot" or index that device is referenced in
  132028. * @param inputIndex Id of input to be checked
  132029. */
  132030. private _updateDevice;
  132031. /**
  132032. * Gets DeviceType from the device name
  132033. * @param deviceName Name of Device from DeviceInputSystem
  132034. * @returns DeviceType enum value
  132035. */
  132036. private _getGamepadDeviceType;
  132037. }
  132038. }
  132039. declare module BABYLON {
  132040. /**
  132041. * Type to handle enforcement of inputs
  132042. */
  132043. 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;
  132044. }
  132045. declare module BABYLON {
  132046. /**
  132047. * Class that handles all input for a specific device
  132048. */
  132049. export class DeviceSource<T extends DeviceType> {
  132050. /** Type of device */
  132051. readonly deviceType: DeviceType;
  132052. /** "Slot" or index that device is referenced in */
  132053. readonly deviceSlot: number;
  132054. /**
  132055. * Observable to handle device input changes per device
  132056. */
  132057. readonly onInputChangedObservable: Observable<{
  132058. inputIndex: DeviceInput<T>;
  132059. previousState: Nullable<number>;
  132060. currentState: Nullable<number>;
  132061. }>;
  132062. private readonly _deviceInputSystem;
  132063. /**
  132064. * Default Constructor
  132065. * @param deviceInputSystem Reference to DeviceInputSystem
  132066. * @param deviceType Type of device
  132067. * @param deviceSlot "Slot" or index that device is referenced in
  132068. */
  132069. constructor(deviceInputSystem: DeviceInputSystem,
  132070. /** Type of device */
  132071. deviceType: DeviceType,
  132072. /** "Slot" or index that device is referenced in */
  132073. deviceSlot?: number);
  132074. /**
  132075. * Get input for specific input
  132076. * @param inputIndex index of specific input on device
  132077. * @returns Input value from DeviceInputSystem
  132078. */
  132079. getInput(inputIndex: DeviceInput<T>): number;
  132080. }
  132081. /**
  132082. * Class to keep track of devices
  132083. */
  132084. export class DeviceSourceManager implements IDisposable {
  132085. /**
  132086. * Observable to be triggered when before a device is connected
  132087. */
  132088. readonly onBeforeDeviceConnectedObservable: Observable<{
  132089. deviceType: DeviceType;
  132090. deviceSlot: number;
  132091. }>;
  132092. /**
  132093. * Observable to be triggered when before a device is disconnected
  132094. */
  132095. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132096. deviceType: DeviceType;
  132097. deviceSlot: number;
  132098. }>;
  132099. /**
  132100. * Observable to be triggered when after a device is connected
  132101. */
  132102. readonly onAfterDeviceConnectedObservable: Observable<{
  132103. deviceType: DeviceType;
  132104. deviceSlot: number;
  132105. }>;
  132106. /**
  132107. * Observable to be triggered when after a device is disconnected
  132108. */
  132109. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132110. deviceType: DeviceType;
  132111. deviceSlot: number;
  132112. }>;
  132113. private readonly _devices;
  132114. private readonly _firstDevice;
  132115. private readonly _deviceInputSystem;
  132116. /**
  132117. * Default Constructor
  132118. * @param engine engine to pull input element from
  132119. */
  132120. constructor(engine: Engine);
  132121. /**
  132122. * Gets a DeviceSource, given a type and slot
  132123. * @param deviceType Enum specifying device type
  132124. * @param deviceSlot "Slot" or index that device is referenced in
  132125. * @returns DeviceSource object
  132126. */
  132127. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132128. /**
  132129. * Gets an array of DeviceSource objects for a given device type
  132130. * @param deviceType Enum specifying device type
  132131. * @returns Array of DeviceSource objects
  132132. */
  132133. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132134. /**
  132135. * Dispose of DeviceInputSystem and other parts
  132136. */
  132137. dispose(): void;
  132138. /**
  132139. * Function to add device name to device list
  132140. * @param deviceType Enum specifying device type
  132141. * @param deviceSlot "Slot" or index that device is referenced in
  132142. */
  132143. private _addDevice;
  132144. /**
  132145. * Function to remove device name to device list
  132146. * @param deviceType Enum specifying device type
  132147. * @param deviceSlot "Slot" or index that device is referenced in
  132148. */
  132149. private _removeDevice;
  132150. /**
  132151. * Updates array storing first connected device of each type
  132152. * @param type Type of Device
  132153. */
  132154. private _updateFirstDevices;
  132155. }
  132156. }
  132157. declare module BABYLON {
  132158. /**
  132159. * Options to create the null engine
  132160. */
  132161. export class NullEngineOptions {
  132162. /**
  132163. * Render width (Default: 512)
  132164. */
  132165. renderWidth: number;
  132166. /**
  132167. * Render height (Default: 256)
  132168. */
  132169. renderHeight: number;
  132170. /**
  132171. * Texture size (Default: 512)
  132172. */
  132173. textureSize: number;
  132174. /**
  132175. * If delta time between frames should be constant
  132176. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132177. */
  132178. deterministicLockstep: boolean;
  132179. /**
  132180. * Maximum about of steps between frames (Default: 4)
  132181. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132182. */
  132183. lockstepMaxSteps: number;
  132184. /**
  132185. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132186. */
  132187. useHighPrecisionMatrix?: boolean;
  132188. }
  132189. /**
  132190. * The null engine class provides support for headless version of babylon.js.
  132191. * This can be used in server side scenario or for testing purposes
  132192. */
  132193. export class NullEngine extends Engine {
  132194. private _options;
  132195. /**
  132196. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132197. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132198. * @returns true if engine is in deterministic lock step mode
  132199. */
  132200. isDeterministicLockStep(): boolean;
  132201. /**
  132202. * Gets the max steps when engine is running in deterministic lock step
  132203. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132204. * @returns the max steps
  132205. */
  132206. getLockstepMaxSteps(): number;
  132207. /**
  132208. * Gets the current hardware scaling level.
  132209. * By default the hardware scaling level is computed from the window device ratio.
  132210. * 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.
  132211. * @returns a number indicating the current hardware scaling level
  132212. */
  132213. getHardwareScalingLevel(): number;
  132214. constructor(options?: NullEngineOptions);
  132215. /**
  132216. * Creates a vertex buffer
  132217. * @param vertices the data for the vertex buffer
  132218. * @returns the new WebGL static buffer
  132219. */
  132220. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132221. /**
  132222. * Creates a new index buffer
  132223. * @param indices defines the content of the index buffer
  132224. * @param updatable defines if the index buffer must be updatable
  132225. * @returns a new webGL buffer
  132226. */
  132227. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132228. /**
  132229. * Clear the current render buffer or the current render target (if any is set up)
  132230. * @param color defines the color to use
  132231. * @param backBuffer defines if the back buffer must be cleared
  132232. * @param depth defines if the depth buffer must be cleared
  132233. * @param stencil defines if the stencil buffer must be cleared
  132234. */
  132235. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132236. /**
  132237. * Gets the current render width
  132238. * @param useScreen defines if screen size must be used (or the current render target if any)
  132239. * @returns a number defining the current render width
  132240. */
  132241. getRenderWidth(useScreen?: boolean): number;
  132242. /**
  132243. * Gets the current render height
  132244. * @param useScreen defines if screen size must be used (or the current render target if any)
  132245. * @returns a number defining the current render height
  132246. */
  132247. getRenderHeight(useScreen?: boolean): number;
  132248. /**
  132249. * Set the WebGL's viewport
  132250. * @param viewport defines the viewport element to be used
  132251. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132252. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132253. */
  132254. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132255. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132256. /**
  132257. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132258. * @param pipelineContext defines the pipeline context to use
  132259. * @param uniformsNames defines the list of uniform names
  132260. * @returns an array of webGL uniform locations
  132261. */
  132262. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132263. /**
  132264. * Gets the lsit of active attributes for a given webGL program
  132265. * @param pipelineContext defines the pipeline context to use
  132266. * @param attributesNames defines the list of attribute names to get
  132267. * @returns an array of indices indicating the offset of each attribute
  132268. */
  132269. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132270. /**
  132271. * Binds an effect to the webGL context
  132272. * @param effect defines the effect to bind
  132273. */
  132274. bindSamplers(effect: Effect): void;
  132275. /**
  132276. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132277. * @param effect defines the effect to activate
  132278. */
  132279. enableEffect(effect: Effect): void;
  132280. /**
  132281. * Set various states to the webGL context
  132282. * @param culling defines backface culling state
  132283. * @param zOffset defines the value to apply to zOffset (0 by default)
  132284. * @param force defines if states must be applied even if cache is up to date
  132285. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132286. */
  132287. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132288. /**
  132289. * Set the value of an uniform to an array of int32
  132290. * @param uniform defines the webGL uniform location where to store the value
  132291. * @param array defines the array of int32 to store
  132292. * @returns true if value was set
  132293. */
  132294. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132295. /**
  132296. * Set the value of an uniform to an array of int32 (stored as vec2)
  132297. * @param uniform defines the webGL uniform location where to store the value
  132298. * @param array defines the array of int32 to store
  132299. * @returns true if value was set
  132300. */
  132301. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132302. /**
  132303. * Set the value of an uniform to an array of int32 (stored as vec3)
  132304. * @param uniform defines the webGL uniform location where to store the value
  132305. * @param array defines the array of int32 to store
  132306. * @returns true if value was set
  132307. */
  132308. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132309. /**
  132310. * Set the value of an uniform to an array of int32 (stored as vec4)
  132311. * @param uniform defines the webGL uniform location where to store the value
  132312. * @param array defines the array of int32 to store
  132313. * @returns true if value was set
  132314. */
  132315. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132316. /**
  132317. * Set the value of an uniform to an array of float32
  132318. * @param uniform defines the webGL uniform location where to store the value
  132319. * @param array defines the array of float32 to store
  132320. * @returns true if value was set
  132321. */
  132322. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132323. /**
  132324. * Set the value of an uniform to an array of float32 (stored as vec2)
  132325. * @param uniform defines the webGL uniform location where to store the value
  132326. * @param array defines the array of float32 to store
  132327. * @returns true if value was set
  132328. */
  132329. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132330. /**
  132331. * Set the value of an uniform to an array of float32 (stored as vec3)
  132332. * @param uniform defines the webGL uniform location where to store the value
  132333. * @param array defines the array of float32 to store
  132334. * @returns true if value was set
  132335. */
  132336. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132337. /**
  132338. * Set the value of an uniform to an array of float32 (stored as vec4)
  132339. * @param uniform defines the webGL uniform location where to store the value
  132340. * @param array defines the array of float32 to store
  132341. * @returns true if value was set
  132342. */
  132343. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132344. /**
  132345. * Set the value of an uniform to an array of number
  132346. * @param uniform defines the webGL uniform location where to store the value
  132347. * @param array defines the array of number to store
  132348. * @returns true if value was set
  132349. */
  132350. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132351. /**
  132352. * Set the value of an uniform to an array of number (stored as vec2)
  132353. * @param uniform defines the webGL uniform location where to store the value
  132354. * @param array defines the array of number to store
  132355. * @returns true if value was set
  132356. */
  132357. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132358. /**
  132359. * Set the value of an uniform to an array of number (stored as vec3)
  132360. * @param uniform defines the webGL uniform location where to store the value
  132361. * @param array defines the array of number to store
  132362. * @returns true if value was set
  132363. */
  132364. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132365. /**
  132366. * Set the value of an uniform to an array of number (stored as vec4)
  132367. * @param uniform defines the webGL uniform location where to store the value
  132368. * @param array defines the array of number to store
  132369. * @returns true if value was set
  132370. */
  132371. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132372. /**
  132373. * Set the value of an uniform to an array of float32 (stored as matrices)
  132374. * @param uniform defines the webGL uniform location where to store the value
  132375. * @param matrices defines the array of float32 to store
  132376. * @returns true if value was set
  132377. */
  132378. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132379. /**
  132380. * Set the value of an uniform to a matrix (3x3)
  132381. * @param uniform defines the webGL uniform location where to store the value
  132382. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132383. * @returns true if value was set
  132384. */
  132385. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132386. /**
  132387. * Set the value of an uniform to a matrix (2x2)
  132388. * @param uniform defines the webGL uniform location where to store the value
  132389. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132390. * @returns true if value was set
  132391. */
  132392. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132393. /**
  132394. * Set the value of an uniform to a number (float)
  132395. * @param uniform defines the webGL uniform location where to store the value
  132396. * @param value defines the float number to store
  132397. * @returns true if value was set
  132398. */
  132399. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132400. /**
  132401. * Set the value of an uniform to a vec2
  132402. * @param uniform defines the webGL uniform location where to store the value
  132403. * @param x defines the 1st component of the value
  132404. * @param y defines the 2nd component of the value
  132405. * @returns true if value was set
  132406. */
  132407. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132408. /**
  132409. * Set the value of an uniform to a vec3
  132410. * @param uniform defines the webGL uniform location where to store the value
  132411. * @param x defines the 1st component of the value
  132412. * @param y defines the 2nd component of the value
  132413. * @param z defines the 3rd component of the value
  132414. * @returns true if value was set
  132415. */
  132416. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132417. /**
  132418. * Set the value of an uniform to a boolean
  132419. * @param uniform defines the webGL uniform location where to store the value
  132420. * @param bool defines the boolean to store
  132421. * @returns true if value was set
  132422. */
  132423. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132424. /**
  132425. * Set the value of an uniform to a vec4
  132426. * @param uniform defines the webGL uniform location where to store the value
  132427. * @param x defines the 1st component of the value
  132428. * @param y defines the 2nd component of the value
  132429. * @param z defines the 3rd component of the value
  132430. * @param w defines the 4th component of the value
  132431. * @returns true if value was set
  132432. */
  132433. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132434. /**
  132435. * Sets the current alpha mode
  132436. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132437. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132438. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132439. */
  132440. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132441. /**
  132442. * Bind webGl buffers directly to the webGL context
  132443. * @param vertexBuffers defines the vertex buffer to bind
  132444. * @param indexBuffer defines the index buffer to bind
  132445. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132446. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132447. * @param effect defines the effect associated with the vertex buffer
  132448. */
  132449. bindBuffers(vertexBuffers: {
  132450. [key: string]: VertexBuffer;
  132451. }, indexBuffer: DataBuffer, effect: Effect): void;
  132452. /**
  132453. * Force the entire cache to be cleared
  132454. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132455. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132456. */
  132457. wipeCaches(bruteForce?: boolean): void;
  132458. /**
  132459. * Send a draw order
  132460. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132461. * @param indexStart defines the starting index
  132462. * @param indexCount defines the number of index to draw
  132463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132464. */
  132465. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132466. /**
  132467. * Draw a list of indexed primitives
  132468. * @param fillMode defines the primitive to use
  132469. * @param indexStart defines the starting index
  132470. * @param indexCount defines the number of index to draw
  132471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132472. */
  132473. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132474. /**
  132475. * Draw a list of unindexed primitives
  132476. * @param fillMode defines the primitive to use
  132477. * @param verticesStart defines the index of first vertex to draw
  132478. * @param verticesCount defines the count of vertices to draw
  132479. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132480. */
  132481. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132482. /** @hidden */
  132483. _createTexture(): WebGLTexture;
  132484. /** @hidden */
  132485. _releaseTexture(texture: InternalTexture): void;
  132486. /**
  132487. * Usually called from Texture.ts.
  132488. * Passed information to create a WebGLTexture
  132489. * @param urlArg defines a value which contains one of the following:
  132490. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132491. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132492. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132493. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132494. * @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)
  132495. * @param scene needed for loading to the correct scene
  132496. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132497. * @param onLoad optional callback to be called upon successful completion
  132498. * @param onError optional callback to be called upon failure
  132499. * @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
  132500. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132501. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132502. * @param forcedExtension defines the extension to use to pick the right loader
  132503. * @param mimeType defines an optional mime type
  132504. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132505. */
  132506. 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;
  132507. /**
  132508. * Creates a new render target texture
  132509. * @param size defines the size of the texture
  132510. * @param options defines the options used to create the texture
  132511. * @returns a new render target texture stored in an InternalTexture
  132512. */
  132513. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132514. /**
  132515. * Update the sampling mode of a given texture
  132516. * @param samplingMode defines the required sampling mode
  132517. * @param texture defines the texture to update
  132518. */
  132519. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132520. /**
  132521. * Binds the frame buffer to the specified texture.
  132522. * @param texture The texture to render to or null for the default canvas
  132523. * @param faceIndex The face of the texture to render to in case of cube texture
  132524. * @param requiredWidth The width of the target to render to
  132525. * @param requiredHeight The height of the target to render to
  132526. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132527. * @param lodLevel defines le lod level to bind to the frame buffer
  132528. */
  132529. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132530. /**
  132531. * Unbind the current render target texture from the webGL context
  132532. * @param texture defines the render target texture to unbind
  132533. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132534. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132535. */
  132536. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132537. /**
  132538. * Creates a dynamic vertex buffer
  132539. * @param vertices the data for the dynamic vertex buffer
  132540. * @returns the new WebGL dynamic buffer
  132541. */
  132542. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132543. /**
  132544. * Update the content of a dynamic texture
  132545. * @param texture defines the texture to update
  132546. * @param canvas defines the canvas containing the source
  132547. * @param invertY defines if data must be stored with Y axis inverted
  132548. * @param premulAlpha defines if alpha is stored as premultiplied
  132549. * @param format defines the format of the data
  132550. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132551. */
  132552. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132553. /**
  132554. * Gets a boolean indicating if all created effects are ready
  132555. * @returns true if all effects are ready
  132556. */
  132557. areAllEffectsReady(): boolean;
  132558. /**
  132559. * @hidden
  132560. * Get the current error code of the webGL context
  132561. * @returns the error code
  132562. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132563. */
  132564. getError(): number;
  132565. /** @hidden */
  132566. _getUnpackAlignement(): number;
  132567. /** @hidden */
  132568. _unpackFlipY(value: boolean): void;
  132569. /**
  132570. * Update a dynamic index buffer
  132571. * @param indexBuffer defines the target index buffer
  132572. * @param indices defines the data to update
  132573. * @param offset defines the offset in the target index buffer where update should start
  132574. */
  132575. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132576. /**
  132577. * Updates a dynamic vertex buffer.
  132578. * @param vertexBuffer the vertex buffer to update
  132579. * @param vertices the data used to update the vertex buffer
  132580. * @param byteOffset the byte offset of the data (optional)
  132581. * @param byteLength the byte length of the data (optional)
  132582. */
  132583. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132584. /** @hidden */
  132585. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132586. /** @hidden */
  132587. _bindTexture(channel: number, texture: InternalTexture): void;
  132588. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132589. /**
  132590. * 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
  132591. */
  132592. releaseEffects(): void;
  132593. displayLoadingUI(): void;
  132594. hideLoadingUI(): void;
  132595. /** @hidden */
  132596. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132597. /** @hidden */
  132598. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132599. /** @hidden */
  132600. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132601. /** @hidden */
  132602. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132603. }
  132604. }
  132605. declare module BABYLON {
  132606. /**
  132607. * @hidden
  132608. **/
  132609. export class _TimeToken {
  132610. _startTimeQuery: Nullable<WebGLQuery>;
  132611. _endTimeQuery: Nullable<WebGLQuery>;
  132612. _timeElapsedQuery: Nullable<WebGLQuery>;
  132613. _timeElapsedQueryEnded: boolean;
  132614. }
  132615. }
  132616. declare module BABYLON {
  132617. /** @hidden */
  132618. export class _OcclusionDataStorage {
  132619. /** @hidden */
  132620. occlusionInternalRetryCounter: number;
  132621. /** @hidden */
  132622. isOcclusionQueryInProgress: boolean;
  132623. /** @hidden */
  132624. isOccluded: boolean;
  132625. /** @hidden */
  132626. occlusionRetryCount: number;
  132627. /** @hidden */
  132628. occlusionType: number;
  132629. /** @hidden */
  132630. occlusionQueryAlgorithmType: number;
  132631. }
  132632. interface Engine {
  132633. /**
  132634. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132635. * @return the new query
  132636. */
  132637. createQuery(): WebGLQuery;
  132638. /**
  132639. * Delete and release a webGL query
  132640. * @param query defines the query to delete
  132641. * @return the current engine
  132642. */
  132643. deleteQuery(query: WebGLQuery): Engine;
  132644. /**
  132645. * Check if a given query has resolved and got its value
  132646. * @param query defines the query to check
  132647. * @returns true if the query got its value
  132648. */
  132649. isQueryResultAvailable(query: WebGLQuery): boolean;
  132650. /**
  132651. * Gets the value of a given query
  132652. * @param query defines the query to check
  132653. * @returns the value of the query
  132654. */
  132655. getQueryResult(query: WebGLQuery): number;
  132656. /**
  132657. * Initiates an occlusion query
  132658. * @param algorithmType defines the algorithm to use
  132659. * @param query defines the query to use
  132660. * @returns the current engine
  132661. * @see https://doc.babylonjs.com/features/occlusionquery
  132662. */
  132663. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132664. /**
  132665. * Ends an occlusion query
  132666. * @see https://doc.babylonjs.com/features/occlusionquery
  132667. * @param algorithmType defines the algorithm to use
  132668. * @returns the current engine
  132669. */
  132670. endOcclusionQuery(algorithmType: number): Engine;
  132671. /**
  132672. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132673. * Please note that only one query can be issued at a time
  132674. * @returns a time token used to track the time span
  132675. */
  132676. startTimeQuery(): Nullable<_TimeToken>;
  132677. /**
  132678. * Ends a time query
  132679. * @param token defines the token used to measure the time span
  132680. * @returns the time spent (in ns)
  132681. */
  132682. endTimeQuery(token: _TimeToken): int;
  132683. /** @hidden */
  132684. _currentNonTimestampToken: Nullable<_TimeToken>;
  132685. /** @hidden */
  132686. _createTimeQuery(): WebGLQuery;
  132687. /** @hidden */
  132688. _deleteTimeQuery(query: WebGLQuery): void;
  132689. /** @hidden */
  132690. _getGlAlgorithmType(algorithmType: number): number;
  132691. /** @hidden */
  132692. _getTimeQueryResult(query: WebGLQuery): any;
  132693. /** @hidden */
  132694. _getTimeQueryAvailability(query: WebGLQuery): any;
  132695. }
  132696. interface AbstractMesh {
  132697. /**
  132698. * Backing filed
  132699. * @hidden
  132700. */
  132701. __occlusionDataStorage: _OcclusionDataStorage;
  132702. /**
  132703. * Access property
  132704. * @hidden
  132705. */
  132706. _occlusionDataStorage: _OcclusionDataStorage;
  132707. /**
  132708. * 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.
  132709. * The default value is -1 which means don't break the query and wait till the result
  132710. * @see https://doc.babylonjs.com/features/occlusionquery
  132711. */
  132712. occlusionRetryCount: number;
  132713. /**
  132714. * 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:
  132715. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132716. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132717. * * 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.
  132718. * @see https://doc.babylonjs.com/features/occlusionquery
  132719. */
  132720. occlusionType: number;
  132721. /**
  132722. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132723. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132724. * * 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.
  132725. * @see https://doc.babylonjs.com/features/occlusionquery
  132726. */
  132727. occlusionQueryAlgorithmType: number;
  132728. /**
  132729. * 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
  132730. * @see https://doc.babylonjs.com/features/occlusionquery
  132731. */
  132732. isOccluded: boolean;
  132733. /**
  132734. * Flag to check the progress status of the query
  132735. * @see https://doc.babylonjs.com/features/occlusionquery
  132736. */
  132737. isOcclusionQueryInProgress: boolean;
  132738. }
  132739. }
  132740. declare module BABYLON {
  132741. /** @hidden */
  132742. export var _forceTransformFeedbackToBundle: boolean;
  132743. interface Engine {
  132744. /**
  132745. * Creates a webGL transform feedback object
  132746. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132747. * @returns the webGL transform feedback object
  132748. */
  132749. createTransformFeedback(): WebGLTransformFeedback;
  132750. /**
  132751. * Delete a webGL transform feedback object
  132752. * @param value defines the webGL transform feedback object to delete
  132753. */
  132754. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132755. /**
  132756. * Bind a webGL transform feedback object to the webgl context
  132757. * @param value defines the webGL transform feedback object to bind
  132758. */
  132759. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132760. /**
  132761. * Begins a transform feedback operation
  132762. * @param usePoints defines if points or triangles must be used
  132763. */
  132764. beginTransformFeedback(usePoints: boolean): void;
  132765. /**
  132766. * Ends a transform feedback operation
  132767. */
  132768. endTransformFeedback(): void;
  132769. /**
  132770. * Specify the varyings to use with transform feedback
  132771. * @param program defines the associated webGL program
  132772. * @param value defines the list of strings representing the varying names
  132773. */
  132774. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132775. /**
  132776. * Bind a webGL buffer for a transform feedback operation
  132777. * @param value defines the webGL buffer to bind
  132778. */
  132779. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132780. }
  132781. }
  132782. declare module BABYLON {
  132783. /**
  132784. * Class used to define an additional view for the engine
  132785. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132786. */
  132787. export class EngineView {
  132788. /** Defines the canvas where to render the view */
  132789. target: HTMLCanvasElement;
  132790. /** Defines an optional camera used to render the view (will use active camera else) */
  132791. camera?: Camera;
  132792. }
  132793. interface Engine {
  132794. /**
  132795. * Gets or sets the HTML element to use for attaching events
  132796. */
  132797. inputElement: Nullable<HTMLElement>;
  132798. /**
  132799. * Gets the current engine view
  132800. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132801. */
  132802. activeView: Nullable<EngineView>;
  132803. /** Gets or sets the list of views */
  132804. views: EngineView[];
  132805. /**
  132806. * Register a new child canvas
  132807. * @param canvas defines the canvas to register
  132808. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132809. * @returns the associated view
  132810. */
  132811. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132812. /**
  132813. * Remove a registered child canvas
  132814. * @param canvas defines the canvas to remove
  132815. * @returns the current engine
  132816. */
  132817. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132818. }
  132819. }
  132820. declare module BABYLON {
  132821. interface Engine {
  132822. /** @hidden */
  132823. _excludedCompressedTextures: string[];
  132824. /** @hidden */
  132825. _textureFormatInUse: string;
  132826. /**
  132827. * Gets the list of texture formats supported
  132828. */
  132829. readonly texturesSupported: Array<string>;
  132830. /**
  132831. * Gets the texture format in use
  132832. */
  132833. readonly textureFormatInUse: Nullable<string>;
  132834. /**
  132835. * Set the compressed texture extensions or file names to skip.
  132836. *
  132837. * @param skippedFiles defines the list of those texture files you want to skip
  132838. * Example: [".dds", ".env", "myfile.png"]
  132839. */
  132840. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132841. /**
  132842. * Set the compressed texture format to use, based on the formats you have, and the formats
  132843. * supported by the hardware / browser.
  132844. *
  132845. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132846. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132847. * to API arguments needed to compressed textures. This puts the burden on the container
  132848. * generator to house the arcane code for determining these for current & future formats.
  132849. *
  132850. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132851. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132852. *
  132853. * Note: The result of this call is not taken into account when a texture is base64.
  132854. *
  132855. * @param formatsAvailable defines the list of those format families you have created
  132856. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132857. *
  132858. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132859. * @returns The extension selected.
  132860. */
  132861. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132862. }
  132863. }
  132864. declare module BABYLON {
  132865. /**
  132866. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132867. */
  132868. export interface CubeMapInfo {
  132869. /**
  132870. * The pixel array for the front face.
  132871. * This is stored in format, left to right, up to down format.
  132872. */
  132873. front: Nullable<ArrayBufferView>;
  132874. /**
  132875. * The pixel array for the back face.
  132876. * This is stored in format, left to right, up to down format.
  132877. */
  132878. back: Nullable<ArrayBufferView>;
  132879. /**
  132880. * The pixel array for the left face.
  132881. * This is stored in format, left to right, up to down format.
  132882. */
  132883. left: Nullable<ArrayBufferView>;
  132884. /**
  132885. * The pixel array for the right face.
  132886. * This is stored in format, left to right, up to down format.
  132887. */
  132888. right: Nullable<ArrayBufferView>;
  132889. /**
  132890. * The pixel array for the up face.
  132891. * This is stored in format, left to right, up to down format.
  132892. */
  132893. up: Nullable<ArrayBufferView>;
  132894. /**
  132895. * The pixel array for the down face.
  132896. * This is stored in format, left to right, up to down format.
  132897. */
  132898. down: Nullable<ArrayBufferView>;
  132899. /**
  132900. * The size of the cubemap stored.
  132901. *
  132902. * Each faces will be size * size pixels.
  132903. */
  132904. size: number;
  132905. /**
  132906. * The format of the texture.
  132907. *
  132908. * RGBA, RGB.
  132909. */
  132910. format: number;
  132911. /**
  132912. * The type of the texture data.
  132913. *
  132914. * UNSIGNED_INT, FLOAT.
  132915. */
  132916. type: number;
  132917. /**
  132918. * Specifies whether the texture is in gamma space.
  132919. */
  132920. gammaSpace: boolean;
  132921. }
  132922. /**
  132923. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132924. */
  132925. export class PanoramaToCubeMapTools {
  132926. private static FACE_LEFT;
  132927. private static FACE_RIGHT;
  132928. private static FACE_FRONT;
  132929. private static FACE_BACK;
  132930. private static FACE_DOWN;
  132931. private static FACE_UP;
  132932. /**
  132933. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132934. *
  132935. * @param float32Array The source data.
  132936. * @param inputWidth The width of the input panorama.
  132937. * @param inputHeight The height of the input panorama.
  132938. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132939. * @return The cubemap data
  132940. */
  132941. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132942. private static CreateCubemapTexture;
  132943. private static CalcProjectionSpherical;
  132944. }
  132945. }
  132946. declare module BABYLON {
  132947. /**
  132948. * Helper class dealing with the extraction of spherical polynomial dataArray
  132949. * from a cube map.
  132950. */
  132951. export class CubeMapToSphericalPolynomialTools {
  132952. private static FileFaces;
  132953. /**
  132954. * Converts a texture to the according Spherical Polynomial data.
  132955. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132956. *
  132957. * @param texture The texture to extract the information from.
  132958. * @return The Spherical Polynomial data.
  132959. */
  132960. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132961. /**
  132962. * Converts a cubemap to the according Spherical Polynomial data.
  132963. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132964. *
  132965. * @param cubeInfo The Cube map to extract the information from.
  132966. * @return The Spherical Polynomial data.
  132967. */
  132968. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132969. }
  132970. }
  132971. declare module BABYLON {
  132972. interface BaseTexture {
  132973. /**
  132974. * Get the polynomial representation of the texture data.
  132975. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132976. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132977. */
  132978. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132979. }
  132980. }
  132981. declare module BABYLON {
  132982. /** @hidden */
  132983. export var rgbdEncodePixelShader: {
  132984. name: string;
  132985. shader: string;
  132986. };
  132987. }
  132988. declare module BABYLON {
  132989. /** @hidden */
  132990. export var rgbdDecodePixelShader: {
  132991. name: string;
  132992. shader: string;
  132993. };
  132994. }
  132995. declare module BABYLON {
  132996. /**
  132997. * Raw texture data and descriptor sufficient for WebGL texture upload
  132998. */
  132999. export interface EnvironmentTextureInfo {
  133000. /**
  133001. * Version of the environment map
  133002. */
  133003. version: number;
  133004. /**
  133005. * Width of image
  133006. */
  133007. width: number;
  133008. /**
  133009. * Irradiance information stored in the file.
  133010. */
  133011. irradiance: any;
  133012. /**
  133013. * Specular information stored in the file.
  133014. */
  133015. specular: any;
  133016. }
  133017. /**
  133018. * Defines One Image in the file. It requires only the position in the file
  133019. * as well as the length.
  133020. */
  133021. interface BufferImageData {
  133022. /**
  133023. * Length of the image data.
  133024. */
  133025. length: number;
  133026. /**
  133027. * Position of the data from the null terminator delimiting the end of the JSON.
  133028. */
  133029. position: number;
  133030. }
  133031. /**
  133032. * Defines the specular data enclosed in the file.
  133033. * This corresponds to the version 1 of the data.
  133034. */
  133035. export interface EnvironmentTextureSpecularInfoV1 {
  133036. /**
  133037. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133038. */
  133039. specularDataPosition?: number;
  133040. /**
  133041. * This contains all the images data needed to reconstruct the cubemap.
  133042. */
  133043. mipmaps: Array<BufferImageData>;
  133044. /**
  133045. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133046. */
  133047. lodGenerationScale: number;
  133048. }
  133049. /**
  133050. * Sets of helpers addressing the serialization and deserialization of environment texture
  133051. * stored in a BabylonJS env file.
  133052. * Those files are usually stored as .env files.
  133053. */
  133054. export class EnvironmentTextureTools {
  133055. /**
  133056. * Magic number identifying the env file.
  133057. */
  133058. private static _MagicBytes;
  133059. /**
  133060. * Gets the environment info from an env file.
  133061. * @param data The array buffer containing the .env bytes.
  133062. * @returns the environment file info (the json header) if successfully parsed.
  133063. */
  133064. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133065. /**
  133066. * Creates an environment texture from a loaded cube texture.
  133067. * @param texture defines the cube texture to convert in env file
  133068. * @return a promise containing the environment data if succesfull.
  133069. */
  133070. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133071. /**
  133072. * Creates a JSON representation of the spherical data.
  133073. * @param texture defines the texture containing the polynomials
  133074. * @return the JSON representation of the spherical info
  133075. */
  133076. private static _CreateEnvTextureIrradiance;
  133077. /**
  133078. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133079. * @param data the image data
  133080. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133081. * @return the views described by info providing access to the underlying buffer
  133082. */
  133083. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133084. /**
  133085. * Uploads the texture info contained in the env file to the GPU.
  133086. * @param texture defines the internal texture to upload to
  133087. * @param data defines the data to load
  133088. * @param info defines the texture info retrieved through the GetEnvInfo method
  133089. * @returns a promise
  133090. */
  133091. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133092. private static _OnImageReadyAsync;
  133093. /**
  133094. * Uploads the levels of image data to the GPU.
  133095. * @param texture defines the internal texture to upload to
  133096. * @param imageData defines the array buffer views of image data [mipmap][face]
  133097. * @returns a promise
  133098. */
  133099. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133100. /**
  133101. * Uploads spherical polynomials information to the texture.
  133102. * @param texture defines the texture we are trying to upload the information to
  133103. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133104. */
  133105. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133106. /** @hidden */
  133107. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133108. }
  133109. }
  133110. declare module BABYLON {
  133111. /**
  133112. * Class used to inline functions in shader code
  133113. */
  133114. export class ShaderCodeInliner {
  133115. private static readonly _RegexpFindFunctionNameAndType;
  133116. private _sourceCode;
  133117. private _functionDescr;
  133118. private _numMaxIterations;
  133119. /** Gets or sets the token used to mark the functions to inline */
  133120. inlineToken: string;
  133121. /** Gets or sets the debug mode */
  133122. debug: boolean;
  133123. /** Gets the code after the inlining process */
  133124. get code(): string;
  133125. /**
  133126. * Initializes the inliner
  133127. * @param sourceCode shader code source to inline
  133128. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133129. */
  133130. constructor(sourceCode: string, numMaxIterations?: number);
  133131. /**
  133132. * Start the processing of the shader code
  133133. */
  133134. processCode(): void;
  133135. private _collectFunctions;
  133136. private _processInlining;
  133137. private _extractBetweenMarkers;
  133138. private _skipWhitespaces;
  133139. private _removeComments;
  133140. private _replaceFunctionCallsByCode;
  133141. private _findBackward;
  133142. private _escapeRegExp;
  133143. private _replaceNames;
  133144. }
  133145. }
  133146. declare module BABYLON {
  133147. /**
  133148. * Container for accessors for natively-stored mesh data buffers.
  133149. */
  133150. class NativeDataBuffer extends DataBuffer {
  133151. /**
  133152. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133153. */
  133154. nativeIndexBuffer?: any;
  133155. /**
  133156. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133157. */
  133158. nativeVertexBuffer?: any;
  133159. }
  133160. /** @hidden */
  133161. class NativeTexture extends InternalTexture {
  133162. getInternalTexture(): InternalTexture;
  133163. getViewCount(): number;
  133164. }
  133165. /** @hidden */
  133166. export class NativeEngine extends Engine {
  133167. private readonly _native;
  133168. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133169. private readonly INVALID_HANDLE;
  133170. private _boundBuffersVertexArray;
  133171. private _currentDepthTest;
  133172. getHardwareScalingLevel(): number;
  133173. constructor();
  133174. dispose(): void;
  133175. /**
  133176. * Can be used to override the current requestAnimationFrame requester.
  133177. * @hidden
  133178. */
  133179. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133180. /**
  133181. * Override default engine behavior.
  133182. * @param color
  133183. * @param backBuffer
  133184. * @param depth
  133185. * @param stencil
  133186. */
  133187. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133188. /**
  133189. * Gets host document
  133190. * @returns the host document object
  133191. */
  133192. getHostDocument(): Nullable<Document>;
  133193. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133194. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133195. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133196. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133197. [key: string]: VertexBuffer;
  133198. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133199. bindBuffers(vertexBuffers: {
  133200. [key: string]: VertexBuffer;
  133201. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133202. recordVertexArrayObject(vertexBuffers: {
  133203. [key: string]: VertexBuffer;
  133204. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133205. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133206. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133207. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133208. /**
  133209. * Draw a list of indexed primitives
  133210. * @param fillMode defines the primitive to use
  133211. * @param indexStart defines the starting index
  133212. * @param indexCount defines the number of index to draw
  133213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133214. */
  133215. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133216. /**
  133217. * Draw a list of unindexed primitives
  133218. * @param fillMode defines the primitive to use
  133219. * @param verticesStart defines the index of first vertex to draw
  133220. * @param verticesCount defines the count of vertices to draw
  133221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133222. */
  133223. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133224. createPipelineContext(): IPipelineContext;
  133225. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133226. /** @hidden */
  133227. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133228. /** @hidden */
  133229. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133230. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133231. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133232. protected _setProgram(program: WebGLProgram): void;
  133233. _releaseEffect(effect: Effect): void;
  133234. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133235. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133236. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133237. bindSamplers(effect: Effect): void;
  133238. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133239. getRenderWidth(useScreen?: boolean): number;
  133240. getRenderHeight(useScreen?: boolean): number;
  133241. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133242. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133243. /**
  133244. * Set the z offset to apply to current rendering
  133245. * @param value defines the offset to apply
  133246. */
  133247. setZOffset(value: number): void;
  133248. /**
  133249. * Gets the current value of the zOffset
  133250. * @returns the current zOffset state
  133251. */
  133252. getZOffset(): number;
  133253. /**
  133254. * Enable or disable depth buffering
  133255. * @param enable defines the state to set
  133256. */
  133257. setDepthBuffer(enable: boolean): void;
  133258. /**
  133259. * Gets a boolean indicating if depth writing is enabled
  133260. * @returns the current depth writing state
  133261. */
  133262. getDepthWrite(): boolean;
  133263. setDepthFunctionToGreater(): void;
  133264. setDepthFunctionToGreaterOrEqual(): void;
  133265. setDepthFunctionToLess(): void;
  133266. setDepthFunctionToLessOrEqual(): void;
  133267. /**
  133268. * Enable or disable depth writing
  133269. * @param enable defines the state to set
  133270. */
  133271. setDepthWrite(enable: boolean): void;
  133272. /**
  133273. * Enable or disable color writing
  133274. * @param enable defines the state to set
  133275. */
  133276. setColorWrite(enable: boolean): void;
  133277. /**
  133278. * Gets a boolean indicating if color writing is enabled
  133279. * @returns the current color writing state
  133280. */
  133281. getColorWrite(): boolean;
  133282. /**
  133283. * Sets alpha constants used by some alpha blending modes
  133284. * @param r defines the red component
  133285. * @param g defines the green component
  133286. * @param b defines the blue component
  133287. * @param a defines the alpha component
  133288. */
  133289. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133290. /**
  133291. * Sets the current alpha mode
  133292. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133293. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133294. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133295. */
  133296. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133297. /**
  133298. * Gets the current alpha mode
  133299. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133300. * @returns the current alpha mode
  133301. */
  133302. getAlphaMode(): number;
  133303. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133304. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133305. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133306. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133307. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133308. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133309. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133310. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133311. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133312. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133313. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133314. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133315. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133316. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133317. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133318. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133319. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133320. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133321. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133322. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133323. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133324. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133325. wipeCaches(bruteForce?: boolean): void;
  133326. _createTexture(): WebGLTexture;
  133327. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133328. /**
  133329. * Usually called from Texture.ts.
  133330. * Passed information to create a WebGLTexture
  133331. * @param url defines a value which contains one of the following:
  133332. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133333. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133334. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133335. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133336. * @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)
  133337. * @param scene needed for loading to the correct scene
  133338. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133339. * @param onLoad optional callback to be called upon successful completion
  133340. * @param onError optional callback to be called upon failure
  133341. * @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
  133342. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133343. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133344. * @param forcedExtension defines the extension to use to pick the right loader
  133345. * @param mimeType defines an optional mime type
  133346. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133347. */
  133348. 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;
  133349. /**
  133350. * Creates a cube texture
  133351. * @param rootUrl defines the url where the files to load is located
  133352. * @param scene defines the current scene
  133353. * @param files defines the list of files to load (1 per face)
  133354. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133355. * @param onLoad defines an optional callback raised when the texture is loaded
  133356. * @param onError defines an optional callback raised if there is an issue to load the texture
  133357. * @param format defines the format of the data
  133358. * @param forcedExtension defines the extension to use to pick the right loader
  133359. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133360. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133361. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133362. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133363. * @returns the cube texture as an InternalTexture
  133364. */
  133365. 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;
  133366. private _getSamplingFilter;
  133367. private static _GetNativeTextureFormat;
  133368. createRenderTargetTexture(size: number | {
  133369. width: number;
  133370. height: number;
  133371. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133372. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133373. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133374. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133375. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133376. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133377. /**
  133378. * Updates a dynamic vertex buffer.
  133379. * @param vertexBuffer the vertex buffer to update
  133380. * @param data the data used to update the vertex buffer
  133381. * @param byteOffset the byte offset of the data (optional)
  133382. * @param byteLength the byte length of the data (optional)
  133383. */
  133384. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133385. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133386. private _updateAnisotropicLevel;
  133387. private _getAddressMode;
  133388. /** @hidden */
  133389. _bindTexture(channel: number, texture: InternalTexture): void;
  133390. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133391. releaseEffects(): void;
  133392. /** @hidden */
  133393. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133394. /** @hidden */
  133395. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133396. /** @hidden */
  133397. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133398. /** @hidden */
  133399. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133400. }
  133401. }
  133402. declare module BABYLON {
  133403. /**
  133404. * Gather the list of clipboard event types as constants.
  133405. */
  133406. export class ClipboardEventTypes {
  133407. /**
  133408. * The clipboard event is fired when a copy command is active (pressed).
  133409. */
  133410. static readonly COPY: number;
  133411. /**
  133412. * The clipboard event is fired when a cut command is active (pressed).
  133413. */
  133414. static readonly CUT: number;
  133415. /**
  133416. * The clipboard event is fired when a paste command is active (pressed).
  133417. */
  133418. static readonly PASTE: number;
  133419. }
  133420. /**
  133421. * This class is used to store clipboard related info for the onClipboardObservable event.
  133422. */
  133423. export class ClipboardInfo {
  133424. /**
  133425. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133426. */
  133427. type: number;
  133428. /**
  133429. * Defines the related dom event
  133430. */
  133431. event: ClipboardEvent;
  133432. /**
  133433. *Creates an instance of ClipboardInfo.
  133434. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133435. * @param event Defines the related dom event
  133436. */
  133437. constructor(
  133438. /**
  133439. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133440. */
  133441. type: number,
  133442. /**
  133443. * Defines the related dom event
  133444. */
  133445. event: ClipboardEvent);
  133446. /**
  133447. * Get the clipboard event's type from the keycode.
  133448. * @param keyCode Defines the keyCode for the current keyboard event.
  133449. * @return {number}
  133450. */
  133451. static GetTypeFromCharacter(keyCode: number): number;
  133452. }
  133453. }
  133454. declare module BABYLON {
  133455. /**
  133456. * Google Daydream controller
  133457. */
  133458. export class DaydreamController extends WebVRController {
  133459. /**
  133460. * Base Url for the controller model.
  133461. */
  133462. static MODEL_BASE_URL: string;
  133463. /**
  133464. * File name for the controller model.
  133465. */
  133466. static MODEL_FILENAME: string;
  133467. /**
  133468. * Gamepad Id prefix used to identify Daydream Controller.
  133469. */
  133470. static readonly GAMEPAD_ID_PREFIX: string;
  133471. /**
  133472. * Creates a new DaydreamController from a gamepad
  133473. * @param vrGamepad the gamepad that the controller should be created from
  133474. */
  133475. constructor(vrGamepad: any);
  133476. /**
  133477. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133478. * @param scene scene in which to add meshes
  133479. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133480. */
  133481. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133482. /**
  133483. * Called once for each button that changed state since the last frame
  133484. * @param buttonIdx Which button index changed
  133485. * @param state New state of the button
  133486. * @param changes Which properties on the state changed since last frame
  133487. */
  133488. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133489. }
  133490. }
  133491. declare module BABYLON {
  133492. /**
  133493. * Gear VR Controller
  133494. */
  133495. export class GearVRController extends WebVRController {
  133496. /**
  133497. * Base Url for the controller model.
  133498. */
  133499. static MODEL_BASE_URL: string;
  133500. /**
  133501. * File name for the controller model.
  133502. */
  133503. static MODEL_FILENAME: string;
  133504. /**
  133505. * Gamepad Id prefix used to identify this controller.
  133506. */
  133507. static readonly GAMEPAD_ID_PREFIX: string;
  133508. private readonly _buttonIndexToObservableNameMap;
  133509. /**
  133510. * Creates a new GearVRController from a gamepad
  133511. * @param vrGamepad the gamepad that the controller should be created from
  133512. */
  133513. constructor(vrGamepad: any);
  133514. /**
  133515. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133516. * @param scene scene in which to add meshes
  133517. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133518. */
  133519. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133520. /**
  133521. * Called once for each button that changed state since the last frame
  133522. * @param buttonIdx Which button index changed
  133523. * @param state New state of the button
  133524. * @param changes Which properties on the state changed since last frame
  133525. */
  133526. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133527. }
  133528. }
  133529. declare module BABYLON {
  133530. /**
  133531. * Generic Controller
  133532. */
  133533. export class GenericController extends WebVRController {
  133534. /**
  133535. * Base Url for the controller model.
  133536. */
  133537. static readonly MODEL_BASE_URL: string;
  133538. /**
  133539. * File name for the controller model.
  133540. */
  133541. static readonly MODEL_FILENAME: string;
  133542. /**
  133543. * Creates a new GenericController from a gamepad
  133544. * @param vrGamepad the gamepad that the controller should be created from
  133545. */
  133546. constructor(vrGamepad: any);
  133547. /**
  133548. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133549. * @param scene scene in which to add meshes
  133550. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133551. */
  133552. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133553. /**
  133554. * Called once for each button that changed state since the last frame
  133555. * @param buttonIdx Which button index changed
  133556. * @param state New state of the button
  133557. * @param changes Which properties on the state changed since last frame
  133558. */
  133559. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133560. }
  133561. }
  133562. declare module BABYLON {
  133563. /**
  133564. * Oculus Touch Controller
  133565. */
  133566. export class OculusTouchController extends WebVRController {
  133567. /**
  133568. * Base Url for the controller model.
  133569. */
  133570. static MODEL_BASE_URL: string;
  133571. /**
  133572. * File name for the left controller model.
  133573. */
  133574. static MODEL_LEFT_FILENAME: string;
  133575. /**
  133576. * File name for the right controller model.
  133577. */
  133578. static MODEL_RIGHT_FILENAME: string;
  133579. /**
  133580. * Base Url for the Quest controller model.
  133581. */
  133582. static QUEST_MODEL_BASE_URL: string;
  133583. /**
  133584. * @hidden
  133585. * If the controllers are running on a device that needs the updated Quest controller models
  133586. */
  133587. static _IsQuest: boolean;
  133588. /**
  133589. * Fired when the secondary trigger on this controller is modified
  133590. */
  133591. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133592. /**
  133593. * Fired when the thumb rest on this controller is modified
  133594. */
  133595. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133596. /**
  133597. * Creates a new OculusTouchController from a gamepad
  133598. * @param vrGamepad the gamepad that the controller should be created from
  133599. */
  133600. constructor(vrGamepad: any);
  133601. /**
  133602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133603. * @param scene scene in which to add meshes
  133604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133605. */
  133606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133607. /**
  133608. * Fired when the A button on this controller is modified
  133609. */
  133610. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133611. /**
  133612. * Fired when the B button on this controller is modified
  133613. */
  133614. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133615. /**
  133616. * Fired when the X button on this controller is modified
  133617. */
  133618. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133619. /**
  133620. * Fired when the Y button on this controller is modified
  133621. */
  133622. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133623. /**
  133624. * Called once for each button that changed state since the last frame
  133625. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133626. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133627. * 2) secondary trigger (same)
  133628. * 3) A (right) X (left), touch, pressed = value
  133629. * 4) B / Y
  133630. * 5) thumb rest
  133631. * @param buttonIdx Which button index changed
  133632. * @param state New state of the button
  133633. * @param changes Which properties on the state changed since last frame
  133634. */
  133635. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133636. }
  133637. }
  133638. declare module BABYLON {
  133639. /**
  133640. * Vive Controller
  133641. */
  133642. export class ViveController extends WebVRController {
  133643. /**
  133644. * Base Url for the controller model.
  133645. */
  133646. static MODEL_BASE_URL: string;
  133647. /**
  133648. * File name for the controller model.
  133649. */
  133650. static MODEL_FILENAME: string;
  133651. /**
  133652. * Creates a new ViveController from a gamepad
  133653. * @param vrGamepad the gamepad that the controller should be created from
  133654. */
  133655. constructor(vrGamepad: any);
  133656. /**
  133657. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133658. * @param scene scene in which to add meshes
  133659. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133660. */
  133661. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133662. /**
  133663. * Fired when the left button on this controller is modified
  133664. */
  133665. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133666. /**
  133667. * Fired when the right button on this controller is modified
  133668. */
  133669. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133670. /**
  133671. * Fired when the menu button on this controller is modified
  133672. */
  133673. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133674. /**
  133675. * Called once for each button that changed state since the last frame
  133676. * Vive mapping:
  133677. * 0: touchpad
  133678. * 1: trigger
  133679. * 2: left AND right buttons
  133680. * 3: menu button
  133681. * @param buttonIdx Which button index changed
  133682. * @param state New state of the button
  133683. * @param changes Which properties on the state changed since last frame
  133684. */
  133685. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133686. }
  133687. }
  133688. declare module BABYLON {
  133689. /**
  133690. * Defines the WindowsMotionController object that the state of the windows motion controller
  133691. */
  133692. export class WindowsMotionController extends WebVRController {
  133693. /**
  133694. * The base url used to load the left and right controller models
  133695. */
  133696. static MODEL_BASE_URL: string;
  133697. /**
  133698. * The name of the left controller model file
  133699. */
  133700. static MODEL_LEFT_FILENAME: string;
  133701. /**
  133702. * The name of the right controller model file
  133703. */
  133704. static MODEL_RIGHT_FILENAME: string;
  133705. /**
  133706. * The controller name prefix for this controller type
  133707. */
  133708. static readonly GAMEPAD_ID_PREFIX: string;
  133709. /**
  133710. * The controller id pattern for this controller type
  133711. */
  133712. private static readonly GAMEPAD_ID_PATTERN;
  133713. private _loadedMeshInfo;
  133714. protected readonly _mapping: {
  133715. buttons: string[];
  133716. buttonMeshNames: {
  133717. trigger: string;
  133718. menu: string;
  133719. grip: string;
  133720. thumbstick: string;
  133721. trackpad: string;
  133722. };
  133723. buttonObservableNames: {
  133724. trigger: string;
  133725. menu: string;
  133726. grip: string;
  133727. thumbstick: string;
  133728. trackpad: string;
  133729. };
  133730. axisMeshNames: string[];
  133731. pointingPoseMeshName: string;
  133732. };
  133733. /**
  133734. * Fired when the trackpad on this controller is clicked
  133735. */
  133736. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133737. /**
  133738. * Fired when the trackpad on this controller is modified
  133739. */
  133740. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133741. /**
  133742. * The current x and y values of this controller's trackpad
  133743. */
  133744. trackpad: StickValues;
  133745. /**
  133746. * Creates a new WindowsMotionController from a gamepad
  133747. * @param vrGamepad the gamepad that the controller should be created from
  133748. */
  133749. constructor(vrGamepad: any);
  133750. /**
  133751. * Fired when the trigger on this controller is modified
  133752. */
  133753. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133754. /**
  133755. * Fired when the menu button on this controller is modified
  133756. */
  133757. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133758. /**
  133759. * Fired when the grip button on this controller is modified
  133760. */
  133761. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133762. /**
  133763. * Fired when the thumbstick button on this controller is modified
  133764. */
  133765. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133766. /**
  133767. * Fired when the touchpad button on this controller is modified
  133768. */
  133769. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133770. /**
  133771. * Fired when the touchpad values on this controller are modified
  133772. */
  133773. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133774. protected _updateTrackpad(): void;
  133775. /**
  133776. * Called once per frame by the engine.
  133777. */
  133778. update(): void;
  133779. /**
  133780. * Called once for each button that changed state since the last frame
  133781. * @param buttonIdx Which button index changed
  133782. * @param state New state of the button
  133783. * @param changes Which properties on the state changed since last frame
  133784. */
  133785. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133786. /**
  133787. * Moves the buttons on the controller mesh based on their current state
  133788. * @param buttonName the name of the button to move
  133789. * @param buttonValue the value of the button which determines the buttons new position
  133790. */
  133791. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133792. /**
  133793. * Moves the axis on the controller mesh based on its current state
  133794. * @param axis the index of the axis
  133795. * @param axisValue the value of the axis which determines the meshes new position
  133796. * @hidden
  133797. */
  133798. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133799. /**
  133800. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133801. * @param scene scene in which to add meshes
  133802. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133803. */
  133804. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133805. /**
  133806. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133807. * can be transformed by button presses and axes values, based on this._mapping.
  133808. *
  133809. * @param scene scene in which the meshes exist
  133810. * @param meshes list of meshes that make up the controller model to process
  133811. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133812. */
  133813. private processModel;
  133814. private createMeshInfo;
  133815. /**
  133816. * Gets the ray of the controller in the direction the controller is pointing
  133817. * @param length the length the resulting ray should be
  133818. * @returns a ray in the direction the controller is pointing
  133819. */
  133820. getForwardRay(length?: number): Ray;
  133821. /**
  133822. * Disposes of the controller
  133823. */
  133824. dispose(): void;
  133825. }
  133826. /**
  133827. * This class represents a new windows motion controller in XR.
  133828. */
  133829. export class XRWindowsMotionController extends WindowsMotionController {
  133830. /**
  133831. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133832. */
  133833. protected readonly _mapping: {
  133834. buttons: string[];
  133835. buttonMeshNames: {
  133836. trigger: string;
  133837. menu: string;
  133838. grip: string;
  133839. thumbstick: string;
  133840. trackpad: string;
  133841. };
  133842. buttonObservableNames: {
  133843. trigger: string;
  133844. menu: string;
  133845. grip: string;
  133846. thumbstick: string;
  133847. trackpad: string;
  133848. };
  133849. axisMeshNames: string[];
  133850. pointingPoseMeshName: string;
  133851. };
  133852. /**
  133853. * Construct a new XR-Based windows motion controller
  133854. *
  133855. * @param gamepadInfo the gamepad object from the browser
  133856. */
  133857. constructor(gamepadInfo: any);
  133858. /**
  133859. * holds the thumbstick values (X,Y)
  133860. */
  133861. thumbstickValues: StickValues;
  133862. /**
  133863. * Fired when the thumbstick on this controller is clicked
  133864. */
  133865. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133866. /**
  133867. * Fired when the thumbstick on this controller is modified
  133868. */
  133869. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133870. /**
  133871. * Fired when the touchpad button on this controller is modified
  133872. */
  133873. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133874. /**
  133875. * Fired when the touchpad values on this controller are modified
  133876. */
  133877. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133878. /**
  133879. * Fired when the thumbstick button on this controller is modified
  133880. * here to prevent breaking changes
  133881. */
  133882. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133883. /**
  133884. * updating the thumbstick(!) and not the trackpad.
  133885. * This is named this way due to the difference between WebVR and XR and to avoid
  133886. * changing the parent class.
  133887. */
  133888. protected _updateTrackpad(): void;
  133889. /**
  133890. * Disposes the class with joy
  133891. */
  133892. dispose(): void;
  133893. }
  133894. }
  133895. declare module BABYLON {
  133896. /**
  133897. * Class containing static functions to help procedurally build meshes
  133898. */
  133899. export class PolyhedronBuilder {
  133900. /**
  133901. * Creates a polyhedron mesh
  133902. * * 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
  133903. * * The parameter `size` (positive float, default 1) sets the polygon size
  133904. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133905. * * 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`
  133906. * * 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
  133907. * * 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)`)
  133908. * * 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
  133909. * * 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
  133910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133913. * @param name defines the name of the mesh
  133914. * @param options defines the options used to create the mesh
  133915. * @param scene defines the hosting scene
  133916. * @returns the polyhedron mesh
  133917. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133918. */
  133919. static CreatePolyhedron(name: string, options: {
  133920. type?: number;
  133921. size?: number;
  133922. sizeX?: number;
  133923. sizeY?: number;
  133924. sizeZ?: number;
  133925. custom?: any;
  133926. faceUV?: Vector4[];
  133927. faceColors?: Color4[];
  133928. flat?: boolean;
  133929. updatable?: boolean;
  133930. sideOrientation?: number;
  133931. frontUVs?: Vector4;
  133932. backUVs?: Vector4;
  133933. }, scene?: Nullable<Scene>): Mesh;
  133934. }
  133935. }
  133936. declare module BABYLON {
  133937. /**
  133938. * Gizmo that enables scaling a mesh along 3 axis
  133939. */
  133940. export class ScaleGizmo extends Gizmo {
  133941. /**
  133942. * Internal gizmo used for interactions on the x axis
  133943. */
  133944. xGizmo: AxisScaleGizmo;
  133945. /**
  133946. * Internal gizmo used for interactions on the y axis
  133947. */
  133948. yGizmo: AxisScaleGizmo;
  133949. /**
  133950. * Internal gizmo used for interactions on the z axis
  133951. */
  133952. zGizmo: AxisScaleGizmo;
  133953. /**
  133954. * Internal gizmo used to scale all axis equally
  133955. */
  133956. uniformScaleGizmo: AxisScaleGizmo;
  133957. private _meshAttached;
  133958. private _nodeAttached;
  133959. private _snapDistance;
  133960. private _uniformScalingMesh;
  133961. private _octahedron;
  133962. private _sensitivity;
  133963. /** Fires an event when any of it's sub gizmos are dragged */
  133964. onDragStartObservable: Observable<unknown>;
  133965. /** Fires an event when any of it's sub gizmos are released from dragging */
  133966. onDragEndObservable: Observable<unknown>;
  133967. get attachedMesh(): Nullable<AbstractMesh>;
  133968. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133969. get attachedNode(): Nullable<Node>;
  133970. set attachedNode(node: Nullable<Node>);
  133971. /**
  133972. * True when the mouse pointer is hovering a gizmo mesh
  133973. */
  133974. get isHovered(): boolean;
  133975. /**
  133976. * Creates a ScaleGizmo
  133977. * @param gizmoLayer The utility layer the gizmo will be added to
  133978. * @param thickness display gizmo axis thickness
  133979. */
  133980. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133981. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133982. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133983. /**
  133984. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133985. */
  133986. set snapDistance(value: number);
  133987. get snapDistance(): number;
  133988. /**
  133989. * Ratio for the scale of the gizmo (Default: 1)
  133990. */
  133991. set scaleRatio(value: number);
  133992. get scaleRatio(): number;
  133993. /**
  133994. * Sensitivity factor for dragging (Default: 1)
  133995. */
  133996. set sensitivity(value: number);
  133997. get sensitivity(): number;
  133998. /**
  133999. * Disposes of the gizmo
  134000. */
  134001. dispose(): void;
  134002. }
  134003. }
  134004. declare module BABYLON {
  134005. /**
  134006. * Single axis scale gizmo
  134007. */
  134008. export class AxisScaleGizmo extends Gizmo {
  134009. /**
  134010. * Drag behavior responsible for the gizmos dragging interactions
  134011. */
  134012. dragBehavior: PointerDragBehavior;
  134013. private _pointerObserver;
  134014. /**
  134015. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134016. */
  134017. snapDistance: number;
  134018. /**
  134019. * Event that fires each time the gizmo snaps to a new location.
  134020. * * snapDistance is the the change in distance
  134021. */
  134022. onSnapObservable: Observable<{
  134023. snapDistance: number;
  134024. }>;
  134025. /**
  134026. * If the scaling operation should be done on all axis (default: false)
  134027. */
  134028. uniformScaling: boolean;
  134029. /**
  134030. * Custom sensitivity value for the drag strength
  134031. */
  134032. sensitivity: number;
  134033. private _isEnabled;
  134034. private _parent;
  134035. private _arrow;
  134036. private _coloredMaterial;
  134037. private _hoverMaterial;
  134038. /**
  134039. * Creates an AxisScaleGizmo
  134040. * @param gizmoLayer The utility layer the gizmo will be added to
  134041. * @param dragAxis The axis which the gizmo will be able to scale on
  134042. * @param color The color of the gizmo
  134043. * @param thickness display gizmo axis thickness
  134044. */
  134045. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134046. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134047. /**
  134048. * If the gizmo is enabled
  134049. */
  134050. set isEnabled(value: boolean);
  134051. get isEnabled(): boolean;
  134052. /**
  134053. * Disposes of the gizmo
  134054. */
  134055. dispose(): void;
  134056. /**
  134057. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134058. * @param mesh The mesh to replace the default mesh of the gizmo
  134059. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134060. */
  134061. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134062. }
  134063. }
  134064. declare module BABYLON {
  134065. /**
  134066. * Bounding box gizmo
  134067. */
  134068. export class BoundingBoxGizmo extends Gizmo {
  134069. private _lineBoundingBox;
  134070. private _rotateSpheresParent;
  134071. private _scaleBoxesParent;
  134072. private _boundingDimensions;
  134073. private _renderObserver;
  134074. private _pointerObserver;
  134075. private _scaleDragSpeed;
  134076. private _tmpQuaternion;
  134077. private _tmpVector;
  134078. private _tmpRotationMatrix;
  134079. /**
  134080. * 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)
  134081. */
  134082. ignoreChildren: boolean;
  134083. /**
  134084. * 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)
  134085. */
  134086. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134087. /**
  134088. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134089. */
  134090. rotationSphereSize: number;
  134091. /**
  134092. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134093. */
  134094. scaleBoxSize: number;
  134095. /**
  134096. * 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)
  134097. */
  134098. fixedDragMeshScreenSize: boolean;
  134099. /**
  134100. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134101. */
  134102. fixedDragMeshScreenSizeDistanceFactor: number;
  134103. /**
  134104. * Fired when a rotation sphere or scale box is dragged
  134105. */
  134106. onDragStartObservable: Observable<{}>;
  134107. /**
  134108. * Fired when a scale box is dragged
  134109. */
  134110. onScaleBoxDragObservable: Observable<{}>;
  134111. /**
  134112. * Fired when a scale box drag is ended
  134113. */
  134114. onScaleBoxDragEndObservable: Observable<{}>;
  134115. /**
  134116. * Fired when a rotation sphere is dragged
  134117. */
  134118. onRotationSphereDragObservable: Observable<{}>;
  134119. /**
  134120. * Fired when a rotation sphere drag is ended
  134121. */
  134122. onRotationSphereDragEndObservable: Observable<{}>;
  134123. /**
  134124. * 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)
  134125. */
  134126. scalePivot: Nullable<Vector3>;
  134127. /**
  134128. * Mesh used as a pivot to rotate the attached node
  134129. */
  134130. private _anchorMesh;
  134131. private _existingMeshScale;
  134132. private _dragMesh;
  134133. private pointerDragBehavior;
  134134. private coloredMaterial;
  134135. private hoverColoredMaterial;
  134136. /**
  134137. * Sets the color of the bounding box gizmo
  134138. * @param color the color to set
  134139. */
  134140. setColor(color: Color3): void;
  134141. /**
  134142. * Creates an BoundingBoxGizmo
  134143. * @param gizmoLayer The utility layer the gizmo will be added to
  134144. * @param color The color of the gizmo
  134145. */
  134146. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134147. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134148. private _selectNode;
  134149. /**
  134150. * Updates the bounding box information for the Gizmo
  134151. */
  134152. updateBoundingBox(): void;
  134153. private _updateRotationSpheres;
  134154. private _updateScaleBoxes;
  134155. /**
  134156. * Enables rotation on the specified axis and disables rotation on the others
  134157. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134158. */
  134159. setEnabledRotationAxis(axis: string): void;
  134160. /**
  134161. * Enables/disables scaling
  134162. * @param enable if scaling should be enabled
  134163. * @param homogeneousScaling defines if scaling should only be homogeneous
  134164. */
  134165. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134166. private _updateDummy;
  134167. /**
  134168. * Enables a pointer drag behavior on the bounding box of the gizmo
  134169. */
  134170. enableDragBehavior(): void;
  134171. /**
  134172. * Disposes of the gizmo
  134173. */
  134174. dispose(): void;
  134175. /**
  134176. * 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)
  134177. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134178. * @returns the bounding box mesh with the passed in mesh as a child
  134179. */
  134180. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134181. /**
  134182. * CustomMeshes are not supported by this gizmo
  134183. * @param mesh The mesh to replace the default mesh of the gizmo
  134184. */
  134185. setCustomMesh(mesh: Mesh): void;
  134186. }
  134187. }
  134188. declare module BABYLON {
  134189. /**
  134190. * Single plane rotation gizmo
  134191. */
  134192. export class PlaneRotationGizmo extends Gizmo {
  134193. /**
  134194. * Drag behavior responsible for the gizmos dragging interactions
  134195. */
  134196. dragBehavior: PointerDragBehavior;
  134197. private _pointerObserver;
  134198. /**
  134199. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134200. */
  134201. snapDistance: number;
  134202. /**
  134203. * Event that fires each time the gizmo snaps to a new location.
  134204. * * snapDistance is the the change in distance
  134205. */
  134206. onSnapObservable: Observable<{
  134207. snapDistance: number;
  134208. }>;
  134209. private _isEnabled;
  134210. private _parent;
  134211. /**
  134212. * Creates a PlaneRotationGizmo
  134213. * @param gizmoLayer The utility layer the gizmo will be added to
  134214. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134215. * @param color The color of the gizmo
  134216. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134217. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134218. * @param thickness display gizmo axis thickness
  134219. */
  134220. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134221. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134222. /**
  134223. * If the gizmo is enabled
  134224. */
  134225. set isEnabled(value: boolean);
  134226. get isEnabled(): boolean;
  134227. /**
  134228. * Disposes of the gizmo
  134229. */
  134230. dispose(): void;
  134231. }
  134232. }
  134233. declare module BABYLON {
  134234. /**
  134235. * Gizmo that enables rotating a mesh along 3 axis
  134236. */
  134237. export class RotationGizmo extends Gizmo {
  134238. /**
  134239. * Internal gizmo used for interactions on the x axis
  134240. */
  134241. xGizmo: PlaneRotationGizmo;
  134242. /**
  134243. * Internal gizmo used for interactions on the y axis
  134244. */
  134245. yGizmo: PlaneRotationGizmo;
  134246. /**
  134247. * Internal gizmo used for interactions on the z axis
  134248. */
  134249. zGizmo: PlaneRotationGizmo;
  134250. /** Fires an event when any of it's sub gizmos are dragged */
  134251. onDragStartObservable: Observable<unknown>;
  134252. /** Fires an event when any of it's sub gizmos are released from dragging */
  134253. onDragEndObservable: Observable<unknown>;
  134254. private _meshAttached;
  134255. private _nodeAttached;
  134256. get attachedMesh(): Nullable<AbstractMesh>;
  134257. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134258. get attachedNode(): Nullable<Node>;
  134259. set attachedNode(node: Nullable<Node>);
  134260. /**
  134261. * True when the mouse pointer is hovering a gizmo mesh
  134262. */
  134263. get isHovered(): boolean;
  134264. /**
  134265. * Creates a RotationGizmo
  134266. * @param gizmoLayer The utility layer the gizmo will be added to
  134267. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134268. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134269. * @param thickness display gizmo axis thickness
  134270. */
  134271. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134272. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134273. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134274. /**
  134275. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134276. */
  134277. set snapDistance(value: number);
  134278. get snapDistance(): number;
  134279. /**
  134280. * Ratio for the scale of the gizmo (Default: 1)
  134281. */
  134282. set scaleRatio(value: number);
  134283. get scaleRatio(): number;
  134284. /**
  134285. * Disposes of the gizmo
  134286. */
  134287. dispose(): void;
  134288. /**
  134289. * CustomMeshes are not supported by this gizmo
  134290. * @param mesh The mesh to replace the default mesh of the gizmo
  134291. */
  134292. setCustomMesh(mesh: Mesh): void;
  134293. }
  134294. }
  134295. declare module BABYLON {
  134296. /**
  134297. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134298. */
  134299. export class GizmoManager implements IDisposable {
  134300. private scene;
  134301. /**
  134302. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134303. */
  134304. gizmos: {
  134305. positionGizmo: Nullable<PositionGizmo>;
  134306. rotationGizmo: Nullable<RotationGizmo>;
  134307. scaleGizmo: Nullable<ScaleGizmo>;
  134308. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134309. };
  134310. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134311. clearGizmoOnEmptyPointerEvent: boolean;
  134312. /** Fires an event when the manager is attached to a mesh */
  134313. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134314. /** Fires an event when the manager is attached to a node */
  134315. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134316. private _gizmosEnabled;
  134317. private _pointerObserver;
  134318. private _attachedMesh;
  134319. private _attachedNode;
  134320. private _boundingBoxColor;
  134321. private _defaultUtilityLayer;
  134322. private _defaultKeepDepthUtilityLayer;
  134323. private _thickness;
  134324. /**
  134325. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134326. */
  134327. boundingBoxDragBehavior: SixDofDragBehavior;
  134328. /**
  134329. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134330. */
  134331. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134332. /**
  134333. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134334. */
  134335. attachableNodes: Nullable<Array<Node>>;
  134336. /**
  134337. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134338. */
  134339. usePointerToAttachGizmos: boolean;
  134340. /**
  134341. * Utility layer that the bounding box gizmo belongs to
  134342. */
  134343. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134344. /**
  134345. * Utility layer that all gizmos besides bounding box belong to
  134346. */
  134347. get utilityLayer(): UtilityLayerRenderer;
  134348. /**
  134349. * True when the mouse pointer is hovering a gizmo mesh
  134350. */
  134351. get isHovered(): boolean;
  134352. /**
  134353. * Instatiates a gizmo manager
  134354. * @param scene the scene to overlay the gizmos on top of
  134355. * @param thickness display gizmo axis thickness
  134356. */
  134357. constructor(scene: Scene, thickness?: number);
  134358. /**
  134359. * Attaches a set of gizmos to the specified mesh
  134360. * @param mesh The mesh the gizmo's should be attached to
  134361. */
  134362. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134363. /**
  134364. * Attaches a set of gizmos to the specified node
  134365. * @param node The node the gizmo's should be attached to
  134366. */
  134367. attachToNode(node: Nullable<Node>): void;
  134368. /**
  134369. * If the position gizmo is enabled
  134370. */
  134371. set positionGizmoEnabled(value: boolean);
  134372. get positionGizmoEnabled(): boolean;
  134373. /**
  134374. * If the rotation gizmo is enabled
  134375. */
  134376. set rotationGizmoEnabled(value: boolean);
  134377. get rotationGizmoEnabled(): boolean;
  134378. /**
  134379. * If the scale gizmo is enabled
  134380. */
  134381. set scaleGizmoEnabled(value: boolean);
  134382. get scaleGizmoEnabled(): boolean;
  134383. /**
  134384. * If the boundingBox gizmo is enabled
  134385. */
  134386. set boundingBoxGizmoEnabled(value: boolean);
  134387. get boundingBoxGizmoEnabled(): boolean;
  134388. /**
  134389. * Disposes of the gizmo manager
  134390. */
  134391. dispose(): void;
  134392. }
  134393. }
  134394. declare module BABYLON {
  134395. /**
  134396. * A directional light is defined by a direction (what a surprise!).
  134397. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134398. * 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.
  134399. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134400. */
  134401. export class DirectionalLight extends ShadowLight {
  134402. private _shadowFrustumSize;
  134403. /**
  134404. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134405. */
  134406. get shadowFrustumSize(): number;
  134407. /**
  134408. * Specifies a fix frustum size for the shadow generation.
  134409. */
  134410. set shadowFrustumSize(value: number);
  134411. private _shadowOrthoScale;
  134412. /**
  134413. * Gets the shadow projection scale against the optimal computed one.
  134414. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134415. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134416. */
  134417. get shadowOrthoScale(): number;
  134418. /**
  134419. * Sets the shadow projection scale against the optimal computed one.
  134420. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134421. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134422. */
  134423. set shadowOrthoScale(value: number);
  134424. /**
  134425. * Automatically compute the projection matrix to best fit (including all the casters)
  134426. * on each frame.
  134427. */
  134428. autoUpdateExtends: boolean;
  134429. /**
  134430. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134431. * on each frame. autoUpdateExtends must be set to true for this to work
  134432. */
  134433. autoCalcShadowZBounds: boolean;
  134434. private _orthoLeft;
  134435. private _orthoRight;
  134436. private _orthoTop;
  134437. private _orthoBottom;
  134438. /**
  134439. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134440. * The directional light is emitted from everywhere in the given direction.
  134441. * It can cast shadows.
  134442. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134443. * @param name The friendly name of the light
  134444. * @param direction The direction of the light
  134445. * @param scene The scene the light belongs to
  134446. */
  134447. constructor(name: string, direction: Vector3, scene: Scene);
  134448. /**
  134449. * Returns the string "DirectionalLight".
  134450. * @return The class name
  134451. */
  134452. getClassName(): string;
  134453. /**
  134454. * Returns the integer 1.
  134455. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134456. */
  134457. getTypeID(): number;
  134458. /**
  134459. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134460. * Returns the DirectionalLight Shadow projection matrix.
  134461. */
  134462. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134463. /**
  134464. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134465. * Returns the DirectionalLight Shadow projection matrix.
  134466. */
  134467. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134468. /**
  134469. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134470. * Returns the DirectionalLight Shadow projection matrix.
  134471. */
  134472. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134473. protected _buildUniformLayout(): void;
  134474. /**
  134475. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134476. * @param effect The effect to update
  134477. * @param lightIndex The index of the light in the effect to update
  134478. * @returns The directional light
  134479. */
  134480. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134481. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134482. /**
  134483. * Gets the minZ used for shadow according to both the scene and the light.
  134484. *
  134485. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134486. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134487. * @param activeCamera The camera we are returning the min for
  134488. * @returns the depth min z
  134489. */
  134490. getDepthMinZ(activeCamera: Camera): number;
  134491. /**
  134492. * Gets the maxZ used for shadow according to both the scene and the light.
  134493. *
  134494. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134495. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134496. * @param activeCamera The camera we are returning the max for
  134497. * @returns the depth max z
  134498. */
  134499. getDepthMaxZ(activeCamera: Camera): number;
  134500. /**
  134501. * Prepares the list of defines specific to the light type.
  134502. * @param defines the list of defines
  134503. * @param lightIndex defines the index of the light for the effect
  134504. */
  134505. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134506. }
  134507. }
  134508. declare module BABYLON {
  134509. /**
  134510. * Class containing static functions to help procedurally build meshes
  134511. */
  134512. export class HemisphereBuilder {
  134513. /**
  134514. * Creates a hemisphere mesh
  134515. * @param name defines the name of the mesh
  134516. * @param options defines the options used to create the mesh
  134517. * @param scene defines the hosting scene
  134518. * @returns the hemisphere mesh
  134519. */
  134520. static CreateHemisphere(name: string, options: {
  134521. segments?: number;
  134522. diameter?: number;
  134523. sideOrientation?: number;
  134524. }, scene: any): Mesh;
  134525. }
  134526. }
  134527. declare module BABYLON {
  134528. /**
  134529. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134530. * These values define a cone of light starting from the position, emitting toward the direction.
  134531. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134532. * and the exponent defines the speed of the decay of the light with distance (reach).
  134533. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134534. */
  134535. export class SpotLight extends ShadowLight {
  134536. private _angle;
  134537. private _innerAngle;
  134538. private _cosHalfAngle;
  134539. private _lightAngleScale;
  134540. private _lightAngleOffset;
  134541. /**
  134542. * Gets the cone angle of the spot light in Radians.
  134543. */
  134544. get angle(): number;
  134545. /**
  134546. * Sets the cone angle of the spot light in Radians.
  134547. */
  134548. set angle(value: number);
  134549. /**
  134550. * Only used in gltf falloff mode, this defines the angle where
  134551. * the directional falloff will start before cutting at angle which could be seen
  134552. * as outer angle.
  134553. */
  134554. get innerAngle(): number;
  134555. /**
  134556. * Only used in gltf falloff mode, this defines the angle where
  134557. * the directional falloff will start before cutting at angle which could be seen
  134558. * as outer angle.
  134559. */
  134560. set innerAngle(value: number);
  134561. private _shadowAngleScale;
  134562. /**
  134563. * Allows scaling the angle of the light for shadow generation only.
  134564. */
  134565. get shadowAngleScale(): number;
  134566. /**
  134567. * Allows scaling the angle of the light for shadow generation only.
  134568. */
  134569. set shadowAngleScale(value: number);
  134570. /**
  134571. * The light decay speed with the distance from the emission spot.
  134572. */
  134573. exponent: number;
  134574. private _projectionTextureMatrix;
  134575. /**
  134576. * Allows reading the projecton texture
  134577. */
  134578. get projectionTextureMatrix(): Matrix;
  134579. protected _projectionTextureLightNear: number;
  134580. /**
  134581. * Gets the near clip of the Spotlight for texture projection.
  134582. */
  134583. get projectionTextureLightNear(): number;
  134584. /**
  134585. * Sets the near clip of the Spotlight for texture projection.
  134586. */
  134587. set projectionTextureLightNear(value: number);
  134588. protected _projectionTextureLightFar: number;
  134589. /**
  134590. * Gets the far clip of the Spotlight for texture projection.
  134591. */
  134592. get projectionTextureLightFar(): number;
  134593. /**
  134594. * Sets the far clip of the Spotlight for texture projection.
  134595. */
  134596. set projectionTextureLightFar(value: number);
  134597. protected _projectionTextureUpDirection: Vector3;
  134598. /**
  134599. * Gets the Up vector of the Spotlight for texture projection.
  134600. */
  134601. get projectionTextureUpDirection(): Vector3;
  134602. /**
  134603. * Sets the Up vector of the Spotlight for texture projection.
  134604. */
  134605. set projectionTextureUpDirection(value: Vector3);
  134606. private _projectionTexture;
  134607. /**
  134608. * Gets the projection texture of the light.
  134609. */
  134610. get projectionTexture(): Nullable<BaseTexture>;
  134611. /**
  134612. * Sets the projection texture of the light.
  134613. */
  134614. set projectionTexture(value: Nullable<BaseTexture>);
  134615. private _projectionTextureViewLightDirty;
  134616. private _projectionTextureProjectionLightDirty;
  134617. private _projectionTextureDirty;
  134618. private _projectionTextureViewTargetVector;
  134619. private _projectionTextureViewLightMatrix;
  134620. private _projectionTextureProjectionLightMatrix;
  134621. private _projectionTextureScalingMatrix;
  134622. /**
  134623. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134624. * It can cast shadows.
  134625. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134626. * @param name The light friendly name
  134627. * @param position The position of the spot light in the scene
  134628. * @param direction The direction of the light in the scene
  134629. * @param angle The cone angle of the light in Radians
  134630. * @param exponent The light decay speed with the distance from the emission spot
  134631. * @param scene The scene the lights belongs to
  134632. */
  134633. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134634. /**
  134635. * Returns the string "SpotLight".
  134636. * @returns the class name
  134637. */
  134638. getClassName(): string;
  134639. /**
  134640. * Returns the integer 2.
  134641. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134642. */
  134643. getTypeID(): number;
  134644. /**
  134645. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134646. */
  134647. protected _setDirection(value: Vector3): void;
  134648. /**
  134649. * Overrides the position setter to recompute the projection texture view light Matrix.
  134650. */
  134651. protected _setPosition(value: Vector3): void;
  134652. /**
  134653. * 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.
  134654. * Returns the SpotLight.
  134655. */
  134656. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134657. protected _computeProjectionTextureViewLightMatrix(): void;
  134658. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134659. /**
  134660. * Main function for light texture projection matrix computing.
  134661. */
  134662. protected _computeProjectionTextureMatrix(): void;
  134663. protected _buildUniformLayout(): void;
  134664. private _computeAngleValues;
  134665. /**
  134666. * Sets the passed Effect "effect" with the Light textures.
  134667. * @param effect The effect to update
  134668. * @param lightIndex The index of the light in the effect to update
  134669. * @returns The light
  134670. */
  134671. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134672. /**
  134673. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134674. * @param effect The effect to update
  134675. * @param lightIndex The index of the light in the effect to update
  134676. * @returns The spot light
  134677. */
  134678. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134679. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134680. /**
  134681. * Disposes the light and the associated resources.
  134682. */
  134683. dispose(): void;
  134684. /**
  134685. * Prepares the list of defines specific to the light type.
  134686. * @param defines the list of defines
  134687. * @param lightIndex defines the index of the light for the effect
  134688. */
  134689. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134690. }
  134691. }
  134692. declare module BABYLON {
  134693. /**
  134694. * Gizmo that enables viewing a light
  134695. */
  134696. export class LightGizmo extends Gizmo {
  134697. private _lightMesh;
  134698. private _material;
  134699. private _cachedPosition;
  134700. private _cachedForward;
  134701. private _attachedMeshParent;
  134702. private _pointerObserver;
  134703. /**
  134704. * Event that fires each time the gizmo is clicked
  134705. */
  134706. onClickedObservable: Observable<Light>;
  134707. /**
  134708. * Creates a LightGizmo
  134709. * @param gizmoLayer The utility layer the gizmo will be added to
  134710. */
  134711. constructor(gizmoLayer?: UtilityLayerRenderer);
  134712. private _light;
  134713. /**
  134714. * The light that the gizmo is attached to
  134715. */
  134716. set light(light: Nullable<Light>);
  134717. get light(): Nullable<Light>;
  134718. /**
  134719. * Gets the material used to render the light gizmo
  134720. */
  134721. get material(): StandardMaterial;
  134722. /**
  134723. * @hidden
  134724. * Updates the gizmo to match the attached mesh's position/rotation
  134725. */
  134726. protected _update(): void;
  134727. private static _Scale;
  134728. /**
  134729. * Creates the lines for a light mesh
  134730. */
  134731. private static _CreateLightLines;
  134732. /**
  134733. * Disposes of the light gizmo
  134734. */
  134735. dispose(): void;
  134736. private static _CreateHemisphericLightMesh;
  134737. private static _CreatePointLightMesh;
  134738. private static _CreateSpotLightMesh;
  134739. private static _CreateDirectionalLightMesh;
  134740. }
  134741. }
  134742. declare module BABYLON {
  134743. /**
  134744. * Gizmo that enables viewing a camera
  134745. */
  134746. export class CameraGizmo extends Gizmo {
  134747. private _cameraMesh;
  134748. private _cameraLinesMesh;
  134749. private _material;
  134750. private _pointerObserver;
  134751. /**
  134752. * Event that fires each time the gizmo is clicked
  134753. */
  134754. onClickedObservable: Observable<Camera>;
  134755. /**
  134756. * Creates a CameraGizmo
  134757. * @param gizmoLayer The utility layer the gizmo will be added to
  134758. */
  134759. constructor(gizmoLayer?: UtilityLayerRenderer);
  134760. private _camera;
  134761. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134762. get displayFrustum(): boolean;
  134763. set displayFrustum(value: boolean);
  134764. /**
  134765. * The camera that the gizmo is attached to
  134766. */
  134767. set camera(camera: Nullable<Camera>);
  134768. get camera(): Nullable<Camera>;
  134769. /**
  134770. * Gets the material used to render the camera gizmo
  134771. */
  134772. get material(): StandardMaterial;
  134773. /**
  134774. * @hidden
  134775. * Updates the gizmo to match the attached mesh's position/rotation
  134776. */
  134777. protected _update(): void;
  134778. private static _Scale;
  134779. private _invProjection;
  134780. /**
  134781. * Disposes of the camera gizmo
  134782. */
  134783. dispose(): void;
  134784. private static _CreateCameraMesh;
  134785. private static _CreateCameraFrustum;
  134786. }
  134787. }
  134788. declare module BABYLON {
  134789. /** @hidden */
  134790. export var backgroundFragmentDeclaration: {
  134791. name: string;
  134792. shader: string;
  134793. };
  134794. }
  134795. declare module BABYLON {
  134796. /** @hidden */
  134797. export var backgroundUboDeclaration: {
  134798. name: string;
  134799. shader: string;
  134800. };
  134801. }
  134802. declare module BABYLON {
  134803. /** @hidden */
  134804. export var backgroundPixelShader: {
  134805. name: string;
  134806. shader: string;
  134807. };
  134808. }
  134809. declare module BABYLON {
  134810. /** @hidden */
  134811. export var backgroundVertexDeclaration: {
  134812. name: string;
  134813. shader: string;
  134814. };
  134815. }
  134816. declare module BABYLON {
  134817. /** @hidden */
  134818. export var backgroundVertexShader: {
  134819. name: string;
  134820. shader: string;
  134821. };
  134822. }
  134823. declare module BABYLON {
  134824. /**
  134825. * Background material used to create an efficient environement around your scene.
  134826. */
  134827. export class BackgroundMaterial extends PushMaterial {
  134828. /**
  134829. * Standard reflectance value at parallel view angle.
  134830. */
  134831. static StandardReflectance0: number;
  134832. /**
  134833. * Standard reflectance value at grazing angle.
  134834. */
  134835. static StandardReflectance90: number;
  134836. protected _primaryColor: Color3;
  134837. /**
  134838. * Key light Color (multiply against the environement texture)
  134839. */
  134840. primaryColor: Color3;
  134841. protected __perceptualColor: Nullable<Color3>;
  134842. /**
  134843. * Experimental Internal Use Only.
  134844. *
  134845. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134846. * This acts as a helper to set the primary color to a more "human friendly" value.
  134847. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134848. * output color as close as possible from the chosen value.
  134849. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134850. * part of lighting setup.)
  134851. */
  134852. get _perceptualColor(): Nullable<Color3>;
  134853. set _perceptualColor(value: Nullable<Color3>);
  134854. protected _primaryColorShadowLevel: float;
  134855. /**
  134856. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134857. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134858. */
  134859. get primaryColorShadowLevel(): float;
  134860. set primaryColorShadowLevel(value: float);
  134861. protected _primaryColorHighlightLevel: float;
  134862. /**
  134863. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134864. * The primary color is used at the level chosen to define what the white area would look.
  134865. */
  134866. get primaryColorHighlightLevel(): float;
  134867. set primaryColorHighlightLevel(value: float);
  134868. protected _reflectionTexture: Nullable<BaseTexture>;
  134869. /**
  134870. * Reflection Texture used in the material.
  134871. * Should be author in a specific way for the best result (refer to the documentation).
  134872. */
  134873. reflectionTexture: Nullable<BaseTexture>;
  134874. protected _reflectionBlur: float;
  134875. /**
  134876. * Reflection Texture level of blur.
  134877. *
  134878. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134879. * texture twice.
  134880. */
  134881. reflectionBlur: float;
  134882. protected _diffuseTexture: Nullable<BaseTexture>;
  134883. /**
  134884. * Diffuse Texture used in the material.
  134885. * Should be author in a specific way for the best result (refer to the documentation).
  134886. */
  134887. diffuseTexture: Nullable<BaseTexture>;
  134888. protected _shadowLights: Nullable<IShadowLight[]>;
  134889. /**
  134890. * Specify the list of lights casting shadow on the material.
  134891. * All scene shadow lights will be included if null.
  134892. */
  134893. shadowLights: Nullable<IShadowLight[]>;
  134894. protected _shadowLevel: float;
  134895. /**
  134896. * Helps adjusting the shadow to a softer level if required.
  134897. * 0 means black shadows and 1 means no shadows.
  134898. */
  134899. shadowLevel: float;
  134900. protected _sceneCenter: Vector3;
  134901. /**
  134902. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134903. * It is usually zero but might be interesting to modify according to your setup.
  134904. */
  134905. sceneCenter: Vector3;
  134906. protected _opacityFresnel: boolean;
  134907. /**
  134908. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134909. * This helps ensuring a nice transition when the camera goes under the ground.
  134910. */
  134911. opacityFresnel: boolean;
  134912. protected _reflectionFresnel: boolean;
  134913. /**
  134914. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134915. * This helps adding a mirror texture on the ground.
  134916. */
  134917. reflectionFresnel: boolean;
  134918. protected _reflectionFalloffDistance: number;
  134919. /**
  134920. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134921. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134922. */
  134923. reflectionFalloffDistance: number;
  134924. protected _reflectionAmount: number;
  134925. /**
  134926. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134927. */
  134928. reflectionAmount: number;
  134929. protected _reflectionReflectance0: number;
  134930. /**
  134931. * This specifies the weight of the reflection at grazing angle.
  134932. */
  134933. reflectionReflectance0: number;
  134934. protected _reflectionReflectance90: number;
  134935. /**
  134936. * This specifies the weight of the reflection at a perpendicular point of view.
  134937. */
  134938. reflectionReflectance90: number;
  134939. /**
  134940. * Sets the reflection reflectance fresnel values according to the default standard
  134941. * empirically know to work well :-)
  134942. */
  134943. set reflectionStandardFresnelWeight(value: number);
  134944. protected _useRGBColor: boolean;
  134945. /**
  134946. * Helps to directly use the maps channels instead of their level.
  134947. */
  134948. useRGBColor: boolean;
  134949. protected _enableNoise: boolean;
  134950. /**
  134951. * This helps reducing the banding effect that could occur on the background.
  134952. */
  134953. enableNoise: boolean;
  134954. /**
  134955. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134956. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134957. * Recommended to be keep at 1.0 except for special cases.
  134958. */
  134959. get fovMultiplier(): number;
  134960. set fovMultiplier(value: number);
  134961. private _fovMultiplier;
  134962. /**
  134963. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134964. */
  134965. useEquirectangularFOV: boolean;
  134966. private _maxSimultaneousLights;
  134967. /**
  134968. * Number of Simultaneous lights allowed on the material.
  134969. */
  134970. maxSimultaneousLights: int;
  134971. private _shadowOnly;
  134972. /**
  134973. * Make the material only render shadows
  134974. */
  134975. shadowOnly: boolean;
  134976. /**
  134977. * Default configuration related to image processing available in the Background Material.
  134978. */
  134979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134980. /**
  134981. * Keep track of the image processing observer to allow dispose and replace.
  134982. */
  134983. private _imageProcessingObserver;
  134984. /**
  134985. * Attaches a new image processing configuration to the PBR Material.
  134986. * @param configuration (if null the scene configuration will be use)
  134987. */
  134988. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134989. /**
  134990. * Gets the image processing configuration used either in this material.
  134991. */
  134992. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134993. /**
  134994. * Sets the Default image processing configuration used either in the this material.
  134995. *
  134996. * If sets to null, the scene one is in use.
  134997. */
  134998. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134999. /**
  135000. * Gets wether the color curves effect is enabled.
  135001. */
  135002. get cameraColorCurvesEnabled(): boolean;
  135003. /**
  135004. * Sets wether the color curves effect is enabled.
  135005. */
  135006. set cameraColorCurvesEnabled(value: boolean);
  135007. /**
  135008. * Gets wether the color grading effect is enabled.
  135009. */
  135010. get cameraColorGradingEnabled(): boolean;
  135011. /**
  135012. * Gets wether the color grading effect is enabled.
  135013. */
  135014. set cameraColorGradingEnabled(value: boolean);
  135015. /**
  135016. * Gets wether tonemapping is enabled or not.
  135017. */
  135018. get cameraToneMappingEnabled(): boolean;
  135019. /**
  135020. * Sets wether tonemapping is enabled or not
  135021. */
  135022. set cameraToneMappingEnabled(value: boolean);
  135023. /**
  135024. * The camera exposure used on this material.
  135025. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135026. * This corresponds to a photographic exposure.
  135027. */
  135028. get cameraExposure(): float;
  135029. /**
  135030. * The camera exposure used on this material.
  135031. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135032. * This corresponds to a photographic exposure.
  135033. */
  135034. set cameraExposure(value: float);
  135035. /**
  135036. * Gets The camera contrast used on this material.
  135037. */
  135038. get cameraContrast(): float;
  135039. /**
  135040. * Sets The camera contrast used on this material.
  135041. */
  135042. set cameraContrast(value: float);
  135043. /**
  135044. * Gets the Color Grading 2D Lookup Texture.
  135045. */
  135046. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135047. /**
  135048. * Sets the Color Grading 2D Lookup Texture.
  135049. */
  135050. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135051. /**
  135052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135054. * 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;
  135055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135056. */
  135057. get cameraColorCurves(): Nullable<ColorCurves>;
  135058. /**
  135059. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135060. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135061. * 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;
  135062. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135063. */
  135064. set cameraColorCurves(value: Nullable<ColorCurves>);
  135065. /**
  135066. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135067. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135068. */
  135069. switchToBGR: boolean;
  135070. private _renderTargets;
  135071. private _reflectionControls;
  135072. private _white;
  135073. private _primaryShadowColor;
  135074. private _primaryHighlightColor;
  135075. /**
  135076. * Instantiates a Background Material in the given scene
  135077. * @param name The friendly name of the material
  135078. * @param scene The scene to add the material to
  135079. */
  135080. constructor(name: string, scene: Scene);
  135081. /**
  135082. * Gets a boolean indicating that current material needs to register RTT
  135083. */
  135084. get hasRenderTargetTextures(): boolean;
  135085. /**
  135086. * The entire material has been created in order to prevent overdraw.
  135087. * @returns false
  135088. */
  135089. needAlphaTesting(): boolean;
  135090. /**
  135091. * The entire material has been created in order to prevent overdraw.
  135092. * @returns true if blending is enable
  135093. */
  135094. needAlphaBlending(): boolean;
  135095. /**
  135096. * Checks wether the material is ready to be rendered for a given mesh.
  135097. * @param mesh The mesh to render
  135098. * @param subMesh The submesh to check against
  135099. * @param useInstances Specify wether or not the material is used with instances
  135100. * @returns true if all the dependencies are ready (Textures, Effects...)
  135101. */
  135102. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135103. /**
  135104. * Compute the primary color according to the chosen perceptual color.
  135105. */
  135106. private _computePrimaryColorFromPerceptualColor;
  135107. /**
  135108. * Compute the highlights and shadow colors according to their chosen levels.
  135109. */
  135110. private _computePrimaryColors;
  135111. /**
  135112. * Build the uniform buffer used in the material.
  135113. */
  135114. buildUniformLayout(): void;
  135115. /**
  135116. * Unbind the material.
  135117. */
  135118. unbind(): void;
  135119. /**
  135120. * Bind only the world matrix to the material.
  135121. * @param world The world matrix to bind.
  135122. */
  135123. bindOnlyWorldMatrix(world: Matrix): void;
  135124. /**
  135125. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135126. * @param world The world matrix to bind.
  135127. * @param subMesh The submesh to bind for.
  135128. */
  135129. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135130. /**
  135131. * Checks to see if a texture is used in the material.
  135132. * @param texture - Base texture to use.
  135133. * @returns - Boolean specifying if a texture is used in the material.
  135134. */
  135135. hasTexture(texture: BaseTexture): boolean;
  135136. /**
  135137. * Dispose the material.
  135138. * @param forceDisposeEffect Force disposal of the associated effect.
  135139. * @param forceDisposeTextures Force disposal of the associated textures.
  135140. */
  135141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135142. /**
  135143. * Clones the material.
  135144. * @param name The cloned name.
  135145. * @returns The cloned material.
  135146. */
  135147. clone(name: string): BackgroundMaterial;
  135148. /**
  135149. * Serializes the current material to its JSON representation.
  135150. * @returns The JSON representation.
  135151. */
  135152. serialize(): any;
  135153. /**
  135154. * Gets the class name of the material
  135155. * @returns "BackgroundMaterial"
  135156. */
  135157. getClassName(): string;
  135158. /**
  135159. * Parse a JSON input to create back a background material.
  135160. * @param source The JSON data to parse
  135161. * @param scene The scene to create the parsed material in
  135162. * @param rootUrl The root url of the assets the material depends upon
  135163. * @returns the instantiated BackgroundMaterial.
  135164. */
  135165. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135166. }
  135167. }
  135168. declare module BABYLON {
  135169. /**
  135170. * Represents the different options available during the creation of
  135171. * a Environment helper.
  135172. *
  135173. * This can control the default ground, skybox and image processing setup of your scene.
  135174. */
  135175. export interface IEnvironmentHelperOptions {
  135176. /**
  135177. * Specifies whether or not to create a ground.
  135178. * True by default.
  135179. */
  135180. createGround: boolean;
  135181. /**
  135182. * Specifies the ground size.
  135183. * 15 by default.
  135184. */
  135185. groundSize: number;
  135186. /**
  135187. * The texture used on the ground for the main color.
  135188. * Comes from the BabylonJS CDN by default.
  135189. *
  135190. * Remarks: Can be either a texture or a url.
  135191. */
  135192. groundTexture: string | BaseTexture;
  135193. /**
  135194. * The color mixed in the ground texture by default.
  135195. * BabylonJS clearColor by default.
  135196. */
  135197. groundColor: Color3;
  135198. /**
  135199. * Specifies the ground opacity.
  135200. * 1 by default.
  135201. */
  135202. groundOpacity: number;
  135203. /**
  135204. * Enables the ground to receive shadows.
  135205. * True by default.
  135206. */
  135207. enableGroundShadow: boolean;
  135208. /**
  135209. * Helps preventing the shadow to be fully black on the ground.
  135210. * 0.5 by default.
  135211. */
  135212. groundShadowLevel: number;
  135213. /**
  135214. * Creates a mirror texture attach to the ground.
  135215. * false by default.
  135216. */
  135217. enableGroundMirror: boolean;
  135218. /**
  135219. * Specifies the ground mirror size ratio.
  135220. * 0.3 by default as the default kernel is 64.
  135221. */
  135222. groundMirrorSizeRatio: number;
  135223. /**
  135224. * Specifies the ground mirror blur kernel size.
  135225. * 64 by default.
  135226. */
  135227. groundMirrorBlurKernel: number;
  135228. /**
  135229. * Specifies the ground mirror visibility amount.
  135230. * 1 by default
  135231. */
  135232. groundMirrorAmount: number;
  135233. /**
  135234. * Specifies the ground mirror reflectance weight.
  135235. * This uses the standard weight of the background material to setup the fresnel effect
  135236. * of the mirror.
  135237. * 1 by default.
  135238. */
  135239. groundMirrorFresnelWeight: number;
  135240. /**
  135241. * Specifies the ground mirror Falloff distance.
  135242. * This can helps reducing the size of the reflection.
  135243. * 0 by Default.
  135244. */
  135245. groundMirrorFallOffDistance: number;
  135246. /**
  135247. * Specifies the ground mirror texture type.
  135248. * Unsigned Int by Default.
  135249. */
  135250. groundMirrorTextureType: number;
  135251. /**
  135252. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135253. * the shown objects.
  135254. */
  135255. groundYBias: number;
  135256. /**
  135257. * Specifies whether or not to create a skybox.
  135258. * True by default.
  135259. */
  135260. createSkybox: boolean;
  135261. /**
  135262. * Specifies the skybox size.
  135263. * 20 by default.
  135264. */
  135265. skyboxSize: number;
  135266. /**
  135267. * The texture used on the skybox for the main color.
  135268. * Comes from the BabylonJS CDN by default.
  135269. *
  135270. * Remarks: Can be either a texture or a url.
  135271. */
  135272. skyboxTexture: string | BaseTexture;
  135273. /**
  135274. * The color mixed in the skybox texture by default.
  135275. * BabylonJS clearColor by default.
  135276. */
  135277. skyboxColor: Color3;
  135278. /**
  135279. * The background rotation around the Y axis of the scene.
  135280. * This helps aligning the key lights of your scene with the background.
  135281. * 0 by default.
  135282. */
  135283. backgroundYRotation: number;
  135284. /**
  135285. * Compute automatically the size of the elements to best fit with the scene.
  135286. */
  135287. sizeAuto: boolean;
  135288. /**
  135289. * Default position of the rootMesh if autoSize is not true.
  135290. */
  135291. rootPosition: Vector3;
  135292. /**
  135293. * Sets up the image processing in the scene.
  135294. * true by default.
  135295. */
  135296. setupImageProcessing: boolean;
  135297. /**
  135298. * The texture used as your environment texture in the scene.
  135299. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135300. *
  135301. * Remarks: Can be either a texture or a url.
  135302. */
  135303. environmentTexture: string | BaseTexture;
  135304. /**
  135305. * The value of the exposure to apply to the scene.
  135306. * 0.6 by default if setupImageProcessing is true.
  135307. */
  135308. cameraExposure: number;
  135309. /**
  135310. * The value of the contrast to apply to the scene.
  135311. * 1.6 by default if setupImageProcessing is true.
  135312. */
  135313. cameraContrast: number;
  135314. /**
  135315. * Specifies whether or not tonemapping should be enabled in the scene.
  135316. * true by default if setupImageProcessing is true.
  135317. */
  135318. toneMappingEnabled: boolean;
  135319. }
  135320. /**
  135321. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135322. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135323. * It also helps with the default setup of your imageProcessing configuration.
  135324. */
  135325. export class EnvironmentHelper {
  135326. /**
  135327. * Default ground texture URL.
  135328. */
  135329. private static _groundTextureCDNUrl;
  135330. /**
  135331. * Default skybox texture URL.
  135332. */
  135333. private static _skyboxTextureCDNUrl;
  135334. /**
  135335. * Default environment texture URL.
  135336. */
  135337. private static _environmentTextureCDNUrl;
  135338. /**
  135339. * Creates the default options for the helper.
  135340. */
  135341. private static _getDefaultOptions;
  135342. private _rootMesh;
  135343. /**
  135344. * Gets the root mesh created by the helper.
  135345. */
  135346. get rootMesh(): Mesh;
  135347. private _skybox;
  135348. /**
  135349. * Gets the skybox created by the helper.
  135350. */
  135351. get skybox(): Nullable<Mesh>;
  135352. private _skyboxTexture;
  135353. /**
  135354. * Gets the skybox texture created by the helper.
  135355. */
  135356. get skyboxTexture(): Nullable<BaseTexture>;
  135357. private _skyboxMaterial;
  135358. /**
  135359. * Gets the skybox material created by the helper.
  135360. */
  135361. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135362. private _ground;
  135363. /**
  135364. * Gets the ground mesh created by the helper.
  135365. */
  135366. get ground(): Nullable<Mesh>;
  135367. private _groundTexture;
  135368. /**
  135369. * Gets the ground texture created by the helper.
  135370. */
  135371. get groundTexture(): Nullable<BaseTexture>;
  135372. private _groundMirror;
  135373. /**
  135374. * Gets the ground mirror created by the helper.
  135375. */
  135376. get groundMirror(): Nullable<MirrorTexture>;
  135377. /**
  135378. * Gets the ground mirror render list to helps pushing the meshes
  135379. * you wish in the ground reflection.
  135380. */
  135381. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135382. private _groundMaterial;
  135383. /**
  135384. * Gets the ground material created by the helper.
  135385. */
  135386. get groundMaterial(): Nullable<BackgroundMaterial>;
  135387. /**
  135388. * Stores the creation options.
  135389. */
  135390. private readonly _scene;
  135391. private _options;
  135392. /**
  135393. * This observable will be notified with any error during the creation of the environment,
  135394. * mainly texture creation errors.
  135395. */
  135396. onErrorObservable: Observable<{
  135397. message?: string;
  135398. exception?: any;
  135399. }>;
  135400. /**
  135401. * constructor
  135402. * @param options Defines the options we want to customize the helper
  135403. * @param scene The scene to add the material to
  135404. */
  135405. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135406. /**
  135407. * Updates the background according to the new options
  135408. * @param options
  135409. */
  135410. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135411. /**
  135412. * Sets the primary color of all the available elements.
  135413. * @param color the main color to affect to the ground and the background
  135414. */
  135415. setMainColor(color: Color3): void;
  135416. /**
  135417. * Setup the image processing according to the specified options.
  135418. */
  135419. private _setupImageProcessing;
  135420. /**
  135421. * Setup the environment texture according to the specified options.
  135422. */
  135423. private _setupEnvironmentTexture;
  135424. /**
  135425. * Setup the background according to the specified options.
  135426. */
  135427. private _setupBackground;
  135428. /**
  135429. * Get the scene sizes according to the setup.
  135430. */
  135431. private _getSceneSize;
  135432. /**
  135433. * Setup the ground according to the specified options.
  135434. */
  135435. private _setupGround;
  135436. /**
  135437. * Setup the ground material according to the specified options.
  135438. */
  135439. private _setupGroundMaterial;
  135440. /**
  135441. * Setup the ground diffuse texture according to the specified options.
  135442. */
  135443. private _setupGroundDiffuseTexture;
  135444. /**
  135445. * Setup the ground mirror texture according to the specified options.
  135446. */
  135447. private _setupGroundMirrorTexture;
  135448. /**
  135449. * Setup the ground to receive the mirror texture.
  135450. */
  135451. private _setupMirrorInGroundMaterial;
  135452. /**
  135453. * Setup the skybox according to the specified options.
  135454. */
  135455. private _setupSkybox;
  135456. /**
  135457. * Setup the skybox material according to the specified options.
  135458. */
  135459. private _setupSkyboxMaterial;
  135460. /**
  135461. * Setup the skybox reflection texture according to the specified options.
  135462. */
  135463. private _setupSkyboxReflectionTexture;
  135464. private _errorHandler;
  135465. /**
  135466. * Dispose all the elements created by the Helper.
  135467. */
  135468. dispose(): void;
  135469. }
  135470. }
  135471. declare module BABYLON {
  135472. /**
  135473. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135474. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135475. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135476. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135477. */
  135478. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135479. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135480. /**
  135481. * Define the source as a Monoscopic panoramic 360/180.
  135482. */
  135483. static readonly MODE_MONOSCOPIC: number;
  135484. /**
  135485. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135486. */
  135487. static readonly MODE_TOPBOTTOM: number;
  135488. /**
  135489. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135490. */
  135491. static readonly MODE_SIDEBYSIDE: number;
  135492. private _halfDome;
  135493. protected _useDirectMapping: boolean;
  135494. /**
  135495. * The texture being displayed on the sphere
  135496. */
  135497. protected _texture: T;
  135498. /**
  135499. * Gets the texture being displayed on the sphere
  135500. */
  135501. get texture(): T;
  135502. /**
  135503. * Sets the texture being displayed on the sphere
  135504. */
  135505. set texture(newTexture: T);
  135506. /**
  135507. * The skybox material
  135508. */
  135509. protected _material: BackgroundMaterial;
  135510. /**
  135511. * The surface used for the dome
  135512. */
  135513. protected _mesh: Mesh;
  135514. /**
  135515. * Gets the mesh used for the dome.
  135516. */
  135517. get mesh(): Mesh;
  135518. /**
  135519. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135520. */
  135521. private _halfDomeMask;
  135522. /**
  135523. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135524. * Also see the options.resolution property.
  135525. */
  135526. get fovMultiplier(): number;
  135527. set fovMultiplier(value: number);
  135528. protected _textureMode: number;
  135529. /**
  135530. * Gets or set the current texture mode for the texture. It can be:
  135531. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135532. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135533. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135534. */
  135535. get textureMode(): number;
  135536. /**
  135537. * Sets the current texture mode for the texture. It can be:
  135538. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135539. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135540. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135541. */
  135542. set textureMode(value: number);
  135543. /**
  135544. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135545. */
  135546. get halfDome(): boolean;
  135547. /**
  135548. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135549. */
  135550. set halfDome(enabled: boolean);
  135551. /**
  135552. * Oberserver used in Stereoscopic VR Mode.
  135553. */
  135554. private _onBeforeCameraRenderObserver;
  135555. /**
  135556. * Observable raised when an error occured while loading the 360 image
  135557. */
  135558. onLoadErrorObservable: Observable<string>;
  135559. /**
  135560. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135561. * @param name Element's name, child elements will append suffixes for their own names.
  135562. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135563. * @param options An object containing optional or exposed sub element properties
  135564. */
  135565. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135566. resolution?: number;
  135567. clickToPlay?: boolean;
  135568. autoPlay?: boolean;
  135569. loop?: boolean;
  135570. size?: number;
  135571. poster?: string;
  135572. faceForward?: boolean;
  135573. useDirectMapping?: boolean;
  135574. halfDomeMode?: boolean;
  135575. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135576. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135577. protected _changeTextureMode(value: number): void;
  135578. /**
  135579. * Releases resources associated with this node.
  135580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135582. */
  135583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135584. }
  135585. }
  135586. declare module BABYLON {
  135587. /**
  135588. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135589. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135590. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135591. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135592. */
  135593. export class PhotoDome extends TextureDome<Texture> {
  135594. /**
  135595. * Define the image as a Monoscopic panoramic 360 image.
  135596. */
  135597. static readonly MODE_MONOSCOPIC: number;
  135598. /**
  135599. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135600. */
  135601. static readonly MODE_TOPBOTTOM: number;
  135602. /**
  135603. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135604. */
  135605. static readonly MODE_SIDEBYSIDE: number;
  135606. /**
  135607. * Gets or sets the texture being displayed on the sphere
  135608. */
  135609. get photoTexture(): Texture;
  135610. /**
  135611. * sets the texture being displayed on the sphere
  135612. */
  135613. set photoTexture(value: Texture);
  135614. /**
  135615. * Gets the current video mode for the video. It can be:
  135616. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135617. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135618. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135619. */
  135620. get imageMode(): number;
  135621. /**
  135622. * Sets the current video mode for the video. It can be:
  135623. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135624. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135625. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135626. */
  135627. set imageMode(value: number);
  135628. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135629. }
  135630. }
  135631. declare module BABYLON {
  135632. /**
  135633. * Class used to host RGBD texture specific utilities
  135634. */
  135635. export class RGBDTextureTools {
  135636. /**
  135637. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135638. * @param texture the texture to expand.
  135639. */
  135640. static ExpandRGBDTexture(texture: Texture): void;
  135641. }
  135642. }
  135643. declare module BABYLON {
  135644. /**
  135645. * Class used to host texture specific utilities
  135646. */
  135647. export class BRDFTextureTools {
  135648. /**
  135649. * Prevents texture cache collision
  135650. */
  135651. private static _instanceNumber;
  135652. /**
  135653. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135654. * @param scene defines the hosting scene
  135655. * @returns the environment BRDF texture
  135656. */
  135657. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135658. private static _environmentBRDFBase64Texture;
  135659. }
  135660. }
  135661. declare module BABYLON {
  135662. /**
  135663. * @hidden
  135664. */
  135665. export interface IMaterialClearCoatDefines {
  135666. CLEARCOAT: boolean;
  135667. CLEARCOAT_DEFAULTIOR: boolean;
  135668. CLEARCOAT_TEXTURE: boolean;
  135669. CLEARCOAT_TEXTUREDIRECTUV: number;
  135670. CLEARCOAT_BUMP: boolean;
  135671. CLEARCOAT_BUMPDIRECTUV: number;
  135672. CLEARCOAT_TINT: boolean;
  135673. CLEARCOAT_TINT_TEXTURE: boolean;
  135674. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135675. /** @hidden */
  135676. _areTexturesDirty: boolean;
  135677. }
  135678. /**
  135679. * Define the code related to the clear coat parameters of the pbr material.
  135680. */
  135681. export class PBRClearCoatConfiguration {
  135682. /**
  135683. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135684. * The default fits with a polyurethane material.
  135685. */
  135686. private static readonly _DefaultIndexOfRefraction;
  135687. private _isEnabled;
  135688. /**
  135689. * Defines if the clear coat is enabled in the material.
  135690. */
  135691. isEnabled: boolean;
  135692. /**
  135693. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135694. */
  135695. intensity: number;
  135696. /**
  135697. * Defines the clear coat layer roughness.
  135698. */
  135699. roughness: number;
  135700. private _indexOfRefraction;
  135701. /**
  135702. * Defines the index of refraction of the clear coat.
  135703. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135704. * The default fits with a polyurethane material.
  135705. * Changing the default value is more performance intensive.
  135706. */
  135707. indexOfRefraction: number;
  135708. private _texture;
  135709. /**
  135710. * Stores the clear coat values in a texture.
  135711. */
  135712. texture: Nullable<BaseTexture>;
  135713. private _bumpTexture;
  135714. /**
  135715. * Define the clear coat specific bump texture.
  135716. */
  135717. bumpTexture: Nullable<BaseTexture>;
  135718. private _isTintEnabled;
  135719. /**
  135720. * Defines if the clear coat tint is enabled in the material.
  135721. */
  135722. isTintEnabled: boolean;
  135723. /**
  135724. * Defines the clear coat tint of the material.
  135725. * This is only use if tint is enabled
  135726. */
  135727. tintColor: Color3;
  135728. /**
  135729. * Defines the distance at which the tint color should be found in the
  135730. * clear coat media.
  135731. * This is only use if tint is enabled
  135732. */
  135733. tintColorAtDistance: number;
  135734. /**
  135735. * Defines the clear coat layer thickness.
  135736. * This is only use if tint is enabled
  135737. */
  135738. tintThickness: number;
  135739. private _tintTexture;
  135740. /**
  135741. * Stores the clear tint values in a texture.
  135742. * rgb is tint
  135743. * a is a thickness factor
  135744. */
  135745. tintTexture: Nullable<BaseTexture>;
  135746. /** @hidden */
  135747. private _internalMarkAllSubMeshesAsTexturesDirty;
  135748. /** @hidden */
  135749. _markAllSubMeshesAsTexturesDirty(): void;
  135750. /**
  135751. * Instantiate a new istance of clear coat configuration.
  135752. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135753. */
  135754. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135755. /**
  135756. * Gets wehter the submesh is ready to be used or not.
  135757. * @param defines the list of "defines" to update.
  135758. * @param scene defines the scene the material belongs to.
  135759. * @param engine defines the engine the material belongs to.
  135760. * @param disableBumpMap defines wether the material disables bump or not.
  135761. * @returns - boolean indicating that the submesh is ready or not.
  135762. */
  135763. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135764. /**
  135765. * Checks to see if a texture is used in the material.
  135766. * @param defines the list of "defines" to update.
  135767. * @param scene defines the scene to the material belongs to.
  135768. */
  135769. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135770. /**
  135771. * Binds the material data.
  135772. * @param uniformBuffer defines the Uniform buffer to fill in.
  135773. * @param scene defines the scene the material belongs to.
  135774. * @param engine defines the engine the material belongs to.
  135775. * @param disableBumpMap defines wether the material disables bump or not.
  135776. * @param isFrozen defines wether the material is frozen or not.
  135777. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135778. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135779. */
  135780. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135781. /**
  135782. * Checks to see if a texture is used in the material.
  135783. * @param texture - Base texture to use.
  135784. * @returns - Boolean specifying if a texture is used in the material.
  135785. */
  135786. hasTexture(texture: BaseTexture): boolean;
  135787. /**
  135788. * Returns an array of the actively used textures.
  135789. * @param activeTextures Array of BaseTextures
  135790. */
  135791. getActiveTextures(activeTextures: BaseTexture[]): void;
  135792. /**
  135793. * Returns the animatable textures.
  135794. * @param animatables Array of animatable textures.
  135795. */
  135796. getAnimatables(animatables: IAnimatable[]): void;
  135797. /**
  135798. * Disposes the resources of the material.
  135799. * @param forceDisposeTextures - Forces the disposal of all textures.
  135800. */
  135801. dispose(forceDisposeTextures?: boolean): void;
  135802. /**
  135803. * Get the current class name of the texture useful for serialization or dynamic coding.
  135804. * @returns "PBRClearCoatConfiguration"
  135805. */
  135806. getClassName(): string;
  135807. /**
  135808. * Add fallbacks to the effect fallbacks list.
  135809. * @param defines defines the Base texture to use.
  135810. * @param fallbacks defines the current fallback list.
  135811. * @param currentRank defines the current fallback rank.
  135812. * @returns the new fallback rank.
  135813. */
  135814. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135815. /**
  135816. * Add the required uniforms to the current list.
  135817. * @param uniforms defines the current uniform list.
  135818. */
  135819. static AddUniforms(uniforms: string[]): 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. * Add the required uniforms to the current buffer.
  135827. * @param uniformBuffer defines the current uniform buffer.
  135828. */
  135829. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135830. /**
  135831. * Makes a duplicate of the current configuration into another one.
  135832. * @param clearCoatConfiguration define the config where to copy the info
  135833. */
  135834. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135835. /**
  135836. * Serializes this clear coat configuration.
  135837. * @returns - An object with the serialized config.
  135838. */
  135839. serialize(): any;
  135840. /**
  135841. * Parses a anisotropy Configuration from a serialized object.
  135842. * @param source - Serialized object.
  135843. * @param scene Defines the scene we are parsing for
  135844. * @param rootUrl Defines the rootUrl to load from
  135845. */
  135846. parse(source: any, scene: Scene, rootUrl: string): void;
  135847. }
  135848. }
  135849. declare module BABYLON {
  135850. /**
  135851. * @hidden
  135852. */
  135853. export interface IMaterialAnisotropicDefines {
  135854. ANISOTROPIC: boolean;
  135855. ANISOTROPIC_TEXTURE: boolean;
  135856. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135857. MAINUV1: boolean;
  135858. _areTexturesDirty: boolean;
  135859. _needUVs: boolean;
  135860. }
  135861. /**
  135862. * Define the code related to the anisotropic parameters of the pbr material.
  135863. */
  135864. export class PBRAnisotropicConfiguration {
  135865. private _isEnabled;
  135866. /**
  135867. * Defines if the anisotropy is enabled in the material.
  135868. */
  135869. isEnabled: boolean;
  135870. /**
  135871. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135872. */
  135873. intensity: number;
  135874. /**
  135875. * Defines if the effect is along the tangents, bitangents or in between.
  135876. * By default, the effect is "strectching" the highlights along the tangents.
  135877. */
  135878. direction: Vector2;
  135879. private _texture;
  135880. /**
  135881. * Stores the anisotropy values in a texture.
  135882. * rg is direction (like normal from -1 to 1)
  135883. * b is a intensity
  135884. */
  135885. texture: Nullable<BaseTexture>;
  135886. /** @hidden */
  135887. private _internalMarkAllSubMeshesAsTexturesDirty;
  135888. /** @hidden */
  135889. _markAllSubMeshesAsTexturesDirty(): void;
  135890. /**
  135891. * Instantiate a new istance of anisotropy configuration.
  135892. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135893. */
  135894. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135895. /**
  135896. * Specifies that the submesh is ready to be used.
  135897. * @param defines the list of "defines" to update.
  135898. * @param scene defines the scene the material belongs to.
  135899. * @returns - boolean indicating that the submesh is ready or not.
  135900. */
  135901. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135902. /**
  135903. * Checks to see if a texture is used in the material.
  135904. * @param defines the list of "defines" to update.
  135905. * @param mesh the mesh we are preparing the defines for.
  135906. * @param scene defines the scene the material belongs to.
  135907. */
  135908. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135909. /**
  135910. * Binds the material data.
  135911. * @param uniformBuffer defines the Uniform buffer to fill in.
  135912. * @param scene defines the scene the material belongs to.
  135913. * @param isFrozen defines wether the material is frozen or not.
  135914. */
  135915. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135916. /**
  135917. * Checks to see if a texture is used in the material.
  135918. * @param texture - Base texture to use.
  135919. * @returns - Boolean specifying if a texture is used in the material.
  135920. */
  135921. hasTexture(texture: BaseTexture): boolean;
  135922. /**
  135923. * Returns an array of the actively used textures.
  135924. * @param activeTextures Array of BaseTextures
  135925. */
  135926. getActiveTextures(activeTextures: BaseTexture[]): void;
  135927. /**
  135928. * Returns the animatable textures.
  135929. * @param animatables Array of animatable textures.
  135930. */
  135931. getAnimatables(animatables: IAnimatable[]): void;
  135932. /**
  135933. * Disposes the resources of the material.
  135934. * @param forceDisposeTextures - Forces the disposal of all textures.
  135935. */
  135936. dispose(forceDisposeTextures?: boolean): void;
  135937. /**
  135938. * Get the current class name of the texture useful for serialization or dynamic coding.
  135939. * @returns "PBRAnisotropicConfiguration"
  135940. */
  135941. getClassName(): string;
  135942. /**
  135943. * Add fallbacks to the effect fallbacks list.
  135944. * @param defines defines the Base texture to use.
  135945. * @param fallbacks defines the current fallback list.
  135946. * @param currentRank defines the current fallback rank.
  135947. * @returns the new fallback rank.
  135948. */
  135949. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135950. /**
  135951. * Add the required uniforms to the current list.
  135952. * @param uniforms defines the current uniform list.
  135953. */
  135954. static AddUniforms(uniforms: string[]): void;
  135955. /**
  135956. * Add the required uniforms to the current buffer.
  135957. * @param uniformBuffer defines the current uniform buffer.
  135958. */
  135959. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135960. /**
  135961. * Add the required samplers to the current list.
  135962. * @param samplers defines the current sampler list.
  135963. */
  135964. static AddSamplers(samplers: string[]): void;
  135965. /**
  135966. * Makes a duplicate of the current configuration into another one.
  135967. * @param anisotropicConfiguration define the config where to copy the info
  135968. */
  135969. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135970. /**
  135971. * Serializes this anisotropy configuration.
  135972. * @returns - An object with the serialized config.
  135973. */
  135974. serialize(): any;
  135975. /**
  135976. * Parses a anisotropy Configuration from a serialized object.
  135977. * @param source - Serialized object.
  135978. * @param scene Defines the scene we are parsing for
  135979. * @param rootUrl Defines the rootUrl to load from
  135980. */
  135981. parse(source: any, scene: Scene, rootUrl: string): void;
  135982. }
  135983. }
  135984. declare module BABYLON {
  135985. /**
  135986. * @hidden
  135987. */
  135988. export interface IMaterialBRDFDefines {
  135989. BRDF_V_HEIGHT_CORRELATED: boolean;
  135990. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135991. SPHERICAL_HARMONICS: boolean;
  135992. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135993. /** @hidden */
  135994. _areMiscDirty: boolean;
  135995. }
  135996. /**
  135997. * Define the code related to the BRDF parameters of the pbr material.
  135998. */
  135999. export class PBRBRDFConfiguration {
  136000. /**
  136001. * Default value used for the energy conservation.
  136002. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136003. */
  136004. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  136005. /**
  136006. * Default value used for the Smith Visibility Height Correlated mode.
  136007. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136008. */
  136009. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136010. /**
  136011. * Default value used for the IBL diffuse part.
  136012. * This can help switching back to the polynomials mode globally which is a tiny bit
  136013. * less GPU intensive at the drawback of a lower quality.
  136014. */
  136015. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136016. /**
  136017. * Default value used for activating energy conservation for the specular workflow.
  136018. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136019. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136020. */
  136021. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136022. private _useEnergyConservation;
  136023. /**
  136024. * Defines if the material uses energy conservation.
  136025. */
  136026. useEnergyConservation: boolean;
  136027. private _useSmithVisibilityHeightCorrelated;
  136028. /**
  136029. * LEGACY Mode set to false
  136030. * Defines if the material uses height smith correlated visibility term.
  136031. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136032. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136033. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136034. * Not relying on height correlated will also disable energy conservation.
  136035. */
  136036. useSmithVisibilityHeightCorrelated: boolean;
  136037. private _useSphericalHarmonics;
  136038. /**
  136039. * LEGACY Mode set to false
  136040. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136041. * diffuse part of the IBL.
  136042. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136043. * to the ground truth.
  136044. */
  136045. useSphericalHarmonics: boolean;
  136046. private _useSpecularGlossinessInputEnergyConservation;
  136047. /**
  136048. * Defines if the material uses energy conservation, when the specular workflow is active.
  136049. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136050. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136051. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136052. */
  136053. useSpecularGlossinessInputEnergyConservation: boolean;
  136054. /** @hidden */
  136055. private _internalMarkAllSubMeshesAsMiscDirty;
  136056. /** @hidden */
  136057. _markAllSubMeshesAsMiscDirty(): void;
  136058. /**
  136059. * Instantiate a new istance of clear coat configuration.
  136060. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136061. */
  136062. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136063. /**
  136064. * Checks to see if a texture is used in the material.
  136065. * @param defines the list of "defines" to update.
  136066. */
  136067. prepareDefines(defines: IMaterialBRDFDefines): void;
  136068. /**
  136069. * Get the current class name of the texture useful for serialization or dynamic coding.
  136070. * @returns "PBRClearCoatConfiguration"
  136071. */
  136072. getClassName(): string;
  136073. /**
  136074. * Makes a duplicate of the current configuration into another one.
  136075. * @param brdfConfiguration define the config where to copy the info
  136076. */
  136077. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136078. /**
  136079. * Serializes this BRDF configuration.
  136080. * @returns - An object with the serialized config.
  136081. */
  136082. serialize(): any;
  136083. /**
  136084. * Parses a anisotropy Configuration from a serialized object.
  136085. * @param source - Serialized object.
  136086. * @param scene Defines the scene we are parsing for
  136087. * @param rootUrl Defines the rootUrl to load from
  136088. */
  136089. parse(source: any, scene: Scene, rootUrl: string): void;
  136090. }
  136091. }
  136092. declare module BABYLON {
  136093. /**
  136094. * @hidden
  136095. */
  136096. export interface IMaterialSheenDefines {
  136097. SHEEN: boolean;
  136098. SHEEN_TEXTURE: boolean;
  136099. SHEEN_TEXTUREDIRECTUV: number;
  136100. SHEEN_LINKWITHALBEDO: boolean;
  136101. SHEEN_ROUGHNESS: boolean;
  136102. SHEEN_ALBEDOSCALING: boolean;
  136103. /** @hidden */
  136104. _areTexturesDirty: boolean;
  136105. }
  136106. /**
  136107. * Define the code related to the Sheen parameters of the pbr material.
  136108. */
  136109. export class PBRSheenConfiguration {
  136110. private _isEnabled;
  136111. /**
  136112. * Defines if the material uses sheen.
  136113. */
  136114. isEnabled: boolean;
  136115. private _linkSheenWithAlbedo;
  136116. /**
  136117. * Defines if the sheen is linked to the sheen color.
  136118. */
  136119. linkSheenWithAlbedo: boolean;
  136120. /**
  136121. * Defines the sheen intensity.
  136122. */
  136123. intensity: number;
  136124. /**
  136125. * Defines the sheen color.
  136126. */
  136127. color: Color3;
  136128. private _texture;
  136129. /**
  136130. * Stores the sheen tint values in a texture.
  136131. * rgb is tint
  136132. * a is a intensity or roughness if roughness has been defined
  136133. */
  136134. texture: Nullable<BaseTexture>;
  136135. private _roughness;
  136136. /**
  136137. * Defines the sheen roughness.
  136138. * It is not taken into account if linkSheenWithAlbedo is true.
  136139. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136140. */
  136141. roughness: Nullable<number>;
  136142. private _albedoScaling;
  136143. /**
  136144. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136145. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136146. * making it easier to setup and tweak the effect
  136147. */
  136148. albedoScaling: boolean;
  136149. /** @hidden */
  136150. private _internalMarkAllSubMeshesAsTexturesDirty;
  136151. /** @hidden */
  136152. _markAllSubMeshesAsTexturesDirty(): void;
  136153. /**
  136154. * Instantiate a new istance of clear coat configuration.
  136155. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136156. */
  136157. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136158. /**
  136159. * Specifies that the submesh is ready to be used.
  136160. * @param defines the list of "defines" to update.
  136161. * @param scene defines the scene the material belongs to.
  136162. * @returns - boolean indicating that the submesh is ready or not.
  136163. */
  136164. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136165. /**
  136166. * Checks to see if a texture is used in the material.
  136167. * @param defines the list of "defines" to update.
  136168. * @param scene defines the scene the material belongs to.
  136169. */
  136170. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136171. /**
  136172. * Binds the material data.
  136173. * @param uniformBuffer defines the Uniform buffer to fill in.
  136174. * @param scene defines the scene the material belongs to.
  136175. * @param isFrozen defines wether the material is frozen or not.
  136176. */
  136177. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136178. /**
  136179. * Checks to see if a texture is used in the material.
  136180. * @param texture - Base texture to use.
  136181. * @returns - Boolean specifying if a texture is used in the material.
  136182. */
  136183. hasTexture(texture: BaseTexture): boolean;
  136184. /**
  136185. * Returns an array of the actively used textures.
  136186. * @param activeTextures Array of BaseTextures
  136187. */
  136188. getActiveTextures(activeTextures: BaseTexture[]): void;
  136189. /**
  136190. * Returns the animatable textures.
  136191. * @param animatables Array of animatable textures.
  136192. */
  136193. getAnimatables(animatables: IAnimatable[]): void;
  136194. /**
  136195. * Disposes the resources of the material.
  136196. * @param forceDisposeTextures - Forces the disposal of all textures.
  136197. */
  136198. dispose(forceDisposeTextures?: boolean): void;
  136199. /**
  136200. * Get the current class name of the texture useful for serialization or dynamic coding.
  136201. * @returns "PBRSheenConfiguration"
  136202. */
  136203. getClassName(): string;
  136204. /**
  136205. * Add fallbacks to the effect fallbacks list.
  136206. * @param defines defines the Base texture to use.
  136207. * @param fallbacks defines the current fallback list.
  136208. * @param currentRank defines the current fallback rank.
  136209. * @returns the new fallback rank.
  136210. */
  136211. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136212. /**
  136213. * Add the required uniforms to the current list.
  136214. * @param uniforms defines the current uniform list.
  136215. */
  136216. static AddUniforms(uniforms: string[]): void;
  136217. /**
  136218. * Add the required uniforms to the current buffer.
  136219. * @param uniformBuffer defines the current uniform buffer.
  136220. */
  136221. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136222. /**
  136223. * Add the required samplers to the current list.
  136224. * @param samplers defines the current sampler list.
  136225. */
  136226. static AddSamplers(samplers: string[]): void;
  136227. /**
  136228. * Makes a duplicate of the current configuration into another one.
  136229. * @param sheenConfiguration define the config where to copy the info
  136230. */
  136231. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136232. /**
  136233. * Serializes this BRDF configuration.
  136234. * @returns - An object with the serialized config.
  136235. */
  136236. serialize(): any;
  136237. /**
  136238. * Parses a anisotropy Configuration from a serialized object.
  136239. * @param source - Serialized object.
  136240. * @param scene Defines the scene we are parsing for
  136241. * @param rootUrl Defines the rootUrl to load from
  136242. */
  136243. parse(source: any, scene: Scene, rootUrl: string): void;
  136244. }
  136245. }
  136246. declare module BABYLON {
  136247. /**
  136248. * @hidden
  136249. */
  136250. export interface IMaterialSubSurfaceDefines {
  136251. SUBSURFACE: boolean;
  136252. SS_REFRACTION: boolean;
  136253. SS_TRANSLUCENCY: boolean;
  136254. SS_SCATTERING: boolean;
  136255. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136256. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136257. SS_REFRACTIONMAP_3D: boolean;
  136258. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136259. SS_LODINREFRACTIONALPHA: boolean;
  136260. SS_GAMMAREFRACTION: boolean;
  136261. SS_RGBDREFRACTION: boolean;
  136262. SS_LINEARSPECULARREFRACTION: boolean;
  136263. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136264. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136265. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136266. /** @hidden */
  136267. _areTexturesDirty: boolean;
  136268. }
  136269. /**
  136270. * Define the code related to the sub surface parameters of the pbr material.
  136271. */
  136272. export class PBRSubSurfaceConfiguration {
  136273. private _isRefractionEnabled;
  136274. /**
  136275. * Defines if the refraction is enabled in the material.
  136276. */
  136277. isRefractionEnabled: boolean;
  136278. private _isTranslucencyEnabled;
  136279. /**
  136280. * Defines if the translucency is enabled in the material.
  136281. */
  136282. isTranslucencyEnabled: boolean;
  136283. private _isScatteringEnabled;
  136284. /**
  136285. * Defines if the sub surface scattering is enabled in the material.
  136286. */
  136287. isScatteringEnabled: boolean;
  136288. private _scatteringDiffusionProfileIndex;
  136289. /**
  136290. * Diffusion profile for subsurface scattering.
  136291. * Useful for better scattering in the skins or foliages.
  136292. */
  136293. get scatteringDiffusionProfile(): Nullable<Color3>;
  136294. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136295. /**
  136296. * Defines the refraction intensity of the material.
  136297. * The refraction when enabled replaces the Diffuse part of the material.
  136298. * The intensity helps transitionning between diffuse and refraction.
  136299. */
  136300. refractionIntensity: number;
  136301. /**
  136302. * Defines the translucency intensity of the material.
  136303. * When translucency has been enabled, this defines how much of the "translucency"
  136304. * is addded to the diffuse part of the material.
  136305. */
  136306. translucencyIntensity: number;
  136307. /**
  136308. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136309. */
  136310. useAlbedoToTintRefraction: boolean;
  136311. private _thicknessTexture;
  136312. /**
  136313. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136314. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136315. * 0 would mean minimumThickness
  136316. * 1 would mean maximumThickness
  136317. * The other channels might be use as a mask to vary the different effects intensity.
  136318. */
  136319. thicknessTexture: Nullable<BaseTexture>;
  136320. private _refractionTexture;
  136321. /**
  136322. * Defines the texture to use for refraction.
  136323. */
  136324. refractionTexture: Nullable<BaseTexture>;
  136325. private _indexOfRefraction;
  136326. /**
  136327. * Index of refraction of the material base layer.
  136328. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136329. *
  136330. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136331. *
  136332. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136333. */
  136334. indexOfRefraction: number;
  136335. private _volumeIndexOfRefraction;
  136336. /**
  136337. * Index of refraction of the material's volume.
  136338. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136339. *
  136340. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136341. * the volume will use the same IOR as the surface.
  136342. */
  136343. get volumeIndexOfRefraction(): number;
  136344. set volumeIndexOfRefraction(value: number);
  136345. private _invertRefractionY;
  136346. /**
  136347. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136348. */
  136349. invertRefractionY: boolean;
  136350. private _linkRefractionWithTransparency;
  136351. /**
  136352. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136353. * Materials half opaque for instance using refraction could benefit from this control.
  136354. */
  136355. linkRefractionWithTransparency: boolean;
  136356. /**
  136357. * Defines the minimum thickness stored in the thickness map.
  136358. * If no thickness map is defined, this value will be used to simulate thickness.
  136359. */
  136360. minimumThickness: number;
  136361. /**
  136362. * Defines the maximum thickness stored in the thickness map.
  136363. */
  136364. maximumThickness: number;
  136365. /**
  136366. * Defines the volume tint of the material.
  136367. * This is used for both translucency and scattering.
  136368. */
  136369. tintColor: Color3;
  136370. /**
  136371. * Defines the distance at which the tint color should be found in the media.
  136372. * This is used for refraction only.
  136373. */
  136374. tintColorAtDistance: number;
  136375. /**
  136376. * Defines how far each channel transmit through the media.
  136377. * It is defined as a color to simplify it selection.
  136378. */
  136379. diffusionDistance: Color3;
  136380. private _useMaskFromThicknessTexture;
  136381. /**
  136382. * Stores the intensity of the different subsurface effects in the thickness texture.
  136383. * * the green channel is the translucency intensity.
  136384. * * the blue channel is the scattering intensity.
  136385. * * the alpha channel is the refraction intensity.
  136386. */
  136387. useMaskFromThicknessTexture: boolean;
  136388. private _scene;
  136389. /** @hidden */
  136390. private _internalMarkAllSubMeshesAsTexturesDirty;
  136391. private _internalMarkScenePrePassDirty;
  136392. /** @hidden */
  136393. _markAllSubMeshesAsTexturesDirty(): void;
  136394. /** @hidden */
  136395. _markScenePrePassDirty(): void;
  136396. /**
  136397. * Instantiate a new istance of sub surface configuration.
  136398. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136399. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136400. * @param scene The scene
  136401. */
  136402. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136403. /**
  136404. * Gets wehter the submesh is ready to be used or not.
  136405. * @param defines the list of "defines" to update.
  136406. * @param scene defines the scene the material belongs to.
  136407. * @returns - boolean indicating that the submesh is ready or not.
  136408. */
  136409. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136410. /**
  136411. * Checks to see if a texture is used in the material.
  136412. * @param defines the list of "defines" to update.
  136413. * @param scene defines the scene to the material belongs to.
  136414. */
  136415. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136416. /**
  136417. * Binds the material data.
  136418. * @param uniformBuffer defines the Uniform buffer to fill in.
  136419. * @param scene defines the scene the material belongs to.
  136420. * @param engine defines the engine the material belongs to.
  136421. * @param isFrozen defines whether the material is frozen or not.
  136422. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136423. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136424. */
  136425. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136426. /**
  136427. * Unbinds the material from the mesh.
  136428. * @param activeEffect defines the effect that should be unbound from.
  136429. * @returns true if unbound, otherwise false
  136430. */
  136431. unbind(activeEffect: Effect): boolean;
  136432. /**
  136433. * Returns the texture used for refraction or null if none is used.
  136434. * @param scene defines the scene the material belongs to.
  136435. * @returns - Refraction texture if present. If no refraction texture and refraction
  136436. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136437. */
  136438. private _getRefractionTexture;
  136439. /**
  136440. * Returns true if alpha blending should be disabled.
  136441. */
  136442. get disableAlphaBlending(): boolean;
  136443. /**
  136444. * Fills the list of render target textures.
  136445. * @param renderTargets the list of render targets to update
  136446. */
  136447. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136448. /**
  136449. * Checks to see if a texture is used in the material.
  136450. * @param texture - Base texture to use.
  136451. * @returns - Boolean specifying if a texture is used in the material.
  136452. */
  136453. hasTexture(texture: BaseTexture): boolean;
  136454. /**
  136455. * Gets a boolean indicating that current material needs to register RTT
  136456. * @returns true if this uses a render target otherwise false.
  136457. */
  136458. hasRenderTargetTextures(): boolean;
  136459. /**
  136460. * Returns an array of the actively used textures.
  136461. * @param activeTextures Array of BaseTextures
  136462. */
  136463. getActiveTextures(activeTextures: BaseTexture[]): void;
  136464. /**
  136465. * Returns the animatable textures.
  136466. * @param animatables Array of animatable textures.
  136467. */
  136468. getAnimatables(animatables: IAnimatable[]): void;
  136469. /**
  136470. * Disposes the resources of the material.
  136471. * @param forceDisposeTextures - Forces the disposal of all textures.
  136472. */
  136473. dispose(forceDisposeTextures?: boolean): void;
  136474. /**
  136475. * Get the current class name of the texture useful for serialization or dynamic coding.
  136476. * @returns "PBRSubSurfaceConfiguration"
  136477. */
  136478. getClassName(): string;
  136479. /**
  136480. * Add fallbacks to the effect fallbacks list.
  136481. * @param defines defines the Base texture to use.
  136482. * @param fallbacks defines the current fallback list.
  136483. * @param currentRank defines the current fallback rank.
  136484. * @returns the new fallback rank.
  136485. */
  136486. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136487. /**
  136488. * Add the required uniforms to the current list.
  136489. * @param uniforms defines the current uniform list.
  136490. */
  136491. static AddUniforms(uniforms: string[]): void;
  136492. /**
  136493. * Add the required samplers to the current list.
  136494. * @param samplers defines the current sampler list.
  136495. */
  136496. static AddSamplers(samplers: string[]): void;
  136497. /**
  136498. * Add the required uniforms to the current buffer.
  136499. * @param uniformBuffer defines the current uniform buffer.
  136500. */
  136501. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136502. /**
  136503. * Makes a duplicate of the current configuration into another one.
  136504. * @param configuration define the config where to copy the info
  136505. */
  136506. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136507. /**
  136508. * Serializes this Sub Surface configuration.
  136509. * @returns - An object with the serialized config.
  136510. */
  136511. serialize(): any;
  136512. /**
  136513. * Parses a anisotropy Configuration from a serialized object.
  136514. * @param source - Serialized object.
  136515. * @param scene Defines the scene we are parsing for
  136516. * @param rootUrl Defines the rootUrl to load from
  136517. */
  136518. parse(source: any, scene: Scene, rootUrl: string): void;
  136519. }
  136520. }
  136521. declare module BABYLON {
  136522. /** @hidden */
  136523. export var pbrFragmentDeclaration: {
  136524. name: string;
  136525. shader: string;
  136526. };
  136527. }
  136528. declare module BABYLON {
  136529. /** @hidden */
  136530. export var pbrUboDeclaration: {
  136531. name: string;
  136532. shader: string;
  136533. };
  136534. }
  136535. declare module BABYLON {
  136536. /** @hidden */
  136537. export var pbrFragmentExtraDeclaration: {
  136538. name: string;
  136539. shader: string;
  136540. };
  136541. }
  136542. declare module BABYLON {
  136543. /** @hidden */
  136544. export var pbrFragmentSamplersDeclaration: {
  136545. name: string;
  136546. shader: string;
  136547. };
  136548. }
  136549. declare module BABYLON {
  136550. /** @hidden */
  136551. export var subSurfaceScatteringFunctions: {
  136552. name: string;
  136553. shader: string;
  136554. };
  136555. }
  136556. declare module BABYLON {
  136557. /** @hidden */
  136558. export var importanceSampling: {
  136559. name: string;
  136560. shader: string;
  136561. };
  136562. }
  136563. declare module BABYLON {
  136564. /** @hidden */
  136565. export var pbrHelperFunctions: {
  136566. name: string;
  136567. shader: string;
  136568. };
  136569. }
  136570. declare module BABYLON {
  136571. /** @hidden */
  136572. export var harmonicsFunctions: {
  136573. name: string;
  136574. shader: string;
  136575. };
  136576. }
  136577. declare module BABYLON {
  136578. /** @hidden */
  136579. export var pbrDirectLightingSetupFunctions: {
  136580. name: string;
  136581. shader: string;
  136582. };
  136583. }
  136584. declare module BABYLON {
  136585. /** @hidden */
  136586. export var pbrDirectLightingFalloffFunctions: {
  136587. name: string;
  136588. shader: string;
  136589. };
  136590. }
  136591. declare module BABYLON {
  136592. /** @hidden */
  136593. export var pbrBRDFFunctions: {
  136594. name: string;
  136595. shader: string;
  136596. };
  136597. }
  136598. declare module BABYLON {
  136599. /** @hidden */
  136600. export var hdrFilteringFunctions: {
  136601. name: string;
  136602. shader: string;
  136603. };
  136604. }
  136605. declare module BABYLON {
  136606. /** @hidden */
  136607. export var pbrDirectLightingFunctions: {
  136608. name: string;
  136609. shader: string;
  136610. };
  136611. }
  136612. declare module BABYLON {
  136613. /** @hidden */
  136614. export var pbrIBLFunctions: {
  136615. name: string;
  136616. shader: string;
  136617. };
  136618. }
  136619. declare module BABYLON {
  136620. /** @hidden */
  136621. export var pbrBlockAlbedoOpacity: {
  136622. name: string;
  136623. shader: string;
  136624. };
  136625. }
  136626. declare module BABYLON {
  136627. /** @hidden */
  136628. export var pbrBlockReflectivity: {
  136629. name: string;
  136630. shader: string;
  136631. };
  136632. }
  136633. declare module BABYLON {
  136634. /** @hidden */
  136635. export var pbrBlockAmbientOcclusion: {
  136636. name: string;
  136637. shader: string;
  136638. };
  136639. }
  136640. declare module BABYLON {
  136641. /** @hidden */
  136642. export var pbrBlockAlphaFresnel: {
  136643. name: string;
  136644. shader: string;
  136645. };
  136646. }
  136647. declare module BABYLON {
  136648. /** @hidden */
  136649. export var pbrBlockAnisotropic: {
  136650. name: string;
  136651. shader: string;
  136652. };
  136653. }
  136654. declare module BABYLON {
  136655. /** @hidden */
  136656. export var pbrBlockReflection: {
  136657. name: string;
  136658. shader: string;
  136659. };
  136660. }
  136661. declare module BABYLON {
  136662. /** @hidden */
  136663. export var pbrBlockSheen: {
  136664. name: string;
  136665. shader: string;
  136666. };
  136667. }
  136668. declare module BABYLON {
  136669. /** @hidden */
  136670. export var pbrBlockClearcoat: {
  136671. name: string;
  136672. shader: string;
  136673. };
  136674. }
  136675. declare module BABYLON {
  136676. /** @hidden */
  136677. export var pbrBlockSubSurface: {
  136678. name: string;
  136679. shader: string;
  136680. };
  136681. }
  136682. declare module BABYLON {
  136683. /** @hidden */
  136684. export var pbrBlockNormalGeometric: {
  136685. name: string;
  136686. shader: string;
  136687. };
  136688. }
  136689. declare module BABYLON {
  136690. /** @hidden */
  136691. export var pbrBlockNormalFinal: {
  136692. name: string;
  136693. shader: string;
  136694. };
  136695. }
  136696. declare module BABYLON {
  136697. /** @hidden */
  136698. export var pbrBlockLightmapInit: {
  136699. name: string;
  136700. shader: string;
  136701. };
  136702. }
  136703. declare module BABYLON {
  136704. /** @hidden */
  136705. export var pbrBlockGeometryInfo: {
  136706. name: string;
  136707. shader: string;
  136708. };
  136709. }
  136710. declare module BABYLON {
  136711. /** @hidden */
  136712. export var pbrBlockReflectance0: {
  136713. name: string;
  136714. shader: string;
  136715. };
  136716. }
  136717. declare module BABYLON {
  136718. /** @hidden */
  136719. export var pbrBlockReflectance: {
  136720. name: string;
  136721. shader: string;
  136722. };
  136723. }
  136724. declare module BABYLON {
  136725. /** @hidden */
  136726. export var pbrBlockDirectLighting: {
  136727. name: string;
  136728. shader: string;
  136729. };
  136730. }
  136731. declare module BABYLON {
  136732. /** @hidden */
  136733. export var pbrBlockFinalLitComponents: {
  136734. name: string;
  136735. shader: string;
  136736. };
  136737. }
  136738. declare module BABYLON {
  136739. /** @hidden */
  136740. export var pbrBlockFinalUnlitComponents: {
  136741. name: string;
  136742. shader: string;
  136743. };
  136744. }
  136745. declare module BABYLON {
  136746. /** @hidden */
  136747. export var pbrBlockFinalColorComposition: {
  136748. name: string;
  136749. shader: string;
  136750. };
  136751. }
  136752. declare module BABYLON {
  136753. /** @hidden */
  136754. export var pbrBlockImageProcessing: {
  136755. name: string;
  136756. shader: string;
  136757. };
  136758. }
  136759. declare module BABYLON {
  136760. /** @hidden */
  136761. export var pbrDebug: {
  136762. name: string;
  136763. shader: string;
  136764. };
  136765. }
  136766. declare module BABYLON {
  136767. /** @hidden */
  136768. export var pbrPixelShader: {
  136769. name: string;
  136770. shader: string;
  136771. };
  136772. }
  136773. declare module BABYLON {
  136774. /** @hidden */
  136775. export var pbrVertexDeclaration: {
  136776. name: string;
  136777. shader: string;
  136778. };
  136779. }
  136780. declare module BABYLON {
  136781. /** @hidden */
  136782. export var pbrVertexShader: {
  136783. name: string;
  136784. shader: string;
  136785. };
  136786. }
  136787. declare module BABYLON {
  136788. /**
  136789. * Manages the defines for the PBR Material.
  136790. * @hidden
  136791. */
  136792. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136793. PBR: boolean;
  136794. NUM_SAMPLES: string;
  136795. REALTIME_FILTERING: boolean;
  136796. MAINUV1: boolean;
  136797. MAINUV2: boolean;
  136798. UV1: boolean;
  136799. UV2: boolean;
  136800. ALBEDO: boolean;
  136801. GAMMAALBEDO: boolean;
  136802. ALBEDODIRECTUV: number;
  136803. VERTEXCOLOR: boolean;
  136804. DETAIL: boolean;
  136805. DETAILDIRECTUV: number;
  136806. DETAIL_NORMALBLENDMETHOD: number;
  136807. AMBIENT: boolean;
  136808. AMBIENTDIRECTUV: number;
  136809. AMBIENTINGRAYSCALE: boolean;
  136810. OPACITY: boolean;
  136811. VERTEXALPHA: boolean;
  136812. OPACITYDIRECTUV: number;
  136813. OPACITYRGB: boolean;
  136814. ALPHATEST: boolean;
  136815. DEPTHPREPASS: boolean;
  136816. ALPHABLEND: boolean;
  136817. ALPHAFROMALBEDO: boolean;
  136818. ALPHATESTVALUE: string;
  136819. SPECULAROVERALPHA: boolean;
  136820. RADIANCEOVERALPHA: boolean;
  136821. ALPHAFRESNEL: boolean;
  136822. LINEARALPHAFRESNEL: boolean;
  136823. PREMULTIPLYALPHA: boolean;
  136824. EMISSIVE: boolean;
  136825. EMISSIVEDIRECTUV: number;
  136826. REFLECTIVITY: boolean;
  136827. REFLECTIVITYDIRECTUV: number;
  136828. SPECULARTERM: boolean;
  136829. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136830. MICROSURFACEAUTOMATIC: boolean;
  136831. LODBASEDMICROSFURACE: boolean;
  136832. MICROSURFACEMAP: boolean;
  136833. MICROSURFACEMAPDIRECTUV: number;
  136834. METALLICWORKFLOW: boolean;
  136835. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136836. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136837. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136838. AOSTOREINMETALMAPRED: boolean;
  136839. METALLIC_REFLECTANCE: boolean;
  136840. METALLIC_REFLECTANCEDIRECTUV: number;
  136841. ENVIRONMENTBRDF: boolean;
  136842. ENVIRONMENTBRDF_RGBD: boolean;
  136843. NORMAL: boolean;
  136844. TANGENT: boolean;
  136845. BUMP: boolean;
  136846. BUMPDIRECTUV: number;
  136847. OBJECTSPACE_NORMALMAP: boolean;
  136848. PARALLAX: boolean;
  136849. PARALLAXOCCLUSION: boolean;
  136850. NORMALXYSCALE: boolean;
  136851. LIGHTMAP: boolean;
  136852. LIGHTMAPDIRECTUV: number;
  136853. USELIGHTMAPASSHADOWMAP: boolean;
  136854. GAMMALIGHTMAP: boolean;
  136855. RGBDLIGHTMAP: boolean;
  136856. REFLECTION: boolean;
  136857. REFLECTIONMAP_3D: boolean;
  136858. REFLECTIONMAP_SPHERICAL: boolean;
  136859. REFLECTIONMAP_PLANAR: boolean;
  136860. REFLECTIONMAP_CUBIC: boolean;
  136861. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136862. REFLECTIONMAP_PROJECTION: boolean;
  136863. REFLECTIONMAP_SKYBOX: boolean;
  136864. REFLECTIONMAP_EXPLICIT: boolean;
  136865. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136866. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136867. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136868. INVERTCUBICMAP: boolean;
  136869. USESPHERICALFROMREFLECTIONMAP: boolean;
  136870. USEIRRADIANCEMAP: boolean;
  136871. SPHERICAL_HARMONICS: boolean;
  136872. USESPHERICALINVERTEX: boolean;
  136873. REFLECTIONMAP_OPPOSITEZ: boolean;
  136874. LODINREFLECTIONALPHA: boolean;
  136875. GAMMAREFLECTION: boolean;
  136876. RGBDREFLECTION: boolean;
  136877. LINEARSPECULARREFLECTION: boolean;
  136878. RADIANCEOCCLUSION: boolean;
  136879. HORIZONOCCLUSION: boolean;
  136880. INSTANCES: boolean;
  136881. THIN_INSTANCES: boolean;
  136882. PREPASS: boolean;
  136883. PREPASS_IRRADIANCE: boolean;
  136884. PREPASS_IRRADIANCE_INDEX: number;
  136885. PREPASS_ALBEDO: boolean;
  136886. PREPASS_ALBEDO_INDEX: number;
  136887. PREPASS_DEPTHNORMAL: boolean;
  136888. PREPASS_DEPTHNORMAL_INDEX: number;
  136889. SCENE_MRT_COUNT: number;
  136890. NUM_BONE_INFLUENCERS: number;
  136891. BonesPerMesh: number;
  136892. BONETEXTURE: boolean;
  136893. NONUNIFORMSCALING: boolean;
  136894. MORPHTARGETS: boolean;
  136895. MORPHTARGETS_NORMAL: boolean;
  136896. MORPHTARGETS_TANGENT: boolean;
  136897. MORPHTARGETS_UV: boolean;
  136898. NUM_MORPH_INFLUENCERS: number;
  136899. IMAGEPROCESSING: boolean;
  136900. VIGNETTE: boolean;
  136901. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136902. VIGNETTEBLENDMODEOPAQUE: boolean;
  136903. TONEMAPPING: boolean;
  136904. TONEMAPPING_ACES: boolean;
  136905. CONTRAST: boolean;
  136906. COLORCURVES: boolean;
  136907. COLORGRADING: boolean;
  136908. COLORGRADING3D: boolean;
  136909. SAMPLER3DGREENDEPTH: boolean;
  136910. SAMPLER3DBGRMAP: boolean;
  136911. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136912. EXPOSURE: boolean;
  136913. MULTIVIEW: boolean;
  136914. USEPHYSICALLIGHTFALLOFF: boolean;
  136915. USEGLTFLIGHTFALLOFF: boolean;
  136916. TWOSIDEDLIGHTING: boolean;
  136917. SHADOWFLOAT: boolean;
  136918. CLIPPLANE: boolean;
  136919. CLIPPLANE2: boolean;
  136920. CLIPPLANE3: boolean;
  136921. CLIPPLANE4: boolean;
  136922. CLIPPLANE5: boolean;
  136923. CLIPPLANE6: boolean;
  136924. POINTSIZE: boolean;
  136925. FOG: boolean;
  136926. LOGARITHMICDEPTH: boolean;
  136927. FORCENORMALFORWARD: boolean;
  136928. SPECULARAA: boolean;
  136929. CLEARCOAT: boolean;
  136930. CLEARCOAT_DEFAULTIOR: boolean;
  136931. CLEARCOAT_TEXTURE: boolean;
  136932. CLEARCOAT_TEXTUREDIRECTUV: number;
  136933. CLEARCOAT_BUMP: boolean;
  136934. CLEARCOAT_BUMPDIRECTUV: number;
  136935. CLEARCOAT_TINT: boolean;
  136936. CLEARCOAT_TINT_TEXTURE: boolean;
  136937. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136938. ANISOTROPIC: boolean;
  136939. ANISOTROPIC_TEXTURE: boolean;
  136940. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136941. BRDF_V_HEIGHT_CORRELATED: boolean;
  136942. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136943. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136944. SHEEN: boolean;
  136945. SHEEN_TEXTURE: boolean;
  136946. SHEEN_TEXTUREDIRECTUV: number;
  136947. SHEEN_LINKWITHALBEDO: boolean;
  136948. SHEEN_ROUGHNESS: boolean;
  136949. SHEEN_ALBEDOSCALING: boolean;
  136950. SUBSURFACE: boolean;
  136951. SS_REFRACTION: boolean;
  136952. SS_TRANSLUCENCY: boolean;
  136953. SS_SCATTERING: boolean;
  136954. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136955. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136956. SS_REFRACTIONMAP_3D: boolean;
  136957. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136958. SS_LODINREFRACTIONALPHA: boolean;
  136959. SS_GAMMAREFRACTION: boolean;
  136960. SS_RGBDREFRACTION: boolean;
  136961. SS_LINEARSPECULARREFRACTION: boolean;
  136962. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136963. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136964. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136965. UNLIT: boolean;
  136966. DEBUGMODE: number;
  136967. /**
  136968. * Initializes the PBR Material defines.
  136969. */
  136970. constructor();
  136971. /**
  136972. * Resets the PBR Material defines.
  136973. */
  136974. reset(): void;
  136975. }
  136976. /**
  136977. * The Physically based material base class of BJS.
  136978. *
  136979. * This offers the main features of a standard PBR material.
  136980. * For more information, please refer to the documentation :
  136981. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136982. */
  136983. export abstract class PBRBaseMaterial extends PushMaterial {
  136984. /**
  136985. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136986. */
  136987. static readonly PBRMATERIAL_OPAQUE: number;
  136988. /**
  136989. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136990. */
  136991. static readonly PBRMATERIAL_ALPHATEST: number;
  136992. /**
  136993. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136994. */
  136995. static readonly PBRMATERIAL_ALPHABLEND: number;
  136996. /**
  136997. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136998. * They are also discarded below the alpha cutoff threshold to improve performances.
  136999. */
  137000. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137001. /**
  137002. * Defines the default value of how much AO map is occluding the analytical lights
  137003. * (point spot...).
  137004. */
  137005. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137006. /**
  137007. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137008. */
  137009. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137010. /**
  137011. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137012. * to enhance interoperability with other engines.
  137013. */
  137014. static readonly LIGHTFALLOFF_GLTF: number;
  137015. /**
  137016. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137017. * to enhance interoperability with other materials.
  137018. */
  137019. static readonly LIGHTFALLOFF_STANDARD: number;
  137020. /**
  137021. * Intensity of the direct lights e.g. the four lights available in your scene.
  137022. * This impacts both the direct diffuse and specular highlights.
  137023. */
  137024. protected _directIntensity: number;
  137025. /**
  137026. * Intensity of the emissive part of the material.
  137027. * This helps controlling the emissive effect without modifying the emissive color.
  137028. */
  137029. protected _emissiveIntensity: number;
  137030. /**
  137031. * Intensity of the environment e.g. how much the environment will light the object
  137032. * either through harmonics for rough material or through the refelction for shiny ones.
  137033. */
  137034. protected _environmentIntensity: number;
  137035. /**
  137036. * This is a special control allowing the reduction of the specular highlights coming from the
  137037. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137038. */
  137039. protected _specularIntensity: number;
  137040. /**
  137041. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137042. */
  137043. private _lightingInfos;
  137044. /**
  137045. * Debug Control allowing disabling the bump map on this material.
  137046. */
  137047. protected _disableBumpMap: boolean;
  137048. /**
  137049. * AKA Diffuse Texture in standard nomenclature.
  137050. */
  137051. protected _albedoTexture: Nullable<BaseTexture>;
  137052. /**
  137053. * AKA Occlusion Texture in other nomenclature.
  137054. */
  137055. protected _ambientTexture: Nullable<BaseTexture>;
  137056. /**
  137057. * AKA Occlusion Texture Intensity in other nomenclature.
  137058. */
  137059. protected _ambientTextureStrength: number;
  137060. /**
  137061. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137062. * 1 means it completely occludes it
  137063. * 0 mean it has no impact
  137064. */
  137065. protected _ambientTextureImpactOnAnalyticalLights: number;
  137066. /**
  137067. * Stores the alpha values in a texture.
  137068. */
  137069. protected _opacityTexture: Nullable<BaseTexture>;
  137070. /**
  137071. * Stores the reflection values in a texture.
  137072. */
  137073. protected _reflectionTexture: Nullable<BaseTexture>;
  137074. /**
  137075. * Stores the emissive values in a texture.
  137076. */
  137077. protected _emissiveTexture: Nullable<BaseTexture>;
  137078. /**
  137079. * AKA Specular texture in other nomenclature.
  137080. */
  137081. protected _reflectivityTexture: Nullable<BaseTexture>;
  137082. /**
  137083. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137084. */
  137085. protected _metallicTexture: Nullable<BaseTexture>;
  137086. /**
  137087. * Specifies the metallic scalar of the metallic/roughness workflow.
  137088. * Can also be used to scale the metalness values of the metallic texture.
  137089. */
  137090. protected _metallic: Nullable<number>;
  137091. /**
  137092. * Specifies the roughness scalar of the metallic/roughness workflow.
  137093. * Can also be used to scale the roughness values of the metallic texture.
  137094. */
  137095. protected _roughness: Nullable<number>;
  137096. /**
  137097. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137098. * By default the indexOfrefraction is used to compute F0;
  137099. *
  137100. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137101. *
  137102. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137103. * F90 = metallicReflectanceColor;
  137104. */
  137105. protected _metallicF0Factor: number;
  137106. /**
  137107. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137108. * By default the F90 is always 1;
  137109. *
  137110. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137111. *
  137112. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137113. * F90 = metallicReflectanceColor;
  137114. */
  137115. protected _metallicReflectanceColor: Color3;
  137116. /**
  137117. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137118. * This is multiply against the scalar values defined in the material.
  137119. */
  137120. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137121. /**
  137122. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137123. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137124. */
  137125. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137126. /**
  137127. * Stores surface normal data used to displace a mesh in a texture.
  137128. */
  137129. protected _bumpTexture: Nullable<BaseTexture>;
  137130. /**
  137131. * Stores the pre-calculated light information of a mesh in a texture.
  137132. */
  137133. protected _lightmapTexture: Nullable<BaseTexture>;
  137134. /**
  137135. * The color of a material in ambient lighting.
  137136. */
  137137. protected _ambientColor: Color3;
  137138. /**
  137139. * AKA Diffuse Color in other nomenclature.
  137140. */
  137141. protected _albedoColor: Color3;
  137142. /**
  137143. * AKA Specular Color in other nomenclature.
  137144. */
  137145. protected _reflectivityColor: Color3;
  137146. /**
  137147. * The color applied when light is reflected from a material.
  137148. */
  137149. protected _reflectionColor: Color3;
  137150. /**
  137151. * The color applied when light is emitted from a material.
  137152. */
  137153. protected _emissiveColor: Color3;
  137154. /**
  137155. * AKA Glossiness in other nomenclature.
  137156. */
  137157. protected _microSurface: number;
  137158. /**
  137159. * Specifies that the material will use the light map as a show map.
  137160. */
  137161. protected _useLightmapAsShadowmap: boolean;
  137162. /**
  137163. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137164. * makes the reflect vector face the model (under horizon).
  137165. */
  137166. protected _useHorizonOcclusion: boolean;
  137167. /**
  137168. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137169. * too much the area relying on ambient texture to define their ambient occlusion.
  137170. */
  137171. protected _useRadianceOcclusion: boolean;
  137172. /**
  137173. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137174. */
  137175. protected _useAlphaFromAlbedoTexture: boolean;
  137176. /**
  137177. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137178. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137179. */
  137180. protected _useSpecularOverAlpha: boolean;
  137181. /**
  137182. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137183. */
  137184. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137185. /**
  137186. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137187. */
  137188. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137189. /**
  137190. * Specifies if the metallic texture contains the roughness information in its green channel.
  137191. */
  137192. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137193. /**
  137194. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137195. */
  137196. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137197. /**
  137198. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137199. */
  137200. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137201. /**
  137202. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137203. */
  137204. protected _useAmbientInGrayScale: boolean;
  137205. /**
  137206. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137207. * The material will try to infer what glossiness each pixel should be.
  137208. */
  137209. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137210. /**
  137211. * Defines the falloff type used in this material.
  137212. * It by default is Physical.
  137213. */
  137214. protected _lightFalloff: number;
  137215. /**
  137216. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137217. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137218. */
  137219. protected _useRadianceOverAlpha: boolean;
  137220. /**
  137221. * Allows using an object space normal map (instead of tangent space).
  137222. */
  137223. protected _useObjectSpaceNormalMap: boolean;
  137224. /**
  137225. * Allows using the bump map in parallax mode.
  137226. */
  137227. protected _useParallax: boolean;
  137228. /**
  137229. * Allows using the bump map in parallax occlusion mode.
  137230. */
  137231. protected _useParallaxOcclusion: boolean;
  137232. /**
  137233. * Controls the scale bias of the parallax mode.
  137234. */
  137235. protected _parallaxScaleBias: number;
  137236. /**
  137237. * If sets to true, disables all the lights affecting the material.
  137238. */
  137239. protected _disableLighting: boolean;
  137240. /**
  137241. * Number of Simultaneous lights allowed on the material.
  137242. */
  137243. protected _maxSimultaneousLights: number;
  137244. /**
  137245. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137246. */
  137247. protected _invertNormalMapX: boolean;
  137248. /**
  137249. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137250. */
  137251. protected _invertNormalMapY: boolean;
  137252. /**
  137253. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137254. */
  137255. protected _twoSidedLighting: boolean;
  137256. /**
  137257. * Defines the alpha limits in alpha test mode.
  137258. */
  137259. protected _alphaCutOff: number;
  137260. /**
  137261. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137262. */
  137263. protected _forceAlphaTest: boolean;
  137264. /**
  137265. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137266. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137267. */
  137268. protected _useAlphaFresnel: boolean;
  137269. /**
  137270. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137271. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137272. */
  137273. protected _useLinearAlphaFresnel: boolean;
  137274. /**
  137275. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137276. * from cos thetav and roughness:
  137277. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137278. */
  137279. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137280. /**
  137281. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137282. */
  137283. protected _forceIrradianceInFragment: boolean;
  137284. private _realTimeFiltering;
  137285. /**
  137286. * Enables realtime filtering on the texture.
  137287. */
  137288. get realTimeFiltering(): boolean;
  137289. set realTimeFiltering(b: boolean);
  137290. private _realTimeFilteringQuality;
  137291. /**
  137292. * Quality switch for realtime filtering
  137293. */
  137294. get realTimeFilteringQuality(): number;
  137295. set realTimeFilteringQuality(n: number);
  137296. /**
  137297. * Can this material render to several textures at once
  137298. */
  137299. get canRenderToMRT(): boolean;
  137300. /**
  137301. * Force normal to face away from face.
  137302. */
  137303. protected _forceNormalForward: boolean;
  137304. /**
  137305. * Enables specular anti aliasing in the PBR shader.
  137306. * It will both interacts on the Geometry for analytical and IBL lighting.
  137307. * It also prefilter the roughness map based on the bump values.
  137308. */
  137309. protected _enableSpecularAntiAliasing: boolean;
  137310. /**
  137311. * Default configuration related to image processing available in the PBR Material.
  137312. */
  137313. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137314. /**
  137315. * Keep track of the image processing observer to allow dispose and replace.
  137316. */
  137317. private _imageProcessingObserver;
  137318. /**
  137319. * Attaches a new image processing configuration to the PBR Material.
  137320. * @param configuration
  137321. */
  137322. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137323. /**
  137324. * Stores the available render targets.
  137325. */
  137326. private _renderTargets;
  137327. /**
  137328. * Sets the global ambient color for the material used in lighting calculations.
  137329. */
  137330. private _globalAmbientColor;
  137331. /**
  137332. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137333. */
  137334. private _useLogarithmicDepth;
  137335. /**
  137336. * If set to true, no lighting calculations will be applied.
  137337. */
  137338. private _unlit;
  137339. private _debugMode;
  137340. /**
  137341. * @hidden
  137342. * This is reserved for the inspector.
  137343. * Defines the material debug mode.
  137344. * It helps seeing only some components of the material while troubleshooting.
  137345. */
  137346. debugMode: number;
  137347. /**
  137348. * @hidden
  137349. * This is reserved for the inspector.
  137350. * Specify from where on screen the debug mode should start.
  137351. * The value goes from -1 (full screen) to 1 (not visible)
  137352. * It helps with side by side comparison against the final render
  137353. * This defaults to -1
  137354. */
  137355. private debugLimit;
  137356. /**
  137357. * @hidden
  137358. * This is reserved for the inspector.
  137359. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137360. * You can use the factor to better multiply the final value.
  137361. */
  137362. private debugFactor;
  137363. /**
  137364. * Defines the clear coat layer parameters for the material.
  137365. */
  137366. readonly clearCoat: PBRClearCoatConfiguration;
  137367. /**
  137368. * Defines the anisotropic parameters for the material.
  137369. */
  137370. readonly anisotropy: PBRAnisotropicConfiguration;
  137371. /**
  137372. * Defines the BRDF parameters for the material.
  137373. */
  137374. readonly brdf: PBRBRDFConfiguration;
  137375. /**
  137376. * Defines the Sheen parameters for the material.
  137377. */
  137378. readonly sheen: PBRSheenConfiguration;
  137379. /**
  137380. * Defines the SubSurface parameters for the material.
  137381. */
  137382. readonly subSurface: PBRSubSurfaceConfiguration;
  137383. /**
  137384. * Defines the detail map parameters for the material.
  137385. */
  137386. readonly detailMap: DetailMapConfiguration;
  137387. protected _rebuildInParallel: boolean;
  137388. /**
  137389. * Instantiates a new PBRMaterial instance.
  137390. *
  137391. * @param name The material name
  137392. * @param scene The scene the material will be use in.
  137393. */
  137394. constructor(name: string, scene: Scene);
  137395. /**
  137396. * Gets a boolean indicating that current material needs to register RTT
  137397. */
  137398. get hasRenderTargetTextures(): boolean;
  137399. /**
  137400. * Gets the name of the material class.
  137401. */
  137402. getClassName(): string;
  137403. /**
  137404. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137405. */
  137406. get useLogarithmicDepth(): boolean;
  137407. /**
  137408. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137409. */
  137410. set useLogarithmicDepth(value: boolean);
  137411. /**
  137412. * Returns true if alpha blending should be disabled.
  137413. */
  137414. protected get _disableAlphaBlending(): boolean;
  137415. /**
  137416. * Specifies whether or not this material should be rendered in alpha blend mode.
  137417. */
  137418. needAlphaBlending(): boolean;
  137419. /**
  137420. * Specifies whether or not this material should be rendered in alpha test mode.
  137421. */
  137422. needAlphaTesting(): boolean;
  137423. /**
  137424. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137425. */
  137426. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137427. /**
  137428. * Gets the texture used for the alpha test.
  137429. */
  137430. getAlphaTestTexture(): Nullable<BaseTexture>;
  137431. /**
  137432. * Specifies that the submesh is ready to be used.
  137433. * @param mesh - BJS mesh.
  137434. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137435. * @param useInstances - Specifies that instances should be used.
  137436. * @returns - boolean indicating that the submesh is ready or not.
  137437. */
  137438. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137439. /**
  137440. * Specifies if the material uses metallic roughness workflow.
  137441. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137442. */
  137443. isMetallicWorkflow(): boolean;
  137444. private _prepareEffect;
  137445. private _prepareDefines;
  137446. /**
  137447. * Force shader compilation
  137448. */
  137449. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137450. /**
  137451. * Initializes the uniform buffer layout for the shader.
  137452. */
  137453. buildUniformLayout(): void;
  137454. /**
  137455. * Unbinds the material from the mesh
  137456. */
  137457. unbind(): void;
  137458. /**
  137459. * Binds the submesh data.
  137460. * @param world - The world matrix.
  137461. * @param mesh - The BJS mesh.
  137462. * @param subMesh - A submesh of the BJS mesh.
  137463. */
  137464. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137465. /**
  137466. * Returns the animatable textures.
  137467. * @returns - Array of animatable textures.
  137468. */
  137469. getAnimatables(): IAnimatable[];
  137470. /**
  137471. * Returns the texture used for reflections.
  137472. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137473. */
  137474. private _getReflectionTexture;
  137475. /**
  137476. * Returns an array of the actively used textures.
  137477. * @returns - Array of BaseTextures
  137478. */
  137479. getActiveTextures(): BaseTexture[];
  137480. /**
  137481. * Checks to see if a texture is used in the material.
  137482. * @param texture - Base texture to use.
  137483. * @returns - Boolean specifying if a texture is used in the material.
  137484. */
  137485. hasTexture(texture: BaseTexture): boolean;
  137486. /**
  137487. * Sets the required values to the prepass renderer.
  137488. * @param prePassRenderer defines the prepass renderer to setup
  137489. */
  137490. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137491. /**
  137492. * Disposes the resources of the material.
  137493. * @param forceDisposeEffect - Forces the disposal of effects.
  137494. * @param forceDisposeTextures - Forces the disposal of all textures.
  137495. */
  137496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137497. }
  137498. }
  137499. declare module BABYLON {
  137500. /**
  137501. * The Physically based material of BJS.
  137502. *
  137503. * This offers the main features of a standard PBR material.
  137504. * For more information, please refer to the documentation :
  137505. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137506. */
  137507. export class PBRMaterial extends PBRBaseMaterial {
  137508. /**
  137509. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137510. */
  137511. static readonly PBRMATERIAL_OPAQUE: number;
  137512. /**
  137513. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137514. */
  137515. static readonly PBRMATERIAL_ALPHATEST: number;
  137516. /**
  137517. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137518. */
  137519. static readonly PBRMATERIAL_ALPHABLEND: number;
  137520. /**
  137521. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137522. * They are also discarded below the alpha cutoff threshold to improve performances.
  137523. */
  137524. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137525. /**
  137526. * Defines the default value of how much AO map is occluding the analytical lights
  137527. * (point spot...).
  137528. */
  137529. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137530. /**
  137531. * Intensity of the direct lights e.g. the four lights available in your scene.
  137532. * This impacts both the direct diffuse and specular highlights.
  137533. */
  137534. directIntensity: number;
  137535. /**
  137536. * Intensity of the emissive part of the material.
  137537. * This helps controlling the emissive effect without modifying the emissive color.
  137538. */
  137539. emissiveIntensity: number;
  137540. /**
  137541. * Intensity of the environment e.g. how much the environment will light the object
  137542. * either through harmonics for rough material or through the refelction for shiny ones.
  137543. */
  137544. environmentIntensity: number;
  137545. /**
  137546. * This is a special control allowing the reduction of the specular highlights coming from the
  137547. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137548. */
  137549. specularIntensity: number;
  137550. /**
  137551. * Debug Control allowing disabling the bump map on this material.
  137552. */
  137553. disableBumpMap: boolean;
  137554. /**
  137555. * AKA Diffuse Texture in standard nomenclature.
  137556. */
  137557. albedoTexture: BaseTexture;
  137558. /**
  137559. * AKA Occlusion Texture in other nomenclature.
  137560. */
  137561. ambientTexture: BaseTexture;
  137562. /**
  137563. * AKA Occlusion Texture Intensity in other nomenclature.
  137564. */
  137565. ambientTextureStrength: number;
  137566. /**
  137567. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137568. * 1 means it completely occludes it
  137569. * 0 mean it has no impact
  137570. */
  137571. ambientTextureImpactOnAnalyticalLights: number;
  137572. /**
  137573. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137574. */
  137575. opacityTexture: BaseTexture;
  137576. /**
  137577. * Stores the reflection values in a texture.
  137578. */
  137579. reflectionTexture: Nullable<BaseTexture>;
  137580. /**
  137581. * Stores the emissive values in a texture.
  137582. */
  137583. emissiveTexture: BaseTexture;
  137584. /**
  137585. * AKA Specular texture in other nomenclature.
  137586. */
  137587. reflectivityTexture: BaseTexture;
  137588. /**
  137589. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137590. */
  137591. metallicTexture: BaseTexture;
  137592. /**
  137593. * Specifies the metallic scalar of the metallic/roughness workflow.
  137594. * Can also be used to scale the metalness values of the metallic texture.
  137595. */
  137596. metallic: Nullable<number>;
  137597. /**
  137598. * Specifies the roughness scalar of the metallic/roughness workflow.
  137599. * Can also be used to scale the roughness values of the metallic texture.
  137600. */
  137601. roughness: Nullable<number>;
  137602. /**
  137603. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137604. * By default the indexOfrefraction is used to compute F0;
  137605. *
  137606. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137607. *
  137608. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137609. * F90 = metallicReflectanceColor;
  137610. */
  137611. metallicF0Factor: number;
  137612. /**
  137613. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137614. * By default the F90 is always 1;
  137615. *
  137616. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137617. *
  137618. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137619. * F90 = metallicReflectanceColor;
  137620. */
  137621. metallicReflectanceColor: Color3;
  137622. /**
  137623. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137624. * This is multiply against the scalar values defined in the material.
  137625. */
  137626. metallicReflectanceTexture: Nullable<BaseTexture>;
  137627. /**
  137628. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137629. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137630. */
  137631. microSurfaceTexture: BaseTexture;
  137632. /**
  137633. * Stores surface normal data used to displace a mesh in a texture.
  137634. */
  137635. bumpTexture: BaseTexture;
  137636. /**
  137637. * Stores the pre-calculated light information of a mesh in a texture.
  137638. */
  137639. lightmapTexture: BaseTexture;
  137640. /**
  137641. * Stores the refracted light information in a texture.
  137642. */
  137643. get refractionTexture(): Nullable<BaseTexture>;
  137644. set refractionTexture(value: Nullable<BaseTexture>);
  137645. /**
  137646. * The color of a material in ambient lighting.
  137647. */
  137648. ambientColor: Color3;
  137649. /**
  137650. * AKA Diffuse Color in other nomenclature.
  137651. */
  137652. albedoColor: Color3;
  137653. /**
  137654. * AKA Specular Color in other nomenclature.
  137655. */
  137656. reflectivityColor: Color3;
  137657. /**
  137658. * The color reflected from the material.
  137659. */
  137660. reflectionColor: Color3;
  137661. /**
  137662. * The color emitted from the material.
  137663. */
  137664. emissiveColor: Color3;
  137665. /**
  137666. * AKA Glossiness in other nomenclature.
  137667. */
  137668. microSurface: number;
  137669. /**
  137670. * Index of refraction of the material base layer.
  137671. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137672. *
  137673. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137674. *
  137675. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137676. */
  137677. get indexOfRefraction(): number;
  137678. set indexOfRefraction(value: number);
  137679. /**
  137680. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137681. */
  137682. get invertRefractionY(): boolean;
  137683. set invertRefractionY(value: boolean);
  137684. /**
  137685. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137686. * Materials half opaque for instance using refraction could benefit from this control.
  137687. */
  137688. get linkRefractionWithTransparency(): boolean;
  137689. set linkRefractionWithTransparency(value: boolean);
  137690. /**
  137691. * If true, the light map contains occlusion information instead of lighting info.
  137692. */
  137693. useLightmapAsShadowmap: boolean;
  137694. /**
  137695. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137696. */
  137697. useAlphaFromAlbedoTexture: boolean;
  137698. /**
  137699. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137700. */
  137701. forceAlphaTest: boolean;
  137702. /**
  137703. * Defines the alpha limits in alpha test mode.
  137704. */
  137705. alphaCutOff: number;
  137706. /**
  137707. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137708. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137709. */
  137710. useSpecularOverAlpha: boolean;
  137711. /**
  137712. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137713. */
  137714. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137715. /**
  137716. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137717. */
  137718. useRoughnessFromMetallicTextureAlpha: boolean;
  137719. /**
  137720. * Specifies if the metallic texture contains the roughness information in its green channel.
  137721. */
  137722. useRoughnessFromMetallicTextureGreen: boolean;
  137723. /**
  137724. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137725. */
  137726. useMetallnessFromMetallicTextureBlue: boolean;
  137727. /**
  137728. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137729. */
  137730. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137731. /**
  137732. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137733. */
  137734. useAmbientInGrayScale: boolean;
  137735. /**
  137736. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137737. * The material will try to infer what glossiness each pixel should be.
  137738. */
  137739. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137740. /**
  137741. * BJS is using an harcoded light falloff based on a manually sets up range.
  137742. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137743. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137744. */
  137745. get usePhysicalLightFalloff(): boolean;
  137746. /**
  137747. * BJS is using an harcoded light falloff based on a manually sets up range.
  137748. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137749. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137750. */
  137751. set usePhysicalLightFalloff(value: boolean);
  137752. /**
  137753. * In order to support the falloff compatibility with gltf, a special mode has been added
  137754. * to reproduce the gltf light falloff.
  137755. */
  137756. get useGLTFLightFalloff(): boolean;
  137757. /**
  137758. * In order to support the falloff compatibility with gltf, a special mode has been added
  137759. * to reproduce the gltf light falloff.
  137760. */
  137761. set useGLTFLightFalloff(value: boolean);
  137762. /**
  137763. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137764. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137765. */
  137766. useRadianceOverAlpha: boolean;
  137767. /**
  137768. * Allows using an object space normal map (instead of tangent space).
  137769. */
  137770. useObjectSpaceNormalMap: boolean;
  137771. /**
  137772. * Allows using the bump map in parallax mode.
  137773. */
  137774. useParallax: boolean;
  137775. /**
  137776. * Allows using the bump map in parallax occlusion mode.
  137777. */
  137778. useParallaxOcclusion: boolean;
  137779. /**
  137780. * Controls the scale bias of the parallax mode.
  137781. */
  137782. parallaxScaleBias: number;
  137783. /**
  137784. * If sets to true, disables all the lights affecting the material.
  137785. */
  137786. disableLighting: boolean;
  137787. /**
  137788. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137789. */
  137790. forceIrradianceInFragment: boolean;
  137791. /**
  137792. * Number of Simultaneous lights allowed on the material.
  137793. */
  137794. maxSimultaneousLights: number;
  137795. /**
  137796. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137797. */
  137798. invertNormalMapX: boolean;
  137799. /**
  137800. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137801. */
  137802. invertNormalMapY: boolean;
  137803. /**
  137804. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137805. */
  137806. twoSidedLighting: boolean;
  137807. /**
  137808. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137809. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137810. */
  137811. useAlphaFresnel: boolean;
  137812. /**
  137813. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137814. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137815. */
  137816. useLinearAlphaFresnel: boolean;
  137817. /**
  137818. * Let user defines the brdf lookup texture used for IBL.
  137819. * A default 8bit version is embedded but you could point at :
  137820. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137821. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137822. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137823. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137824. */
  137825. environmentBRDFTexture: Nullable<BaseTexture>;
  137826. /**
  137827. * Force normal to face away from face.
  137828. */
  137829. forceNormalForward: boolean;
  137830. /**
  137831. * Enables specular anti aliasing in the PBR shader.
  137832. * It will both interacts on the Geometry for analytical and IBL lighting.
  137833. * It also prefilter the roughness map based on the bump values.
  137834. */
  137835. enableSpecularAntiAliasing: boolean;
  137836. /**
  137837. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137838. * makes the reflect vector face the model (under horizon).
  137839. */
  137840. useHorizonOcclusion: boolean;
  137841. /**
  137842. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137843. * too much the area relying on ambient texture to define their ambient occlusion.
  137844. */
  137845. useRadianceOcclusion: boolean;
  137846. /**
  137847. * If set to true, no lighting calculations will be applied.
  137848. */
  137849. unlit: boolean;
  137850. /**
  137851. * Gets the image processing configuration used either in this material.
  137852. */
  137853. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137854. /**
  137855. * Sets the Default image processing configuration used either in the this material.
  137856. *
  137857. * If sets to null, the scene one is in use.
  137858. */
  137859. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137860. /**
  137861. * Gets wether the color curves effect is enabled.
  137862. */
  137863. get cameraColorCurvesEnabled(): boolean;
  137864. /**
  137865. * Sets wether the color curves effect is enabled.
  137866. */
  137867. set cameraColorCurvesEnabled(value: boolean);
  137868. /**
  137869. * Gets wether the color grading effect is enabled.
  137870. */
  137871. get cameraColorGradingEnabled(): boolean;
  137872. /**
  137873. * Gets wether the color grading effect is enabled.
  137874. */
  137875. set cameraColorGradingEnabled(value: boolean);
  137876. /**
  137877. * Gets wether tonemapping is enabled or not.
  137878. */
  137879. get cameraToneMappingEnabled(): boolean;
  137880. /**
  137881. * Sets wether tonemapping is enabled or not
  137882. */
  137883. set cameraToneMappingEnabled(value: boolean);
  137884. /**
  137885. * The camera exposure used on this material.
  137886. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137887. * This corresponds to a photographic exposure.
  137888. */
  137889. get cameraExposure(): number;
  137890. /**
  137891. * The camera exposure used on this material.
  137892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137893. * This corresponds to a photographic exposure.
  137894. */
  137895. set cameraExposure(value: number);
  137896. /**
  137897. * Gets The camera contrast used on this material.
  137898. */
  137899. get cameraContrast(): number;
  137900. /**
  137901. * Sets The camera contrast used on this material.
  137902. */
  137903. set cameraContrast(value: number);
  137904. /**
  137905. * Gets the Color Grading 2D Lookup Texture.
  137906. */
  137907. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137908. /**
  137909. * Sets the Color Grading 2D Lookup Texture.
  137910. */
  137911. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137912. /**
  137913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137915. * 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;
  137916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137917. */
  137918. get cameraColorCurves(): Nullable<ColorCurves>;
  137919. /**
  137920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137922. * 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;
  137923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137924. */
  137925. set cameraColorCurves(value: Nullable<ColorCurves>);
  137926. /**
  137927. * Instantiates a new PBRMaterial instance.
  137928. *
  137929. * @param name The material name
  137930. * @param scene The scene the material will be use in.
  137931. */
  137932. constructor(name: string, scene: Scene);
  137933. /**
  137934. * Returns the name of this material class.
  137935. */
  137936. getClassName(): string;
  137937. /**
  137938. * Makes a duplicate of the current material.
  137939. * @param name - name to use for the new material.
  137940. */
  137941. clone(name: string): PBRMaterial;
  137942. /**
  137943. * Serializes this PBR Material.
  137944. * @returns - An object with the serialized material.
  137945. */
  137946. serialize(): any;
  137947. /**
  137948. * Parses a PBR Material from a serialized object.
  137949. * @param source - Serialized object.
  137950. * @param scene - BJS scene instance.
  137951. * @param rootUrl - url for the scene object
  137952. * @returns - PBRMaterial
  137953. */
  137954. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137955. }
  137956. }
  137957. declare module BABYLON {
  137958. /**
  137959. * Direct draw surface info
  137960. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137961. */
  137962. export interface DDSInfo {
  137963. /**
  137964. * Width of the texture
  137965. */
  137966. width: number;
  137967. /**
  137968. * Width of the texture
  137969. */
  137970. height: number;
  137971. /**
  137972. * Number of Mipmaps for the texture
  137973. * @see https://en.wikipedia.org/wiki/Mipmap
  137974. */
  137975. mipmapCount: number;
  137976. /**
  137977. * If the textures format is a known fourCC format
  137978. * @see https://www.fourcc.org/
  137979. */
  137980. isFourCC: boolean;
  137981. /**
  137982. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137983. */
  137984. isRGB: boolean;
  137985. /**
  137986. * If the texture is a lumincance format
  137987. */
  137988. isLuminance: boolean;
  137989. /**
  137990. * If this is a cube texture
  137991. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137992. */
  137993. isCube: boolean;
  137994. /**
  137995. * If the texture is a compressed format eg. FOURCC_DXT1
  137996. */
  137997. isCompressed: boolean;
  137998. /**
  137999. * The dxgiFormat of the texture
  138000. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138001. */
  138002. dxgiFormat: number;
  138003. /**
  138004. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138005. */
  138006. textureType: number;
  138007. /**
  138008. * Sphericle polynomial created for the dds texture
  138009. */
  138010. sphericalPolynomial?: SphericalPolynomial;
  138011. }
  138012. /**
  138013. * Class used to provide DDS decompression tools
  138014. */
  138015. export class DDSTools {
  138016. /**
  138017. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138018. */
  138019. static StoreLODInAlphaChannel: boolean;
  138020. /**
  138021. * Gets DDS information from an array buffer
  138022. * @param data defines the array buffer view to read data from
  138023. * @returns the DDS information
  138024. */
  138025. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138026. private static _FloatView;
  138027. private static _Int32View;
  138028. private static _ToHalfFloat;
  138029. private static _FromHalfFloat;
  138030. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138031. private static _GetHalfFloatRGBAArrayBuffer;
  138032. private static _GetFloatRGBAArrayBuffer;
  138033. private static _GetFloatAsUIntRGBAArrayBuffer;
  138034. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138035. private static _GetRGBAArrayBuffer;
  138036. private static _ExtractLongWordOrder;
  138037. private static _GetRGBArrayBuffer;
  138038. private static _GetLuminanceArrayBuffer;
  138039. /**
  138040. * Uploads DDS Levels to a Babylon Texture
  138041. * @hidden
  138042. */
  138043. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138044. }
  138045. interface ThinEngine {
  138046. /**
  138047. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138048. * @param rootUrl defines the url where the file to load is located
  138049. * @param scene defines the current scene
  138050. * @param lodScale defines scale to apply to the mip map selection
  138051. * @param lodOffset defines offset to apply to the mip map selection
  138052. * @param onLoad defines an optional callback raised when the texture is loaded
  138053. * @param onError defines an optional callback raised if there is an issue to load the texture
  138054. * @param format defines the format of the data
  138055. * @param forcedExtension defines the extension to use to pick the right loader
  138056. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138057. * @returns the cube texture as an InternalTexture
  138058. */
  138059. 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;
  138060. }
  138061. }
  138062. declare module BABYLON {
  138063. /**
  138064. * Implementation of the DDS Texture Loader.
  138065. * @hidden
  138066. */
  138067. export class _DDSTextureLoader implements IInternalTextureLoader {
  138068. /**
  138069. * Defines wether the loader supports cascade loading the different faces.
  138070. */
  138071. readonly supportCascades: boolean;
  138072. /**
  138073. * This returns if the loader support the current file information.
  138074. * @param extension defines the file extension of the file being loaded
  138075. * @returns true if the loader can load the specified file
  138076. */
  138077. canLoad(extension: string): boolean;
  138078. /**
  138079. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138080. * @param data contains the texture data
  138081. * @param texture defines the BabylonJS internal texture
  138082. * @param createPolynomials will be true if polynomials have been requested
  138083. * @param onLoad defines the callback to trigger once the texture is ready
  138084. * @param onError defines the callback to trigger in case of error
  138085. */
  138086. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138087. /**
  138088. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138089. * @param data contains the texture data
  138090. * @param texture defines the BabylonJS internal texture
  138091. * @param callback defines the method to call once ready to upload
  138092. */
  138093. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138094. }
  138095. }
  138096. declare module BABYLON {
  138097. /**
  138098. * Implementation of the ENV Texture Loader.
  138099. * @hidden
  138100. */
  138101. export class _ENVTextureLoader implements IInternalTextureLoader {
  138102. /**
  138103. * Defines wether the loader supports cascade loading the different faces.
  138104. */
  138105. readonly supportCascades: boolean;
  138106. /**
  138107. * This returns if the loader support the current file information.
  138108. * @param extension defines the file extension of the file being loaded
  138109. * @returns true if the loader can load the specified file
  138110. */
  138111. canLoad(extension: string): boolean;
  138112. /**
  138113. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138114. * @param data contains the texture data
  138115. * @param texture defines the BabylonJS internal texture
  138116. * @param createPolynomials will be true if polynomials have been requested
  138117. * @param onLoad defines the callback to trigger once the texture is ready
  138118. * @param onError defines the callback to trigger in case of error
  138119. */
  138120. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138121. /**
  138122. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138123. * @param data contains the texture data
  138124. * @param texture defines the BabylonJS internal texture
  138125. * @param callback defines the method to call once ready to upload
  138126. */
  138127. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138128. }
  138129. }
  138130. declare module BABYLON {
  138131. /**
  138132. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138133. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138134. */
  138135. export class KhronosTextureContainer {
  138136. /** contents of the KTX container file */
  138137. data: ArrayBufferView;
  138138. private static HEADER_LEN;
  138139. private static COMPRESSED_2D;
  138140. private static COMPRESSED_3D;
  138141. private static TEX_2D;
  138142. private static TEX_3D;
  138143. /**
  138144. * Gets the openGL type
  138145. */
  138146. glType: number;
  138147. /**
  138148. * Gets the openGL type size
  138149. */
  138150. glTypeSize: number;
  138151. /**
  138152. * Gets the openGL format
  138153. */
  138154. glFormat: number;
  138155. /**
  138156. * Gets the openGL internal format
  138157. */
  138158. glInternalFormat: number;
  138159. /**
  138160. * Gets the base internal format
  138161. */
  138162. glBaseInternalFormat: number;
  138163. /**
  138164. * Gets image width in pixel
  138165. */
  138166. pixelWidth: number;
  138167. /**
  138168. * Gets image height in pixel
  138169. */
  138170. pixelHeight: number;
  138171. /**
  138172. * Gets image depth in pixels
  138173. */
  138174. pixelDepth: number;
  138175. /**
  138176. * Gets the number of array elements
  138177. */
  138178. numberOfArrayElements: number;
  138179. /**
  138180. * Gets the number of faces
  138181. */
  138182. numberOfFaces: number;
  138183. /**
  138184. * Gets the number of mipmap levels
  138185. */
  138186. numberOfMipmapLevels: number;
  138187. /**
  138188. * Gets the bytes of key value data
  138189. */
  138190. bytesOfKeyValueData: number;
  138191. /**
  138192. * Gets the load type
  138193. */
  138194. loadType: number;
  138195. /**
  138196. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138197. */
  138198. isInvalid: boolean;
  138199. /**
  138200. * Creates a new KhronosTextureContainer
  138201. * @param data contents of the KTX container file
  138202. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138203. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138204. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138205. */
  138206. constructor(
  138207. /** contents of the KTX container file */
  138208. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138209. /**
  138210. * Uploads KTX content to a Babylon Texture.
  138211. * It is assumed that the texture has already been created & is currently bound
  138212. * @hidden
  138213. */
  138214. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138215. private _upload2DCompressedLevels;
  138216. /**
  138217. * Checks if the given data starts with a KTX file identifier.
  138218. * @param data the data to check
  138219. * @returns true if the data is a KTX file or false otherwise
  138220. */
  138221. static IsValid(data: ArrayBufferView): boolean;
  138222. }
  138223. }
  138224. declare module BABYLON {
  138225. /**
  138226. * Helper class to push actions to a pool of workers.
  138227. */
  138228. export class WorkerPool implements IDisposable {
  138229. private _workerInfos;
  138230. private _pendingActions;
  138231. /**
  138232. * Constructor
  138233. * @param workers Array of workers to use for actions
  138234. */
  138235. constructor(workers: Array<Worker>);
  138236. /**
  138237. * Terminates all workers and clears any pending actions.
  138238. */
  138239. dispose(): void;
  138240. /**
  138241. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138242. * pended until a worker has completed its action.
  138243. * @param action The action to perform. Call onComplete when the action is complete.
  138244. */
  138245. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138246. private _execute;
  138247. }
  138248. }
  138249. declare module BABYLON {
  138250. /**
  138251. * Class for loading KTX2 files
  138252. * @hidden
  138253. */
  138254. export class KhronosTextureContainer2 {
  138255. private static _WorkerPoolPromise?;
  138256. private static _Initialized;
  138257. private static _Ktx2Decoder;
  138258. /**
  138259. * URL to use when loading the KTX2 decoder module
  138260. */
  138261. static JSModuleURL: string;
  138262. /**
  138263. * Default number of workers used to handle data decoding
  138264. */
  138265. static DefaultNumWorkers: number;
  138266. private static GetDefaultNumWorkers;
  138267. private _engine;
  138268. private static _CreateWorkerPool;
  138269. /**
  138270. * Constructor
  138271. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138272. */
  138273. constructor(engine: ThinEngine, numWorkers?: number);
  138274. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138275. /**
  138276. * Stop all async operations and release resources.
  138277. */
  138278. dispose(): void;
  138279. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138280. /**
  138281. * Checks if the given data starts with a KTX2 file identifier.
  138282. * @param data the data to check
  138283. * @returns true if the data is a KTX2 file or false otherwise
  138284. */
  138285. static IsValid(data: ArrayBufferView): boolean;
  138286. }
  138287. export function workerFunc(): void;
  138288. }
  138289. declare module BABYLON {
  138290. /**
  138291. * Implementation of the KTX Texture Loader.
  138292. * @hidden
  138293. */
  138294. export class _KTXTextureLoader implements IInternalTextureLoader {
  138295. /**
  138296. * Defines wether the loader supports cascade loading the different faces.
  138297. */
  138298. readonly supportCascades: boolean;
  138299. /**
  138300. * This returns if the loader support the current file information.
  138301. * @param extension defines the file extension of the file being loaded
  138302. * @param mimeType defines the optional mime type of the file being loaded
  138303. * @returns true if the loader can load the specified file
  138304. */
  138305. canLoad(extension: string, mimeType?: string): boolean;
  138306. /**
  138307. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138308. * @param data contains the texture data
  138309. * @param texture defines the BabylonJS internal texture
  138310. * @param createPolynomials will be true if polynomials have been requested
  138311. * @param onLoad defines the callback to trigger once the texture is ready
  138312. * @param onError defines the callback to trigger in case of error
  138313. */
  138314. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138315. /**
  138316. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138317. * @param data contains the texture data
  138318. * @param texture defines the BabylonJS internal texture
  138319. * @param callback defines the method to call once ready to upload
  138320. */
  138321. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138322. }
  138323. }
  138324. declare module BABYLON {
  138325. /** @hidden */
  138326. export var _forceSceneHelpersToBundle: boolean;
  138327. interface Scene {
  138328. /**
  138329. * Creates a default light for the scene.
  138330. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138331. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138332. */
  138333. createDefaultLight(replace?: boolean): void;
  138334. /**
  138335. * Creates a default camera for the scene.
  138336. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138337. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138338. * @param replace has default false, when true replaces the active camera in the scene
  138339. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138340. */
  138341. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138342. /**
  138343. * Creates a default camera and a default light.
  138344. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138345. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138346. * @param replace has the default false, when true replaces the active camera/light in the scene
  138347. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138348. */
  138349. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138350. /**
  138351. * Creates a new sky box
  138352. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138353. * @param environmentTexture defines the texture to use as environment texture
  138354. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138355. * @param scale defines the overall scale of the skybox
  138356. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138357. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138358. * @returns a new mesh holding the sky box
  138359. */
  138360. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138361. /**
  138362. * Creates a new environment
  138363. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138364. * @param options defines the options you can use to configure the environment
  138365. * @returns the new EnvironmentHelper
  138366. */
  138367. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138368. /**
  138369. * Creates a new VREXperienceHelper
  138370. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138371. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138372. * @returns a new VREXperienceHelper
  138373. */
  138374. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138375. /**
  138376. * Creates a new WebXRDefaultExperience
  138377. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138378. * @param options experience options
  138379. * @returns a promise for a new WebXRDefaultExperience
  138380. */
  138381. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138382. }
  138383. }
  138384. declare module BABYLON {
  138385. /**
  138386. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138387. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138388. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138389. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138390. */
  138391. export class VideoDome extends TextureDome<VideoTexture> {
  138392. /**
  138393. * Define the video source as a Monoscopic panoramic 360 video.
  138394. */
  138395. static readonly MODE_MONOSCOPIC: number;
  138396. /**
  138397. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138398. */
  138399. static readonly MODE_TOPBOTTOM: number;
  138400. /**
  138401. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138402. */
  138403. static readonly MODE_SIDEBYSIDE: number;
  138404. /**
  138405. * Get the video texture associated with this video dome
  138406. */
  138407. get videoTexture(): VideoTexture;
  138408. /**
  138409. * Get the video mode of this dome
  138410. */
  138411. get videoMode(): number;
  138412. /**
  138413. * Set the video mode of this dome.
  138414. * @see textureMode
  138415. */
  138416. set videoMode(value: number);
  138417. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138418. }
  138419. }
  138420. declare module BABYLON {
  138421. /**
  138422. * This class can be used to get instrumentation data from a Babylon engine
  138423. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138424. */
  138425. export class EngineInstrumentation implements IDisposable {
  138426. /**
  138427. * Define the instrumented engine.
  138428. */
  138429. engine: Engine;
  138430. private _captureGPUFrameTime;
  138431. private _gpuFrameTimeToken;
  138432. private _gpuFrameTime;
  138433. private _captureShaderCompilationTime;
  138434. private _shaderCompilationTime;
  138435. private _onBeginFrameObserver;
  138436. private _onEndFrameObserver;
  138437. private _onBeforeShaderCompilationObserver;
  138438. private _onAfterShaderCompilationObserver;
  138439. /**
  138440. * Gets the perf counter used for GPU frame time
  138441. */
  138442. get gpuFrameTimeCounter(): PerfCounter;
  138443. /**
  138444. * Gets the GPU frame time capture status
  138445. */
  138446. get captureGPUFrameTime(): boolean;
  138447. /**
  138448. * Enable or disable the GPU frame time capture
  138449. */
  138450. set captureGPUFrameTime(value: boolean);
  138451. /**
  138452. * Gets the perf counter used for shader compilation time
  138453. */
  138454. get shaderCompilationTimeCounter(): PerfCounter;
  138455. /**
  138456. * Gets the shader compilation time capture status
  138457. */
  138458. get captureShaderCompilationTime(): boolean;
  138459. /**
  138460. * Enable or disable the shader compilation time capture
  138461. */
  138462. set captureShaderCompilationTime(value: boolean);
  138463. /**
  138464. * Instantiates a new engine instrumentation.
  138465. * This class can be used to get instrumentation data from a Babylon engine
  138466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138467. * @param engine Defines the engine to instrument
  138468. */
  138469. constructor(
  138470. /**
  138471. * Define the instrumented engine.
  138472. */
  138473. engine: Engine);
  138474. /**
  138475. * Dispose and release associated resources.
  138476. */
  138477. dispose(): void;
  138478. }
  138479. }
  138480. declare module BABYLON {
  138481. /**
  138482. * This class can be used to get instrumentation data from a Babylon engine
  138483. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138484. */
  138485. export class SceneInstrumentation implements IDisposable {
  138486. /**
  138487. * Defines the scene to instrument
  138488. */
  138489. scene: Scene;
  138490. private _captureActiveMeshesEvaluationTime;
  138491. private _activeMeshesEvaluationTime;
  138492. private _captureRenderTargetsRenderTime;
  138493. private _renderTargetsRenderTime;
  138494. private _captureFrameTime;
  138495. private _frameTime;
  138496. private _captureRenderTime;
  138497. private _renderTime;
  138498. private _captureInterFrameTime;
  138499. private _interFrameTime;
  138500. private _captureParticlesRenderTime;
  138501. private _particlesRenderTime;
  138502. private _captureSpritesRenderTime;
  138503. private _spritesRenderTime;
  138504. private _capturePhysicsTime;
  138505. private _physicsTime;
  138506. private _captureAnimationsTime;
  138507. private _animationsTime;
  138508. private _captureCameraRenderTime;
  138509. private _cameraRenderTime;
  138510. private _onBeforeActiveMeshesEvaluationObserver;
  138511. private _onAfterActiveMeshesEvaluationObserver;
  138512. private _onBeforeRenderTargetsRenderObserver;
  138513. private _onAfterRenderTargetsRenderObserver;
  138514. private _onAfterRenderObserver;
  138515. private _onBeforeDrawPhaseObserver;
  138516. private _onAfterDrawPhaseObserver;
  138517. private _onBeforeAnimationsObserver;
  138518. private _onBeforeParticlesRenderingObserver;
  138519. private _onAfterParticlesRenderingObserver;
  138520. private _onBeforeSpritesRenderingObserver;
  138521. private _onAfterSpritesRenderingObserver;
  138522. private _onBeforePhysicsObserver;
  138523. private _onAfterPhysicsObserver;
  138524. private _onAfterAnimationsObserver;
  138525. private _onBeforeCameraRenderObserver;
  138526. private _onAfterCameraRenderObserver;
  138527. /**
  138528. * Gets the perf counter used for active meshes evaluation time
  138529. */
  138530. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138531. /**
  138532. * Gets the active meshes evaluation time capture status
  138533. */
  138534. get captureActiveMeshesEvaluationTime(): boolean;
  138535. /**
  138536. * Enable or disable the active meshes evaluation time capture
  138537. */
  138538. set captureActiveMeshesEvaluationTime(value: boolean);
  138539. /**
  138540. * Gets the perf counter used for render targets render time
  138541. */
  138542. get renderTargetsRenderTimeCounter(): PerfCounter;
  138543. /**
  138544. * Gets the render targets render time capture status
  138545. */
  138546. get captureRenderTargetsRenderTime(): boolean;
  138547. /**
  138548. * Enable or disable the render targets render time capture
  138549. */
  138550. set captureRenderTargetsRenderTime(value: boolean);
  138551. /**
  138552. * Gets the perf counter used for particles render time
  138553. */
  138554. get particlesRenderTimeCounter(): PerfCounter;
  138555. /**
  138556. * Gets the particles render time capture status
  138557. */
  138558. get captureParticlesRenderTime(): boolean;
  138559. /**
  138560. * Enable or disable the particles render time capture
  138561. */
  138562. set captureParticlesRenderTime(value: boolean);
  138563. /**
  138564. * Gets the perf counter used for sprites render time
  138565. */
  138566. get spritesRenderTimeCounter(): PerfCounter;
  138567. /**
  138568. * Gets the sprites render time capture status
  138569. */
  138570. get captureSpritesRenderTime(): boolean;
  138571. /**
  138572. * Enable or disable the sprites render time capture
  138573. */
  138574. set captureSpritesRenderTime(value: boolean);
  138575. /**
  138576. * Gets the perf counter used for physics time
  138577. */
  138578. get physicsTimeCounter(): PerfCounter;
  138579. /**
  138580. * Gets the physics time capture status
  138581. */
  138582. get capturePhysicsTime(): boolean;
  138583. /**
  138584. * Enable or disable the physics time capture
  138585. */
  138586. set capturePhysicsTime(value: boolean);
  138587. /**
  138588. * Gets the perf counter used for animations time
  138589. */
  138590. get animationsTimeCounter(): PerfCounter;
  138591. /**
  138592. * Gets the animations time capture status
  138593. */
  138594. get captureAnimationsTime(): boolean;
  138595. /**
  138596. * Enable or disable the animations time capture
  138597. */
  138598. set captureAnimationsTime(value: boolean);
  138599. /**
  138600. * Gets the perf counter used for frame time capture
  138601. */
  138602. get frameTimeCounter(): PerfCounter;
  138603. /**
  138604. * Gets the frame time capture status
  138605. */
  138606. get captureFrameTime(): boolean;
  138607. /**
  138608. * Enable or disable the frame time capture
  138609. */
  138610. set captureFrameTime(value: boolean);
  138611. /**
  138612. * Gets the perf counter used for inter-frames time capture
  138613. */
  138614. get interFrameTimeCounter(): PerfCounter;
  138615. /**
  138616. * Gets the inter-frames time capture status
  138617. */
  138618. get captureInterFrameTime(): boolean;
  138619. /**
  138620. * Enable or disable the inter-frames time capture
  138621. */
  138622. set captureInterFrameTime(value: boolean);
  138623. /**
  138624. * Gets the perf counter used for render time capture
  138625. */
  138626. get renderTimeCounter(): PerfCounter;
  138627. /**
  138628. * Gets the render time capture status
  138629. */
  138630. get captureRenderTime(): boolean;
  138631. /**
  138632. * Enable or disable the render time capture
  138633. */
  138634. set captureRenderTime(value: boolean);
  138635. /**
  138636. * Gets the perf counter used for camera render time capture
  138637. */
  138638. get cameraRenderTimeCounter(): PerfCounter;
  138639. /**
  138640. * Gets the camera render time capture status
  138641. */
  138642. get captureCameraRenderTime(): boolean;
  138643. /**
  138644. * Enable or disable the camera render time capture
  138645. */
  138646. set captureCameraRenderTime(value: boolean);
  138647. /**
  138648. * Gets the perf counter used for draw calls
  138649. */
  138650. get drawCallsCounter(): PerfCounter;
  138651. /**
  138652. * Instantiates a new scene instrumentation.
  138653. * This class can be used to get instrumentation data from a Babylon engine
  138654. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138655. * @param scene Defines the scene to instrument
  138656. */
  138657. constructor(
  138658. /**
  138659. * Defines the scene to instrument
  138660. */
  138661. scene: Scene);
  138662. /**
  138663. * Dispose and release associated resources.
  138664. */
  138665. dispose(): void;
  138666. }
  138667. }
  138668. declare module BABYLON {
  138669. /** @hidden */
  138670. export var glowMapGenerationPixelShader: {
  138671. name: string;
  138672. shader: string;
  138673. };
  138674. }
  138675. declare module BABYLON {
  138676. /** @hidden */
  138677. export var glowMapGenerationVertexShader: {
  138678. name: string;
  138679. shader: string;
  138680. };
  138681. }
  138682. declare module BABYLON {
  138683. /**
  138684. * Effect layer options. This helps customizing the behaviour
  138685. * of the effect layer.
  138686. */
  138687. export interface IEffectLayerOptions {
  138688. /**
  138689. * Multiplication factor apply to the canvas size to compute the render target size
  138690. * used to generated the objects (the smaller the faster).
  138691. */
  138692. mainTextureRatio: number;
  138693. /**
  138694. * Enforces a fixed size texture to ensure effect stability across devices.
  138695. */
  138696. mainTextureFixedSize?: number;
  138697. /**
  138698. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138699. */
  138700. alphaBlendingMode: number;
  138701. /**
  138702. * The camera attached to the layer.
  138703. */
  138704. camera: Nullable<Camera>;
  138705. /**
  138706. * The rendering group to draw the layer in.
  138707. */
  138708. renderingGroupId: number;
  138709. }
  138710. /**
  138711. * The effect layer Helps adding post process effect blended with the main pass.
  138712. *
  138713. * This can be for instance use to generate glow or higlight effects on the scene.
  138714. *
  138715. * The effect layer class can not be used directly and is intented to inherited from to be
  138716. * customized per effects.
  138717. */
  138718. export abstract class EffectLayer {
  138719. private _vertexBuffers;
  138720. private _indexBuffer;
  138721. private _cachedDefines;
  138722. private _effectLayerMapGenerationEffect;
  138723. private _effectLayerOptions;
  138724. private _mergeEffect;
  138725. protected _scene: Scene;
  138726. protected _engine: Engine;
  138727. protected _maxSize: number;
  138728. protected _mainTextureDesiredSize: ISize;
  138729. protected _mainTexture: RenderTargetTexture;
  138730. protected _shouldRender: boolean;
  138731. protected _postProcesses: PostProcess[];
  138732. protected _textures: BaseTexture[];
  138733. protected _emissiveTextureAndColor: {
  138734. texture: Nullable<BaseTexture>;
  138735. color: Color4;
  138736. };
  138737. /**
  138738. * The name of the layer
  138739. */
  138740. name: string;
  138741. /**
  138742. * The clear color of the texture used to generate the glow map.
  138743. */
  138744. neutralColor: Color4;
  138745. /**
  138746. * Specifies whether the highlight layer is enabled or not.
  138747. */
  138748. isEnabled: boolean;
  138749. /**
  138750. * Gets the camera attached to the layer.
  138751. */
  138752. get camera(): Nullable<Camera>;
  138753. /**
  138754. * Gets the rendering group id the layer should render in.
  138755. */
  138756. get renderingGroupId(): number;
  138757. set renderingGroupId(renderingGroupId: number);
  138758. /**
  138759. * An event triggered when the effect layer has been disposed.
  138760. */
  138761. onDisposeObservable: Observable<EffectLayer>;
  138762. /**
  138763. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138764. */
  138765. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138766. /**
  138767. * An event triggered when the generated texture is being merged in the scene.
  138768. */
  138769. onBeforeComposeObservable: Observable<EffectLayer>;
  138770. /**
  138771. * An event triggered when the mesh is rendered into the effect render target.
  138772. */
  138773. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138774. /**
  138775. * An event triggered after the mesh has been rendered into the effect render target.
  138776. */
  138777. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138778. /**
  138779. * An event triggered when the generated texture has been merged in the scene.
  138780. */
  138781. onAfterComposeObservable: Observable<EffectLayer>;
  138782. /**
  138783. * An event triggered when the efffect layer changes its size.
  138784. */
  138785. onSizeChangedObservable: Observable<EffectLayer>;
  138786. /** @hidden */
  138787. static _SceneComponentInitialization: (scene: Scene) => void;
  138788. /**
  138789. * Instantiates a new effect Layer and references it in the scene.
  138790. * @param name The name of the layer
  138791. * @param scene The scene to use the layer in
  138792. */
  138793. constructor(
  138794. /** The Friendly of the effect in the scene */
  138795. name: string, scene: Scene);
  138796. /**
  138797. * Get the effect name of the layer.
  138798. * @return The effect name
  138799. */
  138800. abstract getEffectName(): string;
  138801. /**
  138802. * Checks for the readiness of the element composing the layer.
  138803. * @param subMesh the mesh to check for
  138804. * @param useInstances specify whether or not to use instances to render the mesh
  138805. * @return true if ready otherwise, false
  138806. */
  138807. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138808. /**
  138809. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138810. * @returns true if the effect requires stencil during the main canvas render pass.
  138811. */
  138812. abstract needStencil(): boolean;
  138813. /**
  138814. * Create the merge effect. This is the shader use to blit the information back
  138815. * to the main canvas at the end of the scene rendering.
  138816. * @returns The effect containing the shader used to merge the effect on the main canvas
  138817. */
  138818. protected abstract _createMergeEffect(): Effect;
  138819. /**
  138820. * Creates the render target textures and post processes used in the effect layer.
  138821. */
  138822. protected abstract _createTextureAndPostProcesses(): void;
  138823. /**
  138824. * Implementation specific of rendering the generating effect on the main canvas.
  138825. * @param effect The effect used to render through
  138826. */
  138827. protected abstract _internalRender(effect: Effect): void;
  138828. /**
  138829. * Sets the required values for both the emissive texture and and the main color.
  138830. */
  138831. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138832. /**
  138833. * Free any resources and references associated to a mesh.
  138834. * Internal use
  138835. * @param mesh The mesh to free.
  138836. */
  138837. abstract _disposeMesh(mesh: Mesh): void;
  138838. /**
  138839. * Serializes this layer (Glow or Highlight for example)
  138840. * @returns a serialized layer object
  138841. */
  138842. abstract serialize?(): any;
  138843. /**
  138844. * Initializes the effect layer with the required options.
  138845. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138846. */
  138847. protected _init(options: Partial<IEffectLayerOptions>): void;
  138848. /**
  138849. * Generates the index buffer of the full screen quad blending to the main canvas.
  138850. */
  138851. private _generateIndexBuffer;
  138852. /**
  138853. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138854. */
  138855. private _generateVertexBuffer;
  138856. /**
  138857. * Sets the main texture desired size which is the closest power of two
  138858. * of the engine canvas size.
  138859. */
  138860. private _setMainTextureSize;
  138861. /**
  138862. * Creates the main texture for the effect layer.
  138863. */
  138864. protected _createMainTexture(): void;
  138865. /**
  138866. * Adds specific effects defines.
  138867. * @param defines The defines to add specifics to.
  138868. */
  138869. protected _addCustomEffectDefines(defines: string[]): void;
  138870. /**
  138871. * Checks for the readiness of the element composing the layer.
  138872. * @param subMesh the mesh to check for
  138873. * @param useInstances specify whether or not to use instances to render the mesh
  138874. * @param emissiveTexture the associated emissive texture used to generate the glow
  138875. * @return true if ready otherwise, false
  138876. */
  138877. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138878. /**
  138879. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138880. */
  138881. render(): void;
  138882. /**
  138883. * Determine if a given mesh will be used in the current effect.
  138884. * @param mesh mesh to test
  138885. * @returns true if the mesh will be used
  138886. */
  138887. hasMesh(mesh: AbstractMesh): boolean;
  138888. /**
  138889. * Returns true if the layer contains information to display, otherwise false.
  138890. * @returns true if the glow layer should be rendered
  138891. */
  138892. shouldRender(): boolean;
  138893. /**
  138894. * Returns true if the mesh should render, otherwise false.
  138895. * @param mesh The mesh to render
  138896. * @returns true if it should render otherwise false
  138897. */
  138898. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138899. /**
  138900. * Returns true if the mesh can be rendered, otherwise false.
  138901. * @param mesh The mesh to render
  138902. * @param material The material used on the mesh
  138903. * @returns true if it can be rendered otherwise false
  138904. */
  138905. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138906. /**
  138907. * Returns true if the mesh should render, otherwise false.
  138908. * @param mesh The mesh to render
  138909. * @returns true if it should render otherwise false
  138910. */
  138911. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138912. /**
  138913. * Renders the submesh passed in parameter to the generation map.
  138914. */
  138915. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138916. /**
  138917. * Defines whether the current material of the mesh should be use to render the effect.
  138918. * @param mesh defines the current mesh to render
  138919. */
  138920. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138921. /**
  138922. * Rebuild the required buffers.
  138923. * @hidden Internal use only.
  138924. */
  138925. _rebuild(): void;
  138926. /**
  138927. * Dispose only the render target textures and post process.
  138928. */
  138929. private _disposeTextureAndPostProcesses;
  138930. /**
  138931. * Dispose the highlight layer and free resources.
  138932. */
  138933. dispose(): void;
  138934. /**
  138935. * Gets the class name of the effect layer
  138936. * @returns the string with the class name of the effect layer
  138937. */
  138938. getClassName(): string;
  138939. /**
  138940. * Creates an effect layer from parsed effect layer data
  138941. * @param parsedEffectLayer defines effect layer data
  138942. * @param scene defines the current scene
  138943. * @param rootUrl defines the root URL containing the effect layer information
  138944. * @returns a parsed effect Layer
  138945. */
  138946. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138947. }
  138948. }
  138949. declare module BABYLON {
  138950. interface AbstractScene {
  138951. /**
  138952. * The list of effect layers (highlights/glow) added to the scene
  138953. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138954. * @see https://doc.babylonjs.com/how_to/glow_layer
  138955. */
  138956. effectLayers: Array<EffectLayer>;
  138957. /**
  138958. * Removes the given effect layer from this scene.
  138959. * @param toRemove defines the effect layer to remove
  138960. * @returns the index of the removed effect layer
  138961. */
  138962. removeEffectLayer(toRemove: EffectLayer): number;
  138963. /**
  138964. * Adds the given effect layer to this scene
  138965. * @param newEffectLayer defines the effect layer to add
  138966. */
  138967. addEffectLayer(newEffectLayer: EffectLayer): void;
  138968. }
  138969. /**
  138970. * Defines the layer scene component responsible to manage any effect layers
  138971. * in a given scene.
  138972. */
  138973. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138974. /**
  138975. * The component name helpfull to identify the component in the list of scene components.
  138976. */
  138977. readonly name: string;
  138978. /**
  138979. * The scene the component belongs to.
  138980. */
  138981. scene: Scene;
  138982. private _engine;
  138983. private _renderEffects;
  138984. private _needStencil;
  138985. private _previousStencilState;
  138986. /**
  138987. * Creates a new instance of the component for the given scene
  138988. * @param scene Defines the scene to register the component in
  138989. */
  138990. constructor(scene: Scene);
  138991. /**
  138992. * Registers the component in a given scene
  138993. */
  138994. register(): void;
  138995. /**
  138996. * Rebuilds the elements related to this component in case of
  138997. * context lost for instance.
  138998. */
  138999. rebuild(): void;
  139000. /**
  139001. * Serializes the component data to the specified json object
  139002. * @param serializationObject The object to serialize to
  139003. */
  139004. serialize(serializationObject: any): void;
  139005. /**
  139006. * Adds all the elements from the container to the scene
  139007. * @param container the container holding the elements
  139008. */
  139009. addFromContainer(container: AbstractScene): void;
  139010. /**
  139011. * Removes all the elements in the container from the scene
  139012. * @param container contains the elements to remove
  139013. * @param dispose if the removed element should be disposed (default: false)
  139014. */
  139015. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139016. /**
  139017. * Disposes the component and the associated ressources.
  139018. */
  139019. dispose(): void;
  139020. private _isReadyForMesh;
  139021. private _renderMainTexture;
  139022. private _setStencil;
  139023. private _setStencilBack;
  139024. private _draw;
  139025. private _drawCamera;
  139026. private _drawRenderingGroup;
  139027. }
  139028. }
  139029. declare module BABYLON {
  139030. /** @hidden */
  139031. export var glowMapMergePixelShader: {
  139032. name: string;
  139033. shader: string;
  139034. };
  139035. }
  139036. declare module BABYLON {
  139037. /** @hidden */
  139038. export var glowMapMergeVertexShader: {
  139039. name: string;
  139040. shader: string;
  139041. };
  139042. }
  139043. declare module BABYLON {
  139044. interface AbstractScene {
  139045. /**
  139046. * Return a the first highlight layer of the scene with a given name.
  139047. * @param name The name of the highlight layer to look for.
  139048. * @return The highlight layer if found otherwise null.
  139049. */
  139050. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139051. }
  139052. /**
  139053. * Glow layer options. This helps customizing the behaviour
  139054. * of the glow layer.
  139055. */
  139056. export interface IGlowLayerOptions {
  139057. /**
  139058. * Multiplication factor apply to the canvas size to compute the render target size
  139059. * used to generated the glowing objects (the smaller the faster).
  139060. */
  139061. mainTextureRatio: number;
  139062. /**
  139063. * Enforces a fixed size texture to ensure resize independant blur.
  139064. */
  139065. mainTextureFixedSize?: number;
  139066. /**
  139067. * How big is the kernel of the blur texture.
  139068. */
  139069. blurKernelSize: number;
  139070. /**
  139071. * The camera attached to the layer.
  139072. */
  139073. camera: Nullable<Camera>;
  139074. /**
  139075. * Enable MSAA by chosing the number of samples.
  139076. */
  139077. mainTextureSamples?: number;
  139078. /**
  139079. * The rendering group to draw the layer in.
  139080. */
  139081. renderingGroupId: number;
  139082. }
  139083. /**
  139084. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139085. *
  139086. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139087. *
  139088. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139089. */
  139090. export class GlowLayer extends EffectLayer {
  139091. /**
  139092. * Effect Name of the layer.
  139093. */
  139094. static readonly EffectName: string;
  139095. /**
  139096. * The default blur kernel size used for the glow.
  139097. */
  139098. static DefaultBlurKernelSize: number;
  139099. /**
  139100. * The default texture size ratio used for the glow.
  139101. */
  139102. static DefaultTextureRatio: number;
  139103. /**
  139104. * Sets the kernel size of the blur.
  139105. */
  139106. set blurKernelSize(value: number);
  139107. /**
  139108. * Gets the kernel size of the blur.
  139109. */
  139110. get blurKernelSize(): number;
  139111. /**
  139112. * Sets the glow intensity.
  139113. */
  139114. set intensity(value: number);
  139115. /**
  139116. * Gets the glow intensity.
  139117. */
  139118. get intensity(): number;
  139119. private _options;
  139120. private _intensity;
  139121. private _horizontalBlurPostprocess1;
  139122. private _verticalBlurPostprocess1;
  139123. private _horizontalBlurPostprocess2;
  139124. private _verticalBlurPostprocess2;
  139125. private _blurTexture1;
  139126. private _blurTexture2;
  139127. private _postProcesses1;
  139128. private _postProcesses2;
  139129. private _includedOnlyMeshes;
  139130. private _excludedMeshes;
  139131. private _meshesUsingTheirOwnMaterials;
  139132. /**
  139133. * Callback used to let the user override the color selection on a per mesh basis
  139134. */
  139135. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139136. /**
  139137. * Callback used to let the user override the texture selection on a per mesh basis
  139138. */
  139139. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139140. /**
  139141. * Instantiates a new glow Layer and references it to the scene.
  139142. * @param name The name of the layer
  139143. * @param scene The scene to use the layer in
  139144. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139145. */
  139146. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139147. /**
  139148. * Get the effect name of the layer.
  139149. * @return The effect name
  139150. */
  139151. getEffectName(): string;
  139152. /**
  139153. * Create the merge effect. This is the shader use to blit the information back
  139154. * to the main canvas at the end of the scene rendering.
  139155. */
  139156. protected _createMergeEffect(): Effect;
  139157. /**
  139158. * Creates the render target textures and post processes used in the glow layer.
  139159. */
  139160. protected _createTextureAndPostProcesses(): void;
  139161. /**
  139162. * Checks for the readiness of the element composing the layer.
  139163. * @param subMesh the mesh to check for
  139164. * @param useInstances specify wether or not to use instances to render the mesh
  139165. * @param emissiveTexture the associated emissive texture used to generate the glow
  139166. * @return true if ready otherwise, false
  139167. */
  139168. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139169. /**
  139170. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139171. */
  139172. needStencil(): boolean;
  139173. /**
  139174. * Returns true if the mesh can be rendered, otherwise false.
  139175. * @param mesh The mesh to render
  139176. * @param material The material used on the mesh
  139177. * @returns true if it can be rendered otherwise false
  139178. */
  139179. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139180. /**
  139181. * Implementation specific of rendering the generating effect on the main canvas.
  139182. * @param effect The effect used to render through
  139183. */
  139184. protected _internalRender(effect: Effect): void;
  139185. /**
  139186. * Sets the required values for both the emissive texture and and the main color.
  139187. */
  139188. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139189. /**
  139190. * Returns true if the mesh should render, otherwise false.
  139191. * @param mesh The mesh to render
  139192. * @returns true if it should render otherwise false
  139193. */
  139194. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139195. /**
  139196. * Adds specific effects defines.
  139197. * @param defines The defines to add specifics to.
  139198. */
  139199. protected _addCustomEffectDefines(defines: string[]): void;
  139200. /**
  139201. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139202. * @param mesh The mesh to exclude from the glow layer
  139203. */
  139204. addExcludedMesh(mesh: Mesh): void;
  139205. /**
  139206. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139207. * @param mesh The mesh to remove
  139208. */
  139209. removeExcludedMesh(mesh: Mesh): void;
  139210. /**
  139211. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139212. * @param mesh The mesh to include in the glow layer
  139213. */
  139214. addIncludedOnlyMesh(mesh: Mesh): void;
  139215. /**
  139216. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139217. * @param mesh The mesh to remove
  139218. */
  139219. removeIncludedOnlyMesh(mesh: Mesh): void;
  139220. /**
  139221. * Determine if a given mesh will be used in the glow layer
  139222. * @param mesh The mesh to test
  139223. * @returns true if the mesh will be highlighted by the current glow layer
  139224. */
  139225. hasMesh(mesh: AbstractMesh): boolean;
  139226. /**
  139227. * Defines whether the current material of the mesh should be use to render the effect.
  139228. * @param mesh defines the current mesh to render
  139229. */
  139230. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139231. /**
  139232. * Add a mesh to be rendered through its own material and not with emissive only.
  139233. * @param mesh The mesh for which we need to use its material
  139234. */
  139235. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139236. /**
  139237. * Remove a mesh from being rendered through its own material and not with emissive only.
  139238. * @param mesh The mesh for which we need to not use its material
  139239. */
  139240. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139241. /**
  139242. * Free any resources and references associated to a mesh.
  139243. * Internal use
  139244. * @param mesh The mesh to free.
  139245. * @hidden
  139246. */
  139247. _disposeMesh(mesh: Mesh): void;
  139248. /**
  139249. * Gets the class name of the effect layer
  139250. * @returns the string with the class name of the effect layer
  139251. */
  139252. getClassName(): string;
  139253. /**
  139254. * Serializes this glow layer
  139255. * @returns a serialized glow layer object
  139256. */
  139257. serialize(): any;
  139258. /**
  139259. * Creates a Glow Layer from parsed glow layer data
  139260. * @param parsedGlowLayer defines glow layer data
  139261. * @param scene defines the current scene
  139262. * @param rootUrl defines the root URL containing the glow layer information
  139263. * @returns a parsed Glow Layer
  139264. */
  139265. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139266. }
  139267. }
  139268. declare module BABYLON {
  139269. /** @hidden */
  139270. export var glowBlurPostProcessPixelShader: {
  139271. name: string;
  139272. shader: string;
  139273. };
  139274. }
  139275. declare module BABYLON {
  139276. interface AbstractScene {
  139277. /**
  139278. * Return a the first highlight layer of the scene with a given name.
  139279. * @param name The name of the highlight layer to look for.
  139280. * @return The highlight layer if found otherwise null.
  139281. */
  139282. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139283. }
  139284. /**
  139285. * Highlight layer options. This helps customizing the behaviour
  139286. * of the highlight layer.
  139287. */
  139288. export interface IHighlightLayerOptions {
  139289. /**
  139290. * Multiplication factor apply to the canvas size to compute the render target size
  139291. * used to generated the glowing objects (the smaller the faster).
  139292. */
  139293. mainTextureRatio: number;
  139294. /**
  139295. * Enforces a fixed size texture to ensure resize independant blur.
  139296. */
  139297. mainTextureFixedSize?: number;
  139298. /**
  139299. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139300. * of the picture to blur (the smaller the faster).
  139301. */
  139302. blurTextureSizeRatio: number;
  139303. /**
  139304. * How big in texel of the blur texture is the vertical blur.
  139305. */
  139306. blurVerticalSize: number;
  139307. /**
  139308. * How big in texel of the blur texture is the horizontal blur.
  139309. */
  139310. blurHorizontalSize: number;
  139311. /**
  139312. * Alpha blending mode used to apply the blur. Default is combine.
  139313. */
  139314. alphaBlendingMode: number;
  139315. /**
  139316. * The camera attached to the layer.
  139317. */
  139318. camera: Nullable<Camera>;
  139319. /**
  139320. * Should we display highlight as a solid stroke?
  139321. */
  139322. isStroke?: boolean;
  139323. /**
  139324. * The rendering group to draw the layer in.
  139325. */
  139326. renderingGroupId: number;
  139327. }
  139328. /**
  139329. * The highlight layer Helps adding a glow effect around a mesh.
  139330. *
  139331. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139332. * glowy meshes to your scene.
  139333. *
  139334. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139335. */
  139336. export class HighlightLayer extends EffectLayer {
  139337. name: string;
  139338. /**
  139339. * Effect Name of the highlight layer.
  139340. */
  139341. static readonly EffectName: string;
  139342. /**
  139343. * The neutral color used during the preparation of the glow effect.
  139344. * This is black by default as the blend operation is a blend operation.
  139345. */
  139346. static NeutralColor: Color4;
  139347. /**
  139348. * Stencil value used for glowing meshes.
  139349. */
  139350. static GlowingMeshStencilReference: number;
  139351. /**
  139352. * Stencil value used for the other meshes in the scene.
  139353. */
  139354. static NormalMeshStencilReference: number;
  139355. /**
  139356. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139357. */
  139358. innerGlow: boolean;
  139359. /**
  139360. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139361. */
  139362. outerGlow: boolean;
  139363. /**
  139364. * Specifies the horizontal size of the blur.
  139365. */
  139366. set blurHorizontalSize(value: number);
  139367. /**
  139368. * Specifies the vertical size of the blur.
  139369. */
  139370. set blurVerticalSize(value: number);
  139371. /**
  139372. * Gets the horizontal size of the blur.
  139373. */
  139374. get blurHorizontalSize(): number;
  139375. /**
  139376. * Gets the vertical size of the blur.
  139377. */
  139378. get blurVerticalSize(): number;
  139379. /**
  139380. * An event triggered when the highlight layer is being blurred.
  139381. */
  139382. onBeforeBlurObservable: Observable<HighlightLayer>;
  139383. /**
  139384. * An event triggered when the highlight layer has been blurred.
  139385. */
  139386. onAfterBlurObservable: Observable<HighlightLayer>;
  139387. private _instanceGlowingMeshStencilReference;
  139388. private _options;
  139389. private _downSamplePostprocess;
  139390. private _horizontalBlurPostprocess;
  139391. private _verticalBlurPostprocess;
  139392. private _blurTexture;
  139393. private _meshes;
  139394. private _excludedMeshes;
  139395. /**
  139396. * Instantiates a new highlight Layer and references it to the scene..
  139397. * @param name The name of the layer
  139398. * @param scene The scene to use the layer in
  139399. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139400. */
  139401. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139402. /**
  139403. * Get the effect name of the layer.
  139404. * @return The effect name
  139405. */
  139406. getEffectName(): string;
  139407. /**
  139408. * Create the merge effect. This is the shader use to blit the information back
  139409. * to the main canvas at the end of the scene rendering.
  139410. */
  139411. protected _createMergeEffect(): Effect;
  139412. /**
  139413. * Creates the render target textures and post processes used in the highlight layer.
  139414. */
  139415. protected _createTextureAndPostProcesses(): void;
  139416. /**
  139417. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139418. */
  139419. needStencil(): boolean;
  139420. /**
  139421. * Checks for the readiness of the element composing the layer.
  139422. * @param subMesh the mesh to check for
  139423. * @param useInstances specify wether or not to use instances to render the mesh
  139424. * @param emissiveTexture the associated emissive texture used to generate the glow
  139425. * @return true if ready otherwise, false
  139426. */
  139427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139428. /**
  139429. * Implementation specific of rendering the generating effect on the main canvas.
  139430. * @param effect The effect used to render through
  139431. */
  139432. protected _internalRender(effect: Effect): void;
  139433. /**
  139434. * Returns true if the layer contains information to display, otherwise false.
  139435. */
  139436. shouldRender(): boolean;
  139437. /**
  139438. * Returns true if the mesh should render, otherwise false.
  139439. * @param mesh The mesh to render
  139440. * @returns true if it should render otherwise false
  139441. */
  139442. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139443. /**
  139444. * Returns true if the mesh can be rendered, otherwise false.
  139445. * @param mesh The mesh to render
  139446. * @param material The material used on the mesh
  139447. * @returns true if it can be rendered otherwise false
  139448. */
  139449. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139450. /**
  139451. * Adds specific effects defines.
  139452. * @param defines The defines to add specifics to.
  139453. */
  139454. protected _addCustomEffectDefines(defines: string[]): void;
  139455. /**
  139456. * Sets the required values for both the emissive texture and and the main color.
  139457. */
  139458. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139459. /**
  139460. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139461. * @param mesh The mesh to exclude from the highlight layer
  139462. */
  139463. addExcludedMesh(mesh: Mesh): void;
  139464. /**
  139465. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139466. * @param mesh The mesh to highlight
  139467. */
  139468. removeExcludedMesh(mesh: Mesh): void;
  139469. /**
  139470. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139471. * @param mesh mesh to test
  139472. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139473. */
  139474. hasMesh(mesh: AbstractMesh): boolean;
  139475. /**
  139476. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139477. * @param mesh The mesh to highlight
  139478. * @param color The color of the highlight
  139479. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139480. */
  139481. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139482. /**
  139483. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139484. * @param mesh The mesh to highlight
  139485. */
  139486. removeMesh(mesh: Mesh): void;
  139487. /**
  139488. * Remove all the meshes currently referenced in the highlight layer
  139489. */
  139490. removeAllMeshes(): void;
  139491. /**
  139492. * Force the stencil to the normal expected value for none glowing parts
  139493. */
  139494. private _defaultStencilReference;
  139495. /**
  139496. * Free any resources and references associated to a mesh.
  139497. * Internal use
  139498. * @param mesh The mesh to free.
  139499. * @hidden
  139500. */
  139501. _disposeMesh(mesh: Mesh): void;
  139502. /**
  139503. * Dispose the highlight layer and free resources.
  139504. */
  139505. dispose(): void;
  139506. /**
  139507. * Gets the class name of the effect layer
  139508. * @returns the string with the class name of the effect layer
  139509. */
  139510. getClassName(): string;
  139511. /**
  139512. * Serializes this Highlight layer
  139513. * @returns a serialized Highlight layer object
  139514. */
  139515. serialize(): any;
  139516. /**
  139517. * Creates a Highlight layer from parsed Highlight layer data
  139518. * @param parsedHightlightLayer defines the Highlight layer data
  139519. * @param scene defines the current scene
  139520. * @param rootUrl defines the root URL containing the Highlight layer information
  139521. * @returns a parsed Highlight layer
  139522. */
  139523. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139524. }
  139525. }
  139526. declare module BABYLON {
  139527. interface AbstractScene {
  139528. /**
  139529. * The list of layers (background and foreground) of the scene
  139530. */
  139531. layers: Array<Layer>;
  139532. }
  139533. /**
  139534. * Defines the layer scene component responsible to manage any layers
  139535. * in a given scene.
  139536. */
  139537. export class LayerSceneComponent implements ISceneComponent {
  139538. /**
  139539. * The component name helpfull to identify the component in the list of scene components.
  139540. */
  139541. readonly name: string;
  139542. /**
  139543. * The scene the component belongs to.
  139544. */
  139545. scene: Scene;
  139546. private _engine;
  139547. /**
  139548. * Creates a new instance of the component for the given scene
  139549. * @param scene Defines the scene to register the component in
  139550. */
  139551. constructor(scene: Scene);
  139552. /**
  139553. * Registers the component in a given scene
  139554. */
  139555. register(): void;
  139556. /**
  139557. * Rebuilds the elements related to this component in case of
  139558. * context lost for instance.
  139559. */
  139560. rebuild(): void;
  139561. /**
  139562. * Disposes the component and the associated ressources.
  139563. */
  139564. dispose(): void;
  139565. private _draw;
  139566. private _drawCameraPredicate;
  139567. private _drawCameraBackground;
  139568. private _drawCameraForeground;
  139569. private _drawRenderTargetPredicate;
  139570. private _drawRenderTargetBackground;
  139571. private _drawRenderTargetForeground;
  139572. /**
  139573. * Adds all the elements from the container to the scene
  139574. * @param container the container holding the elements
  139575. */
  139576. addFromContainer(container: AbstractScene): void;
  139577. /**
  139578. * Removes all the elements in the container from the scene
  139579. * @param container contains the elements to remove
  139580. * @param dispose if the removed element should be disposed (default: false)
  139581. */
  139582. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139583. }
  139584. }
  139585. declare module BABYLON {
  139586. /** @hidden */
  139587. export var layerPixelShader: {
  139588. name: string;
  139589. shader: string;
  139590. };
  139591. }
  139592. declare module BABYLON {
  139593. /** @hidden */
  139594. export var layerVertexShader: {
  139595. name: string;
  139596. shader: string;
  139597. };
  139598. }
  139599. declare module BABYLON {
  139600. /**
  139601. * This represents a full screen 2d layer.
  139602. * This can be useful to display a picture in the background of your scene for instance.
  139603. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139604. */
  139605. export class Layer {
  139606. /**
  139607. * Define the name of the layer.
  139608. */
  139609. name: string;
  139610. /**
  139611. * Define the texture the layer should display.
  139612. */
  139613. texture: Nullable<Texture>;
  139614. /**
  139615. * Is the layer in background or foreground.
  139616. */
  139617. isBackground: boolean;
  139618. /**
  139619. * Define the color of the layer (instead of texture).
  139620. */
  139621. color: Color4;
  139622. /**
  139623. * Define the scale of the layer in order to zoom in out of the texture.
  139624. */
  139625. scale: Vector2;
  139626. /**
  139627. * Define an offset for the layer in order to shift the texture.
  139628. */
  139629. offset: Vector2;
  139630. /**
  139631. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139632. */
  139633. alphaBlendingMode: number;
  139634. /**
  139635. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139636. * Alpha test will not mix with the background color in case of transparency.
  139637. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139638. */
  139639. alphaTest: boolean;
  139640. /**
  139641. * Define a mask to restrict the layer to only some of the scene cameras.
  139642. */
  139643. layerMask: number;
  139644. /**
  139645. * Define the list of render target the layer is visible into.
  139646. */
  139647. renderTargetTextures: RenderTargetTexture[];
  139648. /**
  139649. * Define if the layer is only used in renderTarget or if it also
  139650. * renders in the main frame buffer of the canvas.
  139651. */
  139652. renderOnlyInRenderTargetTextures: boolean;
  139653. private _scene;
  139654. private _vertexBuffers;
  139655. private _indexBuffer;
  139656. private _effect;
  139657. private _previousDefines;
  139658. /**
  139659. * An event triggered when the layer is disposed.
  139660. */
  139661. onDisposeObservable: Observable<Layer>;
  139662. private _onDisposeObserver;
  139663. /**
  139664. * Back compatibility with callback before the onDisposeObservable existed.
  139665. * The set callback will be triggered when the layer has been disposed.
  139666. */
  139667. set onDispose(callback: () => void);
  139668. /**
  139669. * An event triggered before rendering the scene
  139670. */
  139671. onBeforeRenderObservable: Observable<Layer>;
  139672. private _onBeforeRenderObserver;
  139673. /**
  139674. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139675. * The set callback will be triggered just before rendering the layer.
  139676. */
  139677. set onBeforeRender(callback: () => void);
  139678. /**
  139679. * An event triggered after rendering the scene
  139680. */
  139681. onAfterRenderObservable: Observable<Layer>;
  139682. private _onAfterRenderObserver;
  139683. /**
  139684. * Back compatibility with callback before the onAfterRenderObservable existed.
  139685. * The set callback will be triggered just after rendering the layer.
  139686. */
  139687. set onAfterRender(callback: () => void);
  139688. /**
  139689. * Instantiates a new layer.
  139690. * This represents a full screen 2d layer.
  139691. * This can be useful to display a picture in the background of your scene for instance.
  139692. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139693. * @param name Define the name of the layer in the scene
  139694. * @param imgUrl Define the url of the texture to display in the layer
  139695. * @param scene Define the scene the layer belongs to
  139696. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139697. * @param color Defines a color for the layer
  139698. */
  139699. constructor(
  139700. /**
  139701. * Define the name of the layer.
  139702. */
  139703. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139704. private _createIndexBuffer;
  139705. /** @hidden */
  139706. _rebuild(): void;
  139707. /**
  139708. * Renders the layer in the scene.
  139709. */
  139710. render(): void;
  139711. /**
  139712. * Disposes and releases the associated ressources.
  139713. */
  139714. dispose(): void;
  139715. }
  139716. }
  139717. declare module BABYLON {
  139718. /** @hidden */
  139719. export var lensFlarePixelShader: {
  139720. name: string;
  139721. shader: string;
  139722. };
  139723. }
  139724. declare module BABYLON {
  139725. /** @hidden */
  139726. export var lensFlareVertexShader: {
  139727. name: string;
  139728. shader: string;
  139729. };
  139730. }
  139731. declare module BABYLON {
  139732. /**
  139733. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139734. * It is usually composed of several `lensFlare`.
  139735. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139736. */
  139737. export class LensFlareSystem {
  139738. /**
  139739. * Define the name of the lens flare system
  139740. */
  139741. name: string;
  139742. /**
  139743. * List of lens flares used in this system.
  139744. */
  139745. lensFlares: LensFlare[];
  139746. /**
  139747. * Define a limit from the border the lens flare can be visible.
  139748. */
  139749. borderLimit: number;
  139750. /**
  139751. * Define a viewport border we do not want to see the lens flare in.
  139752. */
  139753. viewportBorder: number;
  139754. /**
  139755. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139756. */
  139757. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139758. /**
  139759. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139760. */
  139761. layerMask: number;
  139762. /**
  139763. * Define the id of the lens flare system in the scene.
  139764. * (equal to name by default)
  139765. */
  139766. id: string;
  139767. private _scene;
  139768. private _emitter;
  139769. private _vertexBuffers;
  139770. private _indexBuffer;
  139771. private _effect;
  139772. private _positionX;
  139773. private _positionY;
  139774. private _isEnabled;
  139775. /** @hidden */
  139776. static _SceneComponentInitialization: (scene: Scene) => void;
  139777. /**
  139778. * Instantiates a lens flare system.
  139779. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139780. * It is usually composed of several `lensFlare`.
  139781. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139782. * @param name Define the name of the lens flare system in the scene
  139783. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139784. * @param scene Define the scene the lens flare system belongs to
  139785. */
  139786. constructor(
  139787. /**
  139788. * Define the name of the lens flare system
  139789. */
  139790. name: string, emitter: any, scene: Scene);
  139791. /**
  139792. * Define if the lens flare system is enabled.
  139793. */
  139794. get isEnabled(): boolean;
  139795. set isEnabled(value: boolean);
  139796. /**
  139797. * Get the scene the effects belongs to.
  139798. * @returns the scene holding the lens flare system
  139799. */
  139800. getScene(): Scene;
  139801. /**
  139802. * Get the emitter of the lens flare system.
  139803. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139804. * @returns the emitter of the lens flare system
  139805. */
  139806. getEmitter(): any;
  139807. /**
  139808. * Set the emitter of the lens flare system.
  139809. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139810. * @param newEmitter Define the new emitter of the system
  139811. */
  139812. setEmitter(newEmitter: any): void;
  139813. /**
  139814. * Get the lens flare system emitter position.
  139815. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139816. * @returns the position
  139817. */
  139818. getEmitterPosition(): Vector3;
  139819. /**
  139820. * @hidden
  139821. */
  139822. computeEffectivePosition(globalViewport: Viewport): boolean;
  139823. /** @hidden */
  139824. _isVisible(): boolean;
  139825. /**
  139826. * @hidden
  139827. */
  139828. render(): boolean;
  139829. /**
  139830. * Dispose and release the lens flare with its associated resources.
  139831. */
  139832. dispose(): void;
  139833. /**
  139834. * Parse a lens flare system from a JSON repressentation
  139835. * @param parsedLensFlareSystem Define the JSON to parse
  139836. * @param scene Define the scene the parsed system should be instantiated in
  139837. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139838. * @returns the parsed system
  139839. */
  139840. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139841. /**
  139842. * Serialize the current Lens Flare System into a JSON representation.
  139843. * @returns the serialized JSON
  139844. */
  139845. serialize(): any;
  139846. }
  139847. }
  139848. declare module BABYLON {
  139849. /**
  139850. * This represents one of the lens effect in a `lensFlareSystem`.
  139851. * It controls one of the indiviual texture used in the effect.
  139852. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139853. */
  139854. export class LensFlare {
  139855. /**
  139856. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139857. */
  139858. size: number;
  139859. /**
  139860. * 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.
  139861. */
  139862. position: number;
  139863. /**
  139864. * Define the lens color.
  139865. */
  139866. color: Color3;
  139867. /**
  139868. * Define the lens texture.
  139869. */
  139870. texture: Nullable<Texture>;
  139871. /**
  139872. * Define the alpha mode to render this particular lens.
  139873. */
  139874. alphaMode: number;
  139875. private _system;
  139876. /**
  139877. * Creates a new Lens Flare.
  139878. * This represents one of the lens effect in a `lensFlareSystem`.
  139879. * It controls one of the indiviual texture used in the effect.
  139880. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139881. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139882. * @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.
  139883. * @param color Define the lens color
  139884. * @param imgUrl Define the lens texture url
  139885. * @param system Define the `lensFlareSystem` this flare is part of
  139886. * @returns The newly created Lens Flare
  139887. */
  139888. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139889. /**
  139890. * Instantiates a new Lens Flare.
  139891. * This represents one of the lens effect in a `lensFlareSystem`.
  139892. * It controls one of the indiviual texture used in the effect.
  139893. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139894. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139895. * @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.
  139896. * @param color Define the lens color
  139897. * @param imgUrl Define the lens texture url
  139898. * @param system Define the `lensFlareSystem` this flare is part of
  139899. */
  139900. constructor(
  139901. /**
  139902. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139903. */
  139904. size: number,
  139905. /**
  139906. * 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.
  139907. */
  139908. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139909. /**
  139910. * Dispose and release the lens flare with its associated resources.
  139911. */
  139912. dispose(): void;
  139913. }
  139914. }
  139915. declare module BABYLON {
  139916. interface AbstractScene {
  139917. /**
  139918. * The list of lens flare system added to the scene
  139919. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139920. */
  139921. lensFlareSystems: Array<LensFlareSystem>;
  139922. /**
  139923. * Removes the given lens flare system from this scene.
  139924. * @param toRemove The lens flare system to remove
  139925. * @returns The index of the removed lens flare system
  139926. */
  139927. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139928. /**
  139929. * Adds the given lens flare system to this scene
  139930. * @param newLensFlareSystem The lens flare system to add
  139931. */
  139932. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139933. /**
  139934. * Gets a lens flare system using its name
  139935. * @param name defines the name to look for
  139936. * @returns the lens flare system or null if not found
  139937. */
  139938. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139939. /**
  139940. * Gets a lens flare system using its id
  139941. * @param id defines the id to look for
  139942. * @returns the lens flare system or null if not found
  139943. */
  139944. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139945. }
  139946. /**
  139947. * Defines the lens flare scene component responsible to manage any lens flares
  139948. * in a given scene.
  139949. */
  139950. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139951. /**
  139952. * The component name helpfull to identify the component in the list of scene components.
  139953. */
  139954. readonly name: string;
  139955. /**
  139956. * The scene the component belongs to.
  139957. */
  139958. scene: Scene;
  139959. /**
  139960. * Creates a new instance of the component for the given scene
  139961. * @param scene Defines the scene to register the component in
  139962. */
  139963. constructor(scene: Scene);
  139964. /**
  139965. * Registers the component in a given scene
  139966. */
  139967. register(): void;
  139968. /**
  139969. * Rebuilds the elements related to this component in case of
  139970. * context lost for instance.
  139971. */
  139972. rebuild(): void;
  139973. /**
  139974. * Adds all the elements from the container to the scene
  139975. * @param container the container holding the elements
  139976. */
  139977. addFromContainer(container: AbstractScene): void;
  139978. /**
  139979. * Removes all the elements in the container from the scene
  139980. * @param container contains the elements to remove
  139981. * @param dispose if the removed element should be disposed (default: false)
  139982. */
  139983. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139984. /**
  139985. * Serializes the component data to the specified json object
  139986. * @param serializationObject The object to serialize to
  139987. */
  139988. serialize(serializationObject: any): void;
  139989. /**
  139990. * Disposes the component and the associated ressources.
  139991. */
  139992. dispose(): void;
  139993. private _draw;
  139994. }
  139995. }
  139996. declare module BABYLON {
  139997. /** @hidden */
  139998. export var depthPixelShader: {
  139999. name: string;
  140000. shader: string;
  140001. };
  140002. }
  140003. declare module BABYLON {
  140004. /** @hidden */
  140005. export var depthVertexShader: {
  140006. name: string;
  140007. shader: string;
  140008. };
  140009. }
  140010. declare module BABYLON {
  140011. /**
  140012. * This represents a depth renderer in Babylon.
  140013. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140014. */
  140015. export class DepthRenderer {
  140016. private _scene;
  140017. private _depthMap;
  140018. private _effect;
  140019. private readonly _storeNonLinearDepth;
  140020. private readonly _clearColor;
  140021. /** Get if the depth renderer is using packed depth or not */
  140022. readonly isPacked: boolean;
  140023. private _cachedDefines;
  140024. private _camera;
  140025. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140026. enabled: boolean;
  140027. /**
  140028. * Specifiess that the depth renderer will only be used within
  140029. * the camera it is created for.
  140030. * This can help forcing its rendering during the camera processing.
  140031. */
  140032. useOnlyInActiveCamera: boolean;
  140033. /** @hidden */
  140034. static _SceneComponentInitialization: (scene: Scene) => void;
  140035. /**
  140036. * Instantiates a depth renderer
  140037. * @param scene The scene the renderer belongs to
  140038. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140039. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140040. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140041. */
  140042. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140043. /**
  140044. * Creates the depth rendering effect and checks if the effect is ready.
  140045. * @param subMesh The submesh to be used to render the depth map of
  140046. * @param useInstances If multiple world instances should be used
  140047. * @returns if the depth renderer is ready to render the depth map
  140048. */
  140049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140050. /**
  140051. * Gets the texture which the depth map will be written to.
  140052. * @returns The depth map texture
  140053. */
  140054. getDepthMap(): RenderTargetTexture;
  140055. /**
  140056. * Disposes of the depth renderer.
  140057. */
  140058. dispose(): void;
  140059. }
  140060. }
  140061. declare module BABYLON {
  140062. /** @hidden */
  140063. export var minmaxReduxPixelShader: {
  140064. name: string;
  140065. shader: string;
  140066. };
  140067. }
  140068. declare module BABYLON {
  140069. /**
  140070. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140071. * and maximum values from all values of the texture.
  140072. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140073. * The source values are read from the red channel of the texture.
  140074. */
  140075. export class MinMaxReducer {
  140076. /**
  140077. * Observable triggered when the computation has been performed
  140078. */
  140079. onAfterReductionPerformed: Observable<{
  140080. min: number;
  140081. max: number;
  140082. }>;
  140083. protected _camera: Camera;
  140084. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140085. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140086. protected _postProcessManager: PostProcessManager;
  140087. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140088. protected _forceFullscreenViewport: boolean;
  140089. /**
  140090. * Creates a min/max reducer
  140091. * @param camera The camera to use for the post processes
  140092. */
  140093. constructor(camera: Camera);
  140094. /**
  140095. * Gets the texture used to read the values from.
  140096. */
  140097. get sourceTexture(): Nullable<RenderTargetTexture>;
  140098. /**
  140099. * Sets the source texture to read the values from.
  140100. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140101. * because in such textures '1' value must not be taken into account to compute the maximum
  140102. * as this value is used to clear the texture.
  140103. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140104. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140105. * @param depthRedux Indicates if the texture is a depth texture or not
  140106. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140107. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140108. */
  140109. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140110. /**
  140111. * Defines the refresh rate of the computation.
  140112. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140113. */
  140114. get refreshRate(): number;
  140115. set refreshRate(value: number);
  140116. protected _activated: boolean;
  140117. /**
  140118. * Gets the activation status of the reducer
  140119. */
  140120. get activated(): boolean;
  140121. /**
  140122. * Activates the reduction computation.
  140123. * When activated, the observers registered in onAfterReductionPerformed are
  140124. * called after the compuation is performed
  140125. */
  140126. activate(): void;
  140127. /**
  140128. * Deactivates the reduction computation.
  140129. */
  140130. deactivate(): void;
  140131. /**
  140132. * Disposes the min/max reducer
  140133. * @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.
  140134. */
  140135. dispose(disposeAll?: boolean): void;
  140136. }
  140137. }
  140138. declare module BABYLON {
  140139. /**
  140140. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140141. */
  140142. export class DepthReducer extends MinMaxReducer {
  140143. private _depthRenderer;
  140144. private _depthRendererId;
  140145. /**
  140146. * Gets the depth renderer used for the computation.
  140147. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140148. */
  140149. get depthRenderer(): Nullable<DepthRenderer>;
  140150. /**
  140151. * Creates a depth reducer
  140152. * @param camera The camera used to render the depth texture
  140153. */
  140154. constructor(camera: Camera);
  140155. /**
  140156. * Sets the depth renderer to use to generate the depth map
  140157. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140158. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140159. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140160. */
  140161. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140162. /** @hidden */
  140163. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140164. /**
  140165. * Activates the reduction computation.
  140166. * When activated, the observers registered in onAfterReductionPerformed are
  140167. * called after the compuation is performed
  140168. */
  140169. activate(): void;
  140170. /**
  140171. * Deactivates the reduction computation.
  140172. */
  140173. deactivate(): void;
  140174. /**
  140175. * Disposes the depth reducer
  140176. * @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.
  140177. */
  140178. dispose(disposeAll?: boolean): void;
  140179. }
  140180. }
  140181. declare module BABYLON {
  140182. /**
  140183. * A CSM implementation allowing casting shadows on large scenes.
  140184. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140185. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140186. */
  140187. export class CascadedShadowGenerator extends ShadowGenerator {
  140188. private static readonly frustumCornersNDCSpace;
  140189. /**
  140190. * Name of the CSM class
  140191. */
  140192. static CLASSNAME: string;
  140193. /**
  140194. * Defines the default number of cascades used by the CSM.
  140195. */
  140196. static readonly DEFAULT_CASCADES_COUNT: number;
  140197. /**
  140198. * Defines the minimum number of cascades used by the CSM.
  140199. */
  140200. static readonly MIN_CASCADES_COUNT: number;
  140201. /**
  140202. * Defines the maximum number of cascades used by the CSM.
  140203. */
  140204. static readonly MAX_CASCADES_COUNT: number;
  140205. protected _validateFilter(filter: number): number;
  140206. /**
  140207. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140208. */
  140209. penumbraDarkness: number;
  140210. private _numCascades;
  140211. /**
  140212. * Gets or set the number of cascades used by the CSM.
  140213. */
  140214. get numCascades(): number;
  140215. set numCascades(value: number);
  140216. /**
  140217. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140218. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140219. */
  140220. stabilizeCascades: boolean;
  140221. private _freezeShadowCastersBoundingInfo;
  140222. private _freezeShadowCastersBoundingInfoObservable;
  140223. /**
  140224. * Enables or disables the shadow casters bounding info computation.
  140225. * If your shadow casters don't move, you can disable this feature.
  140226. * If it is enabled, the bounding box computation is done every frame.
  140227. */
  140228. get freezeShadowCastersBoundingInfo(): boolean;
  140229. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140230. private _scbiMin;
  140231. private _scbiMax;
  140232. protected _computeShadowCastersBoundingInfo(): void;
  140233. protected _shadowCastersBoundingInfo: BoundingInfo;
  140234. /**
  140235. * Gets or sets the shadow casters bounding info.
  140236. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140237. * so that the system won't overwrite the bounds you provide
  140238. */
  140239. get shadowCastersBoundingInfo(): BoundingInfo;
  140240. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140241. protected _breaksAreDirty: boolean;
  140242. protected _minDistance: number;
  140243. protected _maxDistance: number;
  140244. /**
  140245. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140246. *
  140247. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140248. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140249. * @param min minimal distance for the breaks (default to 0.)
  140250. * @param max maximal distance for the breaks (default to 1.)
  140251. */
  140252. setMinMaxDistance(min: number, max: number): void;
  140253. /** Gets the minimal distance used in the cascade break computation */
  140254. get minDistance(): number;
  140255. /** Gets the maximal distance used in the cascade break computation */
  140256. get maxDistance(): number;
  140257. /**
  140258. * Gets the class name of that object
  140259. * @returns "CascadedShadowGenerator"
  140260. */
  140261. getClassName(): string;
  140262. private _cascadeMinExtents;
  140263. private _cascadeMaxExtents;
  140264. /**
  140265. * Gets a cascade minimum extents
  140266. * @param cascadeIndex index of the cascade
  140267. * @returns the minimum cascade extents
  140268. */
  140269. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140270. /**
  140271. * Gets a cascade maximum extents
  140272. * @param cascadeIndex index of the cascade
  140273. * @returns the maximum cascade extents
  140274. */
  140275. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140276. private _cascades;
  140277. private _currentLayer;
  140278. private _viewSpaceFrustumsZ;
  140279. private _viewMatrices;
  140280. private _projectionMatrices;
  140281. private _transformMatrices;
  140282. private _transformMatricesAsArray;
  140283. private _frustumLengths;
  140284. private _lightSizeUVCorrection;
  140285. private _depthCorrection;
  140286. private _frustumCornersWorldSpace;
  140287. private _frustumCenter;
  140288. private _shadowCameraPos;
  140289. private _shadowMaxZ;
  140290. /**
  140291. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140292. * It defaults to camera.maxZ
  140293. */
  140294. get shadowMaxZ(): number;
  140295. /**
  140296. * Sets the shadow max z distance.
  140297. */
  140298. set shadowMaxZ(value: number);
  140299. protected _debug: boolean;
  140300. /**
  140301. * Gets or sets the debug flag.
  140302. * When enabled, the cascades are materialized by different colors on the screen.
  140303. */
  140304. get debug(): boolean;
  140305. set debug(dbg: boolean);
  140306. private _depthClamp;
  140307. /**
  140308. * Gets or sets the depth clamping value.
  140309. *
  140310. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140311. * to account for the shadow casters far away.
  140312. *
  140313. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140314. */
  140315. get depthClamp(): boolean;
  140316. set depthClamp(value: boolean);
  140317. private _cascadeBlendPercentage;
  140318. /**
  140319. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140320. * It defaults to 0.1 (10% blending).
  140321. */
  140322. get cascadeBlendPercentage(): number;
  140323. set cascadeBlendPercentage(value: number);
  140324. private _lambda;
  140325. /**
  140326. * Gets or set the lambda parameter.
  140327. * This parameter is used to split the camera frustum and create the cascades.
  140328. * 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.
  140329. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140330. */
  140331. get lambda(): number;
  140332. set lambda(value: number);
  140333. /**
  140334. * Gets the view matrix corresponding to a given cascade
  140335. * @param cascadeNum cascade to retrieve the view matrix from
  140336. * @returns the cascade view matrix
  140337. */
  140338. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140339. /**
  140340. * Gets the projection matrix corresponding to a given cascade
  140341. * @param cascadeNum cascade to retrieve the projection matrix from
  140342. * @returns the cascade projection matrix
  140343. */
  140344. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140345. /**
  140346. * Gets the transformation matrix corresponding to a given cascade
  140347. * @param cascadeNum cascade to retrieve the transformation matrix from
  140348. * @returns the cascade transformation matrix
  140349. */
  140350. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140351. private _depthRenderer;
  140352. /**
  140353. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140354. *
  140355. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140356. *
  140357. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140358. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140359. * @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
  140360. */
  140361. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140362. private _depthReducer;
  140363. private _autoCalcDepthBounds;
  140364. /**
  140365. * Gets or sets the autoCalcDepthBounds property.
  140366. *
  140367. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140368. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140369. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140370. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140371. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140372. */
  140373. get autoCalcDepthBounds(): boolean;
  140374. set autoCalcDepthBounds(value: boolean);
  140375. /**
  140376. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140377. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140378. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140379. * for setting the refresh rate on the renderer yourself!
  140380. */
  140381. get autoCalcDepthBoundsRefreshRate(): number;
  140382. set autoCalcDepthBoundsRefreshRate(value: number);
  140383. /**
  140384. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140385. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140386. * you change the camera near/far planes!
  140387. */
  140388. splitFrustum(): void;
  140389. private _splitFrustum;
  140390. private _computeMatrices;
  140391. private _computeFrustumInWorldSpace;
  140392. private _computeCascadeFrustum;
  140393. /**
  140394. * Support test.
  140395. */
  140396. static get IsSupported(): boolean;
  140397. /** @hidden */
  140398. static _SceneComponentInitialization: (scene: Scene) => void;
  140399. /**
  140400. * Creates a Cascaded Shadow Generator object.
  140401. * A ShadowGenerator is the required tool to use the shadows.
  140402. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140403. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140404. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140405. * @param light The directional light object generating the shadows.
  140406. * @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.
  140407. */
  140408. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140409. protected _initializeGenerator(): void;
  140410. protected _createTargetRenderTexture(): void;
  140411. protected _initializeShadowMap(): void;
  140412. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140413. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140414. /**
  140415. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140416. * @param defines Defines of the material we want to update
  140417. * @param lightIndex Index of the light in the enabled light list of the material
  140418. */
  140419. prepareDefines(defines: any, lightIndex: number): void;
  140420. /**
  140421. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140422. * defined in the generator but impacting the effect).
  140423. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140424. * @param effect The effect we are binfing the information for
  140425. */
  140426. bindShadowLight(lightIndex: string, effect: Effect): void;
  140427. /**
  140428. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140429. * (eq to view projection * shadow projection matrices)
  140430. * @returns The transform matrix used to create the shadow map
  140431. */
  140432. getTransformMatrix(): Matrix;
  140433. /**
  140434. * Disposes the ShadowGenerator.
  140435. * Returns nothing.
  140436. */
  140437. dispose(): void;
  140438. /**
  140439. * Serializes the shadow generator setup to a json object.
  140440. * @returns The serialized JSON object
  140441. */
  140442. serialize(): any;
  140443. /**
  140444. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140445. * @param parsedShadowGenerator The JSON object to parse
  140446. * @param scene The scene to create the shadow map for
  140447. * @returns The parsed shadow generator
  140448. */
  140449. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140450. }
  140451. }
  140452. declare module BABYLON {
  140453. /**
  140454. * Defines the shadow generator component responsible to manage any shadow generators
  140455. * in a given scene.
  140456. */
  140457. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140458. /**
  140459. * The component name helpfull to identify the component in the list of scene components.
  140460. */
  140461. readonly name: string;
  140462. /**
  140463. * The scene the component belongs to.
  140464. */
  140465. scene: Scene;
  140466. /**
  140467. * Creates a new instance of the component for the given scene
  140468. * @param scene Defines the scene to register the component in
  140469. */
  140470. constructor(scene: Scene);
  140471. /**
  140472. * Registers the component in a given scene
  140473. */
  140474. register(): void;
  140475. /**
  140476. * Rebuilds the elements related to this component in case of
  140477. * context lost for instance.
  140478. */
  140479. rebuild(): void;
  140480. /**
  140481. * Serializes the component data to the specified json object
  140482. * @param serializationObject The object to serialize to
  140483. */
  140484. serialize(serializationObject: any): void;
  140485. /**
  140486. * Adds all the elements from the container to the scene
  140487. * @param container the container holding the elements
  140488. */
  140489. addFromContainer(container: AbstractScene): void;
  140490. /**
  140491. * Removes all the elements in the container from the scene
  140492. * @param container contains the elements to remove
  140493. * @param dispose if the removed element should be disposed (default: false)
  140494. */
  140495. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140496. /**
  140497. * Rebuilds the elements related to this component in case of
  140498. * context lost for instance.
  140499. */
  140500. dispose(): void;
  140501. private _gatherRenderTargets;
  140502. }
  140503. }
  140504. declare module BABYLON {
  140505. /**
  140506. * A point light is a light defined by an unique point in world space.
  140507. * The light is emitted in every direction from this point.
  140508. * A good example of a point light is a standard light bulb.
  140509. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140510. */
  140511. export class PointLight extends ShadowLight {
  140512. private _shadowAngle;
  140513. /**
  140514. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140515. * This specifies what angle the shadow will use to be created.
  140516. *
  140517. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140518. */
  140519. get shadowAngle(): number;
  140520. /**
  140521. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140522. * This specifies what angle the shadow will use to be created.
  140523. *
  140524. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140525. */
  140526. set shadowAngle(value: number);
  140527. /**
  140528. * Gets the direction if it has been set.
  140529. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140530. */
  140531. get direction(): Vector3;
  140532. /**
  140533. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140534. */
  140535. set direction(value: Vector3);
  140536. /**
  140537. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140538. * A PointLight emits the light in every direction.
  140539. * It can cast shadows.
  140540. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140541. * ```javascript
  140542. * var pointLight = new PointLight("pl", camera.position, scene);
  140543. * ```
  140544. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140545. * @param name The light friendly name
  140546. * @param position The position of the point light in the scene
  140547. * @param scene The scene the lights belongs to
  140548. */
  140549. constructor(name: string, position: Vector3, scene: Scene);
  140550. /**
  140551. * Returns the string "PointLight"
  140552. * @returns the class name
  140553. */
  140554. getClassName(): string;
  140555. /**
  140556. * Returns the integer 0.
  140557. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140558. */
  140559. getTypeID(): number;
  140560. /**
  140561. * Specifies wether or not the shadowmap should be a cube texture.
  140562. * @returns true if the shadowmap needs to be a cube texture.
  140563. */
  140564. needCube(): boolean;
  140565. /**
  140566. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140567. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140568. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140569. */
  140570. getShadowDirection(faceIndex?: number): Vector3;
  140571. /**
  140572. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140573. * - fov = PI / 2
  140574. * - aspect ratio : 1.0
  140575. * - z-near and far equal to the active camera minZ and maxZ.
  140576. * Returns the PointLight.
  140577. */
  140578. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140579. protected _buildUniformLayout(): void;
  140580. /**
  140581. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140582. * @param effect The effect to update
  140583. * @param lightIndex The index of the light in the effect to update
  140584. * @returns The point light
  140585. */
  140586. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140587. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140588. /**
  140589. * Prepares the list of defines specific to the light type.
  140590. * @param defines the list of defines
  140591. * @param lightIndex defines the index of the light for the effect
  140592. */
  140593. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140594. }
  140595. }
  140596. declare module BABYLON {
  140597. /**
  140598. * Header information of HDR texture files.
  140599. */
  140600. export interface HDRInfo {
  140601. /**
  140602. * The height of the texture in pixels.
  140603. */
  140604. height: number;
  140605. /**
  140606. * The width of the texture in pixels.
  140607. */
  140608. width: number;
  140609. /**
  140610. * The index of the beginning of the data in the binary file.
  140611. */
  140612. dataPosition: number;
  140613. }
  140614. /**
  140615. * This groups tools to convert HDR texture to native colors array.
  140616. */
  140617. export class HDRTools {
  140618. private static Ldexp;
  140619. private static Rgbe2float;
  140620. private static readStringLine;
  140621. /**
  140622. * Reads header information from an RGBE texture stored in a native array.
  140623. * More information on this format are available here:
  140624. * https://en.wikipedia.org/wiki/RGBE_image_format
  140625. *
  140626. * @param uint8array The binary file stored in native array.
  140627. * @return The header information.
  140628. */
  140629. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140630. /**
  140631. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140632. * This RGBE texture needs to store the information as a panorama.
  140633. *
  140634. * More information on this format are available here:
  140635. * https://en.wikipedia.org/wiki/RGBE_image_format
  140636. *
  140637. * @param buffer The binary file stored in an array buffer.
  140638. * @param size The expected size of the extracted cubemap.
  140639. * @return The Cube Map information.
  140640. */
  140641. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140642. /**
  140643. * Returns the pixels data extracted from an RGBE texture.
  140644. * This pixels will be stored left to right up to down in the R G B order in one array.
  140645. *
  140646. * More information on this format are available here:
  140647. * https://en.wikipedia.org/wiki/RGBE_image_format
  140648. *
  140649. * @param uint8array The binary file stored in an array buffer.
  140650. * @param hdrInfo The header information of the file.
  140651. * @return The pixels data in RGB right to left up to down order.
  140652. */
  140653. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140654. private static RGBE_ReadPixels_RLE;
  140655. private static RGBE_ReadPixels_NOT_RLE;
  140656. }
  140657. }
  140658. declare module BABYLON {
  140659. /**
  140660. * Effect Render Options
  140661. */
  140662. export interface IEffectRendererOptions {
  140663. /**
  140664. * Defines the vertices positions.
  140665. */
  140666. positions?: number[];
  140667. /**
  140668. * Defines the indices.
  140669. */
  140670. indices?: number[];
  140671. }
  140672. /**
  140673. * Helper class to render one or more effects.
  140674. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140675. */
  140676. export class EffectRenderer {
  140677. private engine;
  140678. private static _DefaultOptions;
  140679. private _vertexBuffers;
  140680. private _indexBuffer;
  140681. private _fullscreenViewport;
  140682. /**
  140683. * Creates an effect renderer
  140684. * @param engine the engine to use for rendering
  140685. * @param options defines the options of the effect renderer
  140686. */
  140687. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140688. /**
  140689. * Sets the current viewport in normalized coordinates 0-1
  140690. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140691. */
  140692. setViewport(viewport?: Viewport): void;
  140693. /**
  140694. * Binds the embedded attributes buffer to the effect.
  140695. * @param effect Defines the effect to bind the attributes for
  140696. */
  140697. bindBuffers(effect: Effect): void;
  140698. /**
  140699. * Sets the current effect wrapper to use during draw.
  140700. * The effect needs to be ready before calling this api.
  140701. * This also sets the default full screen position attribute.
  140702. * @param effectWrapper Defines the effect to draw with
  140703. */
  140704. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140705. /**
  140706. * Restores engine states
  140707. */
  140708. restoreStates(): void;
  140709. /**
  140710. * Draws a full screen quad.
  140711. */
  140712. draw(): void;
  140713. private isRenderTargetTexture;
  140714. /**
  140715. * renders one or more effects to a specified texture
  140716. * @param effectWrapper the effect to renderer
  140717. * @param outputTexture texture to draw to, if null it will render to the screen.
  140718. */
  140719. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140720. /**
  140721. * Disposes of the effect renderer
  140722. */
  140723. dispose(): void;
  140724. }
  140725. /**
  140726. * Options to create an EffectWrapper
  140727. */
  140728. interface EffectWrapperCreationOptions {
  140729. /**
  140730. * Engine to use to create the effect
  140731. */
  140732. engine: ThinEngine;
  140733. /**
  140734. * Fragment shader for the effect
  140735. */
  140736. fragmentShader: string;
  140737. /**
  140738. * Use the shader store instead of direct source code
  140739. */
  140740. useShaderStore?: boolean;
  140741. /**
  140742. * Vertex shader for the effect
  140743. */
  140744. vertexShader?: string;
  140745. /**
  140746. * Attributes to use in the shader
  140747. */
  140748. attributeNames?: Array<string>;
  140749. /**
  140750. * Uniforms to use in the shader
  140751. */
  140752. uniformNames?: Array<string>;
  140753. /**
  140754. * Texture sampler names to use in the shader
  140755. */
  140756. samplerNames?: Array<string>;
  140757. /**
  140758. * Defines to use in the shader
  140759. */
  140760. defines?: Array<string>;
  140761. /**
  140762. * Callback when effect is compiled
  140763. */
  140764. onCompiled?: Nullable<(effect: Effect) => void>;
  140765. /**
  140766. * The friendly name of the effect displayed in Spector.
  140767. */
  140768. name?: string;
  140769. }
  140770. /**
  140771. * Wraps an effect to be used for rendering
  140772. */
  140773. export class EffectWrapper {
  140774. /**
  140775. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140776. */
  140777. onApplyObservable: Observable<{}>;
  140778. /**
  140779. * The underlying effect
  140780. */
  140781. effect: Effect;
  140782. /**
  140783. * Creates an effect to be renderer
  140784. * @param creationOptions options to create the effect
  140785. */
  140786. constructor(creationOptions: EffectWrapperCreationOptions);
  140787. /**
  140788. * Disposes of the effect wrapper
  140789. */
  140790. dispose(): void;
  140791. }
  140792. }
  140793. declare module BABYLON {
  140794. /** @hidden */
  140795. export var hdrFilteringVertexShader: {
  140796. name: string;
  140797. shader: string;
  140798. };
  140799. }
  140800. declare module BABYLON {
  140801. /** @hidden */
  140802. export var hdrFilteringPixelShader: {
  140803. name: string;
  140804. shader: string;
  140805. };
  140806. }
  140807. declare module BABYLON {
  140808. /**
  140809. * Options for texture filtering
  140810. */
  140811. interface IHDRFilteringOptions {
  140812. /**
  140813. * Scales pixel intensity for the input HDR map.
  140814. */
  140815. hdrScale?: number;
  140816. /**
  140817. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140818. */
  140819. quality?: number;
  140820. }
  140821. /**
  140822. * Filters HDR maps to get correct renderings of PBR reflections
  140823. */
  140824. export class HDRFiltering {
  140825. private _engine;
  140826. private _effectRenderer;
  140827. private _effectWrapper;
  140828. private _lodGenerationOffset;
  140829. private _lodGenerationScale;
  140830. /**
  140831. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140832. * you care about baking speed.
  140833. */
  140834. quality: number;
  140835. /**
  140836. * Scales pixel intensity for the input HDR map.
  140837. */
  140838. hdrScale: number;
  140839. /**
  140840. * Instantiates HDR filter for reflection maps
  140841. *
  140842. * @param engine Thin engine
  140843. * @param options Options
  140844. */
  140845. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140846. private _createRenderTarget;
  140847. private _prefilterInternal;
  140848. private _createEffect;
  140849. /**
  140850. * Get a value indicating if the filter is ready to be used
  140851. * @param texture Texture to filter
  140852. * @returns true if the filter is ready
  140853. */
  140854. isReady(texture: BaseTexture): boolean;
  140855. /**
  140856. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140857. * Prefiltering will be invoked at the end of next rendering pass.
  140858. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140859. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140860. * @param texture Texture to filter
  140861. * @param onFinished Callback when filtering is done
  140862. * @return Promise called when prefiltering is done
  140863. */
  140864. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140865. }
  140866. }
  140867. declare module BABYLON {
  140868. /**
  140869. * This represents a texture coming from an HDR input.
  140870. *
  140871. * The only supported format is currently panorama picture stored in RGBE format.
  140872. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140873. */
  140874. export class HDRCubeTexture extends BaseTexture {
  140875. private static _facesMapping;
  140876. private _generateHarmonics;
  140877. private _noMipmap;
  140878. private _prefilterOnLoad;
  140879. private _textureMatrix;
  140880. private _size;
  140881. private _onLoad;
  140882. private _onError;
  140883. /**
  140884. * The texture URL.
  140885. */
  140886. url: string;
  140887. protected _isBlocking: boolean;
  140888. /**
  140889. * Sets wether or not the texture is blocking during loading.
  140890. */
  140891. set isBlocking(value: boolean);
  140892. /**
  140893. * Gets wether or not the texture is blocking during loading.
  140894. */
  140895. get isBlocking(): boolean;
  140896. protected _rotationY: number;
  140897. /**
  140898. * Sets texture matrix rotation angle around Y axis in radians.
  140899. */
  140900. set rotationY(value: number);
  140901. /**
  140902. * Gets texture matrix rotation angle around Y axis radians.
  140903. */
  140904. get rotationY(): number;
  140905. /**
  140906. * Gets or sets the center of the bounding box associated with the cube texture
  140907. * It must define where the camera used to render the texture was set
  140908. */
  140909. boundingBoxPosition: Vector3;
  140910. private _boundingBoxSize;
  140911. /**
  140912. * Gets or sets the size of the bounding box associated with the cube texture
  140913. * When defined, the cubemap will switch to local mode
  140914. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140915. * @example https://www.babylonjs-playground.com/#RNASML
  140916. */
  140917. set boundingBoxSize(value: Vector3);
  140918. get boundingBoxSize(): Vector3;
  140919. /**
  140920. * Instantiates an HDRTexture from the following parameters.
  140921. *
  140922. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140923. * @param sceneOrEngine The scene or engine the texture will be used in
  140924. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140925. * @param noMipmap Forces to not generate the mipmap if true
  140926. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140927. * @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)
  140928. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140929. */
  140930. 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>);
  140931. /**
  140932. * Get the current class name of the texture useful for serialization or dynamic coding.
  140933. * @returns "HDRCubeTexture"
  140934. */
  140935. getClassName(): string;
  140936. /**
  140937. * Occurs when the file is raw .hdr file.
  140938. */
  140939. private loadTexture;
  140940. clone(): HDRCubeTexture;
  140941. delayLoad(): void;
  140942. /**
  140943. * Get the texture reflection matrix used to rotate/transform the reflection.
  140944. * @returns the reflection matrix
  140945. */
  140946. getReflectionTextureMatrix(): Matrix;
  140947. /**
  140948. * Set the texture reflection matrix used to rotate/transform the reflection.
  140949. * @param value Define the reflection matrix to set
  140950. */
  140951. setReflectionTextureMatrix(value: Matrix): void;
  140952. /**
  140953. * Parses a JSON representation of an HDR Texture in order to create the texture
  140954. * @param parsedTexture Define the JSON representation
  140955. * @param scene Define the scene the texture should be created in
  140956. * @param rootUrl Define the root url in case we need to load relative dependencies
  140957. * @returns the newly created texture after parsing
  140958. */
  140959. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140960. serialize(): any;
  140961. }
  140962. }
  140963. declare module BABYLON {
  140964. /**
  140965. * Class used to control physics engine
  140966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140967. */
  140968. export class PhysicsEngine implements IPhysicsEngine {
  140969. private _physicsPlugin;
  140970. /**
  140971. * Global value used to control the smallest number supported by the simulation
  140972. */
  140973. static Epsilon: number;
  140974. private _impostors;
  140975. private _joints;
  140976. private _subTimeStep;
  140977. /**
  140978. * Gets the gravity vector used by the simulation
  140979. */
  140980. gravity: Vector3;
  140981. /**
  140982. * Factory used to create the default physics plugin.
  140983. * @returns The default physics plugin
  140984. */
  140985. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140986. /**
  140987. * Creates a new Physics Engine
  140988. * @param gravity defines the gravity vector used by the simulation
  140989. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140990. */
  140991. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140992. /**
  140993. * Sets the gravity vector used by the simulation
  140994. * @param gravity defines the gravity vector to use
  140995. */
  140996. setGravity(gravity: Vector3): void;
  140997. /**
  140998. * Set the time step of the physics engine.
  140999. * Default is 1/60.
  141000. * To slow it down, enter 1/600 for example.
  141001. * To speed it up, 1/30
  141002. * @param newTimeStep defines the new timestep to apply to this world.
  141003. */
  141004. setTimeStep(newTimeStep?: number): void;
  141005. /**
  141006. * Get the time step of the physics engine.
  141007. * @returns the current time step
  141008. */
  141009. getTimeStep(): number;
  141010. /**
  141011. * Set the sub time step of the physics engine.
  141012. * Default is 0 meaning there is no sub steps
  141013. * To increase physics resolution precision, set a small value (like 1 ms)
  141014. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141015. */
  141016. setSubTimeStep(subTimeStep?: number): void;
  141017. /**
  141018. * Get the sub time step of the physics engine.
  141019. * @returns the current sub time step
  141020. */
  141021. getSubTimeStep(): number;
  141022. /**
  141023. * Release all resources
  141024. */
  141025. dispose(): void;
  141026. /**
  141027. * Gets the name of the current physics plugin
  141028. * @returns the name of the plugin
  141029. */
  141030. getPhysicsPluginName(): string;
  141031. /**
  141032. * Adding a new impostor for the impostor tracking.
  141033. * This will be done by the impostor itself.
  141034. * @param impostor the impostor to add
  141035. */
  141036. addImpostor(impostor: PhysicsImpostor): void;
  141037. /**
  141038. * Remove an impostor from the engine.
  141039. * This impostor and its mesh will not longer be updated by the physics engine.
  141040. * @param impostor the impostor to remove
  141041. */
  141042. removeImpostor(impostor: PhysicsImpostor): void;
  141043. /**
  141044. * Add a joint to the physics engine
  141045. * @param mainImpostor defines the main impostor to which the joint is added.
  141046. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141047. * @param joint defines the joint that will connect both impostors.
  141048. */
  141049. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141050. /**
  141051. * Removes a joint from the simulation
  141052. * @param mainImpostor defines the impostor used with the joint
  141053. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141054. * @param joint defines the joint to remove
  141055. */
  141056. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141057. /**
  141058. * Called by the scene. No need to call it.
  141059. * @param delta defines the timespam between frames
  141060. */
  141061. _step(delta: number): void;
  141062. /**
  141063. * Gets the current plugin used to run the simulation
  141064. * @returns current plugin
  141065. */
  141066. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141067. /**
  141068. * Gets the list of physic impostors
  141069. * @returns an array of PhysicsImpostor
  141070. */
  141071. getImpostors(): Array<PhysicsImpostor>;
  141072. /**
  141073. * Gets the impostor for a physics enabled object
  141074. * @param object defines the object impersonated by the impostor
  141075. * @returns the PhysicsImpostor or null if not found
  141076. */
  141077. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141078. /**
  141079. * Gets the impostor for a physics body object
  141080. * @param body defines physics body used by the impostor
  141081. * @returns the PhysicsImpostor or null if not found
  141082. */
  141083. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141084. /**
  141085. * Does a raycast in the physics world
  141086. * @param from when should the ray start?
  141087. * @param to when should the ray end?
  141088. * @returns PhysicsRaycastResult
  141089. */
  141090. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141091. }
  141092. }
  141093. declare module BABYLON {
  141094. /** @hidden */
  141095. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141096. private _useDeltaForWorldStep;
  141097. world: any;
  141098. name: string;
  141099. private _physicsMaterials;
  141100. private _fixedTimeStep;
  141101. private _cannonRaycastResult;
  141102. private _raycastResult;
  141103. private _physicsBodysToRemoveAfterStep;
  141104. private _firstFrame;
  141105. BJSCANNON: any;
  141106. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141107. setGravity(gravity: Vector3): void;
  141108. setTimeStep(timeStep: number): void;
  141109. getTimeStep(): number;
  141110. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141111. private _removeMarkedPhysicsBodiesFromWorld;
  141112. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141113. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141114. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141115. private _processChildMeshes;
  141116. removePhysicsBody(impostor: PhysicsImpostor): void;
  141117. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141118. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141119. private _addMaterial;
  141120. private _checkWithEpsilon;
  141121. private _createShape;
  141122. private _createHeightmap;
  141123. private _minus90X;
  141124. private _plus90X;
  141125. private _tmpPosition;
  141126. private _tmpDeltaPosition;
  141127. private _tmpUnityRotation;
  141128. private _updatePhysicsBodyTransformation;
  141129. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141130. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141131. isSupported(): boolean;
  141132. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141133. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141134. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141135. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141136. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141137. getBodyMass(impostor: PhysicsImpostor): number;
  141138. getBodyFriction(impostor: PhysicsImpostor): number;
  141139. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141140. getBodyRestitution(impostor: PhysicsImpostor): number;
  141141. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141142. sleepBody(impostor: PhysicsImpostor): void;
  141143. wakeUpBody(impostor: PhysicsImpostor): void;
  141144. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141145. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141146. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141147. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141148. getRadius(impostor: PhysicsImpostor): number;
  141149. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141150. dispose(): void;
  141151. private _extendNamespace;
  141152. /**
  141153. * Does a raycast in the physics world
  141154. * @param from when should the ray start?
  141155. * @param to when should the ray end?
  141156. * @returns PhysicsRaycastResult
  141157. */
  141158. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141159. }
  141160. }
  141161. declare module BABYLON {
  141162. /** @hidden */
  141163. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141164. private _useDeltaForWorldStep;
  141165. world: any;
  141166. name: string;
  141167. BJSOIMO: any;
  141168. private _raycastResult;
  141169. private _fixedTimeStep;
  141170. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141171. setGravity(gravity: Vector3): void;
  141172. setTimeStep(timeStep: number): void;
  141173. getTimeStep(): number;
  141174. private _tmpImpostorsArray;
  141175. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141176. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141177. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141178. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141179. private _tmpPositionVector;
  141180. removePhysicsBody(impostor: PhysicsImpostor): void;
  141181. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141182. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141183. isSupported(): boolean;
  141184. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141185. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141186. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141187. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141188. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141189. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141190. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141191. getBodyMass(impostor: PhysicsImpostor): number;
  141192. getBodyFriction(impostor: PhysicsImpostor): number;
  141193. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141194. getBodyRestitution(impostor: PhysicsImpostor): number;
  141195. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141196. sleepBody(impostor: PhysicsImpostor): void;
  141197. wakeUpBody(impostor: PhysicsImpostor): void;
  141198. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141199. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141200. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141201. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141202. getRadius(impostor: PhysicsImpostor): number;
  141203. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141204. dispose(): void;
  141205. /**
  141206. * Does a raycast in the physics world
  141207. * @param from when should the ray start?
  141208. * @param to when should the ray end?
  141209. * @returns PhysicsRaycastResult
  141210. */
  141211. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141212. }
  141213. }
  141214. declare module BABYLON {
  141215. /**
  141216. * AmmoJS Physics plugin
  141217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141218. * @see https://github.com/kripken/ammo.js/
  141219. */
  141220. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141221. private _useDeltaForWorldStep;
  141222. /**
  141223. * Reference to the Ammo library
  141224. */
  141225. bjsAMMO: any;
  141226. /**
  141227. * Created ammoJS world which physics bodies are added to
  141228. */
  141229. world: any;
  141230. /**
  141231. * Name of the plugin
  141232. */
  141233. name: string;
  141234. private _timeStep;
  141235. private _fixedTimeStep;
  141236. private _maxSteps;
  141237. private _tmpQuaternion;
  141238. private _tmpAmmoTransform;
  141239. private _tmpAmmoQuaternion;
  141240. private _tmpAmmoConcreteContactResultCallback;
  141241. private _collisionConfiguration;
  141242. private _dispatcher;
  141243. private _overlappingPairCache;
  141244. private _solver;
  141245. private _softBodySolver;
  141246. private _tmpAmmoVectorA;
  141247. private _tmpAmmoVectorB;
  141248. private _tmpAmmoVectorC;
  141249. private _tmpAmmoVectorD;
  141250. private _tmpContactCallbackResult;
  141251. private _tmpAmmoVectorRCA;
  141252. private _tmpAmmoVectorRCB;
  141253. private _raycastResult;
  141254. private static readonly DISABLE_COLLISION_FLAG;
  141255. private static readonly KINEMATIC_FLAG;
  141256. private static readonly DISABLE_DEACTIVATION_FLAG;
  141257. /**
  141258. * Initializes the ammoJS plugin
  141259. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141260. * @param ammoInjection can be used to inject your own ammo reference
  141261. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141262. */
  141263. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141264. /**
  141265. * Sets the gravity of the physics world (m/(s^2))
  141266. * @param gravity Gravity to set
  141267. */
  141268. setGravity(gravity: Vector3): void;
  141269. /**
  141270. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141271. * @param timeStep timestep to use in seconds
  141272. */
  141273. setTimeStep(timeStep: number): void;
  141274. /**
  141275. * 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)
  141276. * @param fixedTimeStep fixedTimeStep to use in seconds
  141277. */
  141278. setFixedTimeStep(fixedTimeStep: number): void;
  141279. /**
  141280. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141281. * @param maxSteps the maximum number of steps by the physics engine per frame
  141282. */
  141283. setMaxSteps(maxSteps: number): void;
  141284. /**
  141285. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141286. * @returns the current timestep in seconds
  141287. */
  141288. getTimeStep(): number;
  141289. /**
  141290. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141291. */
  141292. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141293. private _isImpostorInContact;
  141294. private _isImpostorPairInContact;
  141295. private _stepSimulation;
  141296. /**
  141297. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141298. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141299. * After the step the babylon meshes are set to the position of the physics imposters
  141300. * @param delta amount of time to step forward
  141301. * @param impostors array of imposters to update before/after the step
  141302. */
  141303. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141304. /**
  141305. * Update babylon mesh to match physics world object
  141306. * @param impostor imposter to match
  141307. */
  141308. private _afterSoftStep;
  141309. /**
  141310. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141311. * @param impostor imposter to match
  141312. */
  141313. private _ropeStep;
  141314. /**
  141315. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141316. * @param impostor imposter to match
  141317. */
  141318. private _softbodyOrClothStep;
  141319. private _tmpMatrix;
  141320. /**
  141321. * Applies an impulse on the imposter
  141322. * @param impostor imposter to apply impulse to
  141323. * @param force amount of force to be applied to the imposter
  141324. * @param contactPoint the location to apply the impulse on the imposter
  141325. */
  141326. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141327. /**
  141328. * Applies a force on the imposter
  141329. * @param impostor imposter to apply force
  141330. * @param force amount of force to be applied to the imposter
  141331. * @param contactPoint the location to apply the force on the imposter
  141332. */
  141333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141334. /**
  141335. * Creates a physics body using the plugin
  141336. * @param impostor the imposter to create the physics body on
  141337. */
  141338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141339. /**
  141340. * Removes the physics body from the imposter and disposes of the body's memory
  141341. * @param impostor imposter to remove the physics body from
  141342. */
  141343. removePhysicsBody(impostor: PhysicsImpostor): void;
  141344. /**
  141345. * Generates a joint
  141346. * @param impostorJoint the imposter joint to create the joint with
  141347. */
  141348. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141349. /**
  141350. * Removes a joint
  141351. * @param impostorJoint the imposter joint to remove the joint from
  141352. */
  141353. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141354. private _addMeshVerts;
  141355. /**
  141356. * Initialise the soft body vertices to match its object's (mesh) vertices
  141357. * Softbody vertices (nodes) are in world space and to match this
  141358. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141359. * @param impostor to create the softbody for
  141360. */
  141361. private _softVertexData;
  141362. /**
  141363. * Create an impostor's soft body
  141364. * @param impostor to create the softbody for
  141365. */
  141366. private _createSoftbody;
  141367. /**
  141368. * Create cloth for an impostor
  141369. * @param impostor to create the softbody for
  141370. */
  141371. private _createCloth;
  141372. /**
  141373. * Create rope for an impostor
  141374. * @param impostor to create the softbody for
  141375. */
  141376. private _createRope;
  141377. /**
  141378. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141379. * @param impostor to create the custom physics shape for
  141380. */
  141381. private _createCustom;
  141382. private _addHullVerts;
  141383. private _createShape;
  141384. /**
  141385. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141386. * @param impostor imposter containing the physics body and babylon object
  141387. */
  141388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141389. /**
  141390. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141391. * @param impostor imposter containing the physics body and babylon object
  141392. * @param newPosition new position
  141393. * @param newRotation new rotation
  141394. */
  141395. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141396. /**
  141397. * If this plugin is supported
  141398. * @returns true if its supported
  141399. */
  141400. isSupported(): boolean;
  141401. /**
  141402. * Sets the linear velocity of the physics body
  141403. * @param impostor imposter to set the velocity on
  141404. * @param velocity velocity to set
  141405. */
  141406. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141407. /**
  141408. * Sets the angular velocity of the physics body
  141409. * @param impostor imposter to set the velocity on
  141410. * @param velocity velocity to set
  141411. */
  141412. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141413. /**
  141414. * gets the linear velocity
  141415. * @param impostor imposter to get linear velocity from
  141416. * @returns linear velocity
  141417. */
  141418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141419. /**
  141420. * gets the angular velocity
  141421. * @param impostor imposter to get angular velocity from
  141422. * @returns angular velocity
  141423. */
  141424. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141425. /**
  141426. * Sets the mass of physics body
  141427. * @param impostor imposter to set the mass on
  141428. * @param mass mass to set
  141429. */
  141430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141431. /**
  141432. * Gets the mass of the physics body
  141433. * @param impostor imposter to get the mass from
  141434. * @returns mass
  141435. */
  141436. getBodyMass(impostor: PhysicsImpostor): number;
  141437. /**
  141438. * Gets friction of the impostor
  141439. * @param impostor impostor to get friction from
  141440. * @returns friction value
  141441. */
  141442. getBodyFriction(impostor: PhysicsImpostor): number;
  141443. /**
  141444. * Sets friction of the impostor
  141445. * @param impostor impostor to set friction on
  141446. * @param friction friction value
  141447. */
  141448. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141449. /**
  141450. * Gets restitution of the impostor
  141451. * @param impostor impostor to get restitution from
  141452. * @returns restitution value
  141453. */
  141454. getBodyRestitution(impostor: PhysicsImpostor): number;
  141455. /**
  141456. * Sets resitution of the impostor
  141457. * @param impostor impostor to set resitution on
  141458. * @param restitution resitution value
  141459. */
  141460. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141461. /**
  141462. * Gets pressure inside the impostor
  141463. * @param impostor impostor to get pressure from
  141464. * @returns pressure value
  141465. */
  141466. getBodyPressure(impostor: PhysicsImpostor): number;
  141467. /**
  141468. * Sets pressure inside a soft body impostor
  141469. * Cloth and rope must remain 0 pressure
  141470. * @param impostor impostor to set pressure on
  141471. * @param pressure pressure value
  141472. */
  141473. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141474. /**
  141475. * Gets stiffness of the impostor
  141476. * @param impostor impostor to get stiffness from
  141477. * @returns pressure value
  141478. */
  141479. getBodyStiffness(impostor: PhysicsImpostor): number;
  141480. /**
  141481. * Sets stiffness of the impostor
  141482. * @param impostor impostor to set stiffness on
  141483. * @param stiffness stiffness value from 0 to 1
  141484. */
  141485. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141486. /**
  141487. * Gets velocityIterations of the impostor
  141488. * @param impostor impostor to get velocity iterations from
  141489. * @returns velocityIterations value
  141490. */
  141491. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141492. /**
  141493. * Sets velocityIterations of the impostor
  141494. * @param impostor impostor to set velocity iterations on
  141495. * @param velocityIterations velocityIterations value
  141496. */
  141497. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141498. /**
  141499. * Gets positionIterations of the impostor
  141500. * @param impostor impostor to get position iterations from
  141501. * @returns positionIterations value
  141502. */
  141503. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141504. /**
  141505. * Sets positionIterations of the impostor
  141506. * @param impostor impostor to set position on
  141507. * @param positionIterations positionIterations value
  141508. */
  141509. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141510. /**
  141511. * Append an anchor to a cloth object
  141512. * @param impostor is the cloth impostor to add anchor to
  141513. * @param otherImpostor is the rigid impostor to anchor to
  141514. * @param width ratio across width from 0 to 1
  141515. * @param height ratio up height from 0 to 1
  141516. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141517. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141518. */
  141519. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141520. /**
  141521. * Append an hook to a rope object
  141522. * @param impostor is the rope impostor to add hook to
  141523. * @param otherImpostor is the rigid impostor to hook to
  141524. * @param length ratio along the rope from 0 to 1
  141525. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141526. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141527. */
  141528. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141529. /**
  141530. * Sleeps the physics body and stops it from being active
  141531. * @param impostor impostor to sleep
  141532. */
  141533. sleepBody(impostor: PhysicsImpostor): void;
  141534. /**
  141535. * Activates the physics body
  141536. * @param impostor impostor to activate
  141537. */
  141538. wakeUpBody(impostor: PhysicsImpostor): void;
  141539. /**
  141540. * Updates the distance parameters of the joint
  141541. * @param joint joint to update
  141542. * @param maxDistance maximum distance of the joint
  141543. * @param minDistance minimum distance of the joint
  141544. */
  141545. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141546. /**
  141547. * Sets a motor on the joint
  141548. * @param joint joint to set motor on
  141549. * @param speed speed of the motor
  141550. * @param maxForce maximum force of the motor
  141551. * @param motorIndex index of the motor
  141552. */
  141553. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141554. /**
  141555. * Sets the motors limit
  141556. * @param joint joint to set limit on
  141557. * @param upperLimit upper limit
  141558. * @param lowerLimit lower limit
  141559. */
  141560. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141561. /**
  141562. * Syncs the position and rotation of a mesh with the impostor
  141563. * @param mesh mesh to sync
  141564. * @param impostor impostor to update the mesh with
  141565. */
  141566. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141567. /**
  141568. * Gets the radius of the impostor
  141569. * @param impostor impostor to get radius from
  141570. * @returns the radius
  141571. */
  141572. getRadius(impostor: PhysicsImpostor): number;
  141573. /**
  141574. * Gets the box size of the impostor
  141575. * @param impostor impostor to get box size from
  141576. * @param result the resulting box size
  141577. */
  141578. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141579. /**
  141580. * Disposes of the impostor
  141581. */
  141582. dispose(): void;
  141583. /**
  141584. * Does a raycast in the physics world
  141585. * @param from when should the ray start?
  141586. * @param to when should the ray end?
  141587. * @returns PhysicsRaycastResult
  141588. */
  141589. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141590. }
  141591. }
  141592. declare module BABYLON {
  141593. interface AbstractScene {
  141594. /**
  141595. * The list of reflection probes added to the scene
  141596. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141597. */
  141598. reflectionProbes: Array<ReflectionProbe>;
  141599. /**
  141600. * Removes the given reflection probe from this scene.
  141601. * @param toRemove The reflection probe to remove
  141602. * @returns The index of the removed reflection probe
  141603. */
  141604. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141605. /**
  141606. * Adds the given reflection probe to this scene.
  141607. * @param newReflectionProbe The reflection probe to add
  141608. */
  141609. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141610. }
  141611. /**
  141612. * Class used to generate realtime reflection / refraction cube textures
  141613. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141614. */
  141615. export class ReflectionProbe {
  141616. /** defines the name of the probe */
  141617. name: string;
  141618. private _scene;
  141619. private _renderTargetTexture;
  141620. private _projectionMatrix;
  141621. private _viewMatrix;
  141622. private _target;
  141623. private _add;
  141624. private _attachedMesh;
  141625. private _invertYAxis;
  141626. /** Gets or sets probe position (center of the cube map) */
  141627. position: Vector3;
  141628. /**
  141629. * Creates a new reflection probe
  141630. * @param name defines the name of the probe
  141631. * @param size defines the texture resolution (for each face)
  141632. * @param scene defines the hosting scene
  141633. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141634. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141635. */
  141636. constructor(
  141637. /** defines the name of the probe */
  141638. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141639. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141640. get samples(): number;
  141641. set samples(value: number);
  141642. /** Gets or sets the refresh rate to use (on every frame by default) */
  141643. get refreshRate(): number;
  141644. set refreshRate(value: number);
  141645. /**
  141646. * Gets the hosting scene
  141647. * @returns a Scene
  141648. */
  141649. getScene(): Scene;
  141650. /** Gets the internal CubeTexture used to render to */
  141651. get cubeTexture(): RenderTargetTexture;
  141652. /** Gets the list of meshes to render */
  141653. get renderList(): Nullable<AbstractMesh[]>;
  141654. /**
  141655. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141656. * @param mesh defines the mesh to attach to
  141657. */
  141658. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141659. /**
  141660. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141661. * @param renderingGroupId The rendering group id corresponding to its index
  141662. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141663. */
  141664. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141665. /**
  141666. * Clean all associated resources
  141667. */
  141668. dispose(): void;
  141669. /**
  141670. * Converts the reflection probe information to a readable string for debug purpose.
  141671. * @param fullDetails Supports for multiple levels of logging within scene loading
  141672. * @returns the human readable reflection probe info
  141673. */
  141674. toString(fullDetails?: boolean): string;
  141675. /**
  141676. * Get the class name of the relfection probe.
  141677. * @returns "ReflectionProbe"
  141678. */
  141679. getClassName(): string;
  141680. /**
  141681. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141682. * @returns The JSON representation of the texture
  141683. */
  141684. serialize(): any;
  141685. /**
  141686. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141687. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141688. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141689. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141690. * @returns The parsed reflection probe if successful
  141691. */
  141692. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141693. }
  141694. }
  141695. declare module BABYLON {
  141696. /** @hidden */
  141697. export var _BabylonLoaderRegistered: boolean;
  141698. /**
  141699. * Helps setting up some configuration for the babylon file loader.
  141700. */
  141701. export class BabylonFileLoaderConfiguration {
  141702. /**
  141703. * The loader does not allow injecting custom physix engine into the plugins.
  141704. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141705. * So you could set this variable to your engine import to make it work.
  141706. */
  141707. static LoaderInjectedPhysicsEngine: any;
  141708. }
  141709. }
  141710. declare module BABYLON {
  141711. /**
  141712. * The Physically based simple base material of BJS.
  141713. *
  141714. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141715. * It is used as the base class for both the specGloss and metalRough conventions.
  141716. */
  141717. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141718. /**
  141719. * Number of Simultaneous lights allowed on the material.
  141720. */
  141721. maxSimultaneousLights: number;
  141722. /**
  141723. * If sets to true, disables all the lights affecting the material.
  141724. */
  141725. disableLighting: boolean;
  141726. /**
  141727. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141728. */
  141729. environmentTexture: BaseTexture;
  141730. /**
  141731. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141732. */
  141733. invertNormalMapX: boolean;
  141734. /**
  141735. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141736. */
  141737. invertNormalMapY: boolean;
  141738. /**
  141739. * Normal map used in the model.
  141740. */
  141741. normalTexture: BaseTexture;
  141742. /**
  141743. * Emissivie color used to self-illuminate the model.
  141744. */
  141745. emissiveColor: Color3;
  141746. /**
  141747. * Emissivie texture used to self-illuminate the model.
  141748. */
  141749. emissiveTexture: BaseTexture;
  141750. /**
  141751. * Occlusion Channel Strenght.
  141752. */
  141753. occlusionStrength: number;
  141754. /**
  141755. * Occlusion Texture of the material (adding extra occlusion effects).
  141756. */
  141757. occlusionTexture: BaseTexture;
  141758. /**
  141759. * Defines the alpha limits in alpha test mode.
  141760. */
  141761. alphaCutOff: number;
  141762. /**
  141763. * Gets the current double sided mode.
  141764. */
  141765. get doubleSided(): boolean;
  141766. /**
  141767. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141768. */
  141769. set doubleSided(value: boolean);
  141770. /**
  141771. * Stores the pre-calculated light information of a mesh in a texture.
  141772. */
  141773. lightmapTexture: BaseTexture;
  141774. /**
  141775. * If true, the light map contains occlusion information instead of lighting info.
  141776. */
  141777. useLightmapAsShadowmap: boolean;
  141778. /**
  141779. * Instantiates a new PBRMaterial instance.
  141780. *
  141781. * @param name The material name
  141782. * @param scene The scene the material will be use in.
  141783. */
  141784. constructor(name: string, scene: Scene);
  141785. getClassName(): string;
  141786. }
  141787. }
  141788. declare module BABYLON {
  141789. /**
  141790. * The PBR material of BJS following the metal roughness convention.
  141791. *
  141792. * This fits to the PBR convention in the GLTF definition:
  141793. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141794. */
  141795. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141796. /**
  141797. * The base color has two different interpretations depending on the value of metalness.
  141798. * When the material is a metal, the base color is the specific measured reflectance value
  141799. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141800. * of the material.
  141801. */
  141802. baseColor: Color3;
  141803. /**
  141804. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141805. * well as opacity information in the alpha channel.
  141806. */
  141807. baseTexture: BaseTexture;
  141808. /**
  141809. * Specifies the metallic scalar value of the material.
  141810. * Can also be used to scale the metalness values of the metallic texture.
  141811. */
  141812. metallic: number;
  141813. /**
  141814. * Specifies the roughness scalar value of the material.
  141815. * Can also be used to scale the roughness values of the metallic texture.
  141816. */
  141817. roughness: number;
  141818. /**
  141819. * Texture containing both the metallic value in the B channel and the
  141820. * roughness value in the G channel to keep better precision.
  141821. */
  141822. metallicRoughnessTexture: BaseTexture;
  141823. /**
  141824. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141825. *
  141826. * @param name The material name
  141827. * @param scene The scene the material will be use in.
  141828. */
  141829. constructor(name: string, scene: Scene);
  141830. /**
  141831. * Return the currrent class name of the material.
  141832. */
  141833. getClassName(): string;
  141834. /**
  141835. * Makes a duplicate of the current material.
  141836. * @param name - name to use for the new material.
  141837. */
  141838. clone(name: string): PBRMetallicRoughnessMaterial;
  141839. /**
  141840. * Serialize the material to a parsable JSON object.
  141841. */
  141842. serialize(): any;
  141843. /**
  141844. * Parses a JSON object correponding to the serialize function.
  141845. */
  141846. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141847. }
  141848. }
  141849. declare module BABYLON {
  141850. /**
  141851. * The PBR material of BJS following the specular glossiness convention.
  141852. *
  141853. * This fits to the PBR convention in the GLTF definition:
  141854. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141855. */
  141856. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141857. /**
  141858. * Specifies the diffuse color of the material.
  141859. */
  141860. diffuseColor: Color3;
  141861. /**
  141862. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141863. * channel.
  141864. */
  141865. diffuseTexture: BaseTexture;
  141866. /**
  141867. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141868. */
  141869. specularColor: Color3;
  141870. /**
  141871. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141872. */
  141873. glossiness: number;
  141874. /**
  141875. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141876. */
  141877. specularGlossinessTexture: BaseTexture;
  141878. /**
  141879. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141880. *
  141881. * @param name The material name
  141882. * @param scene The scene the material will be use in.
  141883. */
  141884. constructor(name: string, scene: Scene);
  141885. /**
  141886. * Return the currrent class name of the material.
  141887. */
  141888. getClassName(): string;
  141889. /**
  141890. * Makes a duplicate of the current material.
  141891. * @param name - name to use for the new material.
  141892. */
  141893. clone(name: string): PBRSpecularGlossinessMaterial;
  141894. /**
  141895. * Serialize the material to a parsable JSON object.
  141896. */
  141897. serialize(): any;
  141898. /**
  141899. * Parses a JSON object correponding to the serialize function.
  141900. */
  141901. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141902. }
  141903. }
  141904. declare module BABYLON {
  141905. /**
  141906. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141907. * It can help converting any input color in a desired output one. This can then be used to create effects
  141908. * from sepia, black and white to sixties or futuristic rendering...
  141909. *
  141910. * The only supported format is currently 3dl.
  141911. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141912. */
  141913. export class ColorGradingTexture extends BaseTexture {
  141914. /**
  141915. * The texture URL.
  141916. */
  141917. url: string;
  141918. /**
  141919. * Empty line regex stored for GC.
  141920. */
  141921. private static _noneEmptyLineRegex;
  141922. private _textureMatrix;
  141923. private _onLoad;
  141924. /**
  141925. * Instantiates a ColorGradingTexture from the following parameters.
  141926. *
  141927. * @param url The location of the color gradind data (currently only supporting 3dl)
  141928. * @param sceneOrEngine The scene or engine the texture will be used in
  141929. * @param onLoad defines a callback triggered when the texture has been loaded
  141930. */
  141931. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141932. /**
  141933. * Fires the onload event from the constructor if requested.
  141934. */
  141935. private _triggerOnLoad;
  141936. /**
  141937. * Returns the texture matrix used in most of the material.
  141938. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141939. */
  141940. getTextureMatrix(): Matrix;
  141941. /**
  141942. * Occurs when the file being loaded is a .3dl LUT file.
  141943. */
  141944. private load3dlTexture;
  141945. /**
  141946. * Starts the loading process of the texture.
  141947. */
  141948. private loadTexture;
  141949. /**
  141950. * Clones the color gradind texture.
  141951. */
  141952. clone(): ColorGradingTexture;
  141953. /**
  141954. * Called during delayed load for textures.
  141955. */
  141956. delayLoad(): void;
  141957. /**
  141958. * Parses a color grading texture serialized by Babylon.
  141959. * @param parsedTexture The texture information being parsedTexture
  141960. * @param scene The scene to load the texture in
  141961. * @param rootUrl The root url of the data assets to load
  141962. * @return A color gradind texture
  141963. */
  141964. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141965. /**
  141966. * Serializes the LUT texture to json format.
  141967. */
  141968. serialize(): any;
  141969. }
  141970. }
  141971. declare module BABYLON {
  141972. /**
  141973. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141974. */
  141975. export class EquiRectangularCubeTexture extends BaseTexture {
  141976. /** The six faces of the cube. */
  141977. private static _FacesMapping;
  141978. private _noMipmap;
  141979. private _onLoad;
  141980. private _onError;
  141981. /** The size of the cubemap. */
  141982. private _size;
  141983. /** The buffer of the image. */
  141984. private _buffer;
  141985. /** The width of the input image. */
  141986. private _width;
  141987. /** The height of the input image. */
  141988. private _height;
  141989. /** The URL to the image. */
  141990. url: string;
  141991. /**
  141992. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141993. * @param url The location of the image
  141994. * @param scene The scene the texture will be used in
  141995. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141996. * @param noMipmap Forces to not generate the mipmap if true
  141997. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141998. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141999. * @param onLoad — defines a callback called when texture is loaded
  142000. * @param onError — defines a callback called if there is an error
  142001. */
  142002. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142003. /**
  142004. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142005. */
  142006. private loadImage;
  142007. /**
  142008. * Convert the image buffer into a cubemap and create a CubeTexture.
  142009. */
  142010. private loadTexture;
  142011. /**
  142012. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142013. * @param buffer The ArrayBuffer that should be converted.
  142014. * @returns The buffer as Float32Array.
  142015. */
  142016. private getFloat32ArrayFromArrayBuffer;
  142017. /**
  142018. * Get the current class name of the texture useful for serialization or dynamic coding.
  142019. * @returns "EquiRectangularCubeTexture"
  142020. */
  142021. getClassName(): string;
  142022. /**
  142023. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142024. * @returns A clone of the current EquiRectangularCubeTexture.
  142025. */
  142026. clone(): EquiRectangularCubeTexture;
  142027. }
  142028. }
  142029. declare module BABYLON {
  142030. /**
  142031. * Defines the options related to the creation of an HtmlElementTexture
  142032. */
  142033. export interface IHtmlElementTextureOptions {
  142034. /**
  142035. * Defines wether mip maps should be created or not.
  142036. */
  142037. generateMipMaps?: boolean;
  142038. /**
  142039. * Defines the sampling mode of the texture.
  142040. */
  142041. samplingMode?: number;
  142042. /**
  142043. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142044. */
  142045. engine: Nullable<ThinEngine>;
  142046. /**
  142047. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142048. */
  142049. scene: Nullable<Scene>;
  142050. }
  142051. /**
  142052. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142053. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142054. * is automatically managed.
  142055. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142056. * in your application.
  142057. *
  142058. * As the update is not automatic, you need to call them manually.
  142059. */
  142060. export class HtmlElementTexture extends BaseTexture {
  142061. /**
  142062. * The texture URL.
  142063. */
  142064. element: HTMLVideoElement | HTMLCanvasElement;
  142065. private static readonly DefaultOptions;
  142066. private _textureMatrix;
  142067. private _isVideo;
  142068. private _generateMipMaps;
  142069. private _samplingMode;
  142070. /**
  142071. * Instantiates a HtmlElementTexture from the following parameters.
  142072. *
  142073. * @param name Defines the name of the texture
  142074. * @param element Defines the video or canvas the texture is filled with
  142075. * @param options Defines the other none mandatory texture creation options
  142076. */
  142077. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142078. private _createInternalTexture;
  142079. /**
  142080. * Returns the texture matrix used in most of the material.
  142081. */
  142082. getTextureMatrix(): Matrix;
  142083. /**
  142084. * Updates the content of the texture.
  142085. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142086. */
  142087. update(invertY?: Nullable<boolean>): void;
  142088. }
  142089. }
  142090. declare module BABYLON {
  142091. /**
  142092. * Based on jsTGALoader - Javascript loader for TGA file
  142093. * By Vincent Thibault
  142094. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142095. */
  142096. export class TGATools {
  142097. private static _TYPE_INDEXED;
  142098. private static _TYPE_RGB;
  142099. private static _TYPE_GREY;
  142100. private static _TYPE_RLE_INDEXED;
  142101. private static _TYPE_RLE_RGB;
  142102. private static _TYPE_RLE_GREY;
  142103. private static _ORIGIN_MASK;
  142104. private static _ORIGIN_SHIFT;
  142105. private static _ORIGIN_BL;
  142106. private static _ORIGIN_BR;
  142107. private static _ORIGIN_UL;
  142108. private static _ORIGIN_UR;
  142109. /**
  142110. * Gets the header of a TGA file
  142111. * @param data defines the TGA data
  142112. * @returns the header
  142113. */
  142114. static GetTGAHeader(data: Uint8Array): any;
  142115. /**
  142116. * Uploads TGA content to a Babylon Texture
  142117. * @hidden
  142118. */
  142119. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142120. /** @hidden */
  142121. 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;
  142122. /** @hidden */
  142123. 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;
  142124. /** @hidden */
  142125. 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;
  142126. /** @hidden */
  142127. 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;
  142128. /** @hidden */
  142129. 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;
  142130. /** @hidden */
  142131. 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;
  142132. }
  142133. }
  142134. declare module BABYLON {
  142135. /**
  142136. * Implementation of the TGA Texture Loader.
  142137. * @hidden
  142138. */
  142139. export class _TGATextureLoader implements IInternalTextureLoader {
  142140. /**
  142141. * Defines wether the loader supports cascade loading the different faces.
  142142. */
  142143. readonly supportCascades: boolean;
  142144. /**
  142145. * This returns if the loader support the current file information.
  142146. * @param extension defines the file extension of the file being loaded
  142147. * @returns true if the loader can load the specified file
  142148. */
  142149. canLoad(extension: string): boolean;
  142150. /**
  142151. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142152. * @param data contains the texture data
  142153. * @param texture defines the BabylonJS internal texture
  142154. * @param createPolynomials will be true if polynomials have been requested
  142155. * @param onLoad defines the callback to trigger once the texture is ready
  142156. * @param onError defines the callback to trigger in case of error
  142157. */
  142158. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142159. /**
  142160. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142161. * @param data contains the texture data
  142162. * @param texture defines the BabylonJS internal texture
  142163. * @param callback defines the method to call once ready to upload
  142164. */
  142165. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142166. }
  142167. }
  142168. declare module BABYLON {
  142169. /**
  142170. * Info about the .basis files
  142171. */
  142172. class BasisFileInfo {
  142173. /**
  142174. * If the file has alpha
  142175. */
  142176. hasAlpha: boolean;
  142177. /**
  142178. * Info about each image of the basis file
  142179. */
  142180. images: Array<{
  142181. levels: Array<{
  142182. width: number;
  142183. height: number;
  142184. transcodedPixels: ArrayBufferView;
  142185. }>;
  142186. }>;
  142187. }
  142188. /**
  142189. * Result of transcoding a basis file
  142190. */
  142191. class TranscodeResult {
  142192. /**
  142193. * Info about the .basis file
  142194. */
  142195. fileInfo: BasisFileInfo;
  142196. /**
  142197. * Format to use when loading the file
  142198. */
  142199. format: number;
  142200. }
  142201. /**
  142202. * Configuration options for the Basis transcoder
  142203. */
  142204. export class BasisTranscodeConfiguration {
  142205. /**
  142206. * Supported compression formats used to determine the supported output format of the transcoder
  142207. */
  142208. supportedCompressionFormats?: {
  142209. /**
  142210. * etc1 compression format
  142211. */
  142212. etc1?: boolean;
  142213. /**
  142214. * s3tc compression format
  142215. */
  142216. s3tc?: boolean;
  142217. /**
  142218. * pvrtc compression format
  142219. */
  142220. pvrtc?: boolean;
  142221. /**
  142222. * etc2 compression format
  142223. */
  142224. etc2?: boolean;
  142225. };
  142226. /**
  142227. * If mipmap levels should be loaded for transcoded images (Default: true)
  142228. */
  142229. loadMipmapLevels?: boolean;
  142230. /**
  142231. * Index of a single image to load (Default: all images)
  142232. */
  142233. loadSingleImage?: number;
  142234. }
  142235. /**
  142236. * Used to load .Basis files
  142237. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142238. */
  142239. export class BasisTools {
  142240. private static _IgnoreSupportedFormats;
  142241. /**
  142242. * URL to use when loading the basis transcoder
  142243. */
  142244. static JSModuleURL: string;
  142245. /**
  142246. * URL to use when loading the wasm module for the transcoder
  142247. */
  142248. static WasmModuleURL: string;
  142249. /**
  142250. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142251. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142252. * @returns internal format corresponding to the Basis format
  142253. */
  142254. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142255. private static _WorkerPromise;
  142256. private static _Worker;
  142257. private static _actionId;
  142258. private static _CreateWorkerAsync;
  142259. /**
  142260. * Transcodes a loaded image file to compressed pixel data
  142261. * @param data image data to transcode
  142262. * @param config configuration options for the transcoding
  142263. * @returns a promise resulting in the transcoded image
  142264. */
  142265. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142266. /**
  142267. * Loads a texture from the transcode result
  142268. * @param texture texture load to
  142269. * @param transcodeResult the result of transcoding the basis file to load from
  142270. */
  142271. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142272. }
  142273. }
  142274. declare module BABYLON {
  142275. /**
  142276. * Loader for .basis file format
  142277. */
  142278. export class _BasisTextureLoader implements IInternalTextureLoader {
  142279. /**
  142280. * Defines whether the loader supports cascade loading the different faces.
  142281. */
  142282. readonly supportCascades: boolean;
  142283. /**
  142284. * This returns if the loader support the current file information.
  142285. * @param extension defines the file extension of the file being loaded
  142286. * @returns true if the loader can load the specified file
  142287. */
  142288. canLoad(extension: string): boolean;
  142289. /**
  142290. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142291. * @param data contains the texture data
  142292. * @param texture defines the BabylonJS internal texture
  142293. * @param createPolynomials will be true if polynomials have been requested
  142294. * @param onLoad defines the callback to trigger once the texture is ready
  142295. * @param onError defines the callback to trigger in case of error
  142296. */
  142297. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142298. /**
  142299. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142300. * @param data contains the texture data
  142301. * @param texture defines the BabylonJS internal texture
  142302. * @param callback defines the method to call once ready to upload
  142303. */
  142304. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142305. }
  142306. }
  142307. declare module BABYLON {
  142308. /**
  142309. * Defines the basic options interface of a TexturePacker Frame
  142310. */
  142311. export interface ITexturePackerFrame {
  142312. /**
  142313. * The frame ID
  142314. */
  142315. id: number;
  142316. /**
  142317. * The frames Scale
  142318. */
  142319. scale: Vector2;
  142320. /**
  142321. * The Frames offset
  142322. */
  142323. offset: Vector2;
  142324. }
  142325. /**
  142326. * This is a support class for frame Data on texture packer sets.
  142327. */
  142328. export class TexturePackerFrame implements ITexturePackerFrame {
  142329. /**
  142330. * The frame ID
  142331. */
  142332. id: number;
  142333. /**
  142334. * The frames Scale
  142335. */
  142336. scale: Vector2;
  142337. /**
  142338. * The Frames offset
  142339. */
  142340. offset: Vector2;
  142341. /**
  142342. * Initializes a texture package frame.
  142343. * @param id The numerical frame identifier
  142344. * @param scale Scalar Vector2 for UV frame
  142345. * @param offset Vector2 for the frame position in UV units.
  142346. * @returns TexturePackerFrame
  142347. */
  142348. constructor(id: number, scale: Vector2, offset: Vector2);
  142349. }
  142350. }
  142351. declare module BABYLON {
  142352. /**
  142353. * Defines the basic options interface of a TexturePacker
  142354. */
  142355. export interface ITexturePackerOptions {
  142356. /**
  142357. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142358. */
  142359. map?: string[];
  142360. /**
  142361. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142362. */
  142363. uvsIn?: string;
  142364. /**
  142365. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142366. */
  142367. uvsOut?: string;
  142368. /**
  142369. * number representing the layout style. Defaults to LAYOUT_STRIP
  142370. */
  142371. layout?: number;
  142372. /**
  142373. * number of columns if using custom column count layout(2). This defaults to 4.
  142374. */
  142375. colnum?: number;
  142376. /**
  142377. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142378. */
  142379. updateInputMeshes?: boolean;
  142380. /**
  142381. * boolean flag to dispose all the source textures. Defaults to true.
  142382. */
  142383. disposeSources?: boolean;
  142384. /**
  142385. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142386. */
  142387. fillBlanks?: boolean;
  142388. /**
  142389. * string value representing the context fill style color. Defaults to 'black'.
  142390. */
  142391. customFillColor?: string;
  142392. /**
  142393. * Width and Height Value of each Frame in the TexturePacker Sets
  142394. */
  142395. frameSize?: number;
  142396. /**
  142397. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142398. */
  142399. paddingRatio?: number;
  142400. /**
  142401. * Number that declares the fill method for the padding gutter.
  142402. */
  142403. paddingMode?: number;
  142404. /**
  142405. * If in SUBUV_COLOR padding mode what color to use.
  142406. */
  142407. paddingColor?: Color3 | Color4;
  142408. }
  142409. /**
  142410. * Defines the basic interface of a TexturePacker JSON File
  142411. */
  142412. export interface ITexturePackerJSON {
  142413. /**
  142414. * The frame ID
  142415. */
  142416. name: string;
  142417. /**
  142418. * The base64 channel data
  142419. */
  142420. sets: any;
  142421. /**
  142422. * The options of the Packer
  142423. */
  142424. options: ITexturePackerOptions;
  142425. /**
  142426. * The frame data of the Packer
  142427. */
  142428. frames: Array<number>;
  142429. }
  142430. /**
  142431. * This is a support class that generates a series of packed texture sets.
  142432. * @see https://doc.babylonjs.com/babylon101/materials
  142433. */
  142434. export class TexturePacker {
  142435. /** Packer Layout Constant 0 */
  142436. static readonly LAYOUT_STRIP: number;
  142437. /** Packer Layout Constant 1 */
  142438. static readonly LAYOUT_POWER2: number;
  142439. /** Packer Layout Constant 2 */
  142440. static readonly LAYOUT_COLNUM: number;
  142441. /** Packer Layout Constant 0 */
  142442. static readonly SUBUV_WRAP: number;
  142443. /** Packer Layout Constant 1 */
  142444. static readonly SUBUV_EXTEND: number;
  142445. /** Packer Layout Constant 2 */
  142446. static readonly SUBUV_COLOR: number;
  142447. /** The Name of the Texture Package */
  142448. name: string;
  142449. /** The scene scope of the TexturePacker */
  142450. scene: Scene;
  142451. /** The Meshes to target */
  142452. meshes: AbstractMesh[];
  142453. /** Arguments passed with the Constructor */
  142454. options: ITexturePackerOptions;
  142455. /** The promise that is started upon initialization */
  142456. promise: Nullable<Promise<TexturePacker | string>>;
  142457. /** The Container object for the channel sets that are generated */
  142458. sets: object;
  142459. /** The Container array for the frames that are generated */
  142460. frames: TexturePackerFrame[];
  142461. /** The expected number of textures the system is parsing. */
  142462. private _expecting;
  142463. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142464. private _paddingValue;
  142465. /**
  142466. * Initializes a texture package series from an array of meshes or a single mesh.
  142467. * @param name The name of the package
  142468. * @param meshes The target meshes to compose the package from
  142469. * @param options The arguments that texture packer should follow while building.
  142470. * @param scene The scene which the textures are scoped to.
  142471. * @returns TexturePacker
  142472. */
  142473. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142474. /**
  142475. * Starts the package process
  142476. * @param resolve The promises resolution function
  142477. * @returns TexturePacker
  142478. */
  142479. private _createFrames;
  142480. /**
  142481. * Calculates the Size of the Channel Sets
  142482. * @returns Vector2
  142483. */
  142484. private _calculateSize;
  142485. /**
  142486. * Calculates the UV data for the frames.
  142487. * @param baseSize the base frameSize
  142488. * @param padding the base frame padding
  142489. * @param dtSize size of the Dynamic Texture for that channel
  142490. * @param dtUnits is 1/dtSize
  142491. * @param update flag to update the input meshes
  142492. */
  142493. private _calculateMeshUVFrames;
  142494. /**
  142495. * Calculates the frames Offset.
  142496. * @param index of the frame
  142497. * @returns Vector2
  142498. */
  142499. private _getFrameOffset;
  142500. /**
  142501. * Updates a Mesh to the frame data
  142502. * @param mesh that is the target
  142503. * @param frameID or the frame index
  142504. */
  142505. private _updateMeshUV;
  142506. /**
  142507. * Updates a Meshes materials to use the texture packer channels
  142508. * @param m is the mesh to target
  142509. * @param force all channels on the packer to be set.
  142510. */
  142511. private _updateTextureReferences;
  142512. /**
  142513. * Public method to set a Mesh to a frame
  142514. * @param m that is the target
  142515. * @param frameID or the frame index
  142516. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142517. */
  142518. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142519. /**
  142520. * Starts the async promise to compile the texture packer.
  142521. * @returns Promise<void>
  142522. */
  142523. processAsync(): Promise<void>;
  142524. /**
  142525. * Disposes all textures associated with this packer
  142526. */
  142527. dispose(): void;
  142528. /**
  142529. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142530. * @param imageType is the image type to use.
  142531. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142532. */
  142533. download(imageType?: string, quality?: number): void;
  142534. /**
  142535. * Public method to load a texturePacker JSON file.
  142536. * @param data of the JSON file in string format.
  142537. */
  142538. updateFromJSON(data: string): void;
  142539. }
  142540. }
  142541. declare module BABYLON {
  142542. /**
  142543. * 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.
  142544. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142545. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142546. */
  142547. export class CustomProceduralTexture extends ProceduralTexture {
  142548. private _animate;
  142549. private _time;
  142550. private _config;
  142551. private _texturePath;
  142552. /**
  142553. * Instantiates a new Custom Procedural Texture.
  142554. * 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.
  142555. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142556. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142557. * @param name Define the name of the texture
  142558. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142559. * @param size Define the size of the texture to create
  142560. * @param scene Define the scene the texture belongs to
  142561. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142562. * @param generateMipMaps Define if the texture should creates mip maps or not
  142563. */
  142564. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142565. private _loadJson;
  142566. /**
  142567. * Is the texture ready to be used ? (rendered at least once)
  142568. * @returns true if ready, otherwise, false.
  142569. */
  142570. isReady(): boolean;
  142571. /**
  142572. * Render the texture to its associated render target.
  142573. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142574. */
  142575. render(useCameraPostProcess?: boolean): void;
  142576. /**
  142577. * Update the list of dependant textures samplers in the shader.
  142578. */
  142579. updateTextures(): void;
  142580. /**
  142581. * Update the uniform values of the procedural texture in the shader.
  142582. */
  142583. updateShaderUniforms(): void;
  142584. /**
  142585. * Define if the texture animates or not.
  142586. */
  142587. get animate(): boolean;
  142588. set animate(value: boolean);
  142589. }
  142590. }
  142591. declare module BABYLON {
  142592. /** @hidden */
  142593. export var noisePixelShader: {
  142594. name: string;
  142595. shader: string;
  142596. };
  142597. }
  142598. declare module BABYLON {
  142599. /**
  142600. * Class used to generate noise procedural textures
  142601. */
  142602. export class NoiseProceduralTexture extends ProceduralTexture {
  142603. /** Gets or sets the start time (default is 0) */
  142604. time: number;
  142605. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142606. brightness: number;
  142607. /** Defines the number of octaves to process */
  142608. octaves: number;
  142609. /** Defines the level of persistence (0.8 by default) */
  142610. persistence: number;
  142611. /** Gets or sets animation speed factor (default is 1) */
  142612. animationSpeedFactor: number;
  142613. /**
  142614. * Creates a new NoiseProceduralTexture
  142615. * @param name defines the name fo the texture
  142616. * @param size defines the size of the texture (default is 256)
  142617. * @param scene defines the hosting scene
  142618. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142619. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142620. */
  142621. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142622. private _updateShaderUniforms;
  142623. protected _getDefines(): string;
  142624. /** Generate the current state of the procedural texture */
  142625. render(useCameraPostProcess?: boolean): void;
  142626. /**
  142627. * Serializes this noise procedural texture
  142628. * @returns a serialized noise procedural texture object
  142629. */
  142630. serialize(): any;
  142631. /**
  142632. * Clone the texture.
  142633. * @returns the cloned texture
  142634. */
  142635. clone(): NoiseProceduralTexture;
  142636. /**
  142637. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142638. * @param parsedTexture defines parsed texture data
  142639. * @param scene defines the current scene
  142640. * @param rootUrl defines the root URL containing noise procedural texture information
  142641. * @returns a parsed NoiseProceduralTexture
  142642. */
  142643. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142644. }
  142645. }
  142646. declare module BABYLON {
  142647. /**
  142648. * Raw cube texture where the raw buffers are passed in
  142649. */
  142650. export class RawCubeTexture extends CubeTexture {
  142651. /**
  142652. * Creates a cube texture where the raw buffers are passed in.
  142653. * @param scene defines the scene the texture is attached to
  142654. * @param data defines the array of data to use to create each face
  142655. * @param size defines the size of the textures
  142656. * @param format defines the format of the data
  142657. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142658. * @param generateMipMaps defines if the engine should generate the mip levels
  142659. * @param invertY defines if data must be stored with Y axis inverted
  142660. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142661. * @param compression defines the compression used (null by default)
  142662. */
  142663. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142664. /**
  142665. * Updates the raw cube texture.
  142666. * @param data defines the data to store
  142667. * @param format defines the data format
  142668. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142669. * @param invertY defines if data must be stored with Y axis inverted
  142670. * @param compression defines the compression used (null by default)
  142671. * @param level defines which level of the texture to update
  142672. */
  142673. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142674. /**
  142675. * Updates a raw cube texture with RGBD encoded data.
  142676. * @param data defines the array of data [mipmap][face] to use to create each face
  142677. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142680. * @returns a promsie that resolves when the operation is complete
  142681. */
  142682. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142683. /**
  142684. * Clones the raw cube texture.
  142685. * @return a new cube texture
  142686. */
  142687. clone(): CubeTexture;
  142688. /** @hidden */
  142689. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142690. }
  142691. }
  142692. declare module BABYLON {
  142693. /**
  142694. * Class used to store 2D array textures containing user data
  142695. */
  142696. export class RawTexture2DArray extends Texture {
  142697. /** Gets or sets the texture format to use */
  142698. format: number;
  142699. /**
  142700. * Create a new RawTexture2DArray
  142701. * @param data defines the data of the texture
  142702. * @param width defines the width of the texture
  142703. * @param height defines the height of the texture
  142704. * @param depth defines the number of layers of the texture
  142705. * @param format defines the texture format to use
  142706. * @param scene defines the hosting scene
  142707. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142708. * @param invertY defines if texture must be stored with Y axis inverted
  142709. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142710. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142711. */
  142712. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142713. /** Gets or sets the texture format to use */
  142714. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142715. /**
  142716. * Update the texture with new data
  142717. * @param data defines the data to store in the texture
  142718. */
  142719. update(data: ArrayBufferView): void;
  142720. }
  142721. }
  142722. declare module BABYLON {
  142723. /**
  142724. * Class used to store 3D textures containing user data
  142725. */
  142726. export class RawTexture3D extends Texture {
  142727. /** Gets or sets the texture format to use */
  142728. format: number;
  142729. /**
  142730. * Create a new RawTexture3D
  142731. * @param data defines the data of the texture
  142732. * @param width defines the width of the texture
  142733. * @param height defines the height of the texture
  142734. * @param depth defines the depth of the texture
  142735. * @param format defines the texture format to use
  142736. * @param scene defines the hosting scene
  142737. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142738. * @param invertY defines if texture must be stored with Y axis inverted
  142739. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142740. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142741. */
  142742. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142743. /** Gets or sets the texture format to use */
  142744. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142745. /**
  142746. * Update the texture with new data
  142747. * @param data defines the data to store in the texture
  142748. */
  142749. update(data: ArrayBufferView): void;
  142750. }
  142751. }
  142752. declare module BABYLON {
  142753. /**
  142754. * Creates a refraction texture used by refraction channel of the standard material.
  142755. * It is like a mirror but to see through a material.
  142756. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142757. */
  142758. export class RefractionTexture extends RenderTargetTexture {
  142759. /**
  142760. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142761. * 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.
  142762. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142763. */
  142764. refractionPlane: Plane;
  142765. /**
  142766. * Define how deep under the surface we should see.
  142767. */
  142768. depth: number;
  142769. /**
  142770. * Creates a refraction texture used by refraction channel of the standard material.
  142771. * It is like a mirror but to see through a material.
  142772. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142773. * @param name Define the texture name
  142774. * @param size Define the size of the underlying texture
  142775. * @param scene Define the scene the refraction belongs to
  142776. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142777. */
  142778. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142779. /**
  142780. * Clone the refraction texture.
  142781. * @returns the cloned texture
  142782. */
  142783. clone(): RefractionTexture;
  142784. /**
  142785. * Serialize the texture to a JSON representation you could use in Parse later on
  142786. * @returns the serialized JSON representation
  142787. */
  142788. serialize(): any;
  142789. }
  142790. }
  142791. declare module BABYLON {
  142792. /**
  142793. * Block used to add support for vertex skinning (bones)
  142794. */
  142795. export class BonesBlock extends NodeMaterialBlock {
  142796. /**
  142797. * Creates a new BonesBlock
  142798. * @param name defines the block name
  142799. */
  142800. constructor(name: string);
  142801. /**
  142802. * Initialize the block and prepare the context for build
  142803. * @param state defines the state that will be used for the build
  142804. */
  142805. initialize(state: NodeMaterialBuildState): void;
  142806. /**
  142807. * Gets the current class name
  142808. * @returns the class name
  142809. */
  142810. getClassName(): string;
  142811. /**
  142812. * Gets the matrix indices input component
  142813. */
  142814. get matricesIndices(): NodeMaterialConnectionPoint;
  142815. /**
  142816. * Gets the matrix weights input component
  142817. */
  142818. get matricesWeights(): NodeMaterialConnectionPoint;
  142819. /**
  142820. * Gets the extra matrix indices input component
  142821. */
  142822. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142823. /**
  142824. * Gets the extra matrix weights input component
  142825. */
  142826. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142827. /**
  142828. * Gets the world input component
  142829. */
  142830. get world(): NodeMaterialConnectionPoint;
  142831. /**
  142832. * Gets the output component
  142833. */
  142834. get output(): NodeMaterialConnectionPoint;
  142835. autoConfigure(material: NodeMaterial): void;
  142836. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142838. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142839. protected _buildBlock(state: NodeMaterialBuildState): this;
  142840. }
  142841. }
  142842. declare module BABYLON {
  142843. /**
  142844. * Block used to add support for instances
  142845. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142846. */
  142847. export class InstancesBlock extends NodeMaterialBlock {
  142848. /**
  142849. * Creates a new InstancesBlock
  142850. * @param name defines the block name
  142851. */
  142852. constructor(name: string);
  142853. /**
  142854. * Gets the current class name
  142855. * @returns the class name
  142856. */
  142857. getClassName(): string;
  142858. /**
  142859. * Gets the first world row input component
  142860. */
  142861. get world0(): NodeMaterialConnectionPoint;
  142862. /**
  142863. * Gets the second world row input component
  142864. */
  142865. get world1(): NodeMaterialConnectionPoint;
  142866. /**
  142867. * Gets the third world row input component
  142868. */
  142869. get world2(): NodeMaterialConnectionPoint;
  142870. /**
  142871. * Gets the forth world row input component
  142872. */
  142873. get world3(): NodeMaterialConnectionPoint;
  142874. /**
  142875. * Gets the world input component
  142876. */
  142877. get world(): NodeMaterialConnectionPoint;
  142878. /**
  142879. * Gets the output component
  142880. */
  142881. get output(): NodeMaterialConnectionPoint;
  142882. /**
  142883. * Gets the isntanceID component
  142884. */
  142885. get instanceID(): NodeMaterialConnectionPoint;
  142886. autoConfigure(material: NodeMaterial): void;
  142887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142888. protected _buildBlock(state: NodeMaterialBuildState): this;
  142889. }
  142890. }
  142891. declare module BABYLON {
  142892. /**
  142893. * Block used to add morph targets support to vertex shader
  142894. */
  142895. export class MorphTargetsBlock extends NodeMaterialBlock {
  142896. private _repeatableContentAnchor;
  142897. /**
  142898. * Create a new MorphTargetsBlock
  142899. * @param name defines the block name
  142900. */
  142901. constructor(name: string);
  142902. /**
  142903. * Gets the current class name
  142904. * @returns the class name
  142905. */
  142906. getClassName(): string;
  142907. /**
  142908. * Gets the position input component
  142909. */
  142910. get position(): NodeMaterialConnectionPoint;
  142911. /**
  142912. * Gets the normal input component
  142913. */
  142914. get normal(): NodeMaterialConnectionPoint;
  142915. /**
  142916. * Gets the tangent input component
  142917. */
  142918. get tangent(): NodeMaterialConnectionPoint;
  142919. /**
  142920. * Gets the tangent input component
  142921. */
  142922. get uv(): NodeMaterialConnectionPoint;
  142923. /**
  142924. * Gets the position output component
  142925. */
  142926. get positionOutput(): NodeMaterialConnectionPoint;
  142927. /**
  142928. * Gets the normal output component
  142929. */
  142930. get normalOutput(): NodeMaterialConnectionPoint;
  142931. /**
  142932. * Gets the tangent output component
  142933. */
  142934. get tangentOutput(): NodeMaterialConnectionPoint;
  142935. /**
  142936. * Gets the tangent output component
  142937. */
  142938. get uvOutput(): NodeMaterialConnectionPoint;
  142939. initialize(state: NodeMaterialBuildState): void;
  142940. autoConfigure(material: NodeMaterial): void;
  142941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142943. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142944. protected _buildBlock(state: NodeMaterialBuildState): this;
  142945. }
  142946. }
  142947. declare module BABYLON {
  142948. /**
  142949. * Block used to get data information from a light
  142950. */
  142951. export class LightInformationBlock extends NodeMaterialBlock {
  142952. private _lightDataUniformName;
  142953. private _lightColorUniformName;
  142954. private _lightTypeDefineName;
  142955. /**
  142956. * Gets or sets the light associated with this block
  142957. */
  142958. light: Nullable<Light>;
  142959. /**
  142960. * Creates a new LightInformationBlock
  142961. * @param name defines the block name
  142962. */
  142963. constructor(name: string);
  142964. /**
  142965. * Gets the current class name
  142966. * @returns the class name
  142967. */
  142968. getClassName(): string;
  142969. /**
  142970. * Gets the world position input component
  142971. */
  142972. get worldPosition(): NodeMaterialConnectionPoint;
  142973. /**
  142974. * Gets the direction output component
  142975. */
  142976. get direction(): NodeMaterialConnectionPoint;
  142977. /**
  142978. * Gets the direction output component
  142979. */
  142980. get color(): NodeMaterialConnectionPoint;
  142981. /**
  142982. * Gets the direction output component
  142983. */
  142984. get intensity(): NodeMaterialConnectionPoint;
  142985. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142987. protected _buildBlock(state: NodeMaterialBuildState): this;
  142988. serialize(): any;
  142989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142990. }
  142991. }
  142992. declare module BABYLON {
  142993. /**
  142994. * Block used to add image processing support to fragment shader
  142995. */
  142996. export class ImageProcessingBlock extends NodeMaterialBlock {
  142997. /**
  142998. * Create a new ImageProcessingBlock
  142999. * @param name defines the block name
  143000. */
  143001. constructor(name: string);
  143002. /**
  143003. * Gets the current class name
  143004. * @returns the class name
  143005. */
  143006. getClassName(): string;
  143007. /**
  143008. * Gets the color input component
  143009. */
  143010. get color(): NodeMaterialConnectionPoint;
  143011. /**
  143012. * Gets the output component
  143013. */
  143014. get output(): NodeMaterialConnectionPoint;
  143015. /**
  143016. * Initialize the block and prepare the context for build
  143017. * @param state defines the state that will be used for the build
  143018. */
  143019. initialize(state: NodeMaterialBuildState): void;
  143020. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143022. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143023. protected _buildBlock(state: NodeMaterialBuildState): this;
  143024. }
  143025. }
  143026. declare module BABYLON {
  143027. /**
  143028. * Block used to pertub normals based on a normal map
  143029. */
  143030. export class PerturbNormalBlock extends NodeMaterialBlock {
  143031. private _tangentSpaceParameterName;
  143032. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143033. invertX: boolean;
  143034. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143035. invertY: boolean;
  143036. /**
  143037. * Create a new PerturbNormalBlock
  143038. * @param name defines the block name
  143039. */
  143040. constructor(name: string);
  143041. /**
  143042. * Gets the current class name
  143043. * @returns the class name
  143044. */
  143045. getClassName(): string;
  143046. /**
  143047. * Gets the world position input component
  143048. */
  143049. get worldPosition(): NodeMaterialConnectionPoint;
  143050. /**
  143051. * Gets the world normal input component
  143052. */
  143053. get worldNormal(): NodeMaterialConnectionPoint;
  143054. /**
  143055. * Gets the world tangent input component
  143056. */
  143057. get worldTangent(): NodeMaterialConnectionPoint;
  143058. /**
  143059. * Gets the uv input component
  143060. */
  143061. get uv(): NodeMaterialConnectionPoint;
  143062. /**
  143063. * Gets the normal map color input component
  143064. */
  143065. get normalMapColor(): NodeMaterialConnectionPoint;
  143066. /**
  143067. * Gets the strength input component
  143068. */
  143069. get strength(): NodeMaterialConnectionPoint;
  143070. /**
  143071. * Gets the output component
  143072. */
  143073. get output(): NodeMaterialConnectionPoint;
  143074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143075. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143076. autoConfigure(material: NodeMaterial): void;
  143077. protected _buildBlock(state: NodeMaterialBuildState): this;
  143078. protected _dumpPropertiesCode(): string;
  143079. serialize(): any;
  143080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143081. }
  143082. }
  143083. declare module BABYLON {
  143084. /**
  143085. * Block used to discard a pixel if a value is smaller than a cutoff
  143086. */
  143087. export class DiscardBlock extends NodeMaterialBlock {
  143088. /**
  143089. * Create a new DiscardBlock
  143090. * @param name defines the block name
  143091. */
  143092. constructor(name: string);
  143093. /**
  143094. * Gets the current class name
  143095. * @returns the class name
  143096. */
  143097. getClassName(): string;
  143098. /**
  143099. * Gets the color input component
  143100. */
  143101. get value(): NodeMaterialConnectionPoint;
  143102. /**
  143103. * Gets the cutoff input component
  143104. */
  143105. get cutoff(): NodeMaterialConnectionPoint;
  143106. protected _buildBlock(state: NodeMaterialBuildState): this;
  143107. }
  143108. }
  143109. declare module BABYLON {
  143110. /**
  143111. * Block used to test if the fragment shader is front facing
  143112. */
  143113. export class FrontFacingBlock extends NodeMaterialBlock {
  143114. /**
  143115. * Creates a new FrontFacingBlock
  143116. * @param name defines the block name
  143117. */
  143118. constructor(name: string);
  143119. /**
  143120. * Gets the current class name
  143121. * @returns the class name
  143122. */
  143123. getClassName(): string;
  143124. /**
  143125. * Gets the output component
  143126. */
  143127. get output(): NodeMaterialConnectionPoint;
  143128. protected _buildBlock(state: NodeMaterialBuildState): this;
  143129. }
  143130. }
  143131. declare module BABYLON {
  143132. /**
  143133. * Block used to get the derivative value on x and y of a given input
  143134. */
  143135. export class DerivativeBlock extends NodeMaterialBlock {
  143136. /**
  143137. * Create a new DerivativeBlock
  143138. * @param name defines the block name
  143139. */
  143140. constructor(name: string);
  143141. /**
  143142. * Gets the current class name
  143143. * @returns the class name
  143144. */
  143145. getClassName(): string;
  143146. /**
  143147. * Gets the input component
  143148. */
  143149. get input(): NodeMaterialConnectionPoint;
  143150. /**
  143151. * Gets the derivative output on x
  143152. */
  143153. get dx(): NodeMaterialConnectionPoint;
  143154. /**
  143155. * Gets the derivative output on y
  143156. */
  143157. get dy(): NodeMaterialConnectionPoint;
  143158. protected _buildBlock(state: NodeMaterialBuildState): this;
  143159. }
  143160. }
  143161. declare module BABYLON {
  143162. /**
  143163. * Block used to make gl_FragCoord available
  143164. */
  143165. export class FragCoordBlock extends NodeMaterialBlock {
  143166. /**
  143167. * Creates a new FragCoordBlock
  143168. * @param name defines the block name
  143169. */
  143170. constructor(name: string);
  143171. /**
  143172. * Gets the current class name
  143173. * @returns the class name
  143174. */
  143175. getClassName(): string;
  143176. /**
  143177. * Gets the xy component
  143178. */
  143179. get xy(): NodeMaterialConnectionPoint;
  143180. /**
  143181. * Gets the xyz component
  143182. */
  143183. get xyz(): NodeMaterialConnectionPoint;
  143184. /**
  143185. * Gets the xyzw component
  143186. */
  143187. get xyzw(): NodeMaterialConnectionPoint;
  143188. /**
  143189. * Gets the x component
  143190. */
  143191. get x(): NodeMaterialConnectionPoint;
  143192. /**
  143193. * Gets the y component
  143194. */
  143195. get y(): NodeMaterialConnectionPoint;
  143196. /**
  143197. * Gets the z component
  143198. */
  143199. get z(): NodeMaterialConnectionPoint;
  143200. /**
  143201. * Gets the w component
  143202. */
  143203. get output(): NodeMaterialConnectionPoint;
  143204. protected writeOutputs(state: NodeMaterialBuildState): string;
  143205. protected _buildBlock(state: NodeMaterialBuildState): this;
  143206. }
  143207. }
  143208. declare module BABYLON {
  143209. /**
  143210. * Block used to get the screen sizes
  143211. */
  143212. export class ScreenSizeBlock extends NodeMaterialBlock {
  143213. private _varName;
  143214. private _scene;
  143215. /**
  143216. * Creates a new ScreenSizeBlock
  143217. * @param name defines the block name
  143218. */
  143219. constructor(name: string);
  143220. /**
  143221. * Gets the current class name
  143222. * @returns the class name
  143223. */
  143224. getClassName(): string;
  143225. /**
  143226. * Gets the xy component
  143227. */
  143228. get xy(): NodeMaterialConnectionPoint;
  143229. /**
  143230. * Gets the x component
  143231. */
  143232. get x(): NodeMaterialConnectionPoint;
  143233. /**
  143234. * Gets the y component
  143235. */
  143236. get y(): NodeMaterialConnectionPoint;
  143237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143238. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143239. protected _buildBlock(state: NodeMaterialBuildState): this;
  143240. }
  143241. }
  143242. declare module BABYLON {
  143243. /**
  143244. * Block used to add support for scene fog
  143245. */
  143246. export class FogBlock extends NodeMaterialBlock {
  143247. private _fogDistanceName;
  143248. private _fogParameters;
  143249. /**
  143250. * Create a new FogBlock
  143251. * @param name defines the block name
  143252. */
  143253. constructor(name: string);
  143254. /**
  143255. * Gets the current class name
  143256. * @returns the class name
  143257. */
  143258. getClassName(): string;
  143259. /**
  143260. * Gets the world position input component
  143261. */
  143262. get worldPosition(): NodeMaterialConnectionPoint;
  143263. /**
  143264. * Gets the view input component
  143265. */
  143266. get view(): NodeMaterialConnectionPoint;
  143267. /**
  143268. * Gets the color input component
  143269. */
  143270. get input(): NodeMaterialConnectionPoint;
  143271. /**
  143272. * Gets the fog color input component
  143273. */
  143274. get fogColor(): NodeMaterialConnectionPoint;
  143275. /**
  143276. * Gets the output component
  143277. */
  143278. get output(): NodeMaterialConnectionPoint;
  143279. autoConfigure(material: NodeMaterial): void;
  143280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143281. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143282. protected _buildBlock(state: NodeMaterialBuildState): this;
  143283. }
  143284. }
  143285. declare module BABYLON {
  143286. /**
  143287. * Block used to add light in the fragment shader
  143288. */
  143289. export class LightBlock extends NodeMaterialBlock {
  143290. private _lightId;
  143291. /**
  143292. * Gets or sets the light associated with this block
  143293. */
  143294. light: Nullable<Light>;
  143295. /**
  143296. * Create a new LightBlock
  143297. * @param name defines the block name
  143298. */
  143299. constructor(name: string);
  143300. /**
  143301. * Gets the current class name
  143302. * @returns the class name
  143303. */
  143304. getClassName(): string;
  143305. /**
  143306. * Gets the world position input component
  143307. */
  143308. get worldPosition(): NodeMaterialConnectionPoint;
  143309. /**
  143310. * Gets the world normal input component
  143311. */
  143312. get worldNormal(): NodeMaterialConnectionPoint;
  143313. /**
  143314. * Gets the camera (or eye) position component
  143315. */
  143316. get cameraPosition(): NodeMaterialConnectionPoint;
  143317. /**
  143318. * Gets the glossiness component
  143319. */
  143320. get glossiness(): NodeMaterialConnectionPoint;
  143321. /**
  143322. * Gets the glossinness power component
  143323. */
  143324. get glossPower(): NodeMaterialConnectionPoint;
  143325. /**
  143326. * Gets the diffuse color component
  143327. */
  143328. get diffuseColor(): NodeMaterialConnectionPoint;
  143329. /**
  143330. * Gets the specular color component
  143331. */
  143332. get specularColor(): NodeMaterialConnectionPoint;
  143333. /**
  143334. * Gets the diffuse output component
  143335. */
  143336. get diffuseOutput(): NodeMaterialConnectionPoint;
  143337. /**
  143338. * Gets the specular output component
  143339. */
  143340. get specularOutput(): NodeMaterialConnectionPoint;
  143341. /**
  143342. * Gets the shadow output component
  143343. */
  143344. get shadow(): NodeMaterialConnectionPoint;
  143345. autoConfigure(material: NodeMaterial): void;
  143346. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143347. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143349. private _injectVertexCode;
  143350. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143351. serialize(): any;
  143352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143353. }
  143354. }
  143355. declare module BABYLON {
  143356. /**
  143357. * Block used to read a reflection texture from a sampler
  143358. */
  143359. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143360. /**
  143361. * Create a new ReflectionTextureBlock
  143362. * @param name defines the block name
  143363. */
  143364. constructor(name: string);
  143365. /**
  143366. * Gets the current class name
  143367. * @returns the class name
  143368. */
  143369. getClassName(): string;
  143370. /**
  143371. * Gets the world position input component
  143372. */
  143373. get position(): NodeMaterialConnectionPoint;
  143374. /**
  143375. * Gets the world position input component
  143376. */
  143377. get worldPosition(): NodeMaterialConnectionPoint;
  143378. /**
  143379. * Gets the world normal input component
  143380. */
  143381. get worldNormal(): NodeMaterialConnectionPoint;
  143382. /**
  143383. * Gets the world input component
  143384. */
  143385. get world(): NodeMaterialConnectionPoint;
  143386. /**
  143387. * Gets the camera (or eye) position component
  143388. */
  143389. get cameraPosition(): NodeMaterialConnectionPoint;
  143390. /**
  143391. * Gets the view input component
  143392. */
  143393. get view(): NodeMaterialConnectionPoint;
  143394. /**
  143395. * Gets the rgb output component
  143396. */
  143397. get rgb(): NodeMaterialConnectionPoint;
  143398. /**
  143399. * Gets the rgba output component
  143400. */
  143401. get rgba(): NodeMaterialConnectionPoint;
  143402. /**
  143403. * Gets the r output component
  143404. */
  143405. get r(): NodeMaterialConnectionPoint;
  143406. /**
  143407. * Gets the g output component
  143408. */
  143409. get g(): NodeMaterialConnectionPoint;
  143410. /**
  143411. * Gets the b output component
  143412. */
  143413. get b(): NodeMaterialConnectionPoint;
  143414. /**
  143415. * Gets the a output component
  143416. */
  143417. get a(): NodeMaterialConnectionPoint;
  143418. autoConfigure(material: NodeMaterial): void;
  143419. protected _buildBlock(state: NodeMaterialBuildState): this;
  143420. }
  143421. }
  143422. declare module BABYLON {
  143423. /**
  143424. * Block used to add 2 vectors
  143425. */
  143426. export class AddBlock extends NodeMaterialBlock {
  143427. /**
  143428. * Creates a new AddBlock
  143429. * @param name defines the block name
  143430. */
  143431. constructor(name: string);
  143432. /**
  143433. * Gets the current class name
  143434. * @returns the class name
  143435. */
  143436. getClassName(): string;
  143437. /**
  143438. * Gets the left operand input component
  143439. */
  143440. get left(): NodeMaterialConnectionPoint;
  143441. /**
  143442. * Gets the right operand input component
  143443. */
  143444. get right(): NodeMaterialConnectionPoint;
  143445. /**
  143446. * Gets the output component
  143447. */
  143448. get output(): NodeMaterialConnectionPoint;
  143449. protected _buildBlock(state: NodeMaterialBuildState): this;
  143450. }
  143451. }
  143452. declare module BABYLON {
  143453. /**
  143454. * Block used to scale a vector by a float
  143455. */
  143456. export class ScaleBlock extends NodeMaterialBlock {
  143457. /**
  143458. * Creates a new ScaleBlock
  143459. * @param name defines the block name
  143460. */
  143461. constructor(name: string);
  143462. /**
  143463. * Gets the current class name
  143464. * @returns the class name
  143465. */
  143466. getClassName(): string;
  143467. /**
  143468. * Gets the input component
  143469. */
  143470. get input(): NodeMaterialConnectionPoint;
  143471. /**
  143472. * Gets the factor input component
  143473. */
  143474. get factor(): NodeMaterialConnectionPoint;
  143475. /**
  143476. * Gets the output component
  143477. */
  143478. get output(): NodeMaterialConnectionPoint;
  143479. protected _buildBlock(state: NodeMaterialBuildState): this;
  143480. }
  143481. }
  143482. declare module BABYLON {
  143483. /**
  143484. * Block used to clamp a float
  143485. */
  143486. export class ClampBlock extends NodeMaterialBlock {
  143487. /** Gets or sets the minimum range */
  143488. minimum: number;
  143489. /** Gets or sets the maximum range */
  143490. maximum: number;
  143491. /**
  143492. * Creates a new ClampBlock
  143493. * @param name defines the block name
  143494. */
  143495. constructor(name: string);
  143496. /**
  143497. * Gets the current class name
  143498. * @returns the class name
  143499. */
  143500. getClassName(): string;
  143501. /**
  143502. * Gets the value input component
  143503. */
  143504. get value(): NodeMaterialConnectionPoint;
  143505. /**
  143506. * Gets the output component
  143507. */
  143508. get output(): NodeMaterialConnectionPoint;
  143509. protected _buildBlock(state: NodeMaterialBuildState): this;
  143510. protected _dumpPropertiesCode(): string;
  143511. serialize(): any;
  143512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143513. }
  143514. }
  143515. declare module BABYLON {
  143516. /**
  143517. * Block used to apply a cross product between 2 vectors
  143518. */
  143519. export class CrossBlock extends NodeMaterialBlock {
  143520. /**
  143521. * Creates a new CrossBlock
  143522. * @param name defines the block name
  143523. */
  143524. constructor(name: string);
  143525. /**
  143526. * Gets the current class name
  143527. * @returns the class name
  143528. */
  143529. getClassName(): string;
  143530. /**
  143531. * Gets the left operand input component
  143532. */
  143533. get left(): NodeMaterialConnectionPoint;
  143534. /**
  143535. * Gets the right operand input component
  143536. */
  143537. get right(): NodeMaterialConnectionPoint;
  143538. /**
  143539. * Gets the output component
  143540. */
  143541. get output(): NodeMaterialConnectionPoint;
  143542. protected _buildBlock(state: NodeMaterialBuildState): this;
  143543. }
  143544. }
  143545. declare module BABYLON {
  143546. /**
  143547. * Block used to apply a dot product between 2 vectors
  143548. */
  143549. export class DotBlock extends NodeMaterialBlock {
  143550. /**
  143551. * Creates a new DotBlock
  143552. * @param name defines the block name
  143553. */
  143554. constructor(name: string);
  143555. /**
  143556. * Gets the current class name
  143557. * @returns the class name
  143558. */
  143559. getClassName(): string;
  143560. /**
  143561. * Gets the left operand input component
  143562. */
  143563. get left(): NodeMaterialConnectionPoint;
  143564. /**
  143565. * Gets the right operand input component
  143566. */
  143567. get right(): NodeMaterialConnectionPoint;
  143568. /**
  143569. * Gets the output component
  143570. */
  143571. get output(): NodeMaterialConnectionPoint;
  143572. protected _buildBlock(state: NodeMaterialBuildState): this;
  143573. }
  143574. }
  143575. declare module BABYLON {
  143576. /**
  143577. * Block used to normalize a vector
  143578. */
  143579. export class NormalizeBlock extends NodeMaterialBlock {
  143580. /**
  143581. * Creates a new NormalizeBlock
  143582. * @param name defines the block name
  143583. */
  143584. constructor(name: string);
  143585. /**
  143586. * Gets the current class name
  143587. * @returns the class name
  143588. */
  143589. getClassName(): string;
  143590. /**
  143591. * Gets the input component
  143592. */
  143593. get input(): NodeMaterialConnectionPoint;
  143594. /**
  143595. * Gets the output component
  143596. */
  143597. get output(): NodeMaterialConnectionPoint;
  143598. protected _buildBlock(state: NodeMaterialBuildState): this;
  143599. }
  143600. }
  143601. declare module BABYLON {
  143602. /**
  143603. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143604. */
  143605. export class ColorMergerBlock extends NodeMaterialBlock {
  143606. /**
  143607. * Create a new ColorMergerBlock
  143608. * @param name defines the block name
  143609. */
  143610. constructor(name: string);
  143611. /**
  143612. * Gets the current class name
  143613. * @returns the class name
  143614. */
  143615. getClassName(): string;
  143616. /**
  143617. * Gets the rgb component (input)
  143618. */
  143619. get rgbIn(): NodeMaterialConnectionPoint;
  143620. /**
  143621. * Gets the r component (input)
  143622. */
  143623. get r(): NodeMaterialConnectionPoint;
  143624. /**
  143625. * Gets the g component (input)
  143626. */
  143627. get g(): NodeMaterialConnectionPoint;
  143628. /**
  143629. * Gets the b component (input)
  143630. */
  143631. get b(): NodeMaterialConnectionPoint;
  143632. /**
  143633. * Gets the a component (input)
  143634. */
  143635. get a(): NodeMaterialConnectionPoint;
  143636. /**
  143637. * Gets the rgba component (output)
  143638. */
  143639. get rgba(): NodeMaterialConnectionPoint;
  143640. /**
  143641. * Gets the rgb component (output)
  143642. */
  143643. get rgbOut(): NodeMaterialConnectionPoint;
  143644. /**
  143645. * Gets the rgb component (output)
  143646. * @deprecated Please use rgbOut instead.
  143647. */
  143648. get rgb(): NodeMaterialConnectionPoint;
  143649. protected _buildBlock(state: NodeMaterialBuildState): this;
  143650. }
  143651. }
  143652. declare module BABYLON {
  143653. /**
  143654. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143655. */
  143656. export class VectorSplitterBlock extends NodeMaterialBlock {
  143657. /**
  143658. * Create a new VectorSplitterBlock
  143659. * @param name defines the block name
  143660. */
  143661. constructor(name: string);
  143662. /**
  143663. * Gets the current class name
  143664. * @returns the class name
  143665. */
  143666. getClassName(): string;
  143667. /**
  143668. * Gets the xyzw component (input)
  143669. */
  143670. get xyzw(): NodeMaterialConnectionPoint;
  143671. /**
  143672. * Gets the xyz component (input)
  143673. */
  143674. get xyzIn(): NodeMaterialConnectionPoint;
  143675. /**
  143676. * Gets the xy component (input)
  143677. */
  143678. get xyIn(): NodeMaterialConnectionPoint;
  143679. /**
  143680. * Gets the xyz component (output)
  143681. */
  143682. get xyzOut(): NodeMaterialConnectionPoint;
  143683. /**
  143684. * Gets the xy component (output)
  143685. */
  143686. get xyOut(): NodeMaterialConnectionPoint;
  143687. /**
  143688. * Gets the x component (output)
  143689. */
  143690. get x(): NodeMaterialConnectionPoint;
  143691. /**
  143692. * Gets the y component (output)
  143693. */
  143694. get y(): NodeMaterialConnectionPoint;
  143695. /**
  143696. * Gets the z component (output)
  143697. */
  143698. get z(): NodeMaterialConnectionPoint;
  143699. /**
  143700. * Gets the w component (output)
  143701. */
  143702. get w(): NodeMaterialConnectionPoint;
  143703. protected _inputRename(name: string): string;
  143704. protected _outputRename(name: string): string;
  143705. protected _buildBlock(state: NodeMaterialBuildState): this;
  143706. }
  143707. }
  143708. declare module BABYLON {
  143709. /**
  143710. * Block used to lerp between 2 values
  143711. */
  143712. export class LerpBlock extends NodeMaterialBlock {
  143713. /**
  143714. * Creates a new LerpBlock
  143715. * @param name defines the block name
  143716. */
  143717. constructor(name: string);
  143718. /**
  143719. * Gets the current class name
  143720. * @returns the class name
  143721. */
  143722. getClassName(): string;
  143723. /**
  143724. * Gets the left operand input component
  143725. */
  143726. get left(): NodeMaterialConnectionPoint;
  143727. /**
  143728. * Gets the right operand input component
  143729. */
  143730. get right(): NodeMaterialConnectionPoint;
  143731. /**
  143732. * Gets the gradient operand input component
  143733. */
  143734. get gradient(): NodeMaterialConnectionPoint;
  143735. /**
  143736. * Gets the output component
  143737. */
  143738. get output(): NodeMaterialConnectionPoint;
  143739. protected _buildBlock(state: NodeMaterialBuildState): this;
  143740. }
  143741. }
  143742. declare module BABYLON {
  143743. /**
  143744. * Block used to divide 2 vectors
  143745. */
  143746. export class DivideBlock extends NodeMaterialBlock {
  143747. /**
  143748. * Creates a new DivideBlock
  143749. * @param name defines the block name
  143750. */
  143751. constructor(name: string);
  143752. /**
  143753. * Gets the current class name
  143754. * @returns the class name
  143755. */
  143756. getClassName(): string;
  143757. /**
  143758. * Gets the left operand input component
  143759. */
  143760. get left(): NodeMaterialConnectionPoint;
  143761. /**
  143762. * Gets the right operand input component
  143763. */
  143764. get right(): NodeMaterialConnectionPoint;
  143765. /**
  143766. * Gets the output component
  143767. */
  143768. get output(): NodeMaterialConnectionPoint;
  143769. protected _buildBlock(state: NodeMaterialBuildState): this;
  143770. }
  143771. }
  143772. declare module BABYLON {
  143773. /**
  143774. * Block used to subtract 2 vectors
  143775. */
  143776. export class SubtractBlock extends NodeMaterialBlock {
  143777. /**
  143778. * Creates a new SubtractBlock
  143779. * @param name defines the block name
  143780. */
  143781. constructor(name: string);
  143782. /**
  143783. * Gets the current class name
  143784. * @returns the class name
  143785. */
  143786. getClassName(): string;
  143787. /**
  143788. * Gets the left operand input component
  143789. */
  143790. get left(): NodeMaterialConnectionPoint;
  143791. /**
  143792. * Gets the right operand input component
  143793. */
  143794. get right(): NodeMaterialConnectionPoint;
  143795. /**
  143796. * Gets the output component
  143797. */
  143798. get output(): NodeMaterialConnectionPoint;
  143799. protected _buildBlock(state: NodeMaterialBuildState): this;
  143800. }
  143801. }
  143802. declare module BABYLON {
  143803. /**
  143804. * Block used to step a value
  143805. */
  143806. export class StepBlock extends NodeMaterialBlock {
  143807. /**
  143808. * Creates a new StepBlock
  143809. * @param name defines the block name
  143810. */
  143811. constructor(name: string);
  143812. /**
  143813. * Gets the current class name
  143814. * @returns the class name
  143815. */
  143816. getClassName(): string;
  143817. /**
  143818. * Gets the value operand input component
  143819. */
  143820. get value(): NodeMaterialConnectionPoint;
  143821. /**
  143822. * Gets the edge operand input component
  143823. */
  143824. get edge(): NodeMaterialConnectionPoint;
  143825. /**
  143826. * Gets the output component
  143827. */
  143828. get output(): NodeMaterialConnectionPoint;
  143829. protected _buildBlock(state: NodeMaterialBuildState): this;
  143830. }
  143831. }
  143832. declare module BABYLON {
  143833. /**
  143834. * Block used to get the opposite (1 - x) of a value
  143835. */
  143836. export class OneMinusBlock extends NodeMaterialBlock {
  143837. /**
  143838. * Creates a new OneMinusBlock
  143839. * @param name defines the block name
  143840. */
  143841. constructor(name: string);
  143842. /**
  143843. * Gets the current class name
  143844. * @returns the class name
  143845. */
  143846. getClassName(): string;
  143847. /**
  143848. * Gets the input component
  143849. */
  143850. get input(): NodeMaterialConnectionPoint;
  143851. /**
  143852. * Gets the output component
  143853. */
  143854. get output(): NodeMaterialConnectionPoint;
  143855. protected _buildBlock(state: NodeMaterialBuildState): this;
  143856. }
  143857. }
  143858. declare module BABYLON {
  143859. /**
  143860. * Block used to get the view direction
  143861. */
  143862. export class ViewDirectionBlock extends NodeMaterialBlock {
  143863. /**
  143864. * Creates a new ViewDirectionBlock
  143865. * @param name defines the block name
  143866. */
  143867. constructor(name: string);
  143868. /**
  143869. * Gets the current class name
  143870. * @returns the class name
  143871. */
  143872. getClassName(): string;
  143873. /**
  143874. * Gets the world position component
  143875. */
  143876. get worldPosition(): NodeMaterialConnectionPoint;
  143877. /**
  143878. * Gets the camera position component
  143879. */
  143880. get cameraPosition(): NodeMaterialConnectionPoint;
  143881. /**
  143882. * Gets the output component
  143883. */
  143884. get output(): NodeMaterialConnectionPoint;
  143885. autoConfigure(material: NodeMaterial): void;
  143886. protected _buildBlock(state: NodeMaterialBuildState): this;
  143887. }
  143888. }
  143889. declare module BABYLON {
  143890. /**
  143891. * Block used to compute fresnel value
  143892. */
  143893. export class FresnelBlock extends NodeMaterialBlock {
  143894. /**
  143895. * Create a new FresnelBlock
  143896. * @param name defines the block name
  143897. */
  143898. constructor(name: string);
  143899. /**
  143900. * Gets the current class name
  143901. * @returns the class name
  143902. */
  143903. getClassName(): string;
  143904. /**
  143905. * Gets the world normal input component
  143906. */
  143907. get worldNormal(): NodeMaterialConnectionPoint;
  143908. /**
  143909. * Gets the view direction input component
  143910. */
  143911. get viewDirection(): NodeMaterialConnectionPoint;
  143912. /**
  143913. * Gets the bias input component
  143914. */
  143915. get bias(): NodeMaterialConnectionPoint;
  143916. /**
  143917. * Gets the camera (or eye) position component
  143918. */
  143919. get power(): NodeMaterialConnectionPoint;
  143920. /**
  143921. * Gets the fresnel output component
  143922. */
  143923. get fresnel(): NodeMaterialConnectionPoint;
  143924. autoConfigure(material: NodeMaterial): void;
  143925. protected _buildBlock(state: NodeMaterialBuildState): this;
  143926. }
  143927. }
  143928. declare module BABYLON {
  143929. /**
  143930. * Block used to get the max of 2 values
  143931. */
  143932. export class MaxBlock extends NodeMaterialBlock {
  143933. /**
  143934. * Creates a new MaxBlock
  143935. * @param name defines the block name
  143936. */
  143937. constructor(name: string);
  143938. /**
  143939. * Gets the current class name
  143940. * @returns the class name
  143941. */
  143942. getClassName(): string;
  143943. /**
  143944. * Gets the left operand input component
  143945. */
  143946. get left(): NodeMaterialConnectionPoint;
  143947. /**
  143948. * Gets the right operand input component
  143949. */
  143950. get right(): NodeMaterialConnectionPoint;
  143951. /**
  143952. * Gets the output component
  143953. */
  143954. get output(): NodeMaterialConnectionPoint;
  143955. protected _buildBlock(state: NodeMaterialBuildState): this;
  143956. }
  143957. }
  143958. declare module BABYLON {
  143959. /**
  143960. * Block used to get the min of 2 values
  143961. */
  143962. export class MinBlock extends NodeMaterialBlock {
  143963. /**
  143964. * Creates a new MinBlock
  143965. * @param name defines the block name
  143966. */
  143967. constructor(name: string);
  143968. /**
  143969. * Gets the current class name
  143970. * @returns the class name
  143971. */
  143972. getClassName(): string;
  143973. /**
  143974. * Gets the left operand input component
  143975. */
  143976. get left(): NodeMaterialConnectionPoint;
  143977. /**
  143978. * Gets the right operand input component
  143979. */
  143980. get right(): NodeMaterialConnectionPoint;
  143981. /**
  143982. * Gets the output component
  143983. */
  143984. get output(): NodeMaterialConnectionPoint;
  143985. protected _buildBlock(state: NodeMaterialBuildState): this;
  143986. }
  143987. }
  143988. declare module BABYLON {
  143989. /**
  143990. * Block used to get the distance between 2 values
  143991. */
  143992. export class DistanceBlock extends NodeMaterialBlock {
  143993. /**
  143994. * Creates a new DistanceBlock
  143995. * @param name defines the block name
  143996. */
  143997. constructor(name: string);
  143998. /**
  143999. * Gets the current class name
  144000. * @returns the class name
  144001. */
  144002. getClassName(): string;
  144003. /**
  144004. * Gets the left operand input component
  144005. */
  144006. get left(): NodeMaterialConnectionPoint;
  144007. /**
  144008. * Gets the right operand input component
  144009. */
  144010. get right(): NodeMaterialConnectionPoint;
  144011. /**
  144012. * Gets the output component
  144013. */
  144014. get output(): NodeMaterialConnectionPoint;
  144015. protected _buildBlock(state: NodeMaterialBuildState): this;
  144016. }
  144017. }
  144018. declare module BABYLON {
  144019. /**
  144020. * Block used to get the length of a vector
  144021. */
  144022. export class LengthBlock extends NodeMaterialBlock {
  144023. /**
  144024. * Creates a new LengthBlock
  144025. * @param name defines the block name
  144026. */
  144027. constructor(name: string);
  144028. /**
  144029. * Gets the current class name
  144030. * @returns the class name
  144031. */
  144032. getClassName(): string;
  144033. /**
  144034. * Gets the value input component
  144035. */
  144036. get value(): NodeMaterialConnectionPoint;
  144037. /**
  144038. * Gets the output component
  144039. */
  144040. get output(): NodeMaterialConnectionPoint;
  144041. protected _buildBlock(state: NodeMaterialBuildState): this;
  144042. }
  144043. }
  144044. declare module BABYLON {
  144045. /**
  144046. * Block used to get negative version of a value (i.e. x * -1)
  144047. */
  144048. export class NegateBlock extends NodeMaterialBlock {
  144049. /**
  144050. * Creates a new NegateBlock
  144051. * @param name defines the block name
  144052. */
  144053. constructor(name: string);
  144054. /**
  144055. * Gets the current class name
  144056. * @returns the class name
  144057. */
  144058. getClassName(): string;
  144059. /**
  144060. * Gets the value input component
  144061. */
  144062. get value(): NodeMaterialConnectionPoint;
  144063. /**
  144064. * Gets the output component
  144065. */
  144066. get output(): NodeMaterialConnectionPoint;
  144067. protected _buildBlock(state: NodeMaterialBuildState): this;
  144068. }
  144069. }
  144070. declare module BABYLON {
  144071. /**
  144072. * Block used to get the value of the first parameter raised to the power of the second
  144073. */
  144074. export class PowBlock extends NodeMaterialBlock {
  144075. /**
  144076. * Creates a new PowBlock
  144077. * @param name defines the block name
  144078. */
  144079. constructor(name: string);
  144080. /**
  144081. * Gets the current class name
  144082. * @returns the class name
  144083. */
  144084. getClassName(): string;
  144085. /**
  144086. * Gets the value operand input component
  144087. */
  144088. get value(): NodeMaterialConnectionPoint;
  144089. /**
  144090. * Gets the power operand input component
  144091. */
  144092. get power(): NodeMaterialConnectionPoint;
  144093. /**
  144094. * Gets the output component
  144095. */
  144096. get output(): NodeMaterialConnectionPoint;
  144097. protected _buildBlock(state: NodeMaterialBuildState): this;
  144098. }
  144099. }
  144100. declare module BABYLON {
  144101. /**
  144102. * Block used to get a random number
  144103. */
  144104. export class RandomNumberBlock extends NodeMaterialBlock {
  144105. /**
  144106. * Creates a new RandomNumberBlock
  144107. * @param name defines the block name
  144108. */
  144109. constructor(name: string);
  144110. /**
  144111. * Gets the current class name
  144112. * @returns the class name
  144113. */
  144114. getClassName(): string;
  144115. /**
  144116. * Gets the seed input component
  144117. */
  144118. get seed(): NodeMaterialConnectionPoint;
  144119. /**
  144120. * Gets the output component
  144121. */
  144122. get output(): NodeMaterialConnectionPoint;
  144123. protected _buildBlock(state: NodeMaterialBuildState): this;
  144124. }
  144125. }
  144126. declare module BABYLON {
  144127. /**
  144128. * Block used to compute arc tangent of 2 values
  144129. */
  144130. export class ArcTan2Block extends NodeMaterialBlock {
  144131. /**
  144132. * Creates a new ArcTan2Block
  144133. * @param name defines the block name
  144134. */
  144135. constructor(name: string);
  144136. /**
  144137. * Gets the current class name
  144138. * @returns the class name
  144139. */
  144140. getClassName(): string;
  144141. /**
  144142. * Gets the x operand input component
  144143. */
  144144. get x(): NodeMaterialConnectionPoint;
  144145. /**
  144146. * Gets the y operand input component
  144147. */
  144148. get y(): NodeMaterialConnectionPoint;
  144149. /**
  144150. * Gets the output component
  144151. */
  144152. get output(): NodeMaterialConnectionPoint;
  144153. protected _buildBlock(state: NodeMaterialBuildState): this;
  144154. }
  144155. }
  144156. declare module BABYLON {
  144157. /**
  144158. * Block used to smooth step a value
  144159. */
  144160. export class SmoothStepBlock extends NodeMaterialBlock {
  144161. /**
  144162. * Creates a new SmoothStepBlock
  144163. * @param name defines the block name
  144164. */
  144165. constructor(name: string);
  144166. /**
  144167. * Gets the current class name
  144168. * @returns the class name
  144169. */
  144170. getClassName(): string;
  144171. /**
  144172. * Gets the value operand input component
  144173. */
  144174. get value(): NodeMaterialConnectionPoint;
  144175. /**
  144176. * Gets the first edge operand input component
  144177. */
  144178. get edge0(): NodeMaterialConnectionPoint;
  144179. /**
  144180. * Gets the second edge operand input component
  144181. */
  144182. get edge1(): NodeMaterialConnectionPoint;
  144183. /**
  144184. * Gets the output component
  144185. */
  144186. get output(): NodeMaterialConnectionPoint;
  144187. protected _buildBlock(state: NodeMaterialBuildState): this;
  144188. }
  144189. }
  144190. declare module BABYLON {
  144191. /**
  144192. * Block used to get the reciprocal (1 / x) of a value
  144193. */
  144194. export class ReciprocalBlock extends NodeMaterialBlock {
  144195. /**
  144196. * Creates a new ReciprocalBlock
  144197. * @param name defines the block name
  144198. */
  144199. constructor(name: string);
  144200. /**
  144201. * Gets the current class name
  144202. * @returns the class name
  144203. */
  144204. getClassName(): string;
  144205. /**
  144206. * Gets the input component
  144207. */
  144208. get input(): NodeMaterialConnectionPoint;
  144209. /**
  144210. * Gets the output component
  144211. */
  144212. get output(): NodeMaterialConnectionPoint;
  144213. protected _buildBlock(state: NodeMaterialBuildState): this;
  144214. }
  144215. }
  144216. declare module BABYLON {
  144217. /**
  144218. * Block used to replace a color by another one
  144219. */
  144220. export class ReplaceColorBlock extends NodeMaterialBlock {
  144221. /**
  144222. * Creates a new ReplaceColorBlock
  144223. * @param name defines the block name
  144224. */
  144225. constructor(name: string);
  144226. /**
  144227. * Gets the current class name
  144228. * @returns the class name
  144229. */
  144230. getClassName(): string;
  144231. /**
  144232. * Gets the value input component
  144233. */
  144234. get value(): NodeMaterialConnectionPoint;
  144235. /**
  144236. * Gets the reference input component
  144237. */
  144238. get reference(): NodeMaterialConnectionPoint;
  144239. /**
  144240. * Gets the distance input component
  144241. */
  144242. get distance(): NodeMaterialConnectionPoint;
  144243. /**
  144244. * Gets the replacement input component
  144245. */
  144246. get replacement(): NodeMaterialConnectionPoint;
  144247. /**
  144248. * Gets the output component
  144249. */
  144250. get output(): NodeMaterialConnectionPoint;
  144251. protected _buildBlock(state: NodeMaterialBuildState): this;
  144252. }
  144253. }
  144254. declare module BABYLON {
  144255. /**
  144256. * Block used to posterize a value
  144257. * @see https://en.wikipedia.org/wiki/Posterization
  144258. */
  144259. export class PosterizeBlock extends NodeMaterialBlock {
  144260. /**
  144261. * Creates a new PosterizeBlock
  144262. * @param name defines the block name
  144263. */
  144264. constructor(name: string);
  144265. /**
  144266. * Gets the current class name
  144267. * @returns the class name
  144268. */
  144269. getClassName(): string;
  144270. /**
  144271. * Gets the value input component
  144272. */
  144273. get value(): NodeMaterialConnectionPoint;
  144274. /**
  144275. * Gets the steps input component
  144276. */
  144277. get steps(): NodeMaterialConnectionPoint;
  144278. /**
  144279. * Gets the output component
  144280. */
  144281. get output(): NodeMaterialConnectionPoint;
  144282. protected _buildBlock(state: NodeMaterialBuildState): this;
  144283. }
  144284. }
  144285. declare module BABYLON {
  144286. /**
  144287. * Operations supported by the Wave block
  144288. */
  144289. export enum WaveBlockKind {
  144290. /** SawTooth */
  144291. SawTooth = 0,
  144292. /** Square */
  144293. Square = 1,
  144294. /** Triangle */
  144295. Triangle = 2
  144296. }
  144297. /**
  144298. * Block used to apply wave operation to floats
  144299. */
  144300. export class WaveBlock extends NodeMaterialBlock {
  144301. /**
  144302. * Gets or sets the kibnd of wave to be applied by the block
  144303. */
  144304. kind: WaveBlockKind;
  144305. /**
  144306. * Creates a new WaveBlock
  144307. * @param name defines the block name
  144308. */
  144309. constructor(name: string);
  144310. /**
  144311. * Gets the current class name
  144312. * @returns the class name
  144313. */
  144314. getClassName(): string;
  144315. /**
  144316. * Gets the input component
  144317. */
  144318. get input(): NodeMaterialConnectionPoint;
  144319. /**
  144320. * Gets the output component
  144321. */
  144322. get output(): NodeMaterialConnectionPoint;
  144323. protected _buildBlock(state: NodeMaterialBuildState): this;
  144324. serialize(): any;
  144325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144326. }
  144327. }
  144328. declare module BABYLON {
  144329. /**
  144330. * Class used to store a color step for the GradientBlock
  144331. */
  144332. export class GradientBlockColorStep {
  144333. private _step;
  144334. /**
  144335. * Gets value indicating which step this color is associated with (between 0 and 1)
  144336. */
  144337. get step(): number;
  144338. /**
  144339. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144340. */
  144341. set step(val: number);
  144342. private _color;
  144343. /**
  144344. * Gets the color associated with this step
  144345. */
  144346. get color(): Color3;
  144347. /**
  144348. * Sets the color associated with this step
  144349. */
  144350. set color(val: Color3);
  144351. /**
  144352. * Creates a new GradientBlockColorStep
  144353. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144354. * @param color defines the color associated with this step
  144355. */
  144356. constructor(step: number, color: Color3);
  144357. }
  144358. /**
  144359. * Block used to return a color from a gradient based on an input value between 0 and 1
  144360. */
  144361. export class GradientBlock extends NodeMaterialBlock {
  144362. /**
  144363. * Gets or sets the list of color steps
  144364. */
  144365. colorSteps: GradientBlockColorStep[];
  144366. /** Gets an observable raised when the value is changed */
  144367. onValueChangedObservable: Observable<GradientBlock>;
  144368. /** calls observable when the value is changed*/
  144369. colorStepsUpdated(): void;
  144370. /**
  144371. * Creates a new GradientBlock
  144372. * @param name defines the block name
  144373. */
  144374. constructor(name: string);
  144375. /**
  144376. * Gets the current class name
  144377. * @returns the class name
  144378. */
  144379. getClassName(): string;
  144380. /**
  144381. * Gets the gradient input component
  144382. */
  144383. get gradient(): NodeMaterialConnectionPoint;
  144384. /**
  144385. * Gets the output component
  144386. */
  144387. get output(): NodeMaterialConnectionPoint;
  144388. private _writeColorConstant;
  144389. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144390. serialize(): any;
  144391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144392. protected _dumpPropertiesCode(): string;
  144393. }
  144394. }
  144395. declare module BABYLON {
  144396. /**
  144397. * Block used to normalize lerp between 2 values
  144398. */
  144399. export class NLerpBlock extends NodeMaterialBlock {
  144400. /**
  144401. * Creates a new NLerpBlock
  144402. * @param name defines the block name
  144403. */
  144404. constructor(name: string);
  144405. /**
  144406. * Gets the current class name
  144407. * @returns the class name
  144408. */
  144409. getClassName(): string;
  144410. /**
  144411. * Gets the left operand input component
  144412. */
  144413. get left(): NodeMaterialConnectionPoint;
  144414. /**
  144415. * Gets the right operand input component
  144416. */
  144417. get right(): NodeMaterialConnectionPoint;
  144418. /**
  144419. * Gets the gradient operand input component
  144420. */
  144421. get gradient(): NodeMaterialConnectionPoint;
  144422. /**
  144423. * Gets the output component
  144424. */
  144425. get output(): NodeMaterialConnectionPoint;
  144426. protected _buildBlock(state: NodeMaterialBuildState): this;
  144427. }
  144428. }
  144429. declare module BABYLON {
  144430. /**
  144431. * block used to Generate a Worley Noise 3D Noise Pattern
  144432. */
  144433. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144434. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144435. manhattanDistance: boolean;
  144436. /**
  144437. * Creates a new WorleyNoise3DBlock
  144438. * @param name defines the block name
  144439. */
  144440. constructor(name: string);
  144441. /**
  144442. * Gets the current class name
  144443. * @returns the class name
  144444. */
  144445. getClassName(): string;
  144446. /**
  144447. * Gets the seed input component
  144448. */
  144449. get seed(): NodeMaterialConnectionPoint;
  144450. /**
  144451. * Gets the jitter input component
  144452. */
  144453. get jitter(): NodeMaterialConnectionPoint;
  144454. /**
  144455. * Gets the output component
  144456. */
  144457. get output(): NodeMaterialConnectionPoint;
  144458. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144459. /**
  144460. * Exposes the properties to the UI?
  144461. */
  144462. protected _dumpPropertiesCode(): string;
  144463. /**
  144464. * Exposes the properties to the Seralize?
  144465. */
  144466. serialize(): any;
  144467. /**
  144468. * Exposes the properties to the deseralize?
  144469. */
  144470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144471. }
  144472. }
  144473. declare module BABYLON {
  144474. /**
  144475. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144476. */
  144477. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144478. /**
  144479. * Creates a new SimplexPerlin3DBlock
  144480. * @param name defines the block name
  144481. */
  144482. constructor(name: string);
  144483. /**
  144484. * Gets the current class name
  144485. * @returns the class name
  144486. */
  144487. getClassName(): string;
  144488. /**
  144489. * Gets the seed operand input component
  144490. */
  144491. get seed(): NodeMaterialConnectionPoint;
  144492. /**
  144493. * Gets the output component
  144494. */
  144495. get output(): NodeMaterialConnectionPoint;
  144496. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144497. }
  144498. }
  144499. declare module BABYLON {
  144500. /**
  144501. * Block used to blend normals
  144502. */
  144503. export class NormalBlendBlock extends NodeMaterialBlock {
  144504. /**
  144505. * Creates a new NormalBlendBlock
  144506. * @param name defines the block name
  144507. */
  144508. constructor(name: string);
  144509. /**
  144510. * Gets the current class name
  144511. * @returns the class name
  144512. */
  144513. getClassName(): string;
  144514. /**
  144515. * Gets the first input component
  144516. */
  144517. get normalMap0(): NodeMaterialConnectionPoint;
  144518. /**
  144519. * Gets the second input component
  144520. */
  144521. get normalMap1(): NodeMaterialConnectionPoint;
  144522. /**
  144523. * Gets the output component
  144524. */
  144525. get output(): NodeMaterialConnectionPoint;
  144526. protected _buildBlock(state: NodeMaterialBuildState): this;
  144527. }
  144528. }
  144529. declare module BABYLON {
  144530. /**
  144531. * Block used to rotate a 2d vector by a given angle
  144532. */
  144533. export class Rotate2dBlock extends NodeMaterialBlock {
  144534. /**
  144535. * Creates a new Rotate2dBlock
  144536. * @param name defines the block name
  144537. */
  144538. constructor(name: string);
  144539. /**
  144540. * Gets the current class name
  144541. * @returns the class name
  144542. */
  144543. getClassName(): string;
  144544. /**
  144545. * Gets the input vector
  144546. */
  144547. get input(): NodeMaterialConnectionPoint;
  144548. /**
  144549. * Gets the input angle
  144550. */
  144551. get angle(): NodeMaterialConnectionPoint;
  144552. /**
  144553. * Gets the output component
  144554. */
  144555. get output(): NodeMaterialConnectionPoint;
  144556. autoConfigure(material: NodeMaterial): void;
  144557. protected _buildBlock(state: NodeMaterialBuildState): this;
  144558. }
  144559. }
  144560. declare module BABYLON {
  144561. /**
  144562. * Block used to get the reflected vector from a direction and a normal
  144563. */
  144564. export class ReflectBlock extends NodeMaterialBlock {
  144565. /**
  144566. * Creates a new ReflectBlock
  144567. * @param name defines the block name
  144568. */
  144569. constructor(name: string);
  144570. /**
  144571. * Gets the current class name
  144572. * @returns the class name
  144573. */
  144574. getClassName(): string;
  144575. /**
  144576. * Gets the incident component
  144577. */
  144578. get incident(): NodeMaterialConnectionPoint;
  144579. /**
  144580. * Gets the normal component
  144581. */
  144582. get normal(): NodeMaterialConnectionPoint;
  144583. /**
  144584. * Gets the output component
  144585. */
  144586. get output(): NodeMaterialConnectionPoint;
  144587. protected _buildBlock(state: NodeMaterialBuildState): this;
  144588. }
  144589. }
  144590. declare module BABYLON {
  144591. /**
  144592. * Block used to get the refracted vector from a direction and a normal
  144593. */
  144594. export class RefractBlock extends NodeMaterialBlock {
  144595. /**
  144596. * Creates a new RefractBlock
  144597. * @param name defines the block name
  144598. */
  144599. constructor(name: string);
  144600. /**
  144601. * Gets the current class name
  144602. * @returns the class name
  144603. */
  144604. getClassName(): string;
  144605. /**
  144606. * Gets the incident component
  144607. */
  144608. get incident(): NodeMaterialConnectionPoint;
  144609. /**
  144610. * Gets the normal component
  144611. */
  144612. get normal(): NodeMaterialConnectionPoint;
  144613. /**
  144614. * Gets the index of refraction component
  144615. */
  144616. get ior(): NodeMaterialConnectionPoint;
  144617. /**
  144618. * Gets the output component
  144619. */
  144620. get output(): NodeMaterialConnectionPoint;
  144621. protected _buildBlock(state: NodeMaterialBuildState): this;
  144622. }
  144623. }
  144624. declare module BABYLON {
  144625. /**
  144626. * Block used to desaturate a color
  144627. */
  144628. export class DesaturateBlock extends NodeMaterialBlock {
  144629. /**
  144630. * Creates a new DesaturateBlock
  144631. * @param name defines the block name
  144632. */
  144633. constructor(name: string);
  144634. /**
  144635. * Gets the current class name
  144636. * @returns the class name
  144637. */
  144638. getClassName(): string;
  144639. /**
  144640. * Gets the color operand input component
  144641. */
  144642. get color(): NodeMaterialConnectionPoint;
  144643. /**
  144644. * Gets the level operand input component
  144645. */
  144646. get level(): NodeMaterialConnectionPoint;
  144647. /**
  144648. * Gets the output component
  144649. */
  144650. get output(): NodeMaterialConnectionPoint;
  144651. protected _buildBlock(state: NodeMaterialBuildState): this;
  144652. }
  144653. }
  144654. declare module BABYLON {
  144655. /**
  144656. * Block used to implement the ambient occlusion module of the PBR material
  144657. */
  144658. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144659. /**
  144660. * Create a new AmbientOcclusionBlock
  144661. * @param name defines the block name
  144662. */
  144663. constructor(name: string);
  144664. /**
  144665. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144666. */
  144667. useAmbientInGrayScale: boolean;
  144668. /**
  144669. * Initialize the block and prepare the context for build
  144670. * @param state defines the state that will be used for the build
  144671. */
  144672. initialize(state: NodeMaterialBuildState): void;
  144673. /**
  144674. * Gets the current class name
  144675. * @returns the class name
  144676. */
  144677. getClassName(): string;
  144678. /**
  144679. * Gets the texture input component
  144680. */
  144681. get texture(): NodeMaterialConnectionPoint;
  144682. /**
  144683. * Gets the texture intensity component
  144684. */
  144685. get intensity(): NodeMaterialConnectionPoint;
  144686. /**
  144687. * Gets the direct light intensity input component
  144688. */
  144689. get directLightIntensity(): NodeMaterialConnectionPoint;
  144690. /**
  144691. * Gets the ambient occlusion object output component
  144692. */
  144693. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144694. /**
  144695. * Gets the main code of the block (fragment side)
  144696. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144697. * @returns the shader code
  144698. */
  144699. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144700. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144701. protected _buildBlock(state: NodeMaterialBuildState): this;
  144702. protected _dumpPropertiesCode(): string;
  144703. serialize(): any;
  144704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144705. }
  144706. }
  144707. declare module BABYLON {
  144708. /**
  144709. * Block used to implement the reflection module of the PBR material
  144710. */
  144711. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144712. /** @hidden */
  144713. _defineLODReflectionAlpha: string;
  144714. /** @hidden */
  144715. _defineLinearSpecularReflection: string;
  144716. private _vEnvironmentIrradianceName;
  144717. /** @hidden */
  144718. _vReflectionMicrosurfaceInfosName: string;
  144719. /** @hidden */
  144720. _vReflectionInfosName: string;
  144721. /** @hidden */
  144722. _vReflectionFilteringInfoName: string;
  144723. private _scene;
  144724. /**
  144725. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144726. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144727. * It's less burden on the user side in the editor part.
  144728. */
  144729. /** @hidden */
  144730. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144731. /** @hidden */
  144732. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144733. /** @hidden */
  144734. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144735. /**
  144736. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144737. * diffuse part of the IBL.
  144738. */
  144739. useSphericalHarmonics: boolean;
  144740. /**
  144741. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144742. */
  144743. forceIrradianceInFragment: boolean;
  144744. /**
  144745. * Create a new ReflectionBlock
  144746. * @param name defines the block name
  144747. */
  144748. constructor(name: string);
  144749. /**
  144750. * Gets the current class name
  144751. * @returns the class name
  144752. */
  144753. getClassName(): string;
  144754. /**
  144755. * Gets the position input component
  144756. */
  144757. get position(): NodeMaterialConnectionPoint;
  144758. /**
  144759. * Gets the world position input component
  144760. */
  144761. get worldPosition(): NodeMaterialConnectionPoint;
  144762. /**
  144763. * Gets the world normal input component
  144764. */
  144765. get worldNormal(): NodeMaterialConnectionPoint;
  144766. /**
  144767. * Gets the world input component
  144768. */
  144769. get world(): NodeMaterialConnectionPoint;
  144770. /**
  144771. * Gets the camera (or eye) position component
  144772. */
  144773. get cameraPosition(): NodeMaterialConnectionPoint;
  144774. /**
  144775. * Gets the view input component
  144776. */
  144777. get view(): NodeMaterialConnectionPoint;
  144778. /**
  144779. * Gets the color input component
  144780. */
  144781. get color(): NodeMaterialConnectionPoint;
  144782. /**
  144783. * Gets the reflection object output component
  144784. */
  144785. get reflection(): NodeMaterialConnectionPoint;
  144786. /**
  144787. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144788. */
  144789. get hasTexture(): boolean;
  144790. /**
  144791. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144792. */
  144793. get reflectionColor(): string;
  144794. protected _getTexture(): Nullable<BaseTexture>;
  144795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144796. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144797. /**
  144798. * Gets the code to inject in the vertex shader
  144799. * @param state current state of the node material building
  144800. * @returns the shader code
  144801. */
  144802. handleVertexSide(state: NodeMaterialBuildState): string;
  144803. /**
  144804. * Gets the main code of the block (fragment side)
  144805. * @param state current state of the node material building
  144806. * @param normalVarName name of the existing variable corresponding to the normal
  144807. * @returns the shader code
  144808. */
  144809. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144810. protected _buildBlock(state: NodeMaterialBuildState): this;
  144811. protected _dumpPropertiesCode(): string;
  144812. serialize(): any;
  144813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144814. }
  144815. }
  144816. declare module BABYLON {
  144817. /**
  144818. * Block used to implement the sheen module of the PBR material
  144819. */
  144820. export class SheenBlock extends NodeMaterialBlock {
  144821. /**
  144822. * Create a new SheenBlock
  144823. * @param name defines the block name
  144824. */
  144825. constructor(name: string);
  144826. /**
  144827. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144828. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144829. * making it easier to setup and tweak the effect
  144830. */
  144831. albedoScaling: boolean;
  144832. /**
  144833. * Defines if the sheen is linked to the sheen color.
  144834. */
  144835. linkSheenWithAlbedo: boolean;
  144836. /**
  144837. * Initialize the block and prepare the context for build
  144838. * @param state defines the state that will be used for the build
  144839. */
  144840. initialize(state: NodeMaterialBuildState): void;
  144841. /**
  144842. * Gets the current class name
  144843. * @returns the class name
  144844. */
  144845. getClassName(): string;
  144846. /**
  144847. * Gets the intensity input component
  144848. */
  144849. get intensity(): NodeMaterialConnectionPoint;
  144850. /**
  144851. * Gets the color input component
  144852. */
  144853. get color(): NodeMaterialConnectionPoint;
  144854. /**
  144855. * Gets the roughness input component
  144856. */
  144857. get roughness(): NodeMaterialConnectionPoint;
  144858. /**
  144859. * Gets the sheen object output component
  144860. */
  144861. get sheen(): NodeMaterialConnectionPoint;
  144862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144863. /**
  144864. * Gets the main code of the block (fragment side)
  144865. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144866. * @returns the shader code
  144867. */
  144868. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144869. protected _buildBlock(state: NodeMaterialBuildState): this;
  144870. protected _dumpPropertiesCode(): string;
  144871. serialize(): any;
  144872. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144873. }
  144874. }
  144875. declare module BABYLON {
  144876. /**
  144877. * Block used to implement the reflectivity module of the PBR material
  144878. */
  144879. export class ReflectivityBlock extends NodeMaterialBlock {
  144880. private _metallicReflectanceColor;
  144881. private _metallicF0Factor;
  144882. /** @hidden */
  144883. _vMetallicReflectanceFactorsName: string;
  144884. /**
  144885. * The property below is set by the main PBR block prior to calling methods of this class.
  144886. */
  144887. /** @hidden */
  144888. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144889. /**
  144890. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144891. */
  144892. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144893. /**
  144894. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144895. */
  144896. useMetallnessFromMetallicTextureBlue: boolean;
  144897. /**
  144898. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144899. */
  144900. useRoughnessFromMetallicTextureAlpha: boolean;
  144901. /**
  144902. * Specifies if the metallic texture contains the roughness information in its green channel.
  144903. */
  144904. useRoughnessFromMetallicTextureGreen: boolean;
  144905. /**
  144906. * Create a new ReflectivityBlock
  144907. * @param name defines the block name
  144908. */
  144909. constructor(name: string);
  144910. /**
  144911. * Initialize the block and prepare the context for build
  144912. * @param state defines the state that will be used for the build
  144913. */
  144914. initialize(state: NodeMaterialBuildState): void;
  144915. /**
  144916. * Gets the current class name
  144917. * @returns the class name
  144918. */
  144919. getClassName(): string;
  144920. /**
  144921. * Gets the metallic input component
  144922. */
  144923. get metallic(): NodeMaterialConnectionPoint;
  144924. /**
  144925. * Gets the roughness input component
  144926. */
  144927. get roughness(): NodeMaterialConnectionPoint;
  144928. /**
  144929. * Gets the texture input component
  144930. */
  144931. get texture(): NodeMaterialConnectionPoint;
  144932. /**
  144933. * Gets the reflectivity object output component
  144934. */
  144935. get reflectivity(): NodeMaterialConnectionPoint;
  144936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144937. /**
  144938. * Gets the main code of the block (fragment side)
  144939. * @param state current state of the node material building
  144940. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144941. * @returns the shader code
  144942. */
  144943. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144945. protected _buildBlock(state: NodeMaterialBuildState): this;
  144946. protected _dumpPropertiesCode(): string;
  144947. serialize(): any;
  144948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144949. }
  144950. }
  144951. declare module BABYLON {
  144952. /**
  144953. * Block used to implement the anisotropy module of the PBR material
  144954. */
  144955. export class AnisotropyBlock extends NodeMaterialBlock {
  144956. /**
  144957. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144958. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144959. * It's less burden on the user side in the editor part.
  144960. */
  144961. /** @hidden */
  144962. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144963. /** @hidden */
  144964. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144965. /**
  144966. * Create a new AnisotropyBlock
  144967. * @param name defines the block name
  144968. */
  144969. constructor(name: string);
  144970. /**
  144971. * Initialize the block and prepare the context for build
  144972. * @param state defines the state that will be used for the build
  144973. */
  144974. initialize(state: NodeMaterialBuildState): void;
  144975. /**
  144976. * Gets the current class name
  144977. * @returns the class name
  144978. */
  144979. getClassName(): string;
  144980. /**
  144981. * Gets the intensity input component
  144982. */
  144983. get intensity(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the direction input component
  144986. */
  144987. get direction(): NodeMaterialConnectionPoint;
  144988. /**
  144989. * Gets the texture input component
  144990. */
  144991. get texture(): NodeMaterialConnectionPoint;
  144992. /**
  144993. * Gets the uv input component
  144994. */
  144995. get uv(): NodeMaterialConnectionPoint;
  144996. /**
  144997. * Gets the worldTangent input component
  144998. */
  144999. get worldTangent(): NodeMaterialConnectionPoint;
  145000. /**
  145001. * Gets the anisotropy object output component
  145002. */
  145003. get anisotropy(): NodeMaterialConnectionPoint;
  145004. private _generateTBNSpace;
  145005. /**
  145006. * Gets the main code of the block (fragment side)
  145007. * @param state current state of the node material building
  145008. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145009. * @returns the shader code
  145010. */
  145011. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145012. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145013. protected _buildBlock(state: NodeMaterialBuildState): this;
  145014. }
  145015. }
  145016. declare module BABYLON {
  145017. /**
  145018. * Block used to implement the clear coat module of the PBR material
  145019. */
  145020. export class ClearCoatBlock extends NodeMaterialBlock {
  145021. private _scene;
  145022. /**
  145023. * Create a new ClearCoatBlock
  145024. * @param name defines the block name
  145025. */
  145026. constructor(name: string);
  145027. /**
  145028. * Initialize the block and prepare the context for build
  145029. * @param state defines the state that will be used for the build
  145030. */
  145031. initialize(state: NodeMaterialBuildState): void;
  145032. /**
  145033. * Gets the current class name
  145034. * @returns the class name
  145035. */
  145036. getClassName(): string;
  145037. /**
  145038. * Gets the intensity input component
  145039. */
  145040. get intensity(): NodeMaterialConnectionPoint;
  145041. /**
  145042. * Gets the roughness input component
  145043. */
  145044. get roughness(): NodeMaterialConnectionPoint;
  145045. /**
  145046. * Gets the ior input component
  145047. */
  145048. get ior(): NodeMaterialConnectionPoint;
  145049. /**
  145050. * Gets the texture input component
  145051. */
  145052. get texture(): NodeMaterialConnectionPoint;
  145053. /**
  145054. * Gets the bump texture input component
  145055. */
  145056. get bumpTexture(): NodeMaterialConnectionPoint;
  145057. /**
  145058. * Gets the uv input component
  145059. */
  145060. get uv(): NodeMaterialConnectionPoint;
  145061. /**
  145062. * Gets the tint color input component
  145063. */
  145064. get tintColor(): NodeMaterialConnectionPoint;
  145065. /**
  145066. * Gets the tint "at distance" input component
  145067. */
  145068. get tintAtDistance(): NodeMaterialConnectionPoint;
  145069. /**
  145070. * Gets the tint thickness input component
  145071. */
  145072. get tintThickness(): NodeMaterialConnectionPoint;
  145073. /**
  145074. * Gets the world tangent input component
  145075. */
  145076. get worldTangent(): NodeMaterialConnectionPoint;
  145077. /**
  145078. * Gets the clear coat object output component
  145079. */
  145080. get clearcoat(): NodeMaterialConnectionPoint;
  145081. autoConfigure(material: NodeMaterial): void;
  145082. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145084. private _generateTBNSpace;
  145085. /**
  145086. * Gets the main code of the block (fragment side)
  145087. * @param state current state of the node material building
  145088. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145089. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145090. * @param worldPosVarName name of the variable holding the world position
  145091. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145092. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145093. * @param worldNormalVarName name of the variable holding the world normal
  145094. * @returns the shader code
  145095. */
  145096. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145097. protected _buildBlock(state: NodeMaterialBuildState): this;
  145098. }
  145099. }
  145100. declare module BABYLON {
  145101. /**
  145102. * Block used to implement the sub surface module of the PBR material
  145103. */
  145104. export class SubSurfaceBlock extends NodeMaterialBlock {
  145105. /**
  145106. * Create a new SubSurfaceBlock
  145107. * @param name defines the block name
  145108. */
  145109. constructor(name: string);
  145110. /**
  145111. * Stores the intensity of the different subsurface effects in the thickness texture.
  145112. * * the green channel is the translucency intensity.
  145113. * * the blue channel is the scattering intensity.
  145114. * * the alpha channel is the refraction intensity.
  145115. */
  145116. useMaskFromThicknessTexture: boolean;
  145117. /**
  145118. * Initialize the block and prepare the context for build
  145119. * @param state defines the state that will be used for the build
  145120. */
  145121. initialize(state: NodeMaterialBuildState): void;
  145122. /**
  145123. * Gets the current class name
  145124. * @returns the class name
  145125. */
  145126. getClassName(): string;
  145127. /**
  145128. * Gets the min thickness input component
  145129. */
  145130. get minThickness(): NodeMaterialConnectionPoint;
  145131. /**
  145132. * Gets the max thickness input component
  145133. */
  145134. get maxThickness(): NodeMaterialConnectionPoint;
  145135. /**
  145136. * Gets the thickness texture component
  145137. */
  145138. get thicknessTexture(): NodeMaterialConnectionPoint;
  145139. /**
  145140. * Gets the tint color input component
  145141. */
  145142. get tintColor(): NodeMaterialConnectionPoint;
  145143. /**
  145144. * Gets the translucency intensity input component
  145145. */
  145146. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145147. /**
  145148. * Gets the translucency diffusion distance input component
  145149. */
  145150. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145151. /**
  145152. * Gets the refraction object parameters
  145153. */
  145154. get refraction(): NodeMaterialConnectionPoint;
  145155. /**
  145156. * Gets the sub surface object output component
  145157. */
  145158. get subsurface(): NodeMaterialConnectionPoint;
  145159. autoConfigure(material: NodeMaterial): void;
  145160. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145161. /**
  145162. * Gets the main code of the block (fragment side)
  145163. * @param state current state of the node material building
  145164. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145165. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145166. * @param worldPosVarName name of the variable holding the world position
  145167. * @returns the shader code
  145168. */
  145169. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145170. protected _buildBlock(state: NodeMaterialBuildState): this;
  145171. }
  145172. }
  145173. declare module BABYLON {
  145174. /**
  145175. * Block used to implement the PBR metallic/roughness model
  145176. */
  145177. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145178. /**
  145179. * Gets or sets the light associated with this block
  145180. */
  145181. light: Nullable<Light>;
  145182. private _lightId;
  145183. private _scene;
  145184. private _environmentBRDFTexture;
  145185. private _environmentBrdfSamplerName;
  145186. private _vNormalWName;
  145187. private _invertNormalName;
  145188. /**
  145189. * Create a new ReflectionBlock
  145190. * @param name defines the block name
  145191. */
  145192. constructor(name: string);
  145193. /**
  145194. * Intensity of the direct lights e.g. the four lights available in your scene.
  145195. * This impacts both the direct diffuse and specular highlights.
  145196. */
  145197. directIntensity: number;
  145198. /**
  145199. * Intensity of the environment e.g. how much the environment will light the object
  145200. * either through harmonics for rough material or through the refelction for shiny ones.
  145201. */
  145202. environmentIntensity: number;
  145203. /**
  145204. * This is a special control allowing the reduction of the specular highlights coming from the
  145205. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145206. */
  145207. specularIntensity: number;
  145208. /**
  145209. * Defines the falloff type used in this material.
  145210. * It by default is Physical.
  145211. */
  145212. lightFalloff: number;
  145213. /**
  145214. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145215. */
  145216. useAlphaFromAlbedoTexture: boolean;
  145217. /**
  145218. * Specifies that alpha test should be used
  145219. */
  145220. useAlphaTest: boolean;
  145221. /**
  145222. * Defines the alpha limits in alpha test mode.
  145223. */
  145224. alphaTestCutoff: number;
  145225. /**
  145226. * Specifies that alpha blending should be used
  145227. */
  145228. useAlphaBlending: boolean;
  145229. /**
  145230. * Defines if the alpha value should be determined via the rgb values.
  145231. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145232. */
  145233. opacityRGB: boolean;
  145234. /**
  145235. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145236. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145237. */
  145238. useRadianceOverAlpha: boolean;
  145239. /**
  145240. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145241. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145242. */
  145243. useSpecularOverAlpha: boolean;
  145244. /**
  145245. * Enables specular anti aliasing in the PBR shader.
  145246. * It will both interacts on the Geometry for analytical and IBL lighting.
  145247. * It also prefilter the roughness map based on the bump values.
  145248. */
  145249. enableSpecularAntiAliasing: boolean;
  145250. /**
  145251. * Enables realtime filtering on the texture.
  145252. */
  145253. realTimeFiltering: boolean;
  145254. /**
  145255. * Quality switch for realtime filtering
  145256. */
  145257. realTimeFilteringQuality: number;
  145258. /**
  145259. * Defines if the material uses energy conservation.
  145260. */
  145261. useEnergyConservation: boolean;
  145262. /**
  145263. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145264. * too much the area relying on ambient texture to define their ambient occlusion.
  145265. */
  145266. useRadianceOcclusion: boolean;
  145267. /**
  145268. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145269. * makes the reflect vector face the model (under horizon).
  145270. */
  145271. useHorizonOcclusion: boolean;
  145272. /**
  145273. * If set to true, no lighting calculations will be applied.
  145274. */
  145275. unlit: boolean;
  145276. /**
  145277. * Force normal to face away from face.
  145278. */
  145279. forceNormalForward: boolean;
  145280. /**
  145281. * Defines the material debug mode.
  145282. * It helps seeing only some components of the material while troubleshooting.
  145283. */
  145284. debugMode: number;
  145285. /**
  145286. * Specify from where on screen the debug mode should start.
  145287. * The value goes from -1 (full screen) to 1 (not visible)
  145288. * It helps with side by side comparison against the final render
  145289. * This defaults to 0
  145290. */
  145291. debugLimit: number;
  145292. /**
  145293. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145294. * You can use the factor to better multiply the final value.
  145295. */
  145296. debugFactor: number;
  145297. /**
  145298. * Initialize the block and prepare the context for build
  145299. * @param state defines the state that will be used for the build
  145300. */
  145301. initialize(state: NodeMaterialBuildState): void;
  145302. /**
  145303. * Gets the current class name
  145304. * @returns the class name
  145305. */
  145306. getClassName(): string;
  145307. /**
  145308. * Gets the world position input component
  145309. */
  145310. get worldPosition(): NodeMaterialConnectionPoint;
  145311. /**
  145312. * Gets the world normal input component
  145313. */
  145314. get worldNormal(): NodeMaterialConnectionPoint;
  145315. /**
  145316. * Gets the perturbed normal input component
  145317. */
  145318. get perturbedNormal(): NodeMaterialConnectionPoint;
  145319. /**
  145320. * Gets the camera position input component
  145321. */
  145322. get cameraPosition(): NodeMaterialConnectionPoint;
  145323. /**
  145324. * Gets the base color input component
  145325. */
  145326. get baseColor(): NodeMaterialConnectionPoint;
  145327. /**
  145328. * Gets the opacity texture input component
  145329. */
  145330. get opacityTexture(): NodeMaterialConnectionPoint;
  145331. /**
  145332. * Gets the ambient color input component
  145333. */
  145334. get ambientColor(): NodeMaterialConnectionPoint;
  145335. /**
  145336. * Gets the reflectivity object parameters
  145337. */
  145338. get reflectivity(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the ambient occlusion object parameters
  145341. */
  145342. get ambientOcclusion(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the reflection object parameters
  145345. */
  145346. get reflection(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the sheen object parameters
  145349. */
  145350. get sheen(): NodeMaterialConnectionPoint;
  145351. /**
  145352. * Gets the clear coat object parameters
  145353. */
  145354. get clearcoat(): NodeMaterialConnectionPoint;
  145355. /**
  145356. * Gets the sub surface object parameters
  145357. */
  145358. get subsurface(): NodeMaterialConnectionPoint;
  145359. /**
  145360. * Gets the anisotropy object parameters
  145361. */
  145362. get anisotropy(): NodeMaterialConnectionPoint;
  145363. /**
  145364. * Gets the ambient output component
  145365. */
  145366. get ambient(): NodeMaterialConnectionPoint;
  145367. /**
  145368. * Gets the diffuse output component
  145369. */
  145370. get diffuse(): NodeMaterialConnectionPoint;
  145371. /**
  145372. * Gets the specular output component
  145373. */
  145374. get specular(): NodeMaterialConnectionPoint;
  145375. /**
  145376. * Gets the sheen output component
  145377. */
  145378. get sheenDir(): NodeMaterialConnectionPoint;
  145379. /**
  145380. * Gets the clear coat output component
  145381. */
  145382. get clearcoatDir(): NodeMaterialConnectionPoint;
  145383. /**
  145384. * Gets the indirect diffuse output component
  145385. */
  145386. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145387. /**
  145388. * Gets the indirect specular output component
  145389. */
  145390. get specularIndirect(): NodeMaterialConnectionPoint;
  145391. /**
  145392. * Gets the indirect sheen output component
  145393. */
  145394. get sheenIndirect(): NodeMaterialConnectionPoint;
  145395. /**
  145396. * Gets the indirect clear coat output component
  145397. */
  145398. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145399. /**
  145400. * Gets the refraction output component
  145401. */
  145402. get refraction(): NodeMaterialConnectionPoint;
  145403. /**
  145404. * Gets the global lighting output component
  145405. */
  145406. get lighting(): NodeMaterialConnectionPoint;
  145407. /**
  145408. * Gets the shadow output component
  145409. */
  145410. get shadow(): NodeMaterialConnectionPoint;
  145411. /**
  145412. * Gets the alpha output component
  145413. */
  145414. get alpha(): NodeMaterialConnectionPoint;
  145415. autoConfigure(material: NodeMaterial): void;
  145416. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145417. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145418. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145419. private _injectVertexCode;
  145420. /**
  145421. * Gets the code corresponding to the albedo/opacity module
  145422. * @returns the shader code
  145423. */
  145424. getAlbedoOpacityCode(): string;
  145425. protected _buildBlock(state: NodeMaterialBuildState): this;
  145426. protected _dumpPropertiesCode(): string;
  145427. serialize(): any;
  145428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145429. }
  145430. }
  145431. declare module BABYLON {
  145432. /**
  145433. * Block used to compute value of one parameter modulo another
  145434. */
  145435. export class ModBlock extends NodeMaterialBlock {
  145436. /**
  145437. * Creates a new ModBlock
  145438. * @param name defines the block name
  145439. */
  145440. constructor(name: string);
  145441. /**
  145442. * Gets the current class name
  145443. * @returns the class name
  145444. */
  145445. getClassName(): string;
  145446. /**
  145447. * Gets the left operand input component
  145448. */
  145449. get left(): NodeMaterialConnectionPoint;
  145450. /**
  145451. * Gets the right operand input component
  145452. */
  145453. get right(): NodeMaterialConnectionPoint;
  145454. /**
  145455. * Gets the output component
  145456. */
  145457. get output(): NodeMaterialConnectionPoint;
  145458. protected _buildBlock(state: NodeMaterialBuildState): this;
  145459. }
  145460. }
  145461. declare module BABYLON {
  145462. /**
  145463. * Configuration for Draco compression
  145464. */
  145465. export interface IDracoCompressionConfiguration {
  145466. /**
  145467. * Configuration for the decoder.
  145468. */
  145469. decoder: {
  145470. /**
  145471. * The url to the WebAssembly module.
  145472. */
  145473. wasmUrl?: string;
  145474. /**
  145475. * The url to the WebAssembly binary.
  145476. */
  145477. wasmBinaryUrl?: string;
  145478. /**
  145479. * The url to the fallback JavaScript module.
  145480. */
  145481. fallbackUrl?: string;
  145482. };
  145483. }
  145484. /**
  145485. * Draco compression (https://google.github.io/draco/)
  145486. *
  145487. * This class wraps the Draco module.
  145488. *
  145489. * **Encoder**
  145490. *
  145491. * The encoder is not currently implemented.
  145492. *
  145493. * **Decoder**
  145494. *
  145495. * 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.
  145496. *
  145497. * To update the configuration, use the following code:
  145498. * ```javascript
  145499. * DracoCompression.Configuration = {
  145500. * decoder: {
  145501. * wasmUrl: "<url to the WebAssembly library>",
  145502. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145503. * fallbackUrl: "<url to the fallback JavaScript library>",
  145504. * }
  145505. * };
  145506. * ```
  145507. *
  145508. * 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.
  145509. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145510. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145511. *
  145512. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145513. * ```javascript
  145514. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145515. * ```
  145516. *
  145517. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145518. */
  145519. export class DracoCompression implements IDisposable {
  145520. private _workerPoolPromise?;
  145521. private _decoderModulePromise?;
  145522. /**
  145523. * The configuration. Defaults to the following urls:
  145524. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145525. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145526. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145527. */
  145528. static Configuration: IDracoCompressionConfiguration;
  145529. /**
  145530. * Returns true if the decoder configuration is available.
  145531. */
  145532. static get DecoderAvailable(): boolean;
  145533. /**
  145534. * Default number of workers to create when creating the draco compression object.
  145535. */
  145536. static DefaultNumWorkers: number;
  145537. private static GetDefaultNumWorkers;
  145538. private static _Default;
  145539. /**
  145540. * Default instance for the draco compression object.
  145541. */
  145542. static get Default(): DracoCompression;
  145543. /**
  145544. * Constructor
  145545. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145546. */
  145547. constructor(numWorkers?: number);
  145548. /**
  145549. * Stop all async operations and release resources.
  145550. */
  145551. dispose(): void;
  145552. /**
  145553. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145554. * @returns a promise that resolves when ready
  145555. */
  145556. whenReadyAsync(): Promise<void>;
  145557. /**
  145558. * Decode Draco compressed mesh data to vertex data.
  145559. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145560. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145561. * @returns A promise that resolves with the decoded vertex data
  145562. */
  145563. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145564. [kind: string]: number;
  145565. }): Promise<VertexData>;
  145566. }
  145567. }
  145568. declare module BABYLON {
  145569. /**
  145570. * Class for building Constructive Solid Geometry
  145571. */
  145572. export class CSG {
  145573. private polygons;
  145574. /**
  145575. * The world matrix
  145576. */
  145577. matrix: Matrix;
  145578. /**
  145579. * Stores the position
  145580. */
  145581. position: Vector3;
  145582. /**
  145583. * Stores the rotation
  145584. */
  145585. rotation: Vector3;
  145586. /**
  145587. * Stores the rotation quaternion
  145588. */
  145589. rotationQuaternion: Nullable<Quaternion>;
  145590. /**
  145591. * Stores the scaling vector
  145592. */
  145593. scaling: Vector3;
  145594. /**
  145595. * Convert the Mesh to CSG
  145596. * @param mesh The Mesh to convert to CSG
  145597. * @returns A new CSG from the Mesh
  145598. */
  145599. static FromMesh(mesh: Mesh): CSG;
  145600. /**
  145601. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145602. * @param polygons Polygons used to construct a CSG solid
  145603. */
  145604. private static FromPolygons;
  145605. /**
  145606. * Clones, or makes a deep copy, of the CSG
  145607. * @returns A new CSG
  145608. */
  145609. clone(): CSG;
  145610. /**
  145611. * Unions this CSG with another CSG
  145612. * @param csg The CSG to union against this CSG
  145613. * @returns The unioned CSG
  145614. */
  145615. union(csg: CSG): CSG;
  145616. /**
  145617. * Unions this CSG with another CSG in place
  145618. * @param csg The CSG to union against this CSG
  145619. */
  145620. unionInPlace(csg: CSG): void;
  145621. /**
  145622. * Subtracts this CSG with another CSG
  145623. * @param csg The CSG to subtract against this CSG
  145624. * @returns A new CSG
  145625. */
  145626. subtract(csg: CSG): CSG;
  145627. /**
  145628. * Subtracts this CSG with another CSG in place
  145629. * @param csg The CSG to subtact against this CSG
  145630. */
  145631. subtractInPlace(csg: CSG): void;
  145632. /**
  145633. * Intersect this CSG with another CSG
  145634. * @param csg The CSG to intersect against this CSG
  145635. * @returns A new CSG
  145636. */
  145637. intersect(csg: CSG): CSG;
  145638. /**
  145639. * Intersects this CSG with another CSG in place
  145640. * @param csg The CSG to intersect against this CSG
  145641. */
  145642. intersectInPlace(csg: CSG): void;
  145643. /**
  145644. * Return a new CSG solid with solid and empty space switched. This solid is
  145645. * not modified.
  145646. * @returns A new CSG solid with solid and empty space switched
  145647. */
  145648. inverse(): CSG;
  145649. /**
  145650. * Inverses the CSG in place
  145651. */
  145652. inverseInPlace(): void;
  145653. /**
  145654. * This is used to keep meshes transformations so they can be restored
  145655. * when we build back a Babylon Mesh
  145656. * NB : All CSG operations are performed in world coordinates
  145657. * @param csg The CSG to copy the transform attributes from
  145658. * @returns This CSG
  145659. */
  145660. copyTransformAttributes(csg: CSG): CSG;
  145661. /**
  145662. * Build Raw mesh from CSG
  145663. * Coordinates here are in world space
  145664. * @param name The name of the mesh geometry
  145665. * @param scene The Scene
  145666. * @param keepSubMeshes Specifies if the submeshes should be kept
  145667. * @returns A new Mesh
  145668. */
  145669. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145670. /**
  145671. * Build Mesh from CSG taking material and transforms into account
  145672. * @param name The name of the Mesh
  145673. * @param material The material of the Mesh
  145674. * @param scene The Scene
  145675. * @param keepSubMeshes Specifies if submeshes should be kept
  145676. * @returns The new Mesh
  145677. */
  145678. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145679. }
  145680. }
  145681. declare module BABYLON {
  145682. /**
  145683. * Class used to create a trail following a mesh
  145684. */
  145685. export class TrailMesh extends Mesh {
  145686. private _generator;
  145687. private _autoStart;
  145688. private _running;
  145689. private _diameter;
  145690. private _length;
  145691. private _sectionPolygonPointsCount;
  145692. private _sectionVectors;
  145693. private _sectionNormalVectors;
  145694. private _beforeRenderObserver;
  145695. /**
  145696. * @constructor
  145697. * @param name The value used by scene.getMeshByName() to do a lookup.
  145698. * @param generator The mesh or transform node to generate a trail.
  145699. * @param scene The scene to add this mesh to.
  145700. * @param diameter Diameter of trailing mesh. Default is 1.
  145701. * @param length Length of trailing mesh. Default is 60.
  145702. * @param autoStart Automatically start trailing mesh. Default true.
  145703. */
  145704. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145705. /**
  145706. * "TrailMesh"
  145707. * @returns "TrailMesh"
  145708. */
  145709. getClassName(): string;
  145710. private _createMesh;
  145711. /**
  145712. * Start trailing mesh.
  145713. */
  145714. start(): void;
  145715. /**
  145716. * Stop trailing mesh.
  145717. */
  145718. stop(): void;
  145719. /**
  145720. * Update trailing mesh geometry.
  145721. */
  145722. update(): void;
  145723. /**
  145724. * Returns a new TrailMesh object.
  145725. * @param name is a string, the name given to the new mesh
  145726. * @param newGenerator use new generator object for cloned trail mesh
  145727. * @returns a new mesh
  145728. */
  145729. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145730. /**
  145731. * Serializes this trail mesh
  145732. * @param serializationObject object to write serialization to
  145733. */
  145734. serialize(serializationObject: any): void;
  145735. /**
  145736. * Parses a serialized trail mesh
  145737. * @param parsedMesh the serialized mesh
  145738. * @param scene the scene to create the trail mesh in
  145739. * @returns the created trail mesh
  145740. */
  145741. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145742. }
  145743. }
  145744. declare module BABYLON {
  145745. /**
  145746. * Class containing static functions to help procedurally build meshes
  145747. */
  145748. export class TiledBoxBuilder {
  145749. /**
  145750. * Creates a box mesh
  145751. * 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)
  145752. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145756. * @param name defines the name of the mesh
  145757. * @param options defines the options used to create the mesh
  145758. * @param scene defines the hosting scene
  145759. * @returns the box mesh
  145760. */
  145761. static CreateTiledBox(name: string, options: {
  145762. pattern?: number;
  145763. width?: number;
  145764. height?: number;
  145765. depth?: number;
  145766. tileSize?: number;
  145767. tileWidth?: number;
  145768. tileHeight?: number;
  145769. alignHorizontal?: number;
  145770. alignVertical?: number;
  145771. faceUV?: Vector4[];
  145772. faceColors?: Color4[];
  145773. sideOrientation?: number;
  145774. updatable?: boolean;
  145775. }, scene?: Nullable<Scene>): Mesh;
  145776. }
  145777. }
  145778. declare module BABYLON {
  145779. /**
  145780. * Class containing static functions to help procedurally build meshes
  145781. */
  145782. export class TorusKnotBuilder {
  145783. /**
  145784. * Creates a torus knot mesh
  145785. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145786. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145787. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145788. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145792. * @param name defines the name of the mesh
  145793. * @param options defines the options used to create the mesh
  145794. * @param scene defines the hosting scene
  145795. * @returns the torus knot mesh
  145796. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145797. */
  145798. static CreateTorusKnot(name: string, options: {
  145799. radius?: number;
  145800. tube?: number;
  145801. radialSegments?: number;
  145802. tubularSegments?: number;
  145803. p?: number;
  145804. q?: number;
  145805. updatable?: boolean;
  145806. sideOrientation?: number;
  145807. frontUVs?: Vector4;
  145808. backUVs?: Vector4;
  145809. }, scene: any): Mesh;
  145810. }
  145811. }
  145812. declare module BABYLON {
  145813. /**
  145814. * Polygon
  145815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145816. */
  145817. export class Polygon {
  145818. /**
  145819. * Creates a rectangle
  145820. * @param xmin bottom X coord
  145821. * @param ymin bottom Y coord
  145822. * @param xmax top X coord
  145823. * @param ymax top Y coord
  145824. * @returns points that make the resulting rectation
  145825. */
  145826. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145827. /**
  145828. * Creates a circle
  145829. * @param radius radius of circle
  145830. * @param cx scale in x
  145831. * @param cy scale in y
  145832. * @param numberOfSides number of sides that make up the circle
  145833. * @returns points that make the resulting circle
  145834. */
  145835. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145836. /**
  145837. * Creates a polygon from input string
  145838. * @param input Input polygon data
  145839. * @returns the parsed points
  145840. */
  145841. static Parse(input: string): Vector2[];
  145842. /**
  145843. * Starts building a polygon from x and y coordinates
  145844. * @param x x coordinate
  145845. * @param y y coordinate
  145846. * @returns the started path2
  145847. */
  145848. static StartingAt(x: number, y: number): Path2;
  145849. }
  145850. /**
  145851. * Builds a polygon
  145852. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145853. */
  145854. export class PolygonMeshBuilder {
  145855. private _points;
  145856. private _outlinepoints;
  145857. private _holes;
  145858. private _name;
  145859. private _scene;
  145860. private _epoints;
  145861. private _eholes;
  145862. private _addToepoint;
  145863. /**
  145864. * Babylon reference to the earcut plugin.
  145865. */
  145866. bjsEarcut: any;
  145867. /**
  145868. * Creates a PolygonMeshBuilder
  145869. * @param name name of the builder
  145870. * @param contours Path of the polygon
  145871. * @param scene scene to add to when creating the mesh
  145872. * @param earcutInjection can be used to inject your own earcut reference
  145873. */
  145874. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145875. /**
  145876. * Adds a whole within the polygon
  145877. * @param hole Array of points defining the hole
  145878. * @returns this
  145879. */
  145880. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145881. /**
  145882. * Creates the polygon
  145883. * @param updatable If the mesh should be updatable
  145884. * @param depth The depth of the mesh created
  145885. * @returns the created mesh
  145886. */
  145887. build(updatable?: boolean, depth?: number): Mesh;
  145888. /**
  145889. * Creates the polygon
  145890. * @param depth The depth of the mesh created
  145891. * @returns the created VertexData
  145892. */
  145893. buildVertexData(depth?: number): VertexData;
  145894. /**
  145895. * Adds a side to the polygon
  145896. * @param positions points that make the polygon
  145897. * @param normals normals of the polygon
  145898. * @param uvs uvs of the polygon
  145899. * @param indices indices of the polygon
  145900. * @param bounds bounds of the polygon
  145901. * @param points points of the polygon
  145902. * @param depth depth of the polygon
  145903. * @param flip flip of the polygon
  145904. */
  145905. private addSide;
  145906. }
  145907. }
  145908. declare module BABYLON {
  145909. /**
  145910. * Class containing static functions to help procedurally build meshes
  145911. */
  145912. export class PolygonBuilder {
  145913. /**
  145914. * Creates a polygon mesh
  145915. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145916. * * 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
  145917. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145920. * * Remember you can only change the shape positions, not their number when updating a polygon
  145921. * @param name defines the name of the mesh
  145922. * @param options defines the options used to create the mesh
  145923. * @param scene defines the hosting scene
  145924. * @param earcutInjection can be used to inject your own earcut reference
  145925. * @returns the polygon mesh
  145926. */
  145927. static CreatePolygon(name: string, options: {
  145928. shape: Vector3[];
  145929. holes?: Vector3[][];
  145930. depth?: number;
  145931. faceUV?: Vector4[];
  145932. faceColors?: Color4[];
  145933. updatable?: boolean;
  145934. sideOrientation?: number;
  145935. frontUVs?: Vector4;
  145936. backUVs?: Vector4;
  145937. wrap?: boolean;
  145938. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145939. /**
  145940. * Creates an extruded polygon mesh, with depth in the Y direction.
  145941. * * 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)
  145942. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145943. * @param name defines the name of the mesh
  145944. * @param options defines the options used to create the mesh
  145945. * @param scene defines the hosting scene
  145946. * @param earcutInjection can be used to inject your own earcut reference
  145947. * @returns the polygon mesh
  145948. */
  145949. static ExtrudePolygon(name: string, options: {
  145950. shape: Vector3[];
  145951. holes?: Vector3[][];
  145952. depth?: number;
  145953. faceUV?: Vector4[];
  145954. faceColors?: Color4[];
  145955. updatable?: boolean;
  145956. sideOrientation?: number;
  145957. frontUVs?: Vector4;
  145958. backUVs?: Vector4;
  145959. wrap?: boolean;
  145960. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145961. }
  145962. }
  145963. declare module BABYLON {
  145964. /**
  145965. * Class containing static functions to help procedurally build meshes
  145966. */
  145967. export class LatheBuilder {
  145968. /**
  145969. * Creates lathe mesh.
  145970. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145971. * * 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
  145972. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145973. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145974. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145975. * * 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
  145976. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145977. * * 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
  145978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145982. * @param name defines the name of the mesh
  145983. * @param options defines the options used to create the mesh
  145984. * @param scene defines the hosting scene
  145985. * @returns the lathe mesh
  145986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145987. */
  145988. static CreateLathe(name: string, options: {
  145989. shape: Vector3[];
  145990. radius?: number;
  145991. tessellation?: number;
  145992. clip?: number;
  145993. arc?: number;
  145994. closed?: boolean;
  145995. updatable?: boolean;
  145996. sideOrientation?: number;
  145997. frontUVs?: Vector4;
  145998. backUVs?: Vector4;
  145999. cap?: number;
  146000. invertUV?: boolean;
  146001. }, scene?: Nullable<Scene>): Mesh;
  146002. }
  146003. }
  146004. declare module BABYLON {
  146005. /**
  146006. * Class containing static functions to help procedurally build meshes
  146007. */
  146008. export class TiledPlaneBuilder {
  146009. /**
  146010. * Creates a tiled plane mesh
  146011. * * The parameter `pattern` will, depending on value, do nothing or
  146012. * * * flip (reflect about central vertical) alternate tiles across and up
  146013. * * * flip every tile on alternate rows
  146014. * * * rotate (180 degs) alternate tiles across and up
  146015. * * * rotate every tile on alternate rows
  146016. * * * flip and rotate alternate tiles across and up
  146017. * * * flip and rotate every tile on alternate rows
  146018. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146019. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146022. * * 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)
  146023. * * 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)
  146024. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146025. * @param name defines the name of the mesh
  146026. * @param options defines the options used to create the mesh
  146027. * @param scene defines the hosting scene
  146028. * @returns the box mesh
  146029. */
  146030. static CreateTiledPlane(name: string, options: {
  146031. pattern?: number;
  146032. tileSize?: number;
  146033. tileWidth?: number;
  146034. tileHeight?: number;
  146035. size?: number;
  146036. width?: number;
  146037. height?: number;
  146038. alignHorizontal?: number;
  146039. alignVertical?: number;
  146040. sideOrientation?: number;
  146041. frontUVs?: Vector4;
  146042. backUVs?: Vector4;
  146043. updatable?: boolean;
  146044. }, scene?: Nullable<Scene>): Mesh;
  146045. }
  146046. }
  146047. declare module BABYLON {
  146048. /**
  146049. * Class containing static functions to help procedurally build meshes
  146050. */
  146051. export class TubeBuilder {
  146052. /**
  146053. * Creates a tube mesh.
  146054. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146055. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146056. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146057. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146058. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146059. * * 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)
  146060. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146061. * * 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
  146062. * * 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
  146063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146067. * @param name defines the name of the mesh
  146068. * @param options defines the options used to create the mesh
  146069. * @param scene defines the hosting scene
  146070. * @returns the tube mesh
  146071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146072. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146073. */
  146074. static CreateTube(name: string, options: {
  146075. path: Vector3[];
  146076. radius?: number;
  146077. tessellation?: number;
  146078. radiusFunction?: {
  146079. (i: number, distance: number): number;
  146080. };
  146081. cap?: number;
  146082. arc?: number;
  146083. updatable?: boolean;
  146084. sideOrientation?: number;
  146085. frontUVs?: Vector4;
  146086. backUVs?: Vector4;
  146087. instance?: Mesh;
  146088. invertUV?: boolean;
  146089. }, scene?: Nullable<Scene>): Mesh;
  146090. }
  146091. }
  146092. declare module BABYLON {
  146093. /**
  146094. * Class containing static functions to help procedurally build meshes
  146095. */
  146096. export class IcoSphereBuilder {
  146097. /**
  146098. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146099. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146100. * * 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`)
  146101. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146102. * * 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
  146103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146106. * @param name defines the name of the mesh
  146107. * @param options defines the options used to create the mesh
  146108. * @param scene defines the hosting scene
  146109. * @returns the icosahedron mesh
  146110. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146111. */
  146112. static CreateIcoSphere(name: string, options: {
  146113. radius?: number;
  146114. radiusX?: number;
  146115. radiusY?: number;
  146116. radiusZ?: number;
  146117. flat?: boolean;
  146118. subdivisions?: number;
  146119. sideOrientation?: number;
  146120. frontUVs?: Vector4;
  146121. backUVs?: Vector4;
  146122. updatable?: boolean;
  146123. }, scene?: Nullable<Scene>): Mesh;
  146124. }
  146125. }
  146126. declare module BABYLON {
  146127. /**
  146128. * Class containing static functions to help procedurally build meshes
  146129. */
  146130. export class DecalBuilder {
  146131. /**
  146132. * Creates a decal mesh.
  146133. * 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
  146134. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146135. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146136. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146137. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146138. * @param name defines the name of the mesh
  146139. * @param sourceMesh defines the mesh where the decal must be applied
  146140. * @param options defines the options used to create the mesh
  146141. * @param scene defines the hosting scene
  146142. * @returns the decal mesh
  146143. * @see https://doc.babylonjs.com/how_to/decals
  146144. */
  146145. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146146. position?: Vector3;
  146147. normal?: Vector3;
  146148. size?: Vector3;
  146149. angle?: number;
  146150. }): Mesh;
  146151. }
  146152. }
  146153. declare module BABYLON {
  146154. /**
  146155. * Class containing static functions to help procedurally build meshes
  146156. */
  146157. export class MeshBuilder {
  146158. /**
  146159. * Creates a box mesh
  146160. * * The parameter `size` sets the size (float) of each box side (default 1)
  146161. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146162. * * 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)
  146163. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146167. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146168. * @param name defines the name of the mesh
  146169. * @param options defines the options used to create the mesh
  146170. * @param scene defines the hosting scene
  146171. * @returns the box mesh
  146172. */
  146173. static CreateBox(name: string, options: {
  146174. size?: number;
  146175. width?: number;
  146176. height?: number;
  146177. depth?: number;
  146178. faceUV?: Vector4[];
  146179. faceColors?: Color4[];
  146180. sideOrientation?: number;
  146181. frontUVs?: Vector4;
  146182. backUVs?: Vector4;
  146183. wrap?: boolean;
  146184. topBaseAt?: number;
  146185. bottomBaseAt?: number;
  146186. updatable?: boolean;
  146187. }, scene?: Nullable<Scene>): Mesh;
  146188. /**
  146189. * Creates a tiled box mesh
  146190. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146192. * @param name defines the name of the mesh
  146193. * @param options defines the options used to create the mesh
  146194. * @param scene defines the hosting scene
  146195. * @returns the tiled box mesh
  146196. */
  146197. static CreateTiledBox(name: string, options: {
  146198. pattern?: number;
  146199. size?: number;
  146200. width?: number;
  146201. height?: number;
  146202. depth: number;
  146203. tileSize?: number;
  146204. tileWidth?: number;
  146205. tileHeight?: number;
  146206. faceUV?: Vector4[];
  146207. faceColors?: Color4[];
  146208. alignHorizontal?: number;
  146209. alignVertical?: number;
  146210. sideOrientation?: number;
  146211. updatable?: boolean;
  146212. }, scene?: Nullable<Scene>): Mesh;
  146213. /**
  146214. * Creates a sphere mesh
  146215. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146216. * * 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`)
  146217. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146218. * * 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
  146219. * * 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)
  146220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146223. * @param name defines the name of the mesh
  146224. * @param options defines the options used to create the mesh
  146225. * @param scene defines the hosting scene
  146226. * @returns the sphere mesh
  146227. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146228. */
  146229. static CreateSphere(name: string, options: {
  146230. segments?: number;
  146231. diameter?: number;
  146232. diameterX?: number;
  146233. diameterY?: number;
  146234. diameterZ?: number;
  146235. arc?: number;
  146236. slice?: number;
  146237. sideOrientation?: number;
  146238. frontUVs?: Vector4;
  146239. backUVs?: Vector4;
  146240. updatable?: boolean;
  146241. }, scene?: Nullable<Scene>): Mesh;
  146242. /**
  146243. * Creates a plane polygonal mesh. By default, this is a disc
  146244. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146245. * * 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
  146246. * * 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
  146247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146250. * @param name defines the name of the mesh
  146251. * @param options defines the options used to create the mesh
  146252. * @param scene defines the hosting scene
  146253. * @returns the plane polygonal mesh
  146254. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146255. */
  146256. static CreateDisc(name: string, options: {
  146257. radius?: number;
  146258. tessellation?: number;
  146259. arc?: number;
  146260. updatable?: boolean;
  146261. sideOrientation?: number;
  146262. frontUVs?: Vector4;
  146263. backUVs?: Vector4;
  146264. }, scene?: Nullable<Scene>): Mesh;
  146265. /**
  146266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146268. * * 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`)
  146269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146270. * * 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
  146271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146274. * @param name defines the name of the mesh
  146275. * @param options defines the options used to create the mesh
  146276. * @param scene defines the hosting scene
  146277. * @returns the icosahedron mesh
  146278. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146279. */
  146280. static CreateIcoSphere(name: string, options: {
  146281. radius?: number;
  146282. radiusX?: number;
  146283. radiusY?: number;
  146284. radiusZ?: number;
  146285. flat?: boolean;
  146286. subdivisions?: number;
  146287. sideOrientation?: number;
  146288. frontUVs?: Vector4;
  146289. backUVs?: Vector4;
  146290. updatable?: boolean;
  146291. }, scene?: Nullable<Scene>): Mesh;
  146292. /**
  146293. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146294. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146295. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146296. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146297. * * 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
  146298. * * 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
  146299. * * 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
  146300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146303. * * 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
  146304. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146305. * * 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
  146306. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146308. * @param name defines the name of the mesh
  146309. * @param options defines the options used to create the mesh
  146310. * @param scene defines the hosting scene
  146311. * @returns the ribbon mesh
  146312. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146314. */
  146315. static CreateRibbon(name: string, options: {
  146316. pathArray: Vector3[][];
  146317. closeArray?: boolean;
  146318. closePath?: boolean;
  146319. offset?: number;
  146320. updatable?: boolean;
  146321. sideOrientation?: number;
  146322. frontUVs?: Vector4;
  146323. backUVs?: Vector4;
  146324. instance?: Mesh;
  146325. invertUV?: boolean;
  146326. uvs?: Vector2[];
  146327. colors?: Color4[];
  146328. }, scene?: Nullable<Scene>): Mesh;
  146329. /**
  146330. * Creates a cylinder or a cone mesh
  146331. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146332. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146333. * * 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.
  146334. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146335. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146336. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146337. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146338. * * 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).
  146339. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146340. * * 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).
  146341. * * 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
  146342. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146343. * * 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
  146344. * * 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.
  146345. * * If `enclose` is false, a ring surface is one element.
  146346. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146347. * * 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
  146348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146351. * @param name defines the name of the mesh
  146352. * @param options defines the options used to create the mesh
  146353. * @param scene defines the hosting scene
  146354. * @returns the cylinder mesh
  146355. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146356. */
  146357. static CreateCylinder(name: string, options: {
  146358. height?: number;
  146359. diameterTop?: number;
  146360. diameterBottom?: number;
  146361. diameter?: number;
  146362. tessellation?: number;
  146363. subdivisions?: number;
  146364. arc?: number;
  146365. faceColors?: Color4[];
  146366. faceUV?: Vector4[];
  146367. updatable?: boolean;
  146368. hasRings?: boolean;
  146369. enclose?: boolean;
  146370. cap?: number;
  146371. sideOrientation?: number;
  146372. frontUVs?: Vector4;
  146373. backUVs?: Vector4;
  146374. }, scene?: Nullable<Scene>): Mesh;
  146375. /**
  146376. * Creates a torus mesh
  146377. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146378. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146379. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146383. * @param name defines the name of the mesh
  146384. * @param options defines the options used to create the mesh
  146385. * @param scene defines the hosting scene
  146386. * @returns the torus mesh
  146387. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146388. */
  146389. static CreateTorus(name: string, options: {
  146390. diameter?: number;
  146391. thickness?: number;
  146392. tessellation?: number;
  146393. updatable?: boolean;
  146394. sideOrientation?: number;
  146395. frontUVs?: Vector4;
  146396. backUVs?: Vector4;
  146397. }, scene?: Nullable<Scene>): Mesh;
  146398. /**
  146399. * Creates a torus knot mesh
  146400. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146401. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146402. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146403. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146407. * @param name defines the name of the mesh
  146408. * @param options defines the options used to create the mesh
  146409. * @param scene defines the hosting scene
  146410. * @returns the torus knot mesh
  146411. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146412. */
  146413. static CreateTorusKnot(name: string, options: {
  146414. radius?: number;
  146415. tube?: number;
  146416. radialSegments?: number;
  146417. tubularSegments?: number;
  146418. p?: number;
  146419. q?: number;
  146420. updatable?: boolean;
  146421. sideOrientation?: number;
  146422. frontUVs?: Vector4;
  146423. backUVs?: Vector4;
  146424. }, scene?: Nullable<Scene>): Mesh;
  146425. /**
  146426. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146427. * * 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
  146428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146429. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146430. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146431. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146432. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146433. * * 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
  146434. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146437. * @param name defines the name of the new line system
  146438. * @param options defines the options used to create the line system
  146439. * @param scene defines the hosting scene
  146440. * @returns a new line system mesh
  146441. */
  146442. static CreateLineSystem(name: string, options: {
  146443. lines: Vector3[][];
  146444. updatable?: boolean;
  146445. instance?: Nullable<LinesMesh>;
  146446. colors?: Nullable<Color4[][]>;
  146447. useVertexAlpha?: boolean;
  146448. }, scene: Nullable<Scene>): LinesMesh;
  146449. /**
  146450. * Creates a line mesh
  146451. * 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
  146452. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146453. * * The parameter `points` is an array successive Vector3
  146454. * * 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
  146455. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146456. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146457. * * When updating an instance, remember that only point positions can change, not the number of points
  146458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146460. * @param name defines the name of the new line system
  146461. * @param options defines the options used to create the line system
  146462. * @param scene defines the hosting scene
  146463. * @returns a new line mesh
  146464. */
  146465. static CreateLines(name: string, options: {
  146466. points: Vector3[];
  146467. updatable?: boolean;
  146468. instance?: Nullable<LinesMesh>;
  146469. colors?: Color4[];
  146470. useVertexAlpha?: boolean;
  146471. }, scene?: Nullable<Scene>): LinesMesh;
  146472. /**
  146473. * Creates a dashed line mesh
  146474. * * 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
  146475. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146476. * * The parameter `points` is an array successive Vector3
  146477. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146478. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146479. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146480. * * 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
  146481. * * When updating an instance, remember that only point positions can change, not the number of points
  146482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146483. * @param name defines the name of the mesh
  146484. * @param options defines the options used to create the mesh
  146485. * @param scene defines the hosting scene
  146486. * @returns the dashed line mesh
  146487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146488. */
  146489. static CreateDashedLines(name: string, options: {
  146490. points: Vector3[];
  146491. dashSize?: number;
  146492. gapSize?: number;
  146493. dashNb?: number;
  146494. updatable?: boolean;
  146495. instance?: LinesMesh;
  146496. }, scene?: Nullable<Scene>): LinesMesh;
  146497. /**
  146498. * 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.
  146499. * * 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.
  146500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146501. * * 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.
  146502. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146503. * * 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
  146504. * * 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
  146505. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146510. * @param name defines the name of the mesh
  146511. * @param options defines the options used to create the mesh
  146512. * @param scene defines the hosting scene
  146513. * @returns the extruded shape mesh
  146514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146516. */
  146517. static ExtrudeShape(name: string, options: {
  146518. shape: Vector3[];
  146519. path: Vector3[];
  146520. scale?: number;
  146521. rotation?: number;
  146522. cap?: number;
  146523. updatable?: boolean;
  146524. sideOrientation?: number;
  146525. frontUVs?: Vector4;
  146526. backUVs?: Vector4;
  146527. instance?: Mesh;
  146528. invertUV?: boolean;
  146529. }, scene?: Nullable<Scene>): Mesh;
  146530. /**
  146531. * Creates an custom extruded shape mesh.
  146532. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146533. * * 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.
  146534. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146535. * * 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
  146536. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146537. * * 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
  146538. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146539. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146540. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146541. * * 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
  146542. * * 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
  146543. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146548. * @param name defines the name of the mesh
  146549. * @param options defines the options used to create the mesh
  146550. * @param scene defines the hosting scene
  146551. * @returns the custom extruded shape mesh
  146552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146553. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146555. */
  146556. static ExtrudeShapeCustom(name: string, options: {
  146557. shape: Vector3[];
  146558. path: Vector3[];
  146559. scaleFunction?: any;
  146560. rotationFunction?: any;
  146561. ribbonCloseArray?: boolean;
  146562. ribbonClosePath?: boolean;
  146563. cap?: number;
  146564. updatable?: boolean;
  146565. sideOrientation?: number;
  146566. frontUVs?: Vector4;
  146567. backUVs?: Vector4;
  146568. instance?: Mesh;
  146569. invertUV?: boolean;
  146570. }, scene?: Nullable<Scene>): Mesh;
  146571. /**
  146572. * Creates lathe mesh.
  146573. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146574. * * 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
  146575. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146576. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146577. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146578. * * 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
  146579. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146580. * * 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
  146581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146585. * @param name defines the name of the mesh
  146586. * @param options defines the options used to create the mesh
  146587. * @param scene defines the hosting scene
  146588. * @returns the lathe mesh
  146589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146590. */
  146591. static CreateLathe(name: string, options: {
  146592. shape: Vector3[];
  146593. radius?: number;
  146594. tessellation?: number;
  146595. clip?: number;
  146596. arc?: number;
  146597. closed?: boolean;
  146598. updatable?: boolean;
  146599. sideOrientation?: number;
  146600. frontUVs?: Vector4;
  146601. backUVs?: Vector4;
  146602. cap?: number;
  146603. invertUV?: boolean;
  146604. }, scene?: Nullable<Scene>): Mesh;
  146605. /**
  146606. * Creates a tiled plane mesh
  146607. * * You can set a limited pattern arrangement with the tiles
  146608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146611. * @param name defines the name of the mesh
  146612. * @param options defines the options used to create the mesh
  146613. * @param scene defines the hosting scene
  146614. * @returns the plane mesh
  146615. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146616. */
  146617. static CreateTiledPlane(name: string, options: {
  146618. pattern?: number;
  146619. tileSize?: number;
  146620. tileWidth?: number;
  146621. tileHeight?: number;
  146622. size?: number;
  146623. width?: number;
  146624. height?: number;
  146625. alignHorizontal?: number;
  146626. alignVertical?: number;
  146627. sideOrientation?: number;
  146628. frontUVs?: Vector4;
  146629. backUVs?: Vector4;
  146630. updatable?: boolean;
  146631. }, scene?: Nullable<Scene>): Mesh;
  146632. /**
  146633. * Creates a plane mesh
  146634. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146635. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146636. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146640. * @param name defines the name of the mesh
  146641. * @param options defines the options used to create the mesh
  146642. * @param scene defines the hosting scene
  146643. * @returns the plane mesh
  146644. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146645. */
  146646. static CreatePlane(name: string, options: {
  146647. size?: number;
  146648. width?: number;
  146649. height?: number;
  146650. sideOrientation?: number;
  146651. frontUVs?: Vector4;
  146652. backUVs?: Vector4;
  146653. updatable?: boolean;
  146654. sourcePlane?: Plane;
  146655. }, scene?: Nullable<Scene>): Mesh;
  146656. /**
  146657. * Creates a ground mesh
  146658. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146659. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146661. * @param name defines the name of the mesh
  146662. * @param options defines the options used to create the mesh
  146663. * @param scene defines the hosting scene
  146664. * @returns the ground mesh
  146665. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146666. */
  146667. static CreateGround(name: string, options: {
  146668. width?: number;
  146669. height?: number;
  146670. subdivisions?: number;
  146671. subdivisionsX?: number;
  146672. subdivisionsY?: number;
  146673. updatable?: boolean;
  146674. }, scene?: Nullable<Scene>): Mesh;
  146675. /**
  146676. * Creates a tiled ground mesh
  146677. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146678. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146679. * * 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
  146680. * * 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
  146681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146682. * @param name defines the name of the mesh
  146683. * @param options defines the options used to create the mesh
  146684. * @param scene defines the hosting scene
  146685. * @returns the tiled ground mesh
  146686. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146687. */
  146688. static CreateTiledGround(name: string, options: {
  146689. xmin: number;
  146690. zmin: number;
  146691. xmax: number;
  146692. zmax: number;
  146693. subdivisions?: {
  146694. w: number;
  146695. h: number;
  146696. };
  146697. precision?: {
  146698. w: number;
  146699. h: number;
  146700. };
  146701. updatable?: boolean;
  146702. }, scene?: Nullable<Scene>): Mesh;
  146703. /**
  146704. * Creates a ground mesh from a height map
  146705. * * The parameter `url` sets the URL of the height map image resource.
  146706. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146707. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146708. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146709. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146710. * * 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.
  146711. * * 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).
  146712. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146714. * @param name defines the name of the mesh
  146715. * @param url defines the url to the height map
  146716. * @param options defines the options used to create the mesh
  146717. * @param scene defines the hosting scene
  146718. * @returns the ground mesh
  146719. * @see https://doc.babylonjs.com/babylon101/height_map
  146720. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146721. */
  146722. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146723. width?: number;
  146724. height?: number;
  146725. subdivisions?: number;
  146726. minHeight?: number;
  146727. maxHeight?: number;
  146728. colorFilter?: Color3;
  146729. alphaFilter?: number;
  146730. updatable?: boolean;
  146731. onReady?: (mesh: GroundMesh) => void;
  146732. }, scene?: Nullable<Scene>): GroundMesh;
  146733. /**
  146734. * Creates a polygon mesh
  146735. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146736. * * 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
  146737. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146740. * * Remember you can only change the shape positions, not their number when updating a polygon
  146741. * @param name defines the name of the mesh
  146742. * @param options defines the options used to create the mesh
  146743. * @param scene defines the hosting scene
  146744. * @param earcutInjection can be used to inject your own earcut reference
  146745. * @returns the polygon mesh
  146746. */
  146747. static CreatePolygon(name: string, options: {
  146748. shape: Vector3[];
  146749. holes?: Vector3[][];
  146750. depth?: number;
  146751. faceUV?: Vector4[];
  146752. faceColors?: Color4[];
  146753. updatable?: boolean;
  146754. sideOrientation?: number;
  146755. frontUVs?: Vector4;
  146756. backUVs?: Vector4;
  146757. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146758. /**
  146759. * Creates an extruded polygon mesh, with depth in the Y direction.
  146760. * * 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)
  146761. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146762. * @param name defines the name of the mesh
  146763. * @param options defines the options used to create the mesh
  146764. * @param scene defines the hosting scene
  146765. * @param earcutInjection can be used to inject your own earcut reference
  146766. * @returns the polygon mesh
  146767. */
  146768. static ExtrudePolygon(name: string, options: {
  146769. shape: Vector3[];
  146770. holes?: Vector3[][];
  146771. depth?: number;
  146772. faceUV?: Vector4[];
  146773. faceColors?: Color4[];
  146774. updatable?: boolean;
  146775. sideOrientation?: number;
  146776. frontUVs?: Vector4;
  146777. backUVs?: Vector4;
  146778. wrap?: boolean;
  146779. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146780. /**
  146781. * Creates a tube mesh.
  146782. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146783. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146784. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146785. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146786. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146787. * * 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)
  146788. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146789. * * 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
  146790. * * 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
  146791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146793. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146795. * @param name defines the name of the mesh
  146796. * @param options defines the options used to create the mesh
  146797. * @param scene defines the hosting scene
  146798. * @returns the tube mesh
  146799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146800. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146801. */
  146802. static CreateTube(name: string, options: {
  146803. path: Vector3[];
  146804. radius?: number;
  146805. tessellation?: number;
  146806. radiusFunction?: {
  146807. (i: number, distance: number): number;
  146808. };
  146809. cap?: number;
  146810. arc?: number;
  146811. updatable?: boolean;
  146812. sideOrientation?: number;
  146813. frontUVs?: Vector4;
  146814. backUVs?: Vector4;
  146815. instance?: Mesh;
  146816. invertUV?: boolean;
  146817. }, scene?: Nullable<Scene>): Mesh;
  146818. /**
  146819. * Creates a polyhedron mesh
  146820. * * 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
  146821. * * The parameter `size` (positive float, default 1) sets the polygon size
  146822. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146823. * * 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`
  146824. * * 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
  146825. * * 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)`)
  146826. * * 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
  146827. * * 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
  146828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146831. * @param name defines the name of the mesh
  146832. * @param options defines the options used to create the mesh
  146833. * @param scene defines the hosting scene
  146834. * @returns the polyhedron mesh
  146835. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146836. */
  146837. static CreatePolyhedron(name: string, options: {
  146838. type?: number;
  146839. size?: number;
  146840. sizeX?: number;
  146841. sizeY?: number;
  146842. sizeZ?: number;
  146843. custom?: any;
  146844. faceUV?: Vector4[];
  146845. faceColors?: Color4[];
  146846. flat?: boolean;
  146847. updatable?: boolean;
  146848. sideOrientation?: number;
  146849. frontUVs?: Vector4;
  146850. backUVs?: Vector4;
  146851. }, scene?: Nullable<Scene>): Mesh;
  146852. /**
  146853. * Creates a decal mesh.
  146854. * 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
  146855. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146856. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146857. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146858. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146859. * @param name defines the name of the mesh
  146860. * @param sourceMesh defines the mesh where the decal must be applied
  146861. * @param options defines the options used to create the mesh
  146862. * @param scene defines the hosting scene
  146863. * @returns the decal mesh
  146864. * @see https://doc.babylonjs.com/how_to/decals
  146865. */
  146866. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146867. position?: Vector3;
  146868. normal?: Vector3;
  146869. size?: Vector3;
  146870. angle?: number;
  146871. }): Mesh;
  146872. /**
  146873. * Creates a Capsule Mesh
  146874. * @param name defines the name of the mesh.
  146875. * @param options the constructors options used to shape the mesh.
  146876. * @param scene defines the scene the mesh is scoped to.
  146877. * @returns the capsule mesh
  146878. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146879. */
  146880. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146881. }
  146882. }
  146883. declare module BABYLON {
  146884. /**
  146885. * A simplifier interface for future simplification implementations
  146886. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146887. */
  146888. export interface ISimplifier {
  146889. /**
  146890. * Simplification of a given mesh according to the given settings.
  146891. * Since this requires computation, it is assumed that the function runs async.
  146892. * @param settings The settings of the simplification, including quality and distance
  146893. * @param successCallback A callback that will be called after the mesh was simplified.
  146894. * @param errorCallback in case of an error, this callback will be called. optional.
  146895. */
  146896. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146897. }
  146898. /**
  146899. * Expected simplification settings.
  146900. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146901. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146902. */
  146903. export interface ISimplificationSettings {
  146904. /**
  146905. * Gets or sets the expected quality
  146906. */
  146907. quality: number;
  146908. /**
  146909. * Gets or sets the distance when this optimized version should be used
  146910. */
  146911. distance: number;
  146912. /**
  146913. * Gets an already optimized mesh
  146914. */
  146915. optimizeMesh?: boolean;
  146916. }
  146917. /**
  146918. * Class used to specify simplification options
  146919. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146920. */
  146921. export class SimplificationSettings implements ISimplificationSettings {
  146922. /** expected quality */
  146923. quality: number;
  146924. /** distance when this optimized version should be used */
  146925. distance: number;
  146926. /** already optimized mesh */
  146927. optimizeMesh?: boolean | undefined;
  146928. /**
  146929. * Creates a SimplificationSettings
  146930. * @param quality expected quality
  146931. * @param distance distance when this optimized version should be used
  146932. * @param optimizeMesh already optimized mesh
  146933. */
  146934. constructor(
  146935. /** expected quality */
  146936. quality: number,
  146937. /** distance when this optimized version should be used */
  146938. distance: number,
  146939. /** already optimized mesh */
  146940. optimizeMesh?: boolean | undefined);
  146941. }
  146942. /**
  146943. * Interface used to define a simplification task
  146944. */
  146945. export interface ISimplificationTask {
  146946. /**
  146947. * Array of settings
  146948. */
  146949. settings: Array<ISimplificationSettings>;
  146950. /**
  146951. * Simplification type
  146952. */
  146953. simplificationType: SimplificationType;
  146954. /**
  146955. * Mesh to simplify
  146956. */
  146957. mesh: Mesh;
  146958. /**
  146959. * Callback called on success
  146960. */
  146961. successCallback?: () => void;
  146962. /**
  146963. * Defines if parallel processing can be used
  146964. */
  146965. parallelProcessing: boolean;
  146966. }
  146967. /**
  146968. * Queue used to order the simplification tasks
  146969. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146970. */
  146971. export class SimplificationQueue {
  146972. private _simplificationArray;
  146973. /**
  146974. * Gets a boolean indicating that the process is still running
  146975. */
  146976. running: boolean;
  146977. /**
  146978. * Creates a new queue
  146979. */
  146980. constructor();
  146981. /**
  146982. * Adds a new simplification task
  146983. * @param task defines a task to add
  146984. */
  146985. addTask(task: ISimplificationTask): void;
  146986. /**
  146987. * Execute next task
  146988. */
  146989. executeNext(): void;
  146990. /**
  146991. * Execute a simplification task
  146992. * @param task defines the task to run
  146993. */
  146994. runSimplification(task: ISimplificationTask): void;
  146995. private getSimplifier;
  146996. }
  146997. /**
  146998. * The implemented types of simplification
  146999. * At the moment only Quadratic Error Decimation is implemented
  147000. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147001. */
  147002. export enum SimplificationType {
  147003. /** Quadratic error decimation */
  147004. QUADRATIC = 0
  147005. }
  147006. /**
  147007. * An implementation of the Quadratic Error simplification algorithm.
  147008. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147009. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147010. * @author RaananW
  147011. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147012. */
  147013. export class QuadraticErrorSimplification implements ISimplifier {
  147014. private _mesh;
  147015. private triangles;
  147016. private vertices;
  147017. private references;
  147018. private _reconstructedMesh;
  147019. /** Gets or sets the number pf sync interations */
  147020. syncIterations: number;
  147021. /** Gets or sets the aggressiveness of the simplifier */
  147022. aggressiveness: number;
  147023. /** Gets or sets the number of allowed iterations for decimation */
  147024. decimationIterations: number;
  147025. /** Gets or sets the espilon to use for bounding box computation */
  147026. boundingBoxEpsilon: number;
  147027. /**
  147028. * Creates a new QuadraticErrorSimplification
  147029. * @param _mesh defines the target mesh
  147030. */
  147031. constructor(_mesh: Mesh);
  147032. /**
  147033. * Simplification of a given mesh according to the given settings.
  147034. * Since this requires computation, it is assumed that the function runs async.
  147035. * @param settings The settings of the simplification, including quality and distance
  147036. * @param successCallback A callback that will be called after the mesh was simplified.
  147037. */
  147038. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147039. private runDecimation;
  147040. private initWithMesh;
  147041. private init;
  147042. private reconstructMesh;
  147043. private initDecimatedMesh;
  147044. private isFlipped;
  147045. private updateTriangles;
  147046. private identifyBorder;
  147047. private updateMesh;
  147048. private vertexError;
  147049. private calculateError;
  147050. }
  147051. }
  147052. declare module BABYLON {
  147053. interface Scene {
  147054. /** @hidden (Backing field) */
  147055. _simplificationQueue: SimplificationQueue;
  147056. /**
  147057. * Gets or sets the simplification queue attached to the scene
  147058. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147059. */
  147060. simplificationQueue: SimplificationQueue;
  147061. }
  147062. interface Mesh {
  147063. /**
  147064. * Simplify the mesh according to the given array of settings.
  147065. * Function will return immediately and will simplify async
  147066. * @param settings a collection of simplification settings
  147067. * @param parallelProcessing should all levels calculate parallel or one after the other
  147068. * @param simplificationType the type of simplification to run
  147069. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147070. * @returns the current mesh
  147071. */
  147072. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147073. }
  147074. /**
  147075. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147076. * created in a scene
  147077. */
  147078. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147079. /**
  147080. * The component name helpfull to identify the component in the list of scene components.
  147081. */
  147082. readonly name: string;
  147083. /**
  147084. * The scene the component belongs to.
  147085. */
  147086. scene: Scene;
  147087. /**
  147088. * Creates a new instance of the component for the given scene
  147089. * @param scene Defines the scene to register the component in
  147090. */
  147091. constructor(scene: Scene);
  147092. /**
  147093. * Registers the component in a given scene
  147094. */
  147095. register(): void;
  147096. /**
  147097. * Rebuilds the elements related to this component in case of
  147098. * context lost for instance.
  147099. */
  147100. rebuild(): void;
  147101. /**
  147102. * Disposes the component and the associated ressources
  147103. */
  147104. dispose(): void;
  147105. private _beforeCameraUpdate;
  147106. }
  147107. }
  147108. declare module BABYLON {
  147109. interface Mesh {
  147110. /**
  147111. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147112. */
  147113. thinInstanceEnablePicking: boolean;
  147114. /**
  147115. * Creates a new thin instance
  147116. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147117. * @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
  147118. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147119. */
  147120. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147121. /**
  147122. * Adds the transformation (matrix) of the current mesh as a thin instance
  147123. * @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
  147124. * @returns the thin instance index number
  147125. */
  147126. thinInstanceAddSelf(refresh: boolean): number;
  147127. /**
  147128. * Registers a custom attribute to be used with thin instances
  147129. * @param kind name of the attribute
  147130. * @param stride size in floats of the attribute
  147131. */
  147132. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147133. /**
  147134. * Sets the matrix of a thin instance
  147135. * @param index index of the thin instance
  147136. * @param matrix matrix to set
  147137. * @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
  147138. */
  147139. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147140. /**
  147141. * Sets the value of a custom attribute for a thin instance
  147142. * @param kind name of the attribute
  147143. * @param index index of the thin instance
  147144. * @param value value to set
  147145. * @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
  147146. */
  147147. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147148. /**
  147149. * 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.
  147150. */
  147151. thinInstanceCount: number;
  147152. /**
  147153. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147154. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147155. * @param buffer buffer to set
  147156. * @param stride size in floats of each value of the buffer
  147157. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147158. */
  147159. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147160. /**
  147161. * Gets the list of world matrices
  147162. * @return an array containing all the world matrices from the thin instances
  147163. */
  147164. thinInstanceGetWorldMatrices(): Matrix[];
  147165. /**
  147166. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147167. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147168. */
  147169. thinInstanceBufferUpdated(kind: string): void;
  147170. /**
  147171. * Applies a partial update to a buffer directly on the GPU
  147172. * 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
  147173. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147174. * @param data the data to set in the GPU buffer
  147175. * @param offset the offset in the GPU buffer where to update the data
  147176. */
  147177. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147178. /**
  147179. * Refreshes the bounding info, taking into account all the thin instances defined
  147180. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147181. */
  147182. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147183. /** @hidden */
  147184. _thinInstanceInitializeUserStorage(): void;
  147185. /** @hidden */
  147186. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147187. /** @hidden */
  147188. _userThinInstanceBuffersStorage: {
  147189. data: {
  147190. [key: string]: Float32Array;
  147191. };
  147192. sizes: {
  147193. [key: string]: number;
  147194. };
  147195. vertexBuffers: {
  147196. [key: string]: Nullable<VertexBuffer>;
  147197. };
  147198. strides: {
  147199. [key: string]: number;
  147200. };
  147201. };
  147202. }
  147203. }
  147204. declare module BABYLON {
  147205. /**
  147206. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147207. */
  147208. export interface INavigationEnginePlugin {
  147209. /**
  147210. * plugin name
  147211. */
  147212. name: string;
  147213. /**
  147214. * Creates a navigation mesh
  147215. * @param meshes array of all the geometry used to compute the navigatio mesh
  147216. * @param parameters bunch of parameters used to filter geometry
  147217. */
  147218. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147219. /**
  147220. * Create a navigation mesh debug mesh
  147221. * @param scene is where the mesh will be added
  147222. * @returns debug display mesh
  147223. */
  147224. createDebugNavMesh(scene: Scene): Mesh;
  147225. /**
  147226. * Get a navigation mesh constrained position, closest to the parameter position
  147227. * @param position world position
  147228. * @returns the closest point to position constrained by the navigation mesh
  147229. */
  147230. getClosestPoint(position: Vector3): Vector3;
  147231. /**
  147232. * Get a navigation mesh constrained position, closest to the parameter position
  147233. * @param position world position
  147234. * @param result output the closest point to position constrained by the navigation mesh
  147235. */
  147236. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147237. /**
  147238. * Get a navigation mesh constrained position, within a particular radius
  147239. * @param position world position
  147240. * @param maxRadius the maximum distance to the constrained world position
  147241. * @returns the closest point to position constrained by the navigation mesh
  147242. */
  147243. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147244. /**
  147245. * Get a navigation mesh constrained position, within a particular radius
  147246. * @param position world position
  147247. * @param maxRadius the maximum distance to the constrained world position
  147248. * @param result output the closest point to position constrained by the navigation mesh
  147249. */
  147250. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147251. /**
  147252. * Compute the final position from a segment made of destination-position
  147253. * @param position world position
  147254. * @param destination world position
  147255. * @returns the resulting point along the navmesh
  147256. */
  147257. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147258. /**
  147259. * Compute the final position from a segment made of destination-position
  147260. * @param position world position
  147261. * @param destination world position
  147262. * @param result output the resulting point along the navmesh
  147263. */
  147264. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147265. /**
  147266. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147267. * @param start world position
  147268. * @param end world position
  147269. * @returns array containing world position composing the path
  147270. */
  147271. computePath(start: Vector3, end: Vector3): Vector3[];
  147272. /**
  147273. * If this plugin is supported
  147274. * @returns true if plugin is supported
  147275. */
  147276. isSupported(): boolean;
  147277. /**
  147278. * Create a new Crowd so you can add agents
  147279. * @param maxAgents the maximum agent count in the crowd
  147280. * @param maxAgentRadius the maximum radius an agent can have
  147281. * @param scene to attach the crowd to
  147282. * @returns the crowd you can add agents to
  147283. */
  147284. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147285. /**
  147286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147287. * The queries will try to find a solution within those bounds
  147288. * default is (1,1,1)
  147289. * @param extent x,y,z value that define the extent around the queries point of reference
  147290. */
  147291. setDefaultQueryExtent(extent: Vector3): void;
  147292. /**
  147293. * Get the Bounding box extent specified by setDefaultQueryExtent
  147294. * @returns the box extent values
  147295. */
  147296. getDefaultQueryExtent(): Vector3;
  147297. /**
  147298. * build the navmesh from a previously saved state using getNavmeshData
  147299. * @param data the Uint8Array returned by getNavmeshData
  147300. */
  147301. buildFromNavmeshData(data: Uint8Array): void;
  147302. /**
  147303. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147304. * @returns data the Uint8Array that can be saved and reused
  147305. */
  147306. getNavmeshData(): Uint8Array;
  147307. /**
  147308. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147309. * @param result output the box extent values
  147310. */
  147311. getDefaultQueryExtentToRef(result: Vector3): void;
  147312. /**
  147313. * Release all resources
  147314. */
  147315. dispose(): void;
  147316. }
  147317. /**
  147318. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147319. */
  147320. export interface ICrowd {
  147321. /**
  147322. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147323. * You can attach anything to that node. The node position is updated in the scene update tick.
  147324. * @param pos world position that will be constrained by the navigation mesh
  147325. * @param parameters agent parameters
  147326. * @param transform hooked to the agent that will be update by the scene
  147327. * @returns agent index
  147328. */
  147329. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147330. /**
  147331. * Returns the agent position in world space
  147332. * @param index agent index returned by addAgent
  147333. * @returns world space position
  147334. */
  147335. getAgentPosition(index: number): Vector3;
  147336. /**
  147337. * Gets the agent position result in world space
  147338. * @param index agent index returned by addAgent
  147339. * @param result output world space position
  147340. */
  147341. getAgentPositionToRef(index: number, result: Vector3): void;
  147342. /**
  147343. * Gets the agent velocity in world space
  147344. * @param index agent index returned by addAgent
  147345. * @returns world space velocity
  147346. */
  147347. getAgentVelocity(index: number): Vector3;
  147348. /**
  147349. * Gets the agent velocity result in world space
  147350. * @param index agent index returned by addAgent
  147351. * @param result output world space velocity
  147352. */
  147353. getAgentVelocityToRef(index: number, result: Vector3): void;
  147354. /**
  147355. * remove a particular agent previously created
  147356. * @param index agent index returned by addAgent
  147357. */
  147358. removeAgent(index: number): void;
  147359. /**
  147360. * get the list of all agents attached to this crowd
  147361. * @returns list of agent indices
  147362. */
  147363. getAgents(): number[];
  147364. /**
  147365. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147366. * @param deltaTime in seconds
  147367. */
  147368. update(deltaTime: number): void;
  147369. /**
  147370. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147371. * @param index agent index returned by addAgent
  147372. * @param destination targeted world position
  147373. */
  147374. agentGoto(index: number, destination: Vector3): void;
  147375. /**
  147376. * Teleport the agent to a new position
  147377. * @param index agent index returned by addAgent
  147378. * @param destination targeted world position
  147379. */
  147380. agentTeleport(index: number, destination: Vector3): void;
  147381. /**
  147382. * Update agent parameters
  147383. * @param index agent index returned by addAgent
  147384. * @param parameters agent parameters
  147385. */
  147386. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147387. /**
  147388. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147389. * The queries will try to find a solution within those bounds
  147390. * default is (1,1,1)
  147391. * @param extent x,y,z value that define the extent around the queries point of reference
  147392. */
  147393. setDefaultQueryExtent(extent: Vector3): void;
  147394. /**
  147395. * Get the Bounding box extent specified by setDefaultQueryExtent
  147396. * @returns the box extent values
  147397. */
  147398. getDefaultQueryExtent(): Vector3;
  147399. /**
  147400. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147401. * @param result output the box extent values
  147402. */
  147403. getDefaultQueryExtentToRef(result: Vector3): void;
  147404. /**
  147405. * Release all resources
  147406. */
  147407. dispose(): void;
  147408. }
  147409. /**
  147410. * Configures an agent
  147411. */
  147412. export interface IAgentParameters {
  147413. /**
  147414. * Agent radius. [Limit: >= 0]
  147415. */
  147416. radius: number;
  147417. /**
  147418. * Agent height. [Limit: > 0]
  147419. */
  147420. height: number;
  147421. /**
  147422. * Maximum allowed acceleration. [Limit: >= 0]
  147423. */
  147424. maxAcceleration: number;
  147425. /**
  147426. * Maximum allowed speed. [Limit: >= 0]
  147427. */
  147428. maxSpeed: number;
  147429. /**
  147430. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147431. */
  147432. collisionQueryRange: number;
  147433. /**
  147434. * The path visibility optimization range. [Limit: > 0]
  147435. */
  147436. pathOptimizationRange: number;
  147437. /**
  147438. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147439. */
  147440. separationWeight: number;
  147441. }
  147442. /**
  147443. * Configures the navigation mesh creation
  147444. */
  147445. export interface INavMeshParameters {
  147446. /**
  147447. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147448. */
  147449. cs: number;
  147450. /**
  147451. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147452. */
  147453. ch: number;
  147454. /**
  147455. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147456. */
  147457. walkableSlopeAngle: number;
  147458. /**
  147459. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147460. * be considered walkable. [Limit: >= 3] [Units: vx]
  147461. */
  147462. walkableHeight: number;
  147463. /**
  147464. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147465. */
  147466. walkableClimb: number;
  147467. /**
  147468. * The distance to erode/shrink the walkable area of the heightfield away from
  147469. * obstructions. [Limit: >=0] [Units: vx]
  147470. */
  147471. walkableRadius: number;
  147472. /**
  147473. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147474. */
  147475. maxEdgeLen: number;
  147476. /**
  147477. * The maximum distance a simplfied contour's border edges should deviate
  147478. * the original raw contour. [Limit: >=0] [Units: vx]
  147479. */
  147480. maxSimplificationError: number;
  147481. /**
  147482. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147483. */
  147484. minRegionArea: number;
  147485. /**
  147486. * Any regions with a span count smaller than this value will, if possible,
  147487. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147488. */
  147489. mergeRegionArea: number;
  147490. /**
  147491. * The maximum number of vertices allowed for polygons generated during the
  147492. * contour to polygon conversion process. [Limit: >= 3]
  147493. */
  147494. maxVertsPerPoly: number;
  147495. /**
  147496. * Sets the sampling distance to use when generating the detail mesh.
  147497. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147498. */
  147499. detailSampleDist: number;
  147500. /**
  147501. * The maximum distance the detail mesh surface should deviate from heightfield
  147502. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147503. */
  147504. detailSampleMaxError: number;
  147505. }
  147506. }
  147507. declare module BABYLON {
  147508. /**
  147509. * RecastJS navigation plugin
  147510. */
  147511. export class RecastJSPlugin implements INavigationEnginePlugin {
  147512. /**
  147513. * Reference to the Recast library
  147514. */
  147515. bjsRECAST: any;
  147516. /**
  147517. * plugin name
  147518. */
  147519. name: string;
  147520. /**
  147521. * the first navmesh created. We might extend this to support multiple navmeshes
  147522. */
  147523. navMesh: any;
  147524. /**
  147525. * Initializes the recastJS plugin
  147526. * @param recastInjection can be used to inject your own recast reference
  147527. */
  147528. constructor(recastInjection?: any);
  147529. /**
  147530. * Creates a navigation mesh
  147531. * @param meshes array of all the geometry used to compute the navigatio mesh
  147532. * @param parameters bunch of parameters used to filter geometry
  147533. */
  147534. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147535. /**
  147536. * Create a navigation mesh debug mesh
  147537. * @param scene is where the mesh will be added
  147538. * @returns debug display mesh
  147539. */
  147540. createDebugNavMesh(scene: Scene): Mesh;
  147541. /**
  147542. * Get a navigation mesh constrained position, closest to the parameter position
  147543. * @param position world position
  147544. * @returns the closest point to position constrained by the navigation mesh
  147545. */
  147546. getClosestPoint(position: Vector3): Vector3;
  147547. /**
  147548. * Get a navigation mesh constrained position, closest to the parameter position
  147549. * @param position world position
  147550. * @param result output the closest point to position constrained by the navigation mesh
  147551. */
  147552. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147553. /**
  147554. * Get a navigation mesh constrained position, within a particular radius
  147555. * @param position world position
  147556. * @param maxRadius the maximum distance to the constrained world position
  147557. * @returns the closest point to position constrained by the navigation mesh
  147558. */
  147559. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147560. /**
  147561. * Get a navigation mesh constrained position, within a particular radius
  147562. * @param position world position
  147563. * @param maxRadius the maximum distance to the constrained world position
  147564. * @param result output the closest point to position constrained by the navigation mesh
  147565. */
  147566. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147567. /**
  147568. * Compute the final position from a segment made of destination-position
  147569. * @param position world position
  147570. * @param destination world position
  147571. * @returns the resulting point along the navmesh
  147572. */
  147573. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147574. /**
  147575. * Compute the final position from a segment made of destination-position
  147576. * @param position world position
  147577. * @param destination world position
  147578. * @param result output the resulting point along the navmesh
  147579. */
  147580. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147581. /**
  147582. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147583. * @param start world position
  147584. * @param end world position
  147585. * @returns array containing world position composing the path
  147586. */
  147587. computePath(start: Vector3, end: Vector3): Vector3[];
  147588. /**
  147589. * Create a new Crowd so you can add agents
  147590. * @param maxAgents the maximum agent count in the crowd
  147591. * @param maxAgentRadius the maximum radius an agent can have
  147592. * @param scene to attach the crowd to
  147593. * @returns the crowd you can add agents to
  147594. */
  147595. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147596. /**
  147597. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147598. * The queries will try to find a solution within those bounds
  147599. * default is (1,1,1)
  147600. * @param extent x,y,z value that define the extent around the queries point of reference
  147601. */
  147602. setDefaultQueryExtent(extent: Vector3): void;
  147603. /**
  147604. * Get the Bounding box extent specified by setDefaultQueryExtent
  147605. * @returns the box extent values
  147606. */
  147607. getDefaultQueryExtent(): Vector3;
  147608. /**
  147609. * build the navmesh from a previously saved state using getNavmeshData
  147610. * @param data the Uint8Array returned by getNavmeshData
  147611. */
  147612. buildFromNavmeshData(data: Uint8Array): void;
  147613. /**
  147614. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147615. * @returns data the Uint8Array that can be saved and reused
  147616. */
  147617. getNavmeshData(): Uint8Array;
  147618. /**
  147619. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147620. * @param result output the box extent values
  147621. */
  147622. getDefaultQueryExtentToRef(result: Vector3): void;
  147623. /**
  147624. * Disposes
  147625. */
  147626. dispose(): void;
  147627. /**
  147628. * If this plugin is supported
  147629. * @returns true if plugin is supported
  147630. */
  147631. isSupported(): boolean;
  147632. }
  147633. /**
  147634. * Recast detour crowd implementation
  147635. */
  147636. export class RecastJSCrowd implements ICrowd {
  147637. /**
  147638. * Recast/detour plugin
  147639. */
  147640. bjsRECASTPlugin: RecastJSPlugin;
  147641. /**
  147642. * Link to the detour crowd
  147643. */
  147644. recastCrowd: any;
  147645. /**
  147646. * One transform per agent
  147647. */
  147648. transforms: TransformNode[];
  147649. /**
  147650. * All agents created
  147651. */
  147652. agents: number[];
  147653. /**
  147654. * Link to the scene is kept to unregister the crowd from the scene
  147655. */
  147656. private _scene;
  147657. /**
  147658. * Observer for crowd updates
  147659. */
  147660. private _onBeforeAnimationsObserver;
  147661. /**
  147662. * Constructor
  147663. * @param plugin recastJS plugin
  147664. * @param maxAgents the maximum agent count in the crowd
  147665. * @param maxAgentRadius the maximum radius an agent can have
  147666. * @param scene to attach the crowd to
  147667. * @returns the crowd you can add agents to
  147668. */
  147669. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147670. /**
  147671. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147672. * You can attach anything to that node. The node position is updated in the scene update tick.
  147673. * @param pos world position that will be constrained by the navigation mesh
  147674. * @param parameters agent parameters
  147675. * @param transform hooked to the agent that will be update by the scene
  147676. * @returns agent index
  147677. */
  147678. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147679. /**
  147680. * Returns the agent position in world space
  147681. * @param index agent index returned by addAgent
  147682. * @returns world space position
  147683. */
  147684. getAgentPosition(index: number): Vector3;
  147685. /**
  147686. * Returns the agent position result in world space
  147687. * @param index agent index returned by addAgent
  147688. * @param result output world space position
  147689. */
  147690. getAgentPositionToRef(index: number, result: Vector3): void;
  147691. /**
  147692. * Returns the agent velocity in world space
  147693. * @param index agent index returned by addAgent
  147694. * @returns world space velocity
  147695. */
  147696. getAgentVelocity(index: number): Vector3;
  147697. /**
  147698. * Returns the agent velocity result in world space
  147699. * @param index agent index returned by addAgent
  147700. * @param result output world space velocity
  147701. */
  147702. getAgentVelocityToRef(index: number, result: Vector3): void;
  147703. /**
  147704. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147705. * @param index agent index returned by addAgent
  147706. * @param destination targeted world position
  147707. */
  147708. agentGoto(index: number, destination: Vector3): void;
  147709. /**
  147710. * Teleport the agent to a new position
  147711. * @param index agent index returned by addAgent
  147712. * @param destination targeted world position
  147713. */
  147714. agentTeleport(index: number, destination: Vector3): void;
  147715. /**
  147716. * Update agent parameters
  147717. * @param index agent index returned by addAgent
  147718. * @param parameters agent parameters
  147719. */
  147720. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147721. /**
  147722. * remove a particular agent previously created
  147723. * @param index agent index returned by addAgent
  147724. */
  147725. removeAgent(index: number): void;
  147726. /**
  147727. * get the list of all agents attached to this crowd
  147728. * @returns list of agent indices
  147729. */
  147730. getAgents(): number[];
  147731. /**
  147732. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147733. * @param deltaTime in seconds
  147734. */
  147735. update(deltaTime: number): void;
  147736. /**
  147737. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147738. * The queries will try to find a solution within those bounds
  147739. * default is (1,1,1)
  147740. * @param extent x,y,z value that define the extent around the queries point of reference
  147741. */
  147742. setDefaultQueryExtent(extent: Vector3): void;
  147743. /**
  147744. * Get the Bounding box extent specified by setDefaultQueryExtent
  147745. * @returns the box extent values
  147746. */
  147747. getDefaultQueryExtent(): Vector3;
  147748. /**
  147749. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147750. * @param result output the box extent values
  147751. */
  147752. getDefaultQueryExtentToRef(result: Vector3): void;
  147753. /**
  147754. * Release all resources
  147755. */
  147756. dispose(): void;
  147757. }
  147758. }
  147759. declare module BABYLON {
  147760. /**
  147761. * Class used to enable access to IndexedDB
  147762. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147763. */
  147764. export class Database implements IOfflineProvider {
  147765. private _callbackManifestChecked;
  147766. private _currentSceneUrl;
  147767. private _db;
  147768. private _enableSceneOffline;
  147769. private _enableTexturesOffline;
  147770. private _manifestVersionFound;
  147771. private _mustUpdateRessources;
  147772. private _hasReachedQuota;
  147773. private _isSupported;
  147774. private _idbFactory;
  147775. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147776. private static IsUASupportingBlobStorage;
  147777. /**
  147778. * Gets a boolean indicating if Database storate is enabled (off by default)
  147779. */
  147780. static IDBStorageEnabled: boolean;
  147781. /**
  147782. * Gets a boolean indicating if scene must be saved in the database
  147783. */
  147784. get enableSceneOffline(): boolean;
  147785. /**
  147786. * Gets a boolean indicating if textures must be saved in the database
  147787. */
  147788. get enableTexturesOffline(): boolean;
  147789. /**
  147790. * Creates a new Database
  147791. * @param urlToScene defines the url to load the scene
  147792. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147793. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147794. */
  147795. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147796. private static _ParseURL;
  147797. private static _ReturnFullUrlLocation;
  147798. private _checkManifestFile;
  147799. /**
  147800. * Open the database and make it available
  147801. * @param successCallback defines the callback to call on success
  147802. * @param errorCallback defines the callback to call on error
  147803. */
  147804. open(successCallback: () => void, errorCallback: () => void): void;
  147805. /**
  147806. * Loads an image from the database
  147807. * @param url defines the url to load from
  147808. * @param image defines the target DOM image
  147809. */
  147810. loadImage(url: string, image: HTMLImageElement): void;
  147811. private _loadImageFromDBAsync;
  147812. private _saveImageIntoDBAsync;
  147813. private _checkVersionFromDB;
  147814. private _loadVersionFromDBAsync;
  147815. private _saveVersionIntoDBAsync;
  147816. /**
  147817. * Loads a file from database
  147818. * @param url defines the URL to load from
  147819. * @param sceneLoaded defines a callback to call on success
  147820. * @param progressCallBack defines a callback to call when progress changed
  147821. * @param errorCallback defines a callback to call on error
  147822. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147823. */
  147824. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147825. private _loadFileAsync;
  147826. private _saveFileAsync;
  147827. /**
  147828. * Validates if xhr data is correct
  147829. * @param xhr defines the request to validate
  147830. * @param dataType defines the expected data type
  147831. * @returns true if data is correct
  147832. */
  147833. private static _ValidateXHRData;
  147834. }
  147835. }
  147836. declare module BABYLON {
  147837. /** @hidden */
  147838. export var gpuUpdateParticlesPixelShader: {
  147839. name: string;
  147840. shader: string;
  147841. };
  147842. }
  147843. declare module BABYLON {
  147844. /** @hidden */
  147845. export var gpuUpdateParticlesVertexShader: {
  147846. name: string;
  147847. shader: string;
  147848. };
  147849. }
  147850. declare module BABYLON {
  147851. /** @hidden */
  147852. export var clipPlaneFragmentDeclaration2: {
  147853. name: string;
  147854. shader: string;
  147855. };
  147856. }
  147857. declare module BABYLON {
  147858. /** @hidden */
  147859. export var gpuRenderParticlesPixelShader: {
  147860. name: string;
  147861. shader: string;
  147862. };
  147863. }
  147864. declare module BABYLON {
  147865. /** @hidden */
  147866. export var clipPlaneVertexDeclaration2: {
  147867. name: string;
  147868. shader: string;
  147869. };
  147870. }
  147871. declare module BABYLON {
  147872. /** @hidden */
  147873. export var gpuRenderParticlesVertexShader: {
  147874. name: string;
  147875. shader: string;
  147876. };
  147877. }
  147878. declare module BABYLON {
  147879. /**
  147880. * This represents a GPU particle system in Babylon
  147881. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147882. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147883. */
  147884. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147885. /**
  147886. * The layer mask we are rendering the particles through.
  147887. */
  147888. layerMask: number;
  147889. private _capacity;
  147890. private _activeCount;
  147891. private _currentActiveCount;
  147892. private _accumulatedCount;
  147893. private _renderEffect;
  147894. private _updateEffect;
  147895. private _buffer0;
  147896. private _buffer1;
  147897. private _spriteBuffer;
  147898. private _updateVAO;
  147899. private _renderVAO;
  147900. private _targetIndex;
  147901. private _sourceBuffer;
  147902. private _targetBuffer;
  147903. private _currentRenderId;
  147904. private _started;
  147905. private _stopped;
  147906. private _timeDelta;
  147907. private _randomTexture;
  147908. private _randomTexture2;
  147909. private _attributesStrideSize;
  147910. private _updateEffectOptions;
  147911. private _randomTextureSize;
  147912. private _actualFrame;
  147913. private _customEffect;
  147914. private readonly _rawTextureWidth;
  147915. /**
  147916. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147917. */
  147918. static get IsSupported(): boolean;
  147919. /**
  147920. * An event triggered when the system is disposed.
  147921. */
  147922. onDisposeObservable: Observable<IParticleSystem>;
  147923. /**
  147924. * Gets the maximum number of particles active at the same time.
  147925. * @returns The max number of active particles.
  147926. */
  147927. getCapacity(): number;
  147928. /**
  147929. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147930. * to override the particles.
  147931. */
  147932. forceDepthWrite: boolean;
  147933. /**
  147934. * Gets or set the number of active particles
  147935. */
  147936. get activeParticleCount(): number;
  147937. set activeParticleCount(value: number);
  147938. private _preWarmDone;
  147939. /**
  147940. * Specifies if the particles are updated in emitter local space or world space.
  147941. */
  147942. isLocal: boolean;
  147943. /** Gets or sets a matrix to use to compute projection */
  147944. defaultProjectionMatrix: Matrix;
  147945. /**
  147946. * Is this system ready to be used/rendered
  147947. * @return true if the system is ready
  147948. */
  147949. isReady(): boolean;
  147950. /**
  147951. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147952. * @returns True if it has been started, otherwise false.
  147953. */
  147954. isStarted(): boolean;
  147955. /**
  147956. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147957. * @returns True if it has been stopped, otherwise false.
  147958. */
  147959. isStopped(): boolean;
  147960. /**
  147961. * Gets a boolean indicating that the system is stopping
  147962. * @returns true if the system is currently stopping
  147963. */
  147964. isStopping(): boolean;
  147965. /**
  147966. * Gets the number of particles active at the same time.
  147967. * @returns The number of active particles.
  147968. */
  147969. getActiveCount(): number;
  147970. /**
  147971. * Starts the particle system and begins to emit
  147972. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147973. */
  147974. start(delay?: number): void;
  147975. /**
  147976. * Stops the particle system.
  147977. */
  147978. stop(): void;
  147979. /**
  147980. * Remove all active particles
  147981. */
  147982. reset(): void;
  147983. /**
  147984. * Returns the string "GPUParticleSystem"
  147985. * @returns a string containing the class name
  147986. */
  147987. getClassName(): string;
  147988. /**
  147989. * Gets the custom effect used to render the particles
  147990. * @param blendMode Blend mode for which the effect should be retrieved
  147991. * @returns The effect
  147992. */
  147993. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147994. /**
  147995. * Sets the custom effect used to render the particles
  147996. * @param effect The effect to set
  147997. * @param blendMode Blend mode for which the effect should be set
  147998. */
  147999. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148000. /** @hidden */
  148001. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148002. /**
  148003. * Observable that will be called just before the particles are drawn
  148004. */
  148005. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148006. /**
  148007. * Gets the name of the particle vertex shader
  148008. */
  148009. get vertexShaderName(): string;
  148010. private _colorGradientsTexture;
  148011. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148012. /**
  148013. * Adds a new color gradient
  148014. * @param gradient defines the gradient to use (between 0 and 1)
  148015. * @param color1 defines the color to affect to the specified gradient
  148016. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148017. * @returns the current particle system
  148018. */
  148019. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148020. private _refreshColorGradient;
  148021. /** Force the system to rebuild all gradients that need to be resync */
  148022. forceRefreshGradients(): void;
  148023. /**
  148024. * Remove a specific color gradient
  148025. * @param gradient defines the gradient to remove
  148026. * @returns the current particle system
  148027. */
  148028. removeColorGradient(gradient: number): GPUParticleSystem;
  148029. private _angularSpeedGradientsTexture;
  148030. private _sizeGradientsTexture;
  148031. private _velocityGradientsTexture;
  148032. private _limitVelocityGradientsTexture;
  148033. private _dragGradientsTexture;
  148034. private _addFactorGradient;
  148035. /**
  148036. * Adds a new size gradient
  148037. * @param gradient defines the gradient to use (between 0 and 1)
  148038. * @param factor defines the size factor to affect to the specified gradient
  148039. * @returns the current particle system
  148040. */
  148041. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148042. /**
  148043. * Remove a specific size gradient
  148044. * @param gradient defines the gradient to remove
  148045. * @returns the current particle system
  148046. */
  148047. removeSizeGradient(gradient: number): GPUParticleSystem;
  148048. private _refreshFactorGradient;
  148049. /**
  148050. * Adds a new angular speed gradient
  148051. * @param gradient defines the gradient to use (between 0 and 1)
  148052. * @param factor defines the angular speed to affect to the specified gradient
  148053. * @returns the current particle system
  148054. */
  148055. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148056. /**
  148057. * Remove a specific angular speed gradient
  148058. * @param gradient defines the gradient to remove
  148059. * @returns the current particle system
  148060. */
  148061. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148062. /**
  148063. * Adds a new velocity gradient
  148064. * @param gradient defines the gradient to use (between 0 and 1)
  148065. * @param factor defines the velocity to affect to the specified gradient
  148066. * @returns the current particle system
  148067. */
  148068. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148069. /**
  148070. * Remove a specific velocity gradient
  148071. * @param gradient defines the gradient to remove
  148072. * @returns the current particle system
  148073. */
  148074. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148075. /**
  148076. * Adds a new limit velocity gradient
  148077. * @param gradient defines the gradient to use (between 0 and 1)
  148078. * @param factor defines the limit velocity value to affect to the specified gradient
  148079. * @returns the current particle system
  148080. */
  148081. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148082. /**
  148083. * Remove a specific limit velocity gradient
  148084. * @param gradient defines the gradient to remove
  148085. * @returns the current particle system
  148086. */
  148087. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148088. /**
  148089. * Adds a new drag gradient
  148090. * @param gradient defines the gradient to use (between 0 and 1)
  148091. * @param factor defines the drag value to affect to the specified gradient
  148092. * @returns the current particle system
  148093. */
  148094. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148095. /**
  148096. * Remove a specific drag gradient
  148097. * @param gradient defines the gradient to remove
  148098. * @returns the current particle system
  148099. */
  148100. removeDragGradient(gradient: number): GPUParticleSystem;
  148101. /**
  148102. * Not supported by GPUParticleSystem
  148103. * @param gradient defines the gradient to use (between 0 and 1)
  148104. * @param factor defines the emit rate value to affect to the specified gradient
  148105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148106. * @returns the current particle system
  148107. */
  148108. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148109. /**
  148110. * Not supported by GPUParticleSystem
  148111. * @param gradient defines the gradient to remove
  148112. * @returns the current particle system
  148113. */
  148114. removeEmitRateGradient(gradient: number): IParticleSystem;
  148115. /**
  148116. * Not supported by GPUParticleSystem
  148117. * @param gradient defines the gradient to use (between 0 and 1)
  148118. * @param factor defines the start size value to affect to the specified gradient
  148119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148120. * @returns the current particle system
  148121. */
  148122. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148123. /**
  148124. * Not supported by GPUParticleSystem
  148125. * @param gradient defines the gradient to remove
  148126. * @returns the current particle system
  148127. */
  148128. removeStartSizeGradient(gradient: number): IParticleSystem;
  148129. /**
  148130. * Not supported by GPUParticleSystem
  148131. * @param gradient defines the gradient to use (between 0 and 1)
  148132. * @param min defines the color remap minimal range
  148133. * @param max defines the color remap maximal range
  148134. * @returns the current particle system
  148135. */
  148136. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148137. /**
  148138. * Not supported by GPUParticleSystem
  148139. * @param gradient defines the gradient to remove
  148140. * @returns the current particle system
  148141. */
  148142. removeColorRemapGradient(): IParticleSystem;
  148143. /**
  148144. * Not supported by GPUParticleSystem
  148145. * @param gradient defines the gradient to use (between 0 and 1)
  148146. * @param min defines the alpha remap minimal range
  148147. * @param max defines the alpha remap maximal range
  148148. * @returns the current particle system
  148149. */
  148150. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148151. /**
  148152. * Not supported by GPUParticleSystem
  148153. * @param gradient defines the gradient to remove
  148154. * @returns the current particle system
  148155. */
  148156. removeAlphaRemapGradient(): IParticleSystem;
  148157. /**
  148158. * Not supported by GPUParticleSystem
  148159. * @param gradient defines the gradient to use (between 0 and 1)
  148160. * @param color defines the color to affect to the specified gradient
  148161. * @returns the current particle system
  148162. */
  148163. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148164. /**
  148165. * Not supported by GPUParticleSystem
  148166. * @param gradient defines the gradient to remove
  148167. * @returns the current particle system
  148168. */
  148169. removeRampGradient(): IParticleSystem;
  148170. /**
  148171. * Not supported by GPUParticleSystem
  148172. * @returns the list of ramp gradients
  148173. */
  148174. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148175. /**
  148176. * Not supported by GPUParticleSystem
  148177. * Gets or sets a boolean indicating that ramp gradients must be used
  148178. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148179. */
  148180. get useRampGradients(): boolean;
  148181. set useRampGradients(value: boolean);
  148182. /**
  148183. * Not supported by GPUParticleSystem
  148184. * @param gradient defines the gradient to use (between 0 and 1)
  148185. * @param factor defines the life time factor to affect to the specified gradient
  148186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148187. * @returns the current particle system
  148188. */
  148189. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148190. /**
  148191. * Not supported by GPUParticleSystem
  148192. * @param gradient defines the gradient to remove
  148193. * @returns the current particle system
  148194. */
  148195. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148196. /**
  148197. * Instantiates a GPU particle system.
  148198. * 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.
  148199. * @param name The name of the particle system
  148200. * @param options The options used to create the system
  148201. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148202. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148203. * @param customEffect a custom effect used to change the way particles are rendered by default
  148204. */
  148205. constructor(name: string, options: Partial<{
  148206. capacity: number;
  148207. randomTextureSize: number;
  148208. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148209. protected _reset(): void;
  148210. private _createUpdateVAO;
  148211. private _createRenderVAO;
  148212. private _initialize;
  148213. /** @hidden */
  148214. _recreateUpdateEffect(): void;
  148215. private _getEffect;
  148216. /**
  148217. * Fill the defines array according to the current settings of the particle system
  148218. * @param defines Array to be updated
  148219. * @param blendMode blend mode to take into account when updating the array
  148220. */
  148221. fillDefines(defines: Array<string>, blendMode?: number): void;
  148222. /**
  148223. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148224. * @param uniforms Uniforms array to fill
  148225. * @param attributes Attributes array to fill
  148226. * @param samplers Samplers array to fill
  148227. */
  148228. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148229. /** @hidden */
  148230. _recreateRenderEffect(): Effect;
  148231. /**
  148232. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148233. * @param preWarm defines if we are in the pre-warmimg phase
  148234. */
  148235. animate(preWarm?: boolean): void;
  148236. private _createFactorGradientTexture;
  148237. private _createSizeGradientTexture;
  148238. private _createAngularSpeedGradientTexture;
  148239. private _createVelocityGradientTexture;
  148240. private _createLimitVelocityGradientTexture;
  148241. private _createDragGradientTexture;
  148242. private _createColorGradientTexture;
  148243. /**
  148244. * Renders the particle system in its current state
  148245. * @param preWarm defines if the system should only update the particles but not render them
  148246. * @returns the current number of particles
  148247. */
  148248. render(preWarm?: boolean): number;
  148249. /**
  148250. * Rebuilds the particle system
  148251. */
  148252. rebuild(): void;
  148253. private _releaseBuffers;
  148254. private _releaseVAOs;
  148255. /**
  148256. * Disposes the particle system and free the associated resources
  148257. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148258. */
  148259. dispose(disposeTexture?: boolean): void;
  148260. /**
  148261. * Clones the particle system.
  148262. * @param name The name of the cloned object
  148263. * @param newEmitter The new emitter to use
  148264. * @returns the cloned particle system
  148265. */
  148266. clone(name: string, newEmitter: any): GPUParticleSystem;
  148267. /**
  148268. * Serializes the particle system to a JSON object
  148269. * @param serializeTexture defines if the texture must be serialized as well
  148270. * @returns the JSON object
  148271. */
  148272. serialize(serializeTexture?: boolean): any;
  148273. /**
  148274. * Parses a JSON object to create a GPU particle system.
  148275. * @param parsedParticleSystem The JSON object to parse
  148276. * @param sceneOrEngine The scene or the engine to create the particle system in
  148277. * @param rootUrl The root url to use to load external dependencies like texture
  148278. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148279. * @returns the parsed GPU particle system
  148280. */
  148281. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148282. }
  148283. }
  148284. declare module BABYLON {
  148285. /**
  148286. * Represents a set of particle systems working together to create a specific effect
  148287. */
  148288. export class ParticleSystemSet implements IDisposable {
  148289. /**
  148290. * Gets or sets base Assets URL
  148291. */
  148292. static BaseAssetsUrl: string;
  148293. private _emitterCreationOptions;
  148294. private _emitterNode;
  148295. /**
  148296. * Gets the particle system list
  148297. */
  148298. systems: IParticleSystem[];
  148299. /**
  148300. * Gets the emitter node used with this set
  148301. */
  148302. get emitterNode(): Nullable<TransformNode>;
  148303. /**
  148304. * Creates a new emitter mesh as a sphere
  148305. * @param options defines the options used to create the sphere
  148306. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148307. * @param scene defines the hosting scene
  148308. */
  148309. setEmitterAsSphere(options: {
  148310. diameter: number;
  148311. segments: number;
  148312. color: Color3;
  148313. }, renderingGroupId: number, scene: Scene): void;
  148314. /**
  148315. * Starts all particle systems of the set
  148316. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148317. */
  148318. start(emitter?: AbstractMesh): void;
  148319. /**
  148320. * Release all associated resources
  148321. */
  148322. dispose(): void;
  148323. /**
  148324. * Serialize the set into a JSON compatible object
  148325. * @param serializeTexture defines if the texture must be serialized as well
  148326. * @returns a JSON compatible representation of the set
  148327. */
  148328. serialize(serializeTexture?: boolean): any;
  148329. /**
  148330. * Parse a new ParticleSystemSet from a serialized source
  148331. * @param data defines a JSON compatible representation of the set
  148332. * @param scene defines the hosting scene
  148333. * @param gpu defines if we want GPU particles or CPU particles
  148334. * @returns a new ParticleSystemSet
  148335. */
  148336. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148337. }
  148338. }
  148339. declare module BABYLON {
  148340. /**
  148341. * This class is made for on one-liner static method to help creating particle system set.
  148342. */
  148343. export class ParticleHelper {
  148344. /**
  148345. * Gets or sets base Assets URL
  148346. */
  148347. static BaseAssetsUrl: string;
  148348. /** Define the Url to load snippets */
  148349. static SnippetUrl: string;
  148350. /**
  148351. * Create a default particle system that you can tweak
  148352. * @param emitter defines the emitter to use
  148353. * @param capacity defines the system capacity (default is 500 particles)
  148354. * @param scene defines the hosting scene
  148355. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148356. * @returns the new Particle system
  148357. */
  148358. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148359. /**
  148360. * This is the main static method (one-liner) of this helper to create different particle systems
  148361. * @param type This string represents the type to the particle system to create
  148362. * @param scene The scene where the particle system should live
  148363. * @param gpu If the system will use gpu
  148364. * @returns the ParticleSystemSet created
  148365. */
  148366. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148367. /**
  148368. * Static function used to export a particle system to a ParticleSystemSet variable.
  148369. * Please note that the emitter shape is not exported
  148370. * @param systems defines the particle systems to export
  148371. * @returns the created particle system set
  148372. */
  148373. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148374. /**
  148375. * Creates a particle system from a snippet saved in a remote file
  148376. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148377. * @param url defines the url to load from
  148378. * @param scene defines the hosting scene
  148379. * @param gpu If the system will use gpu
  148380. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148381. * @returns a promise that will resolve to the new particle system
  148382. */
  148383. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148384. /**
  148385. * Creates a particle system from a snippet saved by the particle system editor
  148386. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148387. * @param scene defines the hosting scene
  148388. * @param gpu If the system will use gpu
  148389. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148390. * @returns a promise that will resolve to the new particle system
  148391. */
  148392. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148393. }
  148394. }
  148395. declare module BABYLON {
  148396. interface Engine {
  148397. /**
  148398. * Create an effect to use with particle systems.
  148399. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148400. * the particle system for which you want to create a custom effect in the last parameter
  148401. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148402. * @param uniformsNames defines a list of attribute names
  148403. * @param samplers defines an array of string used to represent textures
  148404. * @param defines defines the string containing the defines to use to compile the shaders
  148405. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148406. * @param onCompiled defines a function to call when the effect creation is successful
  148407. * @param onError defines a function to call when the effect creation has failed
  148408. * @param particleSystem the particle system you want to create the effect for
  148409. * @returns the new Effect
  148410. */
  148411. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148412. }
  148413. interface Mesh {
  148414. /**
  148415. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148416. * @returns an array of IParticleSystem
  148417. */
  148418. getEmittedParticleSystems(): IParticleSystem[];
  148419. /**
  148420. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148421. * @returns an array of IParticleSystem
  148422. */
  148423. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148424. }
  148425. }
  148426. declare module BABYLON {
  148427. /** Defines the 4 color options */
  148428. export enum PointColor {
  148429. /** color value */
  148430. Color = 2,
  148431. /** uv value */
  148432. UV = 1,
  148433. /** random value */
  148434. Random = 0,
  148435. /** stated value */
  148436. Stated = 3
  148437. }
  148438. /**
  148439. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148440. * 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.
  148441. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148442. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148443. *
  148444. * Full documentation here : TO BE ENTERED
  148445. */
  148446. export class PointsCloudSystem implements IDisposable {
  148447. /**
  148448. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148449. * Example : var p = SPS.particles[i];
  148450. */
  148451. particles: CloudPoint[];
  148452. /**
  148453. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148454. */
  148455. nbParticles: number;
  148456. /**
  148457. * This a counter for your own usage. It's not set by any SPS functions.
  148458. */
  148459. counter: number;
  148460. /**
  148461. * The PCS name. This name is also given to the underlying mesh.
  148462. */
  148463. name: string;
  148464. /**
  148465. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148466. */
  148467. mesh: Mesh;
  148468. /**
  148469. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148470. * Please read :
  148471. */
  148472. vars: any;
  148473. /**
  148474. * @hidden
  148475. */
  148476. _size: number;
  148477. private _scene;
  148478. private _promises;
  148479. private _positions;
  148480. private _indices;
  148481. private _normals;
  148482. private _colors;
  148483. private _uvs;
  148484. private _indices32;
  148485. private _positions32;
  148486. private _colors32;
  148487. private _uvs32;
  148488. private _updatable;
  148489. private _isVisibilityBoxLocked;
  148490. private _alwaysVisible;
  148491. private _groups;
  148492. private _groupCounter;
  148493. private _computeParticleColor;
  148494. private _computeParticleTexture;
  148495. private _computeParticleRotation;
  148496. private _computeBoundingBox;
  148497. private _isReady;
  148498. /**
  148499. * Creates a PCS (Points Cloud System) object
  148500. * @param name (String) is the PCS name, this will be the underlying mesh name
  148501. * @param pointSize (number) is the size for each point
  148502. * @param scene (Scene) is the scene in which the PCS is added
  148503. * @param options defines the options of the PCS e.g.
  148504. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148505. */
  148506. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148507. updatable?: boolean;
  148508. });
  148509. /**
  148510. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148511. * If no points were added to the PCS, the returned mesh is just a single point.
  148512. * @returns a promise for the created mesh
  148513. */
  148514. buildMeshAsync(): Promise<Mesh>;
  148515. /**
  148516. * @hidden
  148517. */
  148518. private _buildMesh;
  148519. private _addParticle;
  148520. private _randomUnitVector;
  148521. private _getColorIndicesForCoord;
  148522. private _setPointsColorOrUV;
  148523. private _colorFromTexture;
  148524. private _calculateDensity;
  148525. /**
  148526. * Adds points to the PCS in random positions within a unit sphere
  148527. * @param nb (positive integer) the number of particles to be created from this model
  148528. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148529. * @returns the number of groups in the system
  148530. */
  148531. addPoints(nb: number, pointFunction?: any): number;
  148532. /**
  148533. * Adds points to the PCS from the surface of the model shape
  148534. * @param mesh is any Mesh object that will be used as a surface model for the points
  148535. * @param nb (positive integer) the number of particles to be created from this model
  148536. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148537. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148538. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148539. * @returns the number of groups in the system
  148540. */
  148541. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148542. /**
  148543. * Adds points to the PCS inside the model shape
  148544. * @param mesh is any Mesh object that will be used as a surface model for the points
  148545. * @param nb (positive integer) the number of particles to be created from this model
  148546. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148547. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148548. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148549. * @returns the number of groups in the system
  148550. */
  148551. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148552. /**
  148553. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148554. * This method calls `updateParticle()` for each particle of the SPS.
  148555. * For an animated SPS, it is usually called within the render loop.
  148556. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148557. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148558. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148559. * @returns the PCS.
  148560. */
  148561. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148562. /**
  148563. * Disposes the PCS.
  148564. */
  148565. dispose(): void;
  148566. /**
  148567. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148568. * doc :
  148569. * @returns the PCS.
  148570. */
  148571. refreshVisibleSize(): PointsCloudSystem;
  148572. /**
  148573. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148574. * @param size the size (float) of the visibility box
  148575. * note : this doesn't lock the PCS mesh bounding box.
  148576. * doc :
  148577. */
  148578. setVisibilityBox(size: number): void;
  148579. /**
  148580. * Gets whether the PCS is always visible or not
  148581. * doc :
  148582. */
  148583. get isAlwaysVisible(): boolean;
  148584. /**
  148585. * Sets the PCS as always visible or not
  148586. * doc :
  148587. */
  148588. set isAlwaysVisible(val: boolean);
  148589. /**
  148590. * Tells to `setParticles()` to compute the particle rotations or not
  148591. * Default value : false. The PCS is faster when it's set to false
  148592. * Note : particle rotations are only applied to parent particles
  148593. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148594. */
  148595. set computeParticleRotation(val: boolean);
  148596. /**
  148597. * Tells to `setParticles()` to compute the particle colors or not.
  148598. * Default value : true. The PCS is faster when it's set to false.
  148599. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148600. */
  148601. set computeParticleColor(val: boolean);
  148602. set computeParticleTexture(val: boolean);
  148603. /**
  148604. * Gets if `setParticles()` computes the particle colors or not.
  148605. * Default value : false. The PCS is faster when it's set to false.
  148606. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148607. */
  148608. get computeParticleColor(): boolean;
  148609. /**
  148610. * Gets if `setParticles()` computes the particle textures or not.
  148611. * Default value : false. The PCS is faster when it's set to false.
  148612. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148613. */
  148614. get computeParticleTexture(): boolean;
  148615. /**
  148616. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148617. */
  148618. set computeBoundingBox(val: boolean);
  148619. /**
  148620. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148621. */
  148622. get computeBoundingBox(): boolean;
  148623. /**
  148624. * This function does nothing. It may be overwritten to set all the particle first values.
  148625. * The PCS doesn't call this function, you may have to call it by your own.
  148626. * doc :
  148627. */
  148628. initParticles(): void;
  148629. /**
  148630. * This function does nothing. It may be overwritten to recycle a particle
  148631. * The PCS doesn't call this function, you can to call it
  148632. * doc :
  148633. * @param particle The particle to recycle
  148634. * @returns the recycled particle
  148635. */
  148636. recycleParticle(particle: CloudPoint): CloudPoint;
  148637. /**
  148638. * Updates a particle : this function should be overwritten by the user.
  148639. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148640. * doc :
  148641. * @example : just set a particle position or velocity and recycle conditions
  148642. * @param particle The particle to update
  148643. * @returns the updated particle
  148644. */
  148645. updateParticle(particle: CloudPoint): CloudPoint;
  148646. /**
  148647. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148648. * This does nothing and may be overwritten by the user.
  148649. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148650. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148651. * @param update the boolean update value actually passed to setParticles()
  148652. */
  148653. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148654. /**
  148655. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148656. * This will be passed three parameters.
  148657. * This does nothing and may be overwritten by the user.
  148658. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148659. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148660. * @param update the boolean update value actually passed to setParticles()
  148661. */
  148662. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148663. }
  148664. }
  148665. declare module BABYLON {
  148666. /**
  148667. * Represents one particle of a points cloud system.
  148668. */
  148669. export class CloudPoint {
  148670. /**
  148671. * particle global index
  148672. */
  148673. idx: number;
  148674. /**
  148675. * The color of the particle
  148676. */
  148677. color: Nullable<Color4>;
  148678. /**
  148679. * The world space position of the particle.
  148680. */
  148681. position: Vector3;
  148682. /**
  148683. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148684. */
  148685. rotation: Vector3;
  148686. /**
  148687. * The world space rotation quaternion of the particle.
  148688. */
  148689. rotationQuaternion: Nullable<Quaternion>;
  148690. /**
  148691. * The uv of the particle.
  148692. */
  148693. uv: Nullable<Vector2>;
  148694. /**
  148695. * The current speed of the particle.
  148696. */
  148697. velocity: Vector3;
  148698. /**
  148699. * The pivot point in the particle local space.
  148700. */
  148701. pivot: Vector3;
  148702. /**
  148703. * Must the particle be translated from its pivot point in its local space ?
  148704. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148705. * Default : false
  148706. */
  148707. translateFromPivot: boolean;
  148708. /**
  148709. * Index of this particle in the global "positions" array (Internal use)
  148710. * @hidden
  148711. */
  148712. _pos: number;
  148713. /**
  148714. * @hidden Index of this particle in the global "indices" array (Internal use)
  148715. */
  148716. _ind: number;
  148717. /**
  148718. * Group this particle belongs to
  148719. */
  148720. _group: PointsGroup;
  148721. /**
  148722. * Group id of this particle
  148723. */
  148724. groupId: number;
  148725. /**
  148726. * Index of the particle in its group id (Internal use)
  148727. */
  148728. idxInGroup: number;
  148729. /**
  148730. * @hidden Particle BoundingInfo object (Internal use)
  148731. */
  148732. _boundingInfo: BoundingInfo;
  148733. /**
  148734. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148735. */
  148736. _pcs: PointsCloudSystem;
  148737. /**
  148738. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148739. */
  148740. _stillInvisible: boolean;
  148741. /**
  148742. * @hidden Last computed particle rotation matrix
  148743. */
  148744. _rotationMatrix: number[];
  148745. /**
  148746. * Parent particle Id, if any.
  148747. * Default null.
  148748. */
  148749. parentId: Nullable<number>;
  148750. /**
  148751. * @hidden Internal global position in the PCS.
  148752. */
  148753. _globalPosition: Vector3;
  148754. /**
  148755. * Creates a Point Cloud object.
  148756. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148757. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148758. * @param group (PointsGroup) is the group the particle belongs to
  148759. * @param groupId (integer) is the group identifier in the PCS.
  148760. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148761. * @param pcs defines the PCS it is associated to
  148762. */
  148763. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148764. /**
  148765. * get point size
  148766. */
  148767. get size(): Vector3;
  148768. /**
  148769. * Set point size
  148770. */
  148771. set size(scale: Vector3);
  148772. /**
  148773. * Legacy support, changed quaternion to rotationQuaternion
  148774. */
  148775. get quaternion(): Nullable<Quaternion>;
  148776. /**
  148777. * Legacy support, changed quaternion to rotationQuaternion
  148778. */
  148779. set quaternion(q: Nullable<Quaternion>);
  148780. /**
  148781. * Returns a boolean. True if the particle intersects a mesh, else false
  148782. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148783. * @param target is the object (point or mesh) what the intersection is computed against
  148784. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148785. * @returns true if it intersects
  148786. */
  148787. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148788. /**
  148789. * get the rotation matrix of the particle
  148790. * @hidden
  148791. */
  148792. getRotationMatrix(m: Matrix): void;
  148793. }
  148794. /**
  148795. * Represents a group of points in a points cloud system
  148796. * * PCS internal tool, don't use it manually.
  148797. */
  148798. export class PointsGroup {
  148799. /**
  148800. * The group id
  148801. * @hidden
  148802. */
  148803. groupID: number;
  148804. /**
  148805. * image data for group (internal use)
  148806. * @hidden
  148807. */
  148808. _groupImageData: Nullable<ArrayBufferView>;
  148809. /**
  148810. * Image Width (internal use)
  148811. * @hidden
  148812. */
  148813. _groupImgWidth: number;
  148814. /**
  148815. * Image Height (internal use)
  148816. * @hidden
  148817. */
  148818. _groupImgHeight: number;
  148819. /**
  148820. * Custom position function (internal use)
  148821. * @hidden
  148822. */
  148823. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148824. /**
  148825. * density per facet for surface points
  148826. * @hidden
  148827. */
  148828. _groupDensity: number[];
  148829. /**
  148830. * Only when points are colored by texture carries pointer to texture list array
  148831. * @hidden
  148832. */
  148833. _textureNb: number;
  148834. /**
  148835. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148836. * PCS internal tool, don't use it manually.
  148837. * @hidden
  148838. */
  148839. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148840. }
  148841. }
  148842. declare module BABYLON {
  148843. interface Scene {
  148844. /** @hidden (Backing field) */
  148845. _physicsEngine: Nullable<IPhysicsEngine>;
  148846. /** @hidden */
  148847. _physicsTimeAccumulator: number;
  148848. /**
  148849. * Gets the current physics engine
  148850. * @returns a IPhysicsEngine or null if none attached
  148851. */
  148852. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148853. /**
  148854. * Enables physics to the current scene
  148855. * @param gravity defines the scene's gravity for the physics engine
  148856. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148857. * @return a boolean indicating if the physics engine was initialized
  148858. */
  148859. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148860. /**
  148861. * Disables and disposes the physics engine associated with the scene
  148862. */
  148863. disablePhysicsEngine(): void;
  148864. /**
  148865. * Gets a boolean indicating if there is an active physics engine
  148866. * @returns a boolean indicating if there is an active physics engine
  148867. */
  148868. isPhysicsEnabled(): boolean;
  148869. /**
  148870. * Deletes a physics compound impostor
  148871. * @param compound defines the compound to delete
  148872. */
  148873. deleteCompoundImpostor(compound: any): void;
  148874. /**
  148875. * An event triggered when physic simulation is about to be run
  148876. */
  148877. onBeforePhysicsObservable: Observable<Scene>;
  148878. /**
  148879. * An event triggered when physic simulation has been done
  148880. */
  148881. onAfterPhysicsObservable: Observable<Scene>;
  148882. }
  148883. interface AbstractMesh {
  148884. /** @hidden */
  148885. _physicsImpostor: Nullable<PhysicsImpostor>;
  148886. /**
  148887. * Gets or sets impostor used for physic simulation
  148888. * @see https://doc.babylonjs.com/features/physics_engine
  148889. */
  148890. physicsImpostor: Nullable<PhysicsImpostor>;
  148891. /**
  148892. * Gets the current physics impostor
  148893. * @see https://doc.babylonjs.com/features/physics_engine
  148894. * @returns a physics impostor or null
  148895. */
  148896. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148897. /** Apply a physic impulse to the mesh
  148898. * @param force defines the force to apply
  148899. * @param contactPoint defines where to apply the force
  148900. * @returns the current mesh
  148901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148902. */
  148903. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148904. /**
  148905. * Creates a physic joint between two meshes
  148906. * @param otherMesh defines the other mesh to use
  148907. * @param pivot1 defines the pivot to use on this mesh
  148908. * @param pivot2 defines the pivot to use on the other mesh
  148909. * @param options defines additional options (can be plugin dependent)
  148910. * @returns the current mesh
  148911. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148912. */
  148913. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148914. /** @hidden */
  148915. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148916. }
  148917. /**
  148918. * Defines the physics engine scene component responsible to manage a physics engine
  148919. */
  148920. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148921. /**
  148922. * The component name helpful to identify the component in the list of scene components.
  148923. */
  148924. readonly name: string;
  148925. /**
  148926. * The scene the component belongs to.
  148927. */
  148928. scene: Scene;
  148929. /**
  148930. * Creates a new instance of the component for the given scene
  148931. * @param scene Defines the scene to register the component in
  148932. */
  148933. constructor(scene: Scene);
  148934. /**
  148935. * Registers the component in a given scene
  148936. */
  148937. register(): void;
  148938. /**
  148939. * Rebuilds the elements related to this component in case of
  148940. * context lost for instance.
  148941. */
  148942. rebuild(): void;
  148943. /**
  148944. * Disposes the component and the associated ressources
  148945. */
  148946. dispose(): void;
  148947. }
  148948. }
  148949. declare module BABYLON {
  148950. /**
  148951. * A helper for physics simulations
  148952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148953. */
  148954. export class PhysicsHelper {
  148955. private _scene;
  148956. private _physicsEngine;
  148957. /**
  148958. * Initializes the Physics helper
  148959. * @param scene Babylon.js scene
  148960. */
  148961. constructor(scene: Scene);
  148962. /**
  148963. * Applies a radial explosion impulse
  148964. * @param origin the origin of the explosion
  148965. * @param radiusOrEventOptions the radius or the options of radial explosion
  148966. * @param strength the explosion strength
  148967. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148968. * @returns A physics radial explosion event, or null
  148969. */
  148970. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148971. /**
  148972. * Applies a radial explosion force
  148973. * @param origin the origin of the explosion
  148974. * @param radiusOrEventOptions the radius or the options of radial explosion
  148975. * @param strength the explosion strength
  148976. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148977. * @returns A physics radial explosion event, or null
  148978. */
  148979. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148980. /**
  148981. * Creates a gravitational field
  148982. * @param origin the origin of the explosion
  148983. * @param radiusOrEventOptions the radius or the options of radial explosion
  148984. * @param strength the explosion strength
  148985. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148986. * @returns A physics gravitational field event, or null
  148987. */
  148988. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148989. /**
  148990. * Creates a physics updraft event
  148991. * @param origin the origin of the updraft
  148992. * @param radiusOrEventOptions the radius or the options of the updraft
  148993. * @param strength the strength of the updraft
  148994. * @param height the height of the updraft
  148995. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148996. * @returns A physics updraft event, or null
  148997. */
  148998. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148999. /**
  149000. * Creates a physics vortex event
  149001. * @param origin the of the vortex
  149002. * @param radiusOrEventOptions the radius or the options of the vortex
  149003. * @param strength the strength of the vortex
  149004. * @param height the height of the vortex
  149005. * @returns a Physics vortex event, or null
  149006. * A physics vortex event or null
  149007. */
  149008. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149009. }
  149010. /**
  149011. * Represents a physics radial explosion event
  149012. */
  149013. class PhysicsRadialExplosionEvent {
  149014. private _scene;
  149015. private _options;
  149016. private _sphere;
  149017. private _dataFetched;
  149018. /**
  149019. * Initializes a radial explosioin event
  149020. * @param _scene BabylonJS scene
  149021. * @param _options The options for the vortex event
  149022. */
  149023. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149024. /**
  149025. * Returns the data related to the radial explosion event (sphere).
  149026. * @returns The radial explosion event data
  149027. */
  149028. getData(): PhysicsRadialExplosionEventData;
  149029. /**
  149030. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149031. * @param impostor A physics imposter
  149032. * @param origin the origin of the explosion
  149033. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149034. */
  149035. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149036. /**
  149037. * Triggers affecterd impostors callbacks
  149038. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149039. */
  149040. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149041. /**
  149042. * Disposes the sphere.
  149043. * @param force Specifies if the sphere should be disposed by force
  149044. */
  149045. dispose(force?: boolean): void;
  149046. /*** Helpers ***/
  149047. private _prepareSphere;
  149048. private _intersectsWithSphere;
  149049. }
  149050. /**
  149051. * Represents a gravitational field event
  149052. */
  149053. class PhysicsGravitationalFieldEvent {
  149054. private _physicsHelper;
  149055. private _scene;
  149056. private _origin;
  149057. private _options;
  149058. private _tickCallback;
  149059. private _sphere;
  149060. private _dataFetched;
  149061. /**
  149062. * Initializes the physics gravitational field event
  149063. * @param _physicsHelper A physics helper
  149064. * @param _scene BabylonJS scene
  149065. * @param _origin The origin position of the gravitational field event
  149066. * @param _options The options for the vortex event
  149067. */
  149068. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149069. /**
  149070. * Returns the data related to the gravitational field event (sphere).
  149071. * @returns A gravitational field event
  149072. */
  149073. getData(): PhysicsGravitationalFieldEventData;
  149074. /**
  149075. * Enables the gravitational field.
  149076. */
  149077. enable(): void;
  149078. /**
  149079. * Disables the gravitational field.
  149080. */
  149081. disable(): void;
  149082. /**
  149083. * Disposes the sphere.
  149084. * @param force The force to dispose from the gravitational field event
  149085. */
  149086. dispose(force?: boolean): void;
  149087. private _tick;
  149088. }
  149089. /**
  149090. * Represents a physics updraft event
  149091. */
  149092. class PhysicsUpdraftEvent {
  149093. private _scene;
  149094. private _origin;
  149095. private _options;
  149096. private _physicsEngine;
  149097. private _originTop;
  149098. private _originDirection;
  149099. private _tickCallback;
  149100. private _cylinder;
  149101. private _cylinderPosition;
  149102. private _dataFetched;
  149103. /**
  149104. * Initializes the physics updraft event
  149105. * @param _scene BabylonJS scene
  149106. * @param _origin The origin position of the updraft
  149107. * @param _options The options for the updraft event
  149108. */
  149109. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149110. /**
  149111. * Returns the data related to the updraft event (cylinder).
  149112. * @returns A physics updraft event
  149113. */
  149114. getData(): PhysicsUpdraftEventData;
  149115. /**
  149116. * Enables the updraft.
  149117. */
  149118. enable(): void;
  149119. /**
  149120. * Disables the updraft.
  149121. */
  149122. disable(): void;
  149123. /**
  149124. * Disposes the cylinder.
  149125. * @param force Specifies if the updraft should be disposed by force
  149126. */
  149127. dispose(force?: boolean): void;
  149128. private getImpostorHitData;
  149129. private _tick;
  149130. /*** Helpers ***/
  149131. private _prepareCylinder;
  149132. private _intersectsWithCylinder;
  149133. }
  149134. /**
  149135. * Represents a physics vortex event
  149136. */
  149137. class PhysicsVortexEvent {
  149138. private _scene;
  149139. private _origin;
  149140. private _options;
  149141. private _physicsEngine;
  149142. private _originTop;
  149143. private _tickCallback;
  149144. private _cylinder;
  149145. private _cylinderPosition;
  149146. private _dataFetched;
  149147. /**
  149148. * Initializes the physics vortex event
  149149. * @param _scene The BabylonJS scene
  149150. * @param _origin The origin position of the vortex
  149151. * @param _options The options for the vortex event
  149152. */
  149153. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149154. /**
  149155. * Returns the data related to the vortex event (cylinder).
  149156. * @returns The physics vortex event data
  149157. */
  149158. getData(): PhysicsVortexEventData;
  149159. /**
  149160. * Enables the vortex.
  149161. */
  149162. enable(): void;
  149163. /**
  149164. * Disables the cortex.
  149165. */
  149166. disable(): void;
  149167. /**
  149168. * Disposes the sphere.
  149169. * @param force
  149170. */
  149171. dispose(force?: boolean): void;
  149172. private getImpostorHitData;
  149173. private _tick;
  149174. /*** Helpers ***/
  149175. private _prepareCylinder;
  149176. private _intersectsWithCylinder;
  149177. }
  149178. /**
  149179. * Options fot the radial explosion event
  149180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149181. */
  149182. export class PhysicsRadialExplosionEventOptions {
  149183. /**
  149184. * The radius of the sphere for the radial explosion.
  149185. */
  149186. radius: number;
  149187. /**
  149188. * The strenth of the explosion.
  149189. */
  149190. strength: number;
  149191. /**
  149192. * The strenght of the force in correspondence to the distance of the affected object
  149193. */
  149194. falloff: PhysicsRadialImpulseFalloff;
  149195. /**
  149196. * Sphere options for the radial explosion.
  149197. */
  149198. sphere: {
  149199. segments: number;
  149200. diameter: number;
  149201. };
  149202. /**
  149203. * Sphere options for the radial explosion.
  149204. */
  149205. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149206. }
  149207. /**
  149208. * Options fot the updraft event
  149209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149210. */
  149211. export class PhysicsUpdraftEventOptions {
  149212. /**
  149213. * The radius of the cylinder for the vortex
  149214. */
  149215. radius: number;
  149216. /**
  149217. * The strenth of the updraft.
  149218. */
  149219. strength: number;
  149220. /**
  149221. * The height of the cylinder for the updraft.
  149222. */
  149223. height: number;
  149224. /**
  149225. * The mode for the the updraft.
  149226. */
  149227. updraftMode: PhysicsUpdraftMode;
  149228. }
  149229. /**
  149230. * Options fot the vortex event
  149231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149232. */
  149233. export class PhysicsVortexEventOptions {
  149234. /**
  149235. * The radius of the cylinder for the vortex
  149236. */
  149237. radius: number;
  149238. /**
  149239. * The strenth of the vortex.
  149240. */
  149241. strength: number;
  149242. /**
  149243. * The height of the cylinder for the vortex.
  149244. */
  149245. height: number;
  149246. /**
  149247. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149248. */
  149249. centripetalForceThreshold: number;
  149250. /**
  149251. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149252. */
  149253. centripetalForceMultiplier: number;
  149254. /**
  149255. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149256. */
  149257. centrifugalForceMultiplier: number;
  149258. /**
  149259. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149260. */
  149261. updraftForceMultiplier: number;
  149262. }
  149263. /**
  149264. * The strenght of the force in correspondence to the distance of the affected object
  149265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149266. */
  149267. export enum PhysicsRadialImpulseFalloff {
  149268. /** Defines that impulse is constant in strength across it's whole radius */
  149269. Constant = 0,
  149270. /** Defines that impulse gets weaker if it's further from the origin */
  149271. Linear = 1
  149272. }
  149273. /**
  149274. * The strength of the force in correspondence to the distance of the affected object
  149275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149276. */
  149277. export enum PhysicsUpdraftMode {
  149278. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149279. Center = 0,
  149280. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149281. Perpendicular = 1
  149282. }
  149283. /**
  149284. * Interface for a physics hit data
  149285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149286. */
  149287. export interface PhysicsHitData {
  149288. /**
  149289. * The force applied at the contact point
  149290. */
  149291. force: Vector3;
  149292. /**
  149293. * The contact point
  149294. */
  149295. contactPoint: Vector3;
  149296. /**
  149297. * The distance from the origin to the contact point
  149298. */
  149299. distanceFromOrigin: number;
  149300. }
  149301. /**
  149302. * Interface for radial explosion event data
  149303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149304. */
  149305. export interface PhysicsRadialExplosionEventData {
  149306. /**
  149307. * A sphere used for the radial explosion event
  149308. */
  149309. sphere: Mesh;
  149310. }
  149311. /**
  149312. * Interface for gravitational field event data
  149313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149314. */
  149315. export interface PhysicsGravitationalFieldEventData {
  149316. /**
  149317. * A sphere mesh used for the gravitational field event
  149318. */
  149319. sphere: Mesh;
  149320. }
  149321. /**
  149322. * Interface for updraft event data
  149323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149324. */
  149325. export interface PhysicsUpdraftEventData {
  149326. /**
  149327. * A cylinder used for the updraft event
  149328. */
  149329. cylinder: Mesh;
  149330. }
  149331. /**
  149332. * Interface for vortex event data
  149333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149334. */
  149335. export interface PhysicsVortexEventData {
  149336. /**
  149337. * A cylinder used for the vortex event
  149338. */
  149339. cylinder: Mesh;
  149340. }
  149341. /**
  149342. * Interface for an affected physics impostor
  149343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149344. */
  149345. export interface PhysicsAffectedImpostorWithData {
  149346. /**
  149347. * The impostor affected by the effect
  149348. */
  149349. impostor: PhysicsImpostor;
  149350. /**
  149351. * The data about the hit/horce from the explosion
  149352. */
  149353. hitData: PhysicsHitData;
  149354. }
  149355. }
  149356. declare module BABYLON {
  149357. /** @hidden */
  149358. export var blackAndWhitePixelShader: {
  149359. name: string;
  149360. shader: string;
  149361. };
  149362. }
  149363. declare module BABYLON {
  149364. /**
  149365. * Post process used to render in black and white
  149366. */
  149367. export class BlackAndWhitePostProcess extends PostProcess {
  149368. /**
  149369. * Linear about to convert he result to black and white (default: 1)
  149370. */
  149371. degree: number;
  149372. /**
  149373. * Gets a string identifying the name of the class
  149374. * @returns "BlackAndWhitePostProcess" string
  149375. */
  149376. getClassName(): string;
  149377. /**
  149378. * Creates a black and white post process
  149379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149380. * @param name The name of the effect.
  149381. * @param options The required width/height ratio to downsize to before computing the render pass.
  149382. * @param camera The camera to apply the render pass to.
  149383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149384. * @param engine The engine which the post process will be applied. (default: current engine)
  149385. * @param reusable If the post process can be reused on the same frame. (default: false)
  149386. */
  149387. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149388. /** @hidden */
  149389. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149390. }
  149391. }
  149392. declare module BABYLON {
  149393. /**
  149394. * This represents a set of one or more post processes in Babylon.
  149395. * A post process can be used to apply a shader to a texture after it is rendered.
  149396. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149397. */
  149398. export class PostProcessRenderEffect {
  149399. private _postProcesses;
  149400. private _getPostProcesses;
  149401. private _singleInstance;
  149402. private _cameras;
  149403. private _indicesForCamera;
  149404. /**
  149405. * Name of the effect
  149406. * @hidden
  149407. */
  149408. _name: string;
  149409. /**
  149410. * Instantiates a post process render effect.
  149411. * A post process can be used to apply a shader to a texture after it is rendered.
  149412. * @param engine The engine the effect is tied to
  149413. * @param name The name of the effect
  149414. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149415. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149416. */
  149417. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149418. /**
  149419. * Checks if all the post processes in the effect are supported.
  149420. */
  149421. get isSupported(): boolean;
  149422. /**
  149423. * Updates the current state of the effect
  149424. * @hidden
  149425. */
  149426. _update(): void;
  149427. /**
  149428. * Attaches the effect on cameras
  149429. * @param cameras The camera to attach to.
  149430. * @hidden
  149431. */
  149432. _attachCameras(cameras: Camera): void;
  149433. /**
  149434. * Attaches the effect on cameras
  149435. * @param cameras The camera to attach to.
  149436. * @hidden
  149437. */
  149438. _attachCameras(cameras: Camera[]): void;
  149439. /**
  149440. * Detaches the effect on cameras
  149441. * @param cameras The camera to detatch from.
  149442. * @hidden
  149443. */
  149444. _detachCameras(cameras: Camera): void;
  149445. /**
  149446. * Detatches the effect on cameras
  149447. * @param cameras The camera to detatch from.
  149448. * @hidden
  149449. */
  149450. _detachCameras(cameras: Camera[]): void;
  149451. /**
  149452. * Enables the effect on given cameras
  149453. * @param cameras The camera to enable.
  149454. * @hidden
  149455. */
  149456. _enable(cameras: Camera): void;
  149457. /**
  149458. * Enables the effect on given cameras
  149459. * @param cameras The camera to enable.
  149460. * @hidden
  149461. */
  149462. _enable(cameras: Nullable<Camera[]>): void;
  149463. /**
  149464. * Disables the effect on the given cameras
  149465. * @param cameras The camera to disable.
  149466. * @hidden
  149467. */
  149468. _disable(cameras: Camera): void;
  149469. /**
  149470. * Disables the effect on the given cameras
  149471. * @param cameras The camera to disable.
  149472. * @hidden
  149473. */
  149474. _disable(cameras: Nullable<Camera[]>): void;
  149475. /**
  149476. * Gets a list of the post processes contained in the effect.
  149477. * @param camera The camera to get the post processes on.
  149478. * @returns The list of the post processes in the effect.
  149479. */
  149480. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149481. }
  149482. }
  149483. declare module BABYLON {
  149484. /** @hidden */
  149485. export var extractHighlightsPixelShader: {
  149486. name: string;
  149487. shader: string;
  149488. };
  149489. }
  149490. declare module BABYLON {
  149491. /**
  149492. * 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.
  149493. */
  149494. export class ExtractHighlightsPostProcess extends PostProcess {
  149495. /**
  149496. * The luminance threshold, pixels below this value will be set to black.
  149497. */
  149498. threshold: number;
  149499. /** @hidden */
  149500. _exposure: number;
  149501. /**
  149502. * Post process which has the input texture to be used when performing highlight extraction
  149503. * @hidden
  149504. */
  149505. _inputPostProcess: Nullable<PostProcess>;
  149506. /**
  149507. * Gets a string identifying the name of the class
  149508. * @returns "ExtractHighlightsPostProcess" string
  149509. */
  149510. getClassName(): string;
  149511. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149512. }
  149513. }
  149514. declare module BABYLON {
  149515. /** @hidden */
  149516. export var bloomMergePixelShader: {
  149517. name: string;
  149518. shader: string;
  149519. };
  149520. }
  149521. declare module BABYLON {
  149522. /**
  149523. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149524. */
  149525. export class BloomMergePostProcess extends PostProcess {
  149526. /** Weight of the bloom to be added to the original input. */
  149527. weight: number;
  149528. /**
  149529. * Gets a string identifying the name of the class
  149530. * @returns "BloomMergePostProcess" string
  149531. */
  149532. getClassName(): string;
  149533. /**
  149534. * Creates a new instance of @see BloomMergePostProcess
  149535. * @param name The name of the effect.
  149536. * @param originalFromInput Post process which's input will be used for the merge.
  149537. * @param blurred Blurred highlights post process which's output will be used.
  149538. * @param weight Weight of the bloom to be added to the original input.
  149539. * @param options The required width/height ratio to downsize to before computing the render pass.
  149540. * @param camera The camera to apply the render pass to.
  149541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149542. * @param engine The engine which the post process will be applied. (default: current engine)
  149543. * @param reusable If the post process can be reused on the same frame. (default: false)
  149544. * @param textureType Type of textures used when performing the post process. (default: 0)
  149545. * @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)
  149546. */
  149547. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149548. /** Weight of the bloom to be added to the original input. */
  149549. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149550. }
  149551. }
  149552. declare module BABYLON {
  149553. /**
  149554. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149555. */
  149556. export class BloomEffect extends PostProcessRenderEffect {
  149557. private bloomScale;
  149558. /**
  149559. * @hidden Internal
  149560. */
  149561. _effects: Array<PostProcess>;
  149562. /**
  149563. * @hidden Internal
  149564. */
  149565. _downscale: ExtractHighlightsPostProcess;
  149566. private _blurX;
  149567. private _blurY;
  149568. private _merge;
  149569. /**
  149570. * The luminance threshold to find bright areas of the image to bloom.
  149571. */
  149572. get threshold(): number;
  149573. set threshold(value: number);
  149574. /**
  149575. * The strength of the bloom.
  149576. */
  149577. get weight(): number;
  149578. set weight(value: number);
  149579. /**
  149580. * Specifies the size of the bloom blur kernel, relative to the final output size
  149581. */
  149582. get kernel(): number;
  149583. set kernel(value: number);
  149584. /**
  149585. * Creates a new instance of @see BloomEffect
  149586. * @param scene The scene the effect belongs to.
  149587. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149588. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149589. * @param bloomWeight The the strength of bloom.
  149590. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149591. * @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)
  149592. */
  149593. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149594. /**
  149595. * Disposes each of the internal effects for a given camera.
  149596. * @param camera The camera to dispose the effect on.
  149597. */
  149598. disposeEffects(camera: Camera): void;
  149599. /**
  149600. * @hidden Internal
  149601. */
  149602. _updateEffects(): void;
  149603. /**
  149604. * Internal
  149605. * @returns if all the contained post processes are ready.
  149606. * @hidden
  149607. */
  149608. _isReady(): boolean;
  149609. }
  149610. }
  149611. declare module BABYLON {
  149612. /** @hidden */
  149613. export var chromaticAberrationPixelShader: {
  149614. name: string;
  149615. shader: string;
  149616. };
  149617. }
  149618. declare module BABYLON {
  149619. /**
  149620. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149621. */
  149622. export class ChromaticAberrationPostProcess extends PostProcess {
  149623. /**
  149624. * The amount of seperation of rgb channels (default: 30)
  149625. */
  149626. aberrationAmount: number;
  149627. /**
  149628. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149629. */
  149630. radialIntensity: number;
  149631. /**
  149632. * 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))
  149633. */
  149634. direction: Vector2;
  149635. /**
  149636. * 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))
  149637. */
  149638. centerPosition: Vector2;
  149639. /** The width of the screen to apply the effect on */
  149640. screenWidth: number;
  149641. /** The height of the screen to apply the effect on */
  149642. screenHeight: number;
  149643. /**
  149644. * Gets a string identifying the name of the class
  149645. * @returns "ChromaticAberrationPostProcess" string
  149646. */
  149647. getClassName(): string;
  149648. /**
  149649. * Creates a new instance ChromaticAberrationPostProcess
  149650. * @param name The name of the effect.
  149651. * @param screenWidth The width of the screen to apply the effect on.
  149652. * @param screenHeight The height of the screen to apply the effect on.
  149653. * @param options The required width/height ratio to downsize to before computing the render pass.
  149654. * @param camera The camera to apply the render pass to.
  149655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149656. * @param engine The engine which the post process will be applied. (default: current engine)
  149657. * @param reusable If the post process can be reused on the same frame. (default: false)
  149658. * @param textureType Type of textures used when performing the post process. (default: 0)
  149659. * @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)
  149660. */
  149661. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149662. /** @hidden */
  149663. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149664. }
  149665. }
  149666. declare module BABYLON {
  149667. /** @hidden */
  149668. export var circleOfConfusionPixelShader: {
  149669. name: string;
  149670. shader: string;
  149671. };
  149672. }
  149673. declare module BABYLON {
  149674. /**
  149675. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149676. */
  149677. export class CircleOfConfusionPostProcess extends PostProcess {
  149678. /**
  149679. * 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.
  149680. */
  149681. lensSize: number;
  149682. /**
  149683. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149684. */
  149685. fStop: number;
  149686. /**
  149687. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149688. */
  149689. focusDistance: number;
  149690. /**
  149691. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149692. */
  149693. focalLength: number;
  149694. /**
  149695. * Gets a string identifying the name of the class
  149696. * @returns "CircleOfConfusionPostProcess" string
  149697. */
  149698. getClassName(): string;
  149699. private _depthTexture;
  149700. /**
  149701. * Creates a new instance CircleOfConfusionPostProcess
  149702. * @param name The name of the effect.
  149703. * @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.
  149704. * @param options The required width/height ratio to downsize to before computing the render pass.
  149705. * @param camera The camera to apply the render pass to.
  149706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149707. * @param engine The engine which the post process will be applied. (default: current engine)
  149708. * @param reusable If the post process can be reused on the same frame. (default: false)
  149709. * @param textureType Type of textures used when performing the post process. (default: 0)
  149710. * @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)
  149711. */
  149712. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149713. /**
  149714. * 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.
  149715. */
  149716. set depthTexture(value: RenderTargetTexture);
  149717. }
  149718. }
  149719. declare module BABYLON {
  149720. /** @hidden */
  149721. export var colorCorrectionPixelShader: {
  149722. name: string;
  149723. shader: string;
  149724. };
  149725. }
  149726. declare module BABYLON {
  149727. /**
  149728. *
  149729. * This post-process allows the modification of rendered colors by using
  149730. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149731. *
  149732. * The object needs to be provided an url to a texture containing the color
  149733. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149734. * Use an image editing software to tweak the LUT to match your needs.
  149735. *
  149736. * For an example of a color LUT, see here:
  149737. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149738. * For explanations on color grading, see here:
  149739. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149740. *
  149741. */
  149742. export class ColorCorrectionPostProcess extends PostProcess {
  149743. private _colorTableTexture;
  149744. /**
  149745. * Gets the color table url used to create the LUT texture
  149746. */
  149747. colorTableUrl: string;
  149748. /**
  149749. * Gets a string identifying the name of the class
  149750. * @returns "ColorCorrectionPostProcess" string
  149751. */
  149752. getClassName(): string;
  149753. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149754. /** @hidden */
  149755. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149756. }
  149757. }
  149758. declare module BABYLON {
  149759. /** @hidden */
  149760. export var convolutionPixelShader: {
  149761. name: string;
  149762. shader: string;
  149763. };
  149764. }
  149765. declare module BABYLON {
  149766. /**
  149767. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149768. * input texture to perform effects such as edge detection or sharpening
  149769. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149770. */
  149771. export class ConvolutionPostProcess extends PostProcess {
  149772. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149773. kernel: number[];
  149774. /**
  149775. * Gets a string identifying the name of the class
  149776. * @returns "ConvolutionPostProcess" string
  149777. */
  149778. getClassName(): string;
  149779. /**
  149780. * Creates a new instance ConvolutionPostProcess
  149781. * @param name The name of the effect.
  149782. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149783. * @param options The required width/height ratio to downsize to before computing the render pass.
  149784. * @param camera The camera to apply the render pass to.
  149785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149786. * @param engine The engine which the post process will be applied. (default: current engine)
  149787. * @param reusable If the post process can be reused on the same frame. (default: false)
  149788. * @param textureType Type of textures used when performing the post process. (default: 0)
  149789. */
  149790. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149791. /** @hidden */
  149792. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149793. /**
  149794. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149795. */
  149796. static EdgeDetect0Kernel: number[];
  149797. /**
  149798. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149799. */
  149800. static EdgeDetect1Kernel: number[];
  149801. /**
  149802. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149803. */
  149804. static EdgeDetect2Kernel: number[];
  149805. /**
  149806. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149807. */
  149808. static SharpenKernel: number[];
  149809. /**
  149810. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149811. */
  149812. static EmbossKernel: number[];
  149813. /**
  149814. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149815. */
  149816. static GaussianKernel: number[];
  149817. }
  149818. }
  149819. declare module BABYLON {
  149820. /**
  149821. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149822. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149823. * based on samples that have a large difference in distance than the center pixel.
  149824. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149825. */
  149826. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149827. /**
  149828. * The direction the blur should be applied
  149829. */
  149830. direction: Vector2;
  149831. /**
  149832. * Gets a string identifying the name of the class
  149833. * @returns "DepthOfFieldBlurPostProcess" string
  149834. */
  149835. getClassName(): string;
  149836. /**
  149837. * Creates a new instance CircleOfConfusionPostProcess
  149838. * @param name The name of the effect.
  149839. * @param scene The scene the effect belongs to.
  149840. * @param direction The direction the blur should be applied.
  149841. * @param kernel The size of the kernel used to blur.
  149842. * @param options The required width/height ratio to downsize to before computing the render pass.
  149843. * @param camera The camera to apply the render pass to.
  149844. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149845. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149847. * @param engine The engine which the post process will be applied. (default: current engine)
  149848. * @param reusable If the post process can be reused on the same frame. (default: false)
  149849. * @param textureType Type of textures used when performing the post process. (default: 0)
  149850. * @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)
  149851. */
  149852. 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);
  149853. }
  149854. }
  149855. declare module BABYLON {
  149856. /** @hidden */
  149857. export var depthOfFieldMergePixelShader: {
  149858. name: string;
  149859. shader: string;
  149860. };
  149861. }
  149862. declare module BABYLON {
  149863. /**
  149864. * Options to be set when merging outputs from the default pipeline.
  149865. */
  149866. export class DepthOfFieldMergePostProcessOptions {
  149867. /**
  149868. * The original image to merge on top of
  149869. */
  149870. originalFromInput: PostProcess;
  149871. /**
  149872. * Parameters to perform the merge of the depth of field effect
  149873. */
  149874. depthOfField?: {
  149875. circleOfConfusion: PostProcess;
  149876. blurSteps: Array<PostProcess>;
  149877. };
  149878. /**
  149879. * Parameters to perform the merge of bloom effect
  149880. */
  149881. bloom?: {
  149882. blurred: PostProcess;
  149883. weight: number;
  149884. };
  149885. }
  149886. /**
  149887. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149888. */
  149889. export class DepthOfFieldMergePostProcess extends PostProcess {
  149890. private blurSteps;
  149891. /**
  149892. * Gets a string identifying the name of the class
  149893. * @returns "DepthOfFieldMergePostProcess" string
  149894. */
  149895. getClassName(): string;
  149896. /**
  149897. * Creates a new instance of DepthOfFieldMergePostProcess
  149898. * @param name The name of the effect.
  149899. * @param originalFromInput Post process which's input will be used for the merge.
  149900. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149901. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149902. * @param options The required width/height ratio to downsize to before computing the render pass.
  149903. * @param camera The camera to apply the render pass to.
  149904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149905. * @param engine The engine which the post process will be applied. (default: current engine)
  149906. * @param reusable If the post process can be reused on the same frame. (default: false)
  149907. * @param textureType Type of textures used when performing the post process. (default: 0)
  149908. * @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)
  149909. */
  149910. 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);
  149911. /**
  149912. * Updates the effect with the current post process compile time values and recompiles the shader.
  149913. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149914. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149915. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149916. * @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
  149917. * @param onCompiled Called when the shader has been compiled.
  149918. * @param onError Called if there is an error when compiling a shader.
  149919. */
  149920. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149921. }
  149922. }
  149923. declare module BABYLON {
  149924. /**
  149925. * Specifies the level of max blur that should be applied when using the depth of field effect
  149926. */
  149927. export enum DepthOfFieldEffectBlurLevel {
  149928. /**
  149929. * Subtle blur
  149930. */
  149931. Low = 0,
  149932. /**
  149933. * Medium blur
  149934. */
  149935. Medium = 1,
  149936. /**
  149937. * Large blur
  149938. */
  149939. High = 2
  149940. }
  149941. /**
  149942. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149943. */
  149944. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149945. private _circleOfConfusion;
  149946. /**
  149947. * @hidden Internal, blurs from high to low
  149948. */
  149949. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149950. private _depthOfFieldBlurY;
  149951. private _dofMerge;
  149952. /**
  149953. * @hidden Internal post processes in depth of field effect
  149954. */
  149955. _effects: Array<PostProcess>;
  149956. /**
  149957. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149958. */
  149959. set focalLength(value: number);
  149960. get focalLength(): number;
  149961. /**
  149962. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149963. */
  149964. set fStop(value: number);
  149965. get fStop(): number;
  149966. /**
  149967. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149968. */
  149969. set focusDistance(value: number);
  149970. get focusDistance(): number;
  149971. /**
  149972. * 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.
  149973. */
  149974. set lensSize(value: number);
  149975. get lensSize(): number;
  149976. /**
  149977. * Creates a new instance DepthOfFieldEffect
  149978. * @param scene The scene the effect belongs to.
  149979. * @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.
  149980. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149981. * @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)
  149982. */
  149983. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149984. /**
  149985. * Get the current class name of the current effet
  149986. * @returns "DepthOfFieldEffect"
  149987. */
  149988. getClassName(): string;
  149989. /**
  149990. * 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.
  149991. */
  149992. set depthTexture(value: RenderTargetTexture);
  149993. /**
  149994. * Disposes each of the internal effects for a given camera.
  149995. * @param camera The camera to dispose the effect on.
  149996. */
  149997. disposeEffects(camera: Camera): void;
  149998. /**
  149999. * @hidden Internal
  150000. */
  150001. _updateEffects(): void;
  150002. /**
  150003. * Internal
  150004. * @returns if all the contained post processes are ready.
  150005. * @hidden
  150006. */
  150007. _isReady(): boolean;
  150008. }
  150009. }
  150010. declare module BABYLON {
  150011. /** @hidden */
  150012. export var displayPassPixelShader: {
  150013. name: string;
  150014. shader: string;
  150015. };
  150016. }
  150017. declare module BABYLON {
  150018. /**
  150019. * DisplayPassPostProcess which produces an output the same as it's input
  150020. */
  150021. export class DisplayPassPostProcess extends PostProcess {
  150022. /**
  150023. * Gets a string identifying the name of the class
  150024. * @returns "DisplayPassPostProcess" string
  150025. */
  150026. getClassName(): string;
  150027. /**
  150028. * Creates the DisplayPassPostProcess
  150029. * @param name The name of the effect.
  150030. * @param options The required width/height ratio to downsize to before computing the render pass.
  150031. * @param camera The camera to apply the render pass to.
  150032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150033. * @param engine The engine which the post process will be applied. (default: current engine)
  150034. * @param reusable If the post process can be reused on the same frame. (default: false)
  150035. */
  150036. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150037. /** @hidden */
  150038. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150039. }
  150040. }
  150041. declare module BABYLON {
  150042. /** @hidden */
  150043. export var filterPixelShader: {
  150044. name: string;
  150045. shader: string;
  150046. };
  150047. }
  150048. declare module BABYLON {
  150049. /**
  150050. * Applies a kernel filter to the image
  150051. */
  150052. export class FilterPostProcess extends PostProcess {
  150053. /** The matrix to be applied to the image */
  150054. kernelMatrix: Matrix;
  150055. /**
  150056. * Gets a string identifying the name of the class
  150057. * @returns "FilterPostProcess" string
  150058. */
  150059. getClassName(): string;
  150060. /**
  150061. *
  150062. * @param name The name of the effect.
  150063. * @param kernelMatrix The matrix to be applied to the image
  150064. * @param options The required width/height ratio to downsize to before computing the render pass.
  150065. * @param camera The camera to apply the render pass to.
  150066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150067. * @param engine The engine which the post process will be applied. (default: current engine)
  150068. * @param reusable If the post process can be reused on the same frame. (default: false)
  150069. */
  150070. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150071. /** @hidden */
  150072. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150073. }
  150074. }
  150075. declare module BABYLON {
  150076. /** @hidden */
  150077. export var fxaaPixelShader: {
  150078. name: string;
  150079. shader: string;
  150080. };
  150081. }
  150082. declare module BABYLON {
  150083. /** @hidden */
  150084. export var fxaaVertexShader: {
  150085. name: string;
  150086. shader: string;
  150087. };
  150088. }
  150089. declare module BABYLON {
  150090. /**
  150091. * Fxaa post process
  150092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150093. */
  150094. export class FxaaPostProcess extends PostProcess {
  150095. /**
  150096. * Gets a string identifying the name of the class
  150097. * @returns "FxaaPostProcess" string
  150098. */
  150099. getClassName(): string;
  150100. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150101. private _getDefines;
  150102. /** @hidden */
  150103. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150104. }
  150105. }
  150106. declare module BABYLON {
  150107. /** @hidden */
  150108. export var grainPixelShader: {
  150109. name: string;
  150110. shader: string;
  150111. };
  150112. }
  150113. declare module BABYLON {
  150114. /**
  150115. * The GrainPostProcess adds noise to the image at mid luminance levels
  150116. */
  150117. export class GrainPostProcess extends PostProcess {
  150118. /**
  150119. * The intensity of the grain added (default: 30)
  150120. */
  150121. intensity: number;
  150122. /**
  150123. * If the grain should be randomized on every frame
  150124. */
  150125. animated: boolean;
  150126. /**
  150127. * Gets a string identifying the name of the class
  150128. * @returns "GrainPostProcess" string
  150129. */
  150130. getClassName(): string;
  150131. /**
  150132. * Creates a new instance of @see GrainPostProcess
  150133. * @param name The name of the effect.
  150134. * @param options The required width/height ratio to downsize to before computing the render pass.
  150135. * @param camera The camera to apply the render pass to.
  150136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150137. * @param engine The engine which the post process will be applied. (default: current engine)
  150138. * @param reusable If the post process can be reused on the same frame. (default: false)
  150139. * @param textureType Type of textures used when performing the post process. (default: 0)
  150140. * @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)
  150141. */
  150142. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150143. /** @hidden */
  150144. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150145. }
  150146. }
  150147. declare module BABYLON {
  150148. /** @hidden */
  150149. export var highlightsPixelShader: {
  150150. name: string;
  150151. shader: string;
  150152. };
  150153. }
  150154. declare module BABYLON {
  150155. /**
  150156. * Extracts highlights from the image
  150157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150158. */
  150159. export class HighlightsPostProcess extends PostProcess {
  150160. /**
  150161. * Gets a string identifying the name of the class
  150162. * @returns "HighlightsPostProcess" string
  150163. */
  150164. getClassName(): string;
  150165. /**
  150166. * Extracts highlights from the image
  150167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150168. * @param name The name of the effect.
  150169. * @param options The required width/height ratio to downsize to before computing the render pass.
  150170. * @param camera The camera to apply the render pass to.
  150171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150172. * @param engine The engine which the post process will be applied. (default: current engine)
  150173. * @param reusable If the post process can be reused on the same frame. (default: false)
  150174. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150175. */
  150176. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150177. }
  150178. }
  150179. declare module BABYLON {
  150180. /** @hidden */
  150181. export var mrtFragmentDeclaration: {
  150182. name: string;
  150183. shader: string;
  150184. };
  150185. }
  150186. declare module BABYLON {
  150187. /** @hidden */
  150188. export var geometryPixelShader: {
  150189. name: string;
  150190. shader: string;
  150191. };
  150192. }
  150193. declare module BABYLON {
  150194. /** @hidden */
  150195. export var geometryVertexShader: {
  150196. name: string;
  150197. shader: string;
  150198. };
  150199. }
  150200. declare module BABYLON {
  150201. /** @hidden */
  150202. interface ISavedTransformationMatrix {
  150203. world: Matrix;
  150204. viewProjection: Matrix;
  150205. }
  150206. /**
  150207. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150208. */
  150209. export class GeometryBufferRenderer {
  150210. /**
  150211. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150212. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150213. */
  150214. static readonly POSITION_TEXTURE_TYPE: number;
  150215. /**
  150216. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150217. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150218. */
  150219. static readonly VELOCITY_TEXTURE_TYPE: number;
  150220. /**
  150221. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150222. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150223. */
  150224. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150225. /**
  150226. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150227. * in order to compute objects velocities when enableVelocity is set to "true"
  150228. * @hidden
  150229. */
  150230. _previousTransformationMatrices: {
  150231. [index: number]: ISavedTransformationMatrix;
  150232. };
  150233. /**
  150234. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150235. * in order to compute objects velocities when enableVelocity is set to "true"
  150236. * @hidden
  150237. */
  150238. _previousBonesTransformationMatrices: {
  150239. [index: number]: Float32Array;
  150240. };
  150241. /**
  150242. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150243. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150244. */
  150245. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150246. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150247. renderTransparentMeshes: boolean;
  150248. private _scene;
  150249. private _resizeObserver;
  150250. private _multiRenderTarget;
  150251. private _ratio;
  150252. private _enablePosition;
  150253. private _enableVelocity;
  150254. private _enableReflectivity;
  150255. private _positionIndex;
  150256. private _velocityIndex;
  150257. private _reflectivityIndex;
  150258. protected _effect: Effect;
  150259. protected _cachedDefines: string;
  150260. /**
  150261. * Set the render list (meshes to be rendered) used in the G buffer.
  150262. */
  150263. set renderList(meshes: Mesh[]);
  150264. /**
  150265. * Gets wether or not G buffer are supported by the running hardware.
  150266. * This requires draw buffer supports
  150267. */
  150268. get isSupported(): boolean;
  150269. /**
  150270. * Returns the index of the given texture type in the G-Buffer textures array
  150271. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150272. * @returns the index of the given texture type in the G-Buffer textures array
  150273. */
  150274. getTextureIndex(textureType: number): number;
  150275. /**
  150276. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150277. */
  150278. get enablePosition(): boolean;
  150279. /**
  150280. * Sets whether or not objects positions are enabled for the G buffer.
  150281. */
  150282. set enablePosition(enable: boolean);
  150283. /**
  150284. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150285. */
  150286. get enableVelocity(): boolean;
  150287. /**
  150288. * Sets wether or not objects velocities are enabled for the G buffer.
  150289. */
  150290. set enableVelocity(enable: boolean);
  150291. /**
  150292. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150293. */
  150294. get enableReflectivity(): boolean;
  150295. /**
  150296. * Sets wether or not objects roughness are enabled for the G buffer.
  150297. */
  150298. set enableReflectivity(enable: boolean);
  150299. /**
  150300. * Gets the scene associated with the buffer.
  150301. */
  150302. get scene(): Scene;
  150303. /**
  150304. * Gets the ratio used by the buffer during its creation.
  150305. * How big is the buffer related to the main canvas.
  150306. */
  150307. get ratio(): number;
  150308. /** @hidden */
  150309. static _SceneComponentInitialization: (scene: Scene) => void;
  150310. /**
  150311. * Creates a new G Buffer for the scene
  150312. * @param scene The scene the buffer belongs to
  150313. * @param ratio How big is the buffer related to the main canvas.
  150314. */
  150315. constructor(scene: Scene, ratio?: number);
  150316. /**
  150317. * Checks wether everything is ready to render a submesh to the G buffer.
  150318. * @param subMesh the submesh to check readiness for
  150319. * @param useInstances is the mesh drawn using instance or not
  150320. * @returns true if ready otherwise false
  150321. */
  150322. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150323. /**
  150324. * Gets the current underlying G Buffer.
  150325. * @returns the buffer
  150326. */
  150327. getGBuffer(): MultiRenderTarget;
  150328. /**
  150329. * Gets the number of samples used to render the buffer (anti aliasing).
  150330. */
  150331. get samples(): number;
  150332. /**
  150333. * Sets the number of samples used to render the buffer (anti aliasing).
  150334. */
  150335. set samples(value: number);
  150336. /**
  150337. * Disposes the renderer and frees up associated resources.
  150338. */
  150339. dispose(): void;
  150340. protected _createRenderTargets(): void;
  150341. private _copyBonesTransformationMatrices;
  150342. }
  150343. }
  150344. declare module BABYLON {
  150345. interface Scene {
  150346. /** @hidden (Backing field) */
  150347. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150348. /**
  150349. * Gets or Sets the current geometry buffer associated to the scene.
  150350. */
  150351. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150352. /**
  150353. * Enables a GeometryBufferRender and associates it with the scene
  150354. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150355. * @returns the GeometryBufferRenderer
  150356. */
  150357. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150358. /**
  150359. * Disables the GeometryBufferRender associated with the scene
  150360. */
  150361. disableGeometryBufferRenderer(): void;
  150362. }
  150363. /**
  150364. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150365. * in several rendering techniques.
  150366. */
  150367. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150368. /**
  150369. * The component name helpful to identify the component in the list of scene components.
  150370. */
  150371. readonly name: string;
  150372. /**
  150373. * The scene the component belongs to.
  150374. */
  150375. scene: Scene;
  150376. /**
  150377. * Creates a new instance of the component for the given scene
  150378. * @param scene Defines the scene to register the component in
  150379. */
  150380. constructor(scene: Scene);
  150381. /**
  150382. * Registers the component in a given scene
  150383. */
  150384. register(): void;
  150385. /**
  150386. * Rebuilds the elements related to this component in case of
  150387. * context lost for instance.
  150388. */
  150389. rebuild(): void;
  150390. /**
  150391. * Disposes the component and the associated ressources
  150392. */
  150393. dispose(): void;
  150394. private _gatherRenderTargets;
  150395. }
  150396. }
  150397. declare module BABYLON {
  150398. /** @hidden */
  150399. export var motionBlurPixelShader: {
  150400. name: string;
  150401. shader: string;
  150402. };
  150403. }
  150404. declare module BABYLON {
  150405. /**
  150406. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150407. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150408. * As an example, all you have to do is to create the post-process:
  150409. * var mb = new BABYLON.MotionBlurPostProcess(
  150410. * 'mb', // The name of the effect.
  150411. * scene, // The scene containing the objects to blur according to their velocity.
  150412. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150413. * camera // The camera to apply the render pass to.
  150414. * );
  150415. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150416. */
  150417. export class MotionBlurPostProcess extends PostProcess {
  150418. /**
  150419. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150420. */
  150421. motionStrength: number;
  150422. /**
  150423. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150424. */
  150425. get motionBlurSamples(): number;
  150426. /**
  150427. * Sets the number of iterations to be used for motion blur quality
  150428. */
  150429. set motionBlurSamples(samples: number);
  150430. private _motionBlurSamples;
  150431. private _geometryBufferRenderer;
  150432. /**
  150433. * Gets a string identifying the name of the class
  150434. * @returns "MotionBlurPostProcess" string
  150435. */
  150436. getClassName(): string;
  150437. /**
  150438. * Creates a new instance MotionBlurPostProcess
  150439. * @param name The name of the effect.
  150440. * @param scene The scene containing the objects to blur according to their velocity.
  150441. * @param options The required width/height ratio to downsize to before computing the render pass.
  150442. * @param camera The camera to apply the render pass to.
  150443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150444. * @param engine The engine which the post process will be applied. (default: current engine)
  150445. * @param reusable If the post process can be reused on the same frame. (default: false)
  150446. * @param textureType Type of textures used when performing the post process. (default: 0)
  150447. * @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)
  150448. */
  150449. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150450. /**
  150451. * Excludes the given skinned mesh from computing bones velocities.
  150452. * 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.
  150453. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150454. */
  150455. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150456. /**
  150457. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150458. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150459. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150460. */
  150461. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150462. /**
  150463. * Disposes the post process.
  150464. * @param camera The camera to dispose the post process on.
  150465. */
  150466. dispose(camera?: Camera): void;
  150467. /** @hidden */
  150468. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150469. }
  150470. }
  150471. declare module BABYLON {
  150472. /** @hidden */
  150473. export var refractionPixelShader: {
  150474. name: string;
  150475. shader: string;
  150476. };
  150477. }
  150478. declare module BABYLON {
  150479. /**
  150480. * Post process which applies a refractin texture
  150481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150482. */
  150483. export class RefractionPostProcess extends PostProcess {
  150484. private _refTexture;
  150485. private _ownRefractionTexture;
  150486. /** the base color of the refraction (used to taint the rendering) */
  150487. color: Color3;
  150488. /** simulated refraction depth */
  150489. depth: number;
  150490. /** the coefficient of the base color (0 to remove base color tainting) */
  150491. colorLevel: number;
  150492. /** Gets the url used to load the refraction texture */
  150493. refractionTextureUrl: string;
  150494. /**
  150495. * Gets or sets the refraction texture
  150496. * Please note that you are responsible for disposing the texture if you set it manually
  150497. */
  150498. get refractionTexture(): Texture;
  150499. set refractionTexture(value: Texture);
  150500. /**
  150501. * Gets a string identifying the name of the class
  150502. * @returns "RefractionPostProcess" string
  150503. */
  150504. getClassName(): string;
  150505. /**
  150506. * Initializes the RefractionPostProcess
  150507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150508. * @param name The name of the effect.
  150509. * @param refractionTextureUrl Url of the refraction texture to use
  150510. * @param color the base color of the refraction (used to taint the rendering)
  150511. * @param depth simulated refraction depth
  150512. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150513. * @param camera The camera to apply the render pass to.
  150514. * @param options The required width/height ratio to downsize to before computing the render pass.
  150515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150516. * @param engine The engine which the post process will be applied. (default: current engine)
  150517. * @param reusable If the post process can be reused on the same frame. (default: false)
  150518. */
  150519. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150520. /**
  150521. * Disposes of the post process
  150522. * @param camera Camera to dispose post process on
  150523. */
  150524. dispose(camera: Camera): void;
  150525. /** @hidden */
  150526. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150527. }
  150528. }
  150529. declare module BABYLON {
  150530. /** @hidden */
  150531. export var sharpenPixelShader: {
  150532. name: string;
  150533. shader: string;
  150534. };
  150535. }
  150536. declare module BABYLON {
  150537. /**
  150538. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150539. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150540. */
  150541. export class SharpenPostProcess extends PostProcess {
  150542. /**
  150543. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150544. */
  150545. colorAmount: number;
  150546. /**
  150547. * How much sharpness should be applied (default: 0.3)
  150548. */
  150549. edgeAmount: number;
  150550. /**
  150551. * Gets a string identifying the name of the class
  150552. * @returns "SharpenPostProcess" string
  150553. */
  150554. getClassName(): string;
  150555. /**
  150556. * Creates a new instance ConvolutionPostProcess
  150557. * @param name The name of the effect.
  150558. * @param options The required width/height ratio to downsize to before computing the render pass.
  150559. * @param camera The camera to apply the render pass to.
  150560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150561. * @param engine The engine which the post process will be applied. (default: current engine)
  150562. * @param reusable If the post process can be reused on the same frame. (default: false)
  150563. * @param textureType Type of textures used when performing the post process. (default: 0)
  150564. * @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)
  150565. */
  150566. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150567. /** @hidden */
  150568. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150569. }
  150570. }
  150571. declare module BABYLON {
  150572. /**
  150573. * PostProcessRenderPipeline
  150574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150575. */
  150576. export class PostProcessRenderPipeline {
  150577. private engine;
  150578. private _renderEffects;
  150579. private _renderEffectsForIsolatedPass;
  150580. /**
  150581. * List of inspectable custom properties (used by the Inspector)
  150582. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150583. */
  150584. inspectableCustomProperties: IInspectable[];
  150585. /**
  150586. * @hidden
  150587. */
  150588. protected _cameras: Camera[];
  150589. /** @hidden */
  150590. _name: string;
  150591. /**
  150592. * Gets pipeline name
  150593. */
  150594. get name(): string;
  150595. /** Gets the list of attached cameras */
  150596. get cameras(): Camera[];
  150597. /**
  150598. * Initializes a PostProcessRenderPipeline
  150599. * @param engine engine to add the pipeline to
  150600. * @param name name of the pipeline
  150601. */
  150602. constructor(engine: Engine, name: string);
  150603. /**
  150604. * Gets the class name
  150605. * @returns "PostProcessRenderPipeline"
  150606. */
  150607. getClassName(): string;
  150608. /**
  150609. * If all the render effects in the pipeline are supported
  150610. */
  150611. get isSupported(): boolean;
  150612. /**
  150613. * Adds an effect to the pipeline
  150614. * @param renderEffect the effect to add
  150615. */
  150616. addEffect(renderEffect: PostProcessRenderEffect): void;
  150617. /** @hidden */
  150618. _rebuild(): void;
  150619. /** @hidden */
  150620. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150621. /** @hidden */
  150622. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150623. /** @hidden */
  150624. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150625. /** @hidden */
  150626. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150627. /** @hidden */
  150628. _attachCameras(cameras: Camera, unique: boolean): void;
  150629. /** @hidden */
  150630. _attachCameras(cameras: Camera[], unique: boolean): void;
  150631. /** @hidden */
  150632. _detachCameras(cameras: Camera): void;
  150633. /** @hidden */
  150634. _detachCameras(cameras: Nullable<Camera[]>): void;
  150635. /** @hidden */
  150636. _update(): void;
  150637. /** @hidden */
  150638. _reset(): void;
  150639. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150640. /**
  150641. * Sets the required values to the prepass renderer.
  150642. * @param prePassRenderer defines the prepass renderer to setup.
  150643. * @returns true if the pre pass is needed.
  150644. */
  150645. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150646. /**
  150647. * Disposes of the pipeline
  150648. */
  150649. dispose(): void;
  150650. }
  150651. }
  150652. declare module BABYLON {
  150653. /**
  150654. * PostProcessRenderPipelineManager class
  150655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150656. */
  150657. export class PostProcessRenderPipelineManager {
  150658. private _renderPipelines;
  150659. /**
  150660. * Initializes a PostProcessRenderPipelineManager
  150661. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150662. */
  150663. constructor();
  150664. /**
  150665. * Gets the list of supported render pipelines
  150666. */
  150667. get supportedPipelines(): PostProcessRenderPipeline[];
  150668. /**
  150669. * Adds a pipeline to the manager
  150670. * @param renderPipeline The pipeline to add
  150671. */
  150672. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150673. /**
  150674. * Attaches a camera to the pipeline
  150675. * @param renderPipelineName The name of the pipeline to attach to
  150676. * @param cameras the camera to attach
  150677. * @param unique if the camera can be attached multiple times to the pipeline
  150678. */
  150679. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150680. /**
  150681. * Detaches a camera from the pipeline
  150682. * @param renderPipelineName The name of the pipeline to detach from
  150683. * @param cameras the camera to detach
  150684. */
  150685. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150686. /**
  150687. * Enables an effect by name on a pipeline
  150688. * @param renderPipelineName the name of the pipeline to enable the effect in
  150689. * @param renderEffectName the name of the effect to enable
  150690. * @param cameras the cameras that the effect should be enabled on
  150691. */
  150692. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150693. /**
  150694. * Disables an effect by name on a pipeline
  150695. * @param renderPipelineName the name of the pipeline to disable the effect in
  150696. * @param renderEffectName the name of the effect to disable
  150697. * @param cameras the cameras that the effect should be disabled on
  150698. */
  150699. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150700. /**
  150701. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150702. */
  150703. update(): void;
  150704. /** @hidden */
  150705. _rebuild(): void;
  150706. /**
  150707. * Disposes of the manager and pipelines
  150708. */
  150709. dispose(): void;
  150710. }
  150711. }
  150712. declare module BABYLON {
  150713. interface Scene {
  150714. /** @hidden (Backing field) */
  150715. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150716. /**
  150717. * Gets the postprocess render pipeline manager
  150718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150719. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150720. */
  150721. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150722. }
  150723. /**
  150724. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150725. */
  150726. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150727. /**
  150728. * The component name helpfull to identify the component in the list of scene components.
  150729. */
  150730. readonly name: string;
  150731. /**
  150732. * The scene the component belongs to.
  150733. */
  150734. scene: Scene;
  150735. /**
  150736. * Creates a new instance of the component for the given scene
  150737. * @param scene Defines the scene to register the component in
  150738. */
  150739. constructor(scene: Scene);
  150740. /**
  150741. * Registers the component in a given scene
  150742. */
  150743. register(): void;
  150744. /**
  150745. * Rebuilds the elements related to this component in case of
  150746. * context lost for instance.
  150747. */
  150748. rebuild(): void;
  150749. /**
  150750. * Disposes the component and the associated ressources
  150751. */
  150752. dispose(): void;
  150753. private _gatherRenderTargets;
  150754. }
  150755. }
  150756. declare module BABYLON {
  150757. /**
  150758. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150759. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150760. */
  150761. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150762. private _scene;
  150763. private _camerasToBeAttached;
  150764. /**
  150765. * ID of the sharpen post process,
  150766. */
  150767. private readonly SharpenPostProcessId;
  150768. /**
  150769. * @ignore
  150770. * ID of the image processing post process;
  150771. */
  150772. readonly ImageProcessingPostProcessId: string;
  150773. /**
  150774. * @ignore
  150775. * ID of the Fast Approximate Anti-Aliasing post process;
  150776. */
  150777. readonly FxaaPostProcessId: string;
  150778. /**
  150779. * ID of the chromatic aberration post process,
  150780. */
  150781. private readonly ChromaticAberrationPostProcessId;
  150782. /**
  150783. * ID of the grain post process
  150784. */
  150785. private readonly GrainPostProcessId;
  150786. /**
  150787. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150788. */
  150789. sharpen: SharpenPostProcess;
  150790. private _sharpenEffect;
  150791. private bloom;
  150792. /**
  150793. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150794. */
  150795. depthOfField: DepthOfFieldEffect;
  150796. /**
  150797. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150798. */
  150799. fxaa: FxaaPostProcess;
  150800. /**
  150801. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150802. */
  150803. imageProcessing: ImageProcessingPostProcess;
  150804. /**
  150805. * Chromatic aberration post process which will shift rgb colors in the image
  150806. */
  150807. chromaticAberration: ChromaticAberrationPostProcess;
  150808. private _chromaticAberrationEffect;
  150809. /**
  150810. * Grain post process which add noise to the image
  150811. */
  150812. grain: GrainPostProcess;
  150813. private _grainEffect;
  150814. /**
  150815. * Glow post process which adds a glow to emissive areas of the image
  150816. */
  150817. private _glowLayer;
  150818. /**
  150819. * Animations which can be used to tweak settings over a period of time
  150820. */
  150821. animations: Animation[];
  150822. private _imageProcessingConfigurationObserver;
  150823. private _sharpenEnabled;
  150824. private _bloomEnabled;
  150825. private _depthOfFieldEnabled;
  150826. private _depthOfFieldBlurLevel;
  150827. private _fxaaEnabled;
  150828. private _imageProcessingEnabled;
  150829. private _defaultPipelineTextureType;
  150830. private _bloomScale;
  150831. private _chromaticAberrationEnabled;
  150832. private _grainEnabled;
  150833. private _buildAllowed;
  150834. /**
  150835. * Gets active scene
  150836. */
  150837. get scene(): Scene;
  150838. /**
  150839. * Enable or disable the sharpen process from the pipeline
  150840. */
  150841. set sharpenEnabled(enabled: boolean);
  150842. get sharpenEnabled(): boolean;
  150843. private _resizeObserver;
  150844. private _hardwareScaleLevel;
  150845. private _bloomKernel;
  150846. /**
  150847. * Specifies the size of the bloom blur kernel, relative to the final output size
  150848. */
  150849. get bloomKernel(): number;
  150850. set bloomKernel(value: number);
  150851. /**
  150852. * Specifies the weight of the bloom in the final rendering
  150853. */
  150854. private _bloomWeight;
  150855. /**
  150856. * Specifies the luma threshold for the area that will be blurred by the bloom
  150857. */
  150858. private _bloomThreshold;
  150859. private _hdr;
  150860. /**
  150861. * The strength of the bloom.
  150862. */
  150863. set bloomWeight(value: number);
  150864. get bloomWeight(): number;
  150865. /**
  150866. * The strength of the bloom.
  150867. */
  150868. set bloomThreshold(value: number);
  150869. get bloomThreshold(): number;
  150870. /**
  150871. * The scale of the bloom, lower value will provide better performance.
  150872. */
  150873. set bloomScale(value: number);
  150874. get bloomScale(): number;
  150875. /**
  150876. * Enable or disable the bloom from the pipeline
  150877. */
  150878. set bloomEnabled(enabled: boolean);
  150879. get bloomEnabled(): boolean;
  150880. private _rebuildBloom;
  150881. /**
  150882. * If the depth of field is enabled.
  150883. */
  150884. get depthOfFieldEnabled(): boolean;
  150885. set depthOfFieldEnabled(enabled: boolean);
  150886. /**
  150887. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150888. */
  150889. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150890. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150891. /**
  150892. * If the anti aliasing is enabled.
  150893. */
  150894. set fxaaEnabled(enabled: boolean);
  150895. get fxaaEnabled(): boolean;
  150896. private _samples;
  150897. /**
  150898. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150899. */
  150900. set samples(sampleCount: number);
  150901. get samples(): number;
  150902. /**
  150903. * If image processing is enabled.
  150904. */
  150905. set imageProcessingEnabled(enabled: boolean);
  150906. get imageProcessingEnabled(): boolean;
  150907. /**
  150908. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150909. */
  150910. set glowLayerEnabled(enabled: boolean);
  150911. get glowLayerEnabled(): boolean;
  150912. /**
  150913. * Gets the glow layer (or null if not defined)
  150914. */
  150915. get glowLayer(): Nullable<GlowLayer>;
  150916. /**
  150917. * Enable or disable the chromaticAberration process from the pipeline
  150918. */
  150919. set chromaticAberrationEnabled(enabled: boolean);
  150920. get chromaticAberrationEnabled(): boolean;
  150921. /**
  150922. * Enable or disable the grain process from the pipeline
  150923. */
  150924. set grainEnabled(enabled: boolean);
  150925. get grainEnabled(): boolean;
  150926. /**
  150927. * @constructor
  150928. * @param name - The rendering pipeline name (default: "")
  150929. * @param hdr - If high dynamic range textures should be used (default: true)
  150930. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150931. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150932. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150933. */
  150934. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150935. /**
  150936. * Get the class name
  150937. * @returns "DefaultRenderingPipeline"
  150938. */
  150939. getClassName(): string;
  150940. /**
  150941. * Force the compilation of the entire pipeline.
  150942. */
  150943. prepare(): void;
  150944. private _hasCleared;
  150945. private _prevPostProcess;
  150946. private _prevPrevPostProcess;
  150947. private _setAutoClearAndTextureSharing;
  150948. private _depthOfFieldSceneObserver;
  150949. private _buildPipeline;
  150950. private _disposePostProcesses;
  150951. /**
  150952. * Adds a camera to the pipeline
  150953. * @param camera the camera to be added
  150954. */
  150955. addCamera(camera: Camera): void;
  150956. /**
  150957. * Removes a camera from the pipeline
  150958. * @param camera the camera to remove
  150959. */
  150960. removeCamera(camera: Camera): void;
  150961. /**
  150962. * Dispose of the pipeline and stop all post processes
  150963. */
  150964. dispose(): void;
  150965. /**
  150966. * Serialize the rendering pipeline (Used when exporting)
  150967. * @returns the serialized object
  150968. */
  150969. serialize(): any;
  150970. /**
  150971. * Parse the serialized pipeline
  150972. * @param source Source pipeline.
  150973. * @param scene The scene to load the pipeline to.
  150974. * @param rootUrl The URL of the serialized pipeline.
  150975. * @returns An instantiated pipeline from the serialized object.
  150976. */
  150977. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150978. }
  150979. }
  150980. declare module BABYLON {
  150981. /** @hidden */
  150982. export var lensHighlightsPixelShader: {
  150983. name: string;
  150984. shader: string;
  150985. };
  150986. }
  150987. declare module BABYLON {
  150988. /** @hidden */
  150989. export var depthOfFieldPixelShader: {
  150990. name: string;
  150991. shader: string;
  150992. };
  150993. }
  150994. declare module BABYLON {
  150995. /**
  150996. * BABYLON.JS Chromatic Aberration GLSL Shader
  150997. * Author: Olivier Guyot
  150998. * Separates very slightly R, G and B colors on the edges of the screen
  150999. * Inspired by Francois Tarlier & Martins Upitis
  151000. */
  151001. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151002. /**
  151003. * @ignore
  151004. * The chromatic aberration PostProcess id in the pipeline
  151005. */
  151006. LensChromaticAberrationEffect: string;
  151007. /**
  151008. * @ignore
  151009. * The highlights enhancing PostProcess id in the pipeline
  151010. */
  151011. HighlightsEnhancingEffect: string;
  151012. /**
  151013. * @ignore
  151014. * The depth-of-field PostProcess id in the pipeline
  151015. */
  151016. LensDepthOfFieldEffect: string;
  151017. private _scene;
  151018. private _depthTexture;
  151019. private _grainTexture;
  151020. private _chromaticAberrationPostProcess;
  151021. private _highlightsPostProcess;
  151022. private _depthOfFieldPostProcess;
  151023. private _edgeBlur;
  151024. private _grainAmount;
  151025. private _chromaticAberration;
  151026. private _distortion;
  151027. private _highlightsGain;
  151028. private _highlightsThreshold;
  151029. private _dofDistance;
  151030. private _dofAperture;
  151031. private _dofDarken;
  151032. private _dofPentagon;
  151033. private _blurNoise;
  151034. /**
  151035. * @constructor
  151036. *
  151037. * Effect parameters are as follow:
  151038. * {
  151039. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151040. * edge_blur: number; // from 0 to x (1 for realism)
  151041. * distortion: number; // from 0 to x (1 for realism)
  151042. * grain_amount: number; // from 0 to 1
  151043. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151044. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151045. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151046. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151047. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151048. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151049. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151050. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151051. * }
  151052. * Note: if an effect parameter is unset, effect is disabled
  151053. *
  151054. * @param name The rendering pipeline name
  151055. * @param parameters - An object containing all parameters (see above)
  151056. * @param scene The scene linked to this pipeline
  151057. * @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)
  151058. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151059. */
  151060. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151061. /**
  151062. * Get the class name
  151063. * @returns "LensRenderingPipeline"
  151064. */
  151065. getClassName(): string;
  151066. /**
  151067. * Gets associated scene
  151068. */
  151069. get scene(): Scene;
  151070. /**
  151071. * Gets or sets the edge blur
  151072. */
  151073. get edgeBlur(): number;
  151074. set edgeBlur(value: number);
  151075. /**
  151076. * Gets or sets the grain amount
  151077. */
  151078. get grainAmount(): number;
  151079. set grainAmount(value: number);
  151080. /**
  151081. * Gets or sets the chromatic aberration amount
  151082. */
  151083. get chromaticAberration(): number;
  151084. set chromaticAberration(value: number);
  151085. /**
  151086. * Gets or sets the depth of field aperture
  151087. */
  151088. get dofAperture(): number;
  151089. set dofAperture(value: number);
  151090. /**
  151091. * Gets or sets the edge distortion
  151092. */
  151093. get edgeDistortion(): number;
  151094. set edgeDistortion(value: number);
  151095. /**
  151096. * Gets or sets the depth of field distortion
  151097. */
  151098. get dofDistortion(): number;
  151099. set dofDistortion(value: number);
  151100. /**
  151101. * Gets or sets the darken out of focus amount
  151102. */
  151103. get darkenOutOfFocus(): number;
  151104. set darkenOutOfFocus(value: number);
  151105. /**
  151106. * Gets or sets a boolean indicating if blur noise is enabled
  151107. */
  151108. get blurNoise(): boolean;
  151109. set blurNoise(value: boolean);
  151110. /**
  151111. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151112. */
  151113. get pentagonBokeh(): boolean;
  151114. set pentagonBokeh(value: boolean);
  151115. /**
  151116. * Gets or sets the highlight grain amount
  151117. */
  151118. get highlightsGain(): number;
  151119. set highlightsGain(value: number);
  151120. /**
  151121. * Gets or sets the highlight threshold
  151122. */
  151123. get highlightsThreshold(): number;
  151124. set highlightsThreshold(value: number);
  151125. /**
  151126. * Sets the amount of blur at the edges
  151127. * @param amount blur amount
  151128. */
  151129. setEdgeBlur(amount: number): void;
  151130. /**
  151131. * Sets edge blur to 0
  151132. */
  151133. disableEdgeBlur(): void;
  151134. /**
  151135. * Sets the amout of grain
  151136. * @param amount Amount of grain
  151137. */
  151138. setGrainAmount(amount: number): void;
  151139. /**
  151140. * Set grain amount to 0
  151141. */
  151142. disableGrain(): void;
  151143. /**
  151144. * Sets the chromatic aberration amount
  151145. * @param amount amount of chromatic aberration
  151146. */
  151147. setChromaticAberration(amount: number): void;
  151148. /**
  151149. * Sets chromatic aberration amount to 0
  151150. */
  151151. disableChromaticAberration(): void;
  151152. /**
  151153. * Sets the EdgeDistortion amount
  151154. * @param amount amount of EdgeDistortion
  151155. */
  151156. setEdgeDistortion(amount: number): void;
  151157. /**
  151158. * Sets edge distortion to 0
  151159. */
  151160. disableEdgeDistortion(): void;
  151161. /**
  151162. * Sets the FocusDistance amount
  151163. * @param amount amount of FocusDistance
  151164. */
  151165. setFocusDistance(amount: number): void;
  151166. /**
  151167. * Disables depth of field
  151168. */
  151169. disableDepthOfField(): void;
  151170. /**
  151171. * Sets the Aperture amount
  151172. * @param amount amount of Aperture
  151173. */
  151174. setAperture(amount: number): void;
  151175. /**
  151176. * Sets the DarkenOutOfFocus amount
  151177. * @param amount amount of DarkenOutOfFocus
  151178. */
  151179. setDarkenOutOfFocus(amount: number): void;
  151180. private _pentagonBokehIsEnabled;
  151181. /**
  151182. * Creates a pentagon bokeh effect
  151183. */
  151184. enablePentagonBokeh(): void;
  151185. /**
  151186. * Disables the pentagon bokeh effect
  151187. */
  151188. disablePentagonBokeh(): void;
  151189. /**
  151190. * Enables noise blur
  151191. */
  151192. enableNoiseBlur(): void;
  151193. /**
  151194. * Disables noise blur
  151195. */
  151196. disableNoiseBlur(): void;
  151197. /**
  151198. * Sets the HighlightsGain amount
  151199. * @param amount amount of HighlightsGain
  151200. */
  151201. setHighlightsGain(amount: number): void;
  151202. /**
  151203. * Sets the HighlightsThreshold amount
  151204. * @param amount amount of HighlightsThreshold
  151205. */
  151206. setHighlightsThreshold(amount: number): void;
  151207. /**
  151208. * Disables highlights
  151209. */
  151210. disableHighlights(): void;
  151211. /**
  151212. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151213. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151214. */
  151215. dispose(disableDepthRender?: boolean): void;
  151216. private _createChromaticAberrationPostProcess;
  151217. private _createHighlightsPostProcess;
  151218. private _createDepthOfFieldPostProcess;
  151219. private _createGrainTexture;
  151220. }
  151221. }
  151222. declare module BABYLON {
  151223. /**
  151224. * Contains all parameters needed for the prepass to perform
  151225. * screen space subsurface scattering
  151226. */
  151227. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151228. /**
  151229. * Is subsurface enabled
  151230. */
  151231. enabled: boolean;
  151232. /**
  151233. * Name of the configuration
  151234. */
  151235. name: string;
  151236. /**
  151237. * Textures that should be present in the MRT for this effect to work
  151238. */
  151239. readonly texturesRequired: number[];
  151240. /**
  151241. * Builds a ssao2 configuration object
  151242. * @param scene The scene
  151243. */
  151244. constructor();
  151245. /**
  151246. * Disposes the configuration
  151247. */
  151248. dispose(): void;
  151249. }
  151250. }
  151251. declare module BABYLON {
  151252. /** @hidden */
  151253. export var ssao2PixelShader: {
  151254. name: string;
  151255. shader: string;
  151256. };
  151257. }
  151258. declare module BABYLON {
  151259. /** @hidden */
  151260. export var ssaoCombinePixelShader: {
  151261. name: string;
  151262. shader: string;
  151263. };
  151264. }
  151265. declare module BABYLON {
  151266. /**
  151267. * Render pipeline to produce ssao effect
  151268. */
  151269. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151270. /**
  151271. * @ignore
  151272. * The PassPostProcess id in the pipeline that contains the original scene color
  151273. */
  151274. SSAOOriginalSceneColorEffect: string;
  151275. /**
  151276. * @ignore
  151277. * The SSAO PostProcess id in the pipeline
  151278. */
  151279. SSAORenderEffect: string;
  151280. /**
  151281. * @ignore
  151282. * The horizontal blur PostProcess id in the pipeline
  151283. */
  151284. SSAOBlurHRenderEffect: string;
  151285. /**
  151286. * @ignore
  151287. * The vertical blur PostProcess id in the pipeline
  151288. */
  151289. SSAOBlurVRenderEffect: string;
  151290. /**
  151291. * @ignore
  151292. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151293. */
  151294. SSAOCombineRenderEffect: string;
  151295. /**
  151296. * The output strength of the SSAO post-process. Default value is 1.0.
  151297. */
  151298. totalStrength: number;
  151299. /**
  151300. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151301. */
  151302. maxZ: number;
  151303. /**
  151304. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151305. */
  151306. minZAspect: number;
  151307. private _samples;
  151308. /**
  151309. * Number of samples used for the SSAO calculations. Default value is 8
  151310. */
  151311. set samples(n: number);
  151312. get samples(): number;
  151313. private _textureSamples;
  151314. /**
  151315. * Number of samples to use for antialiasing
  151316. */
  151317. set textureSamples(n: number);
  151318. get textureSamples(): number;
  151319. /**
  151320. * Force rendering the geometry through geometry buffer
  151321. */
  151322. private _forceGeometryBuffer;
  151323. /**
  151324. * Ratio object used for SSAO ratio and blur ratio
  151325. */
  151326. private _ratio;
  151327. /**
  151328. * Dynamically generated sphere sampler.
  151329. */
  151330. private _sampleSphere;
  151331. private _ssao2PrePassConfiguration;
  151332. /**
  151333. * Blur filter offsets
  151334. */
  151335. private _samplerOffsets;
  151336. private _expensiveBlur;
  151337. /**
  151338. * If bilateral blur should be used
  151339. */
  151340. set expensiveBlur(b: boolean);
  151341. get expensiveBlur(): boolean;
  151342. /**
  151343. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151344. */
  151345. radius: number;
  151346. /**
  151347. * The base color of the SSAO post-process
  151348. * The final result is "base + ssao" between [0, 1]
  151349. */
  151350. base: number;
  151351. /**
  151352. * Support test.
  151353. */
  151354. static get IsSupported(): boolean;
  151355. private _scene;
  151356. private _randomTexture;
  151357. private _originalColorPostProcess;
  151358. private _ssaoPostProcess;
  151359. private _blurHPostProcess;
  151360. private _blurVPostProcess;
  151361. private _ssaoCombinePostProcess;
  151362. private _prePassRenderer;
  151363. /**
  151364. * Gets active scene
  151365. */
  151366. get scene(): Scene;
  151367. /**
  151368. * @constructor
  151369. * @param name The rendering pipeline name
  151370. * @param scene The scene linked to this pipeline
  151371. * @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 }
  151372. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151373. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151374. */
  151375. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151376. /**
  151377. * Get the class name
  151378. * @returns "SSAO2RenderingPipeline"
  151379. */
  151380. getClassName(): string;
  151381. /**
  151382. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151383. */
  151384. dispose(disableGeometryBufferRenderer?: boolean): void;
  151385. private _createBlurPostProcess;
  151386. /** @hidden */
  151387. _rebuild(): void;
  151388. private _bits;
  151389. private _radicalInverse_VdC;
  151390. private _hammersley;
  151391. private _hemisphereSample_uniform;
  151392. private _generateHemisphere;
  151393. private _getDefinesForSSAO;
  151394. private _createSSAOPostProcess;
  151395. private _createSSAOCombinePostProcess;
  151396. private _createRandomTexture;
  151397. /**
  151398. * Serialize the rendering pipeline (Used when exporting)
  151399. * @returns the serialized object
  151400. */
  151401. serialize(): any;
  151402. /**
  151403. * Parse the serialized pipeline
  151404. * @param source Source pipeline.
  151405. * @param scene The scene to load the pipeline to.
  151406. * @param rootUrl The URL of the serialized pipeline.
  151407. * @returns An instantiated pipeline from the serialized object.
  151408. */
  151409. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151410. /**
  151411. * Sets the required values to the prepass renderer.
  151412. * @param prePassRenderer defines the prepass renderer to setup
  151413. * @returns true if the pre pass is needed.
  151414. */
  151415. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151416. }
  151417. }
  151418. declare module BABYLON {
  151419. /** @hidden */
  151420. export var ssaoPixelShader: {
  151421. name: string;
  151422. shader: string;
  151423. };
  151424. }
  151425. declare module BABYLON {
  151426. /**
  151427. * Render pipeline to produce ssao effect
  151428. */
  151429. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151430. /**
  151431. * @ignore
  151432. * The PassPostProcess id in the pipeline that contains the original scene color
  151433. */
  151434. SSAOOriginalSceneColorEffect: string;
  151435. /**
  151436. * @ignore
  151437. * The SSAO PostProcess id in the pipeline
  151438. */
  151439. SSAORenderEffect: string;
  151440. /**
  151441. * @ignore
  151442. * The horizontal blur PostProcess id in the pipeline
  151443. */
  151444. SSAOBlurHRenderEffect: string;
  151445. /**
  151446. * @ignore
  151447. * The vertical blur PostProcess id in the pipeline
  151448. */
  151449. SSAOBlurVRenderEffect: string;
  151450. /**
  151451. * @ignore
  151452. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151453. */
  151454. SSAOCombineRenderEffect: string;
  151455. /**
  151456. * The output strength of the SSAO post-process. Default value is 1.0.
  151457. */
  151458. totalStrength: number;
  151459. /**
  151460. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151461. */
  151462. radius: number;
  151463. /**
  151464. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151465. * Must not be equal to fallOff and superior to fallOff.
  151466. * Default value is 0.0075
  151467. */
  151468. area: number;
  151469. /**
  151470. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151471. * Must not be equal to area and inferior to area.
  151472. * Default value is 0.000001
  151473. */
  151474. fallOff: number;
  151475. /**
  151476. * The base color of the SSAO post-process
  151477. * The final result is "base + ssao" between [0, 1]
  151478. */
  151479. base: number;
  151480. private _scene;
  151481. private _depthTexture;
  151482. private _randomTexture;
  151483. private _originalColorPostProcess;
  151484. private _ssaoPostProcess;
  151485. private _blurHPostProcess;
  151486. private _blurVPostProcess;
  151487. private _ssaoCombinePostProcess;
  151488. private _firstUpdate;
  151489. /**
  151490. * Gets active scene
  151491. */
  151492. get scene(): Scene;
  151493. /**
  151494. * @constructor
  151495. * @param name - The rendering pipeline name
  151496. * @param scene - The scene linked to this pipeline
  151497. * @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 }
  151498. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151499. */
  151500. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151501. /**
  151502. * Get the class name
  151503. * @returns "SSAORenderingPipeline"
  151504. */
  151505. getClassName(): string;
  151506. /**
  151507. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151508. */
  151509. dispose(disableDepthRender?: boolean): void;
  151510. private _createBlurPostProcess;
  151511. /** @hidden */
  151512. _rebuild(): void;
  151513. private _createSSAOPostProcess;
  151514. private _createSSAOCombinePostProcess;
  151515. private _createRandomTexture;
  151516. }
  151517. }
  151518. declare module BABYLON {
  151519. /** @hidden */
  151520. export var screenSpaceReflectionPixelShader: {
  151521. name: string;
  151522. shader: string;
  151523. };
  151524. }
  151525. declare module BABYLON {
  151526. /**
  151527. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151528. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151529. */
  151530. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151531. /**
  151532. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151533. */
  151534. threshold: number;
  151535. /**
  151536. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151537. */
  151538. strength: number;
  151539. /**
  151540. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151541. */
  151542. reflectionSpecularFalloffExponent: number;
  151543. /**
  151544. * 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]
  151545. */
  151546. step: number;
  151547. /**
  151548. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151549. */
  151550. roughnessFactor: number;
  151551. private _geometryBufferRenderer;
  151552. private _enableSmoothReflections;
  151553. private _reflectionSamples;
  151554. private _smoothSteps;
  151555. /**
  151556. * Gets a string identifying the name of the class
  151557. * @returns "ScreenSpaceReflectionPostProcess" string
  151558. */
  151559. getClassName(): string;
  151560. /**
  151561. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151562. * @param name The name of the effect.
  151563. * @param scene The scene containing the objects to calculate reflections.
  151564. * @param options The required width/height ratio to downsize to before computing the render pass.
  151565. * @param camera The camera to apply the render pass to.
  151566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151567. * @param engine The engine which the post process will be applied. (default: current engine)
  151568. * @param reusable If the post process can be reused on the same frame. (default: false)
  151569. * @param textureType Type of textures used when performing the post process. (default: 0)
  151570. * @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)
  151571. */
  151572. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151573. /**
  151574. * Gets wether or not smoothing reflections is enabled.
  151575. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151576. */
  151577. get enableSmoothReflections(): boolean;
  151578. /**
  151579. * Sets wether or not smoothing reflections is enabled.
  151580. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151581. */
  151582. set enableSmoothReflections(enabled: boolean);
  151583. /**
  151584. * Gets the number of samples taken while computing reflections. More samples count is high,
  151585. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151586. */
  151587. get reflectionSamples(): number;
  151588. /**
  151589. * Sets the number of samples taken while computing reflections. More samples count is high,
  151590. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151591. */
  151592. set reflectionSamples(samples: number);
  151593. /**
  151594. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151595. * more the post-process will require GPU power and can generate a drop in FPS.
  151596. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151597. */
  151598. get smoothSteps(): number;
  151599. set smoothSteps(steps: number);
  151600. private _updateEffectDefines;
  151601. /** @hidden */
  151602. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151603. }
  151604. }
  151605. declare module BABYLON {
  151606. /** @hidden */
  151607. export var standardPixelShader: {
  151608. name: string;
  151609. shader: string;
  151610. };
  151611. }
  151612. declare module BABYLON {
  151613. /**
  151614. * Standard rendering pipeline
  151615. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151616. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151617. */
  151618. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151619. /**
  151620. * Public members
  151621. */
  151622. /**
  151623. * Post-process which contains the original scene color before the pipeline applies all the effects
  151624. */
  151625. originalPostProcess: Nullable<PostProcess>;
  151626. /**
  151627. * Post-process used to down scale an image x4
  151628. */
  151629. downSampleX4PostProcess: Nullable<PostProcess>;
  151630. /**
  151631. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151632. */
  151633. brightPassPostProcess: Nullable<PostProcess>;
  151634. /**
  151635. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151636. */
  151637. blurHPostProcesses: PostProcess[];
  151638. /**
  151639. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151640. */
  151641. blurVPostProcesses: PostProcess[];
  151642. /**
  151643. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151644. */
  151645. textureAdderPostProcess: Nullable<PostProcess>;
  151646. /**
  151647. * Post-process used to create volumetric lighting effect
  151648. */
  151649. volumetricLightPostProcess: Nullable<PostProcess>;
  151650. /**
  151651. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151652. */
  151653. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151654. /**
  151655. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151656. */
  151657. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151658. /**
  151659. * Post-process used to merge the volumetric light effect and the real scene color
  151660. */
  151661. volumetricLightMergePostProces: Nullable<PostProcess>;
  151662. /**
  151663. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151664. */
  151665. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151666. /**
  151667. * Base post-process used to calculate the average luminance of the final image for HDR
  151668. */
  151669. luminancePostProcess: Nullable<PostProcess>;
  151670. /**
  151671. * Post-processes used to create down sample post-processes in order to get
  151672. * the average luminance of the final image for HDR
  151673. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151674. */
  151675. luminanceDownSamplePostProcesses: PostProcess[];
  151676. /**
  151677. * Post-process used to create a HDR effect (light adaptation)
  151678. */
  151679. hdrPostProcess: Nullable<PostProcess>;
  151680. /**
  151681. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151682. */
  151683. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151684. /**
  151685. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151686. */
  151687. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151688. /**
  151689. * Post-process used to merge the final HDR post-process and the real scene color
  151690. */
  151691. hdrFinalPostProcess: Nullable<PostProcess>;
  151692. /**
  151693. * Post-process used to create a lens flare effect
  151694. */
  151695. lensFlarePostProcess: Nullable<PostProcess>;
  151696. /**
  151697. * Post-process that merges the result of the lens flare post-process and the real scene color
  151698. */
  151699. lensFlareComposePostProcess: Nullable<PostProcess>;
  151700. /**
  151701. * Post-process used to create a motion blur effect
  151702. */
  151703. motionBlurPostProcess: Nullable<PostProcess>;
  151704. /**
  151705. * Post-process used to create a depth of field effect
  151706. */
  151707. depthOfFieldPostProcess: Nullable<PostProcess>;
  151708. /**
  151709. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151710. */
  151711. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151712. /**
  151713. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151714. */
  151715. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151716. /**
  151717. * Represents the brightness threshold in order to configure the illuminated surfaces
  151718. */
  151719. brightThreshold: number;
  151720. /**
  151721. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151722. */
  151723. blurWidth: number;
  151724. /**
  151725. * Sets if the blur for highlighted surfaces must be only horizontal
  151726. */
  151727. horizontalBlur: boolean;
  151728. /**
  151729. * Gets the overall exposure used by the pipeline
  151730. */
  151731. get exposure(): number;
  151732. /**
  151733. * Sets the overall exposure used by the pipeline
  151734. */
  151735. set exposure(value: number);
  151736. /**
  151737. * Texture used typically to simulate "dirty" on camera lens
  151738. */
  151739. lensTexture: Nullable<Texture>;
  151740. /**
  151741. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151742. */
  151743. volumetricLightCoefficient: number;
  151744. /**
  151745. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151746. */
  151747. volumetricLightPower: number;
  151748. /**
  151749. * Used the set the blur intensity to smooth the volumetric lights
  151750. */
  151751. volumetricLightBlurScale: number;
  151752. /**
  151753. * Light (spot or directional) used to generate the volumetric lights rays
  151754. * The source light must have a shadow generate so the pipeline can get its
  151755. * depth map
  151756. */
  151757. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151758. /**
  151759. * For eye adaptation, represents the minimum luminance the eye can see
  151760. */
  151761. hdrMinimumLuminance: number;
  151762. /**
  151763. * For eye adaptation, represents the decrease luminance speed
  151764. */
  151765. hdrDecreaseRate: number;
  151766. /**
  151767. * For eye adaptation, represents the increase luminance speed
  151768. */
  151769. hdrIncreaseRate: number;
  151770. /**
  151771. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151772. */
  151773. get hdrAutoExposure(): boolean;
  151774. /**
  151775. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151776. */
  151777. set hdrAutoExposure(value: boolean);
  151778. /**
  151779. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151780. */
  151781. lensColorTexture: Nullable<Texture>;
  151782. /**
  151783. * The overall strengh for the lens flare effect
  151784. */
  151785. lensFlareStrength: number;
  151786. /**
  151787. * Dispersion coefficient for lens flare ghosts
  151788. */
  151789. lensFlareGhostDispersal: number;
  151790. /**
  151791. * Main lens flare halo width
  151792. */
  151793. lensFlareHaloWidth: number;
  151794. /**
  151795. * Based on the lens distortion effect, defines how much the lens flare result
  151796. * is distorted
  151797. */
  151798. lensFlareDistortionStrength: number;
  151799. /**
  151800. * Configures the blur intensity used for for lens flare (halo)
  151801. */
  151802. lensFlareBlurWidth: number;
  151803. /**
  151804. * Lens star texture must be used to simulate rays on the flares and is available
  151805. * in the documentation
  151806. */
  151807. lensStarTexture: Nullable<Texture>;
  151808. /**
  151809. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151810. * flare effect by taking account of the dirt texture
  151811. */
  151812. lensFlareDirtTexture: Nullable<Texture>;
  151813. /**
  151814. * Represents the focal length for the depth of field effect
  151815. */
  151816. depthOfFieldDistance: number;
  151817. /**
  151818. * Represents the blur intensity for the blurred part of the depth of field effect
  151819. */
  151820. depthOfFieldBlurWidth: number;
  151821. /**
  151822. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151823. */
  151824. get motionStrength(): number;
  151825. /**
  151826. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151827. */
  151828. set motionStrength(strength: number);
  151829. /**
  151830. * Gets wether or not the motion blur post-process is object based or screen based.
  151831. */
  151832. get objectBasedMotionBlur(): boolean;
  151833. /**
  151834. * Sets wether or not the motion blur post-process should be object based or screen based
  151835. */
  151836. set objectBasedMotionBlur(value: boolean);
  151837. /**
  151838. * List of animations for the pipeline (IAnimatable implementation)
  151839. */
  151840. animations: Animation[];
  151841. /**
  151842. * Private members
  151843. */
  151844. private _scene;
  151845. private _currentDepthOfFieldSource;
  151846. private _basePostProcess;
  151847. private _fixedExposure;
  151848. private _currentExposure;
  151849. private _hdrAutoExposure;
  151850. private _hdrCurrentLuminance;
  151851. private _motionStrength;
  151852. private _isObjectBasedMotionBlur;
  151853. private _floatTextureType;
  151854. private _camerasToBeAttached;
  151855. private _ratio;
  151856. private _bloomEnabled;
  151857. private _depthOfFieldEnabled;
  151858. private _vlsEnabled;
  151859. private _lensFlareEnabled;
  151860. private _hdrEnabled;
  151861. private _motionBlurEnabled;
  151862. private _fxaaEnabled;
  151863. private _screenSpaceReflectionsEnabled;
  151864. private _motionBlurSamples;
  151865. private _volumetricLightStepsCount;
  151866. private _samples;
  151867. /**
  151868. * @ignore
  151869. * Specifies if the bloom pipeline is enabled
  151870. */
  151871. get BloomEnabled(): boolean;
  151872. set BloomEnabled(enabled: boolean);
  151873. /**
  151874. * @ignore
  151875. * Specifies if the depth of field pipeline is enabed
  151876. */
  151877. get DepthOfFieldEnabled(): boolean;
  151878. set DepthOfFieldEnabled(enabled: boolean);
  151879. /**
  151880. * @ignore
  151881. * Specifies if the lens flare pipeline is enabed
  151882. */
  151883. get LensFlareEnabled(): boolean;
  151884. set LensFlareEnabled(enabled: boolean);
  151885. /**
  151886. * @ignore
  151887. * Specifies if the HDR pipeline is enabled
  151888. */
  151889. get HDREnabled(): boolean;
  151890. set HDREnabled(enabled: boolean);
  151891. /**
  151892. * @ignore
  151893. * Specifies if the volumetric lights scattering effect is enabled
  151894. */
  151895. get VLSEnabled(): boolean;
  151896. set VLSEnabled(enabled: boolean);
  151897. /**
  151898. * @ignore
  151899. * Specifies if the motion blur effect is enabled
  151900. */
  151901. get MotionBlurEnabled(): boolean;
  151902. set MotionBlurEnabled(enabled: boolean);
  151903. /**
  151904. * Specifies if anti-aliasing is enabled
  151905. */
  151906. get fxaaEnabled(): boolean;
  151907. set fxaaEnabled(enabled: boolean);
  151908. /**
  151909. * Specifies if screen space reflections are enabled.
  151910. */
  151911. get screenSpaceReflectionsEnabled(): boolean;
  151912. set screenSpaceReflectionsEnabled(enabled: boolean);
  151913. /**
  151914. * Specifies the number of steps used to calculate the volumetric lights
  151915. * Typically in interval [50, 200]
  151916. */
  151917. get volumetricLightStepsCount(): number;
  151918. set volumetricLightStepsCount(count: number);
  151919. /**
  151920. * Specifies the number of samples used for the motion blur effect
  151921. * Typically in interval [16, 64]
  151922. */
  151923. get motionBlurSamples(): number;
  151924. set motionBlurSamples(samples: number);
  151925. /**
  151926. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151927. */
  151928. get samples(): number;
  151929. set samples(sampleCount: number);
  151930. /**
  151931. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151932. * @constructor
  151933. * @param name The rendering pipeline name
  151934. * @param scene The scene linked to this pipeline
  151935. * @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)
  151936. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151937. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151938. */
  151939. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151940. private _buildPipeline;
  151941. private _createDownSampleX4PostProcess;
  151942. private _createBrightPassPostProcess;
  151943. private _createBlurPostProcesses;
  151944. private _createTextureAdderPostProcess;
  151945. private _createVolumetricLightPostProcess;
  151946. private _createLuminancePostProcesses;
  151947. private _createHdrPostProcess;
  151948. private _createLensFlarePostProcess;
  151949. private _createDepthOfFieldPostProcess;
  151950. private _createMotionBlurPostProcess;
  151951. private _getDepthTexture;
  151952. private _disposePostProcesses;
  151953. /**
  151954. * Dispose of the pipeline and stop all post processes
  151955. */
  151956. dispose(): void;
  151957. /**
  151958. * Serialize the rendering pipeline (Used when exporting)
  151959. * @returns the serialized object
  151960. */
  151961. serialize(): any;
  151962. /**
  151963. * Parse the serialized pipeline
  151964. * @param source Source pipeline.
  151965. * @param scene The scene to load the pipeline to.
  151966. * @param rootUrl The URL of the serialized pipeline.
  151967. * @returns An instantiated pipeline from the serialized object.
  151968. */
  151969. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151970. /**
  151971. * Luminance steps
  151972. */
  151973. static LuminanceSteps: number;
  151974. }
  151975. }
  151976. declare module BABYLON {
  151977. /** @hidden */
  151978. export var stereoscopicInterlacePixelShader: {
  151979. name: string;
  151980. shader: string;
  151981. };
  151982. }
  151983. declare module BABYLON {
  151984. /**
  151985. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151986. */
  151987. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151988. private _stepSize;
  151989. private _passedProcess;
  151990. /**
  151991. * Gets a string identifying the name of the class
  151992. * @returns "StereoscopicInterlacePostProcessI" string
  151993. */
  151994. getClassName(): string;
  151995. /**
  151996. * Initializes a StereoscopicInterlacePostProcessI
  151997. * @param name The name of the effect.
  151998. * @param rigCameras The rig cameras to be appled to the post process
  151999. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152000. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152002. * @param engine The engine which the post process will be applied. (default: current engine)
  152003. * @param reusable If the post process can be reused on the same frame. (default: false)
  152004. */
  152005. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152006. }
  152007. /**
  152008. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152009. */
  152010. export class StereoscopicInterlacePostProcess extends PostProcess {
  152011. private _stepSize;
  152012. private _passedProcess;
  152013. /**
  152014. * Gets a string identifying the name of the class
  152015. * @returns "StereoscopicInterlacePostProcess" string
  152016. */
  152017. getClassName(): string;
  152018. /**
  152019. * Initializes a StereoscopicInterlacePostProcess
  152020. * @param name The name of the effect.
  152021. * @param rigCameras The rig cameras to be appled to the post process
  152022. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152024. * @param engine The engine which the post process will be applied. (default: current engine)
  152025. * @param reusable If the post process can be reused on the same frame. (default: false)
  152026. */
  152027. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152028. }
  152029. }
  152030. declare module BABYLON {
  152031. /** @hidden */
  152032. export var tonemapPixelShader: {
  152033. name: string;
  152034. shader: string;
  152035. };
  152036. }
  152037. declare module BABYLON {
  152038. /** Defines operator used for tonemapping */
  152039. export enum TonemappingOperator {
  152040. /** Hable */
  152041. Hable = 0,
  152042. /** Reinhard */
  152043. Reinhard = 1,
  152044. /** HejiDawson */
  152045. HejiDawson = 2,
  152046. /** Photographic */
  152047. Photographic = 3
  152048. }
  152049. /**
  152050. * Defines a post process to apply tone mapping
  152051. */
  152052. export class TonemapPostProcess extends PostProcess {
  152053. private _operator;
  152054. /** Defines the required exposure adjustement */
  152055. exposureAdjustment: number;
  152056. /**
  152057. * Gets a string identifying the name of the class
  152058. * @returns "TonemapPostProcess" string
  152059. */
  152060. getClassName(): string;
  152061. /**
  152062. * Creates a new TonemapPostProcess
  152063. * @param name defines the name of the postprocess
  152064. * @param _operator defines the operator to use
  152065. * @param exposureAdjustment defines the required exposure adjustement
  152066. * @param camera defines the camera to use (can be null)
  152067. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152068. * @param engine defines the hosting engine (can be ignore if camera is set)
  152069. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152070. */
  152071. constructor(name: string, _operator: TonemappingOperator,
  152072. /** Defines the required exposure adjustement */
  152073. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152074. }
  152075. }
  152076. declare module BABYLON {
  152077. /** @hidden */
  152078. export var volumetricLightScatteringPixelShader: {
  152079. name: string;
  152080. shader: string;
  152081. };
  152082. }
  152083. declare module BABYLON {
  152084. /** @hidden */
  152085. export var volumetricLightScatteringPassVertexShader: {
  152086. name: string;
  152087. shader: string;
  152088. };
  152089. }
  152090. declare module BABYLON {
  152091. /** @hidden */
  152092. export var volumetricLightScatteringPassPixelShader: {
  152093. name: string;
  152094. shader: string;
  152095. };
  152096. }
  152097. declare module BABYLON {
  152098. /**
  152099. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152100. */
  152101. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152102. private _volumetricLightScatteringPass;
  152103. private _volumetricLightScatteringRTT;
  152104. private _viewPort;
  152105. private _screenCoordinates;
  152106. private _cachedDefines;
  152107. /**
  152108. * If not undefined, the mesh position is computed from the attached node position
  152109. */
  152110. attachedNode: {
  152111. position: Vector3;
  152112. };
  152113. /**
  152114. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152115. */
  152116. customMeshPosition: Vector3;
  152117. /**
  152118. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152119. */
  152120. useCustomMeshPosition: boolean;
  152121. /**
  152122. * If the post-process should inverse the light scattering direction
  152123. */
  152124. invert: boolean;
  152125. /**
  152126. * The internal mesh used by the post-process
  152127. */
  152128. mesh: Mesh;
  152129. /**
  152130. * @hidden
  152131. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152132. */
  152133. get useDiffuseColor(): boolean;
  152134. set useDiffuseColor(useDiffuseColor: boolean);
  152135. /**
  152136. * Array containing the excluded meshes not rendered in the internal pass
  152137. */
  152138. excludedMeshes: AbstractMesh[];
  152139. /**
  152140. * Controls the overall intensity of the post-process
  152141. */
  152142. exposure: number;
  152143. /**
  152144. * Dissipates each sample's contribution in range [0, 1]
  152145. */
  152146. decay: number;
  152147. /**
  152148. * Controls the overall intensity of each sample
  152149. */
  152150. weight: number;
  152151. /**
  152152. * Controls the density of each sample
  152153. */
  152154. density: number;
  152155. /**
  152156. * @constructor
  152157. * @param name The post-process name
  152158. * @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)
  152159. * @param camera The camera that the post-process will be attached to
  152160. * @param mesh The mesh used to create the light scattering
  152161. * @param samples The post-process quality, default 100
  152162. * @param samplingModeThe post-process filtering mode
  152163. * @param engine The babylon engine
  152164. * @param reusable If the post-process is reusable
  152165. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152166. */
  152167. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152168. /**
  152169. * Returns the string "VolumetricLightScatteringPostProcess"
  152170. * @returns "VolumetricLightScatteringPostProcess"
  152171. */
  152172. getClassName(): string;
  152173. private _isReady;
  152174. /**
  152175. * Sets the new light position for light scattering effect
  152176. * @param position The new custom light position
  152177. */
  152178. setCustomMeshPosition(position: Vector3): void;
  152179. /**
  152180. * Returns the light position for light scattering effect
  152181. * @return Vector3 The custom light position
  152182. */
  152183. getCustomMeshPosition(): Vector3;
  152184. /**
  152185. * Disposes the internal assets and detaches the post-process from the camera
  152186. */
  152187. dispose(camera: Camera): void;
  152188. /**
  152189. * Returns the render target texture used by the post-process
  152190. * @return the render target texture used by the post-process
  152191. */
  152192. getPass(): RenderTargetTexture;
  152193. private _meshExcluded;
  152194. private _createPass;
  152195. private _updateMeshScreenCoordinates;
  152196. /**
  152197. * Creates a default mesh for the Volumeric Light Scattering post-process
  152198. * @param name The mesh name
  152199. * @param scene The scene where to create the mesh
  152200. * @return the default mesh
  152201. */
  152202. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152203. }
  152204. }
  152205. declare module BABYLON {
  152206. /** @hidden */
  152207. export var screenSpaceCurvaturePixelShader: {
  152208. name: string;
  152209. shader: string;
  152210. };
  152211. }
  152212. declare module BABYLON {
  152213. /**
  152214. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152215. */
  152216. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152217. /**
  152218. * Defines how much ridge the curvature effect displays.
  152219. */
  152220. ridge: number;
  152221. /**
  152222. * Defines how much valley the curvature effect displays.
  152223. */
  152224. valley: number;
  152225. private _geometryBufferRenderer;
  152226. /**
  152227. * Gets a string identifying the name of the class
  152228. * @returns "ScreenSpaceCurvaturePostProcess" string
  152229. */
  152230. getClassName(): string;
  152231. /**
  152232. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152233. * @param name The name of the effect.
  152234. * @param scene The scene containing the objects to blur according to their velocity.
  152235. * @param options The required width/height ratio to downsize to before computing the render pass.
  152236. * @param camera The camera to apply the render pass to.
  152237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152238. * @param engine The engine which the post process will be applied. (default: current engine)
  152239. * @param reusable If the post process can be reused on the same frame. (default: false)
  152240. * @param textureType Type of textures used when performing the post process. (default: 0)
  152241. * @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)
  152242. */
  152243. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152244. /**
  152245. * Support test.
  152246. */
  152247. static get IsSupported(): boolean;
  152248. /** @hidden */
  152249. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152250. }
  152251. }
  152252. declare module BABYLON {
  152253. interface Scene {
  152254. /** @hidden (Backing field) */
  152255. _boundingBoxRenderer: BoundingBoxRenderer;
  152256. /** @hidden (Backing field) */
  152257. _forceShowBoundingBoxes: boolean;
  152258. /**
  152259. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152260. */
  152261. forceShowBoundingBoxes: boolean;
  152262. /**
  152263. * Gets the bounding box renderer associated with the scene
  152264. * @returns a BoundingBoxRenderer
  152265. */
  152266. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152267. }
  152268. interface AbstractMesh {
  152269. /** @hidden (Backing field) */
  152270. _showBoundingBox: boolean;
  152271. /**
  152272. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152273. */
  152274. showBoundingBox: boolean;
  152275. }
  152276. /**
  152277. * Component responsible of rendering the bounding box of the meshes in a scene.
  152278. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152279. */
  152280. export class BoundingBoxRenderer implements ISceneComponent {
  152281. /**
  152282. * The component name helpfull to identify the component in the list of scene components.
  152283. */
  152284. readonly name: string;
  152285. /**
  152286. * The scene the component belongs to.
  152287. */
  152288. scene: Scene;
  152289. /**
  152290. * Color of the bounding box lines placed in front of an object
  152291. */
  152292. frontColor: Color3;
  152293. /**
  152294. * Color of the bounding box lines placed behind an object
  152295. */
  152296. backColor: Color3;
  152297. /**
  152298. * Defines if the renderer should show the back lines or not
  152299. */
  152300. showBackLines: boolean;
  152301. /**
  152302. * Observable raised before rendering a bounding box
  152303. */
  152304. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152305. /**
  152306. * Observable raised after rendering a bounding box
  152307. */
  152308. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152309. /**
  152310. * @hidden
  152311. */
  152312. renderList: SmartArray<BoundingBox>;
  152313. private _colorShader;
  152314. private _vertexBuffers;
  152315. private _indexBuffer;
  152316. private _fillIndexBuffer;
  152317. private _fillIndexData;
  152318. /**
  152319. * Instantiates a new bounding box renderer in a scene.
  152320. * @param scene the scene the renderer renders in
  152321. */
  152322. constructor(scene: Scene);
  152323. /**
  152324. * Registers the component in a given scene
  152325. */
  152326. register(): void;
  152327. private _evaluateSubMesh;
  152328. private _activeMesh;
  152329. private _prepareRessources;
  152330. private _createIndexBuffer;
  152331. /**
  152332. * Rebuilds the elements related to this component in case of
  152333. * context lost for instance.
  152334. */
  152335. rebuild(): void;
  152336. /**
  152337. * @hidden
  152338. */
  152339. reset(): void;
  152340. /**
  152341. * Render the bounding boxes of a specific rendering group
  152342. * @param renderingGroupId defines the rendering group to render
  152343. */
  152344. render(renderingGroupId: number): void;
  152345. /**
  152346. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152347. * @param mesh Define the mesh to render the occlusion bounding box for
  152348. */
  152349. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152350. /**
  152351. * Dispose and release the resources attached to this renderer.
  152352. */
  152353. dispose(): void;
  152354. }
  152355. }
  152356. declare module BABYLON {
  152357. interface Scene {
  152358. /** @hidden (Backing field) */
  152359. _depthRenderer: {
  152360. [id: string]: DepthRenderer;
  152361. };
  152362. /**
  152363. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152364. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152365. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152366. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152367. * @returns the created depth renderer
  152368. */
  152369. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152370. /**
  152371. * Disables a depth renderer for a given camera
  152372. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152373. */
  152374. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152375. }
  152376. /**
  152377. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152378. * in several rendering techniques.
  152379. */
  152380. export class DepthRendererSceneComponent implements ISceneComponent {
  152381. /**
  152382. * The component name helpfull to identify the component in the list of scene components.
  152383. */
  152384. readonly name: string;
  152385. /**
  152386. * The scene the component belongs to.
  152387. */
  152388. scene: Scene;
  152389. /**
  152390. * Creates a new instance of the component for the given scene
  152391. * @param scene Defines the scene to register the component in
  152392. */
  152393. constructor(scene: Scene);
  152394. /**
  152395. * Registers the component in a given scene
  152396. */
  152397. register(): void;
  152398. /**
  152399. * Rebuilds the elements related to this component in case of
  152400. * context lost for instance.
  152401. */
  152402. rebuild(): void;
  152403. /**
  152404. * Disposes the component and the associated ressources
  152405. */
  152406. dispose(): void;
  152407. private _gatherRenderTargets;
  152408. private _gatherActiveCameraRenderTargets;
  152409. }
  152410. }
  152411. declare module BABYLON {
  152412. interface AbstractScene {
  152413. /** @hidden (Backing field) */
  152414. _prePassRenderer: Nullable<PrePassRenderer>;
  152415. /**
  152416. * Gets or Sets the current prepass renderer associated to the scene.
  152417. */
  152418. prePassRenderer: Nullable<PrePassRenderer>;
  152419. /**
  152420. * Enables the prepass and associates it with the scene
  152421. * @returns the PrePassRenderer
  152422. */
  152423. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152424. /**
  152425. * Disables the prepass associated with the scene
  152426. */
  152427. disablePrePassRenderer(): void;
  152428. }
  152429. /**
  152430. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152431. * in several rendering techniques.
  152432. */
  152433. export class PrePassRendererSceneComponent implements ISceneComponent {
  152434. /**
  152435. * The component name helpful to identify the component in the list of scene components.
  152436. */
  152437. readonly name: string;
  152438. /**
  152439. * The scene the component belongs to.
  152440. */
  152441. scene: Scene;
  152442. /**
  152443. * Creates a new instance of the component for the given scene
  152444. * @param scene Defines the scene to register the component in
  152445. */
  152446. constructor(scene: Scene);
  152447. /**
  152448. * Registers the component in a given scene
  152449. */
  152450. register(): void;
  152451. private _beforeCameraDraw;
  152452. private _afterCameraDraw;
  152453. private _beforeClearStage;
  152454. /**
  152455. * Rebuilds the elements related to this component in case of
  152456. * context lost for instance.
  152457. */
  152458. rebuild(): void;
  152459. /**
  152460. * Disposes the component and the associated ressources
  152461. */
  152462. dispose(): void;
  152463. }
  152464. }
  152465. declare module BABYLON {
  152466. /** @hidden */
  152467. export var fibonacci: {
  152468. name: string;
  152469. shader: string;
  152470. };
  152471. }
  152472. declare module BABYLON {
  152473. /** @hidden */
  152474. export var diffusionProfile: {
  152475. name: string;
  152476. shader: string;
  152477. };
  152478. }
  152479. declare module BABYLON {
  152480. /** @hidden */
  152481. export var subSurfaceScatteringPixelShader: {
  152482. name: string;
  152483. shader: string;
  152484. };
  152485. }
  152486. declare module BABYLON {
  152487. /**
  152488. * Sub surface scattering post process
  152489. */
  152490. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152491. /**
  152492. * Gets a string identifying the name of the class
  152493. * @returns "SubSurfaceScatteringPostProcess" string
  152494. */
  152495. getClassName(): string;
  152496. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152497. }
  152498. }
  152499. declare module BABYLON {
  152500. /**
  152501. * Contains all parameters needed for the prepass to perform
  152502. * screen space subsurface scattering
  152503. */
  152504. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152505. /** @hidden */
  152506. static _SceneComponentInitialization: (scene: Scene) => void;
  152507. private _ssDiffusionS;
  152508. private _ssFilterRadii;
  152509. private _ssDiffusionD;
  152510. /**
  152511. * Post process to attach for screen space subsurface scattering
  152512. */
  152513. postProcess: SubSurfaceScatteringPostProcess;
  152514. /**
  152515. * Diffusion profile color for subsurface scattering
  152516. */
  152517. get ssDiffusionS(): number[];
  152518. /**
  152519. * Diffusion profile max color channel value for subsurface scattering
  152520. */
  152521. get ssDiffusionD(): number[];
  152522. /**
  152523. * Diffusion profile filter radius for subsurface scattering
  152524. */
  152525. get ssFilterRadii(): number[];
  152526. /**
  152527. * Is subsurface enabled
  152528. */
  152529. enabled: boolean;
  152530. /**
  152531. * Name of the configuration
  152532. */
  152533. name: string;
  152534. /**
  152535. * Diffusion profile colors for subsurface scattering
  152536. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152537. * See ...
  152538. * Note that you can only store up to 5 of them
  152539. */
  152540. ssDiffusionProfileColors: Color3[];
  152541. /**
  152542. * Defines the ratio real world => scene units.
  152543. * Used for subsurface scattering
  152544. */
  152545. metersPerUnit: number;
  152546. /**
  152547. * Textures that should be present in the MRT for this effect to work
  152548. */
  152549. readonly texturesRequired: number[];
  152550. private _scene;
  152551. /**
  152552. * Builds a subsurface configuration object
  152553. * @param scene The scene
  152554. */
  152555. constructor(scene: Scene);
  152556. /**
  152557. * Adds a new diffusion profile.
  152558. * Useful for more realistic subsurface scattering on diverse materials.
  152559. * @param color The color of the diffusion profile. Should be the average color of the material.
  152560. * @return The index of the diffusion profile for the material subsurface configuration
  152561. */
  152562. addDiffusionProfile(color: Color3): number;
  152563. /**
  152564. * Creates the sss post process
  152565. * @return The created post process
  152566. */
  152567. createPostProcess(): SubSurfaceScatteringPostProcess;
  152568. /**
  152569. * Deletes all diffusion profiles.
  152570. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152571. */
  152572. clearAllDiffusionProfiles(): void;
  152573. /**
  152574. * Disposes this object
  152575. */
  152576. dispose(): void;
  152577. /**
  152578. * @hidden
  152579. * https://zero-radiance.github.io/post/sampling-diffusion/
  152580. *
  152581. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152582. * ------------------------------------------------------------------------------------
  152583. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152584. * PDF[r, phi, s] = r * R[r, phi, s]
  152585. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152586. * ------------------------------------------------------------------------------------
  152587. * We importance sample the color channel with the widest scattering distance.
  152588. */
  152589. getDiffusionProfileParameters(color: Color3): number;
  152590. /**
  152591. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152592. * 'u' is the random number (the value of the CDF): [0, 1).
  152593. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152594. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152595. */
  152596. private _sampleBurleyDiffusionProfile;
  152597. }
  152598. }
  152599. declare module BABYLON {
  152600. interface AbstractScene {
  152601. /** @hidden (Backing field) */
  152602. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152603. /**
  152604. * Gets or Sets the current prepass renderer associated to the scene.
  152605. */
  152606. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152607. /**
  152608. * Enables the subsurface effect for prepass
  152609. * @returns the SubSurfaceConfiguration
  152610. */
  152611. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152612. /**
  152613. * Disables the subsurface effect for prepass
  152614. */
  152615. disableSubSurfaceForPrePass(): void;
  152616. }
  152617. /**
  152618. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152619. * in several rendering techniques.
  152620. */
  152621. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  152622. /**
  152623. * The component name helpful to identify the component in the list of scene components.
  152624. */
  152625. readonly name: string;
  152626. /**
  152627. * The scene the component belongs to.
  152628. */
  152629. scene: Scene;
  152630. /**
  152631. * Creates a new instance of the component for the given scene
  152632. * @param scene Defines the scene to register the component in
  152633. */
  152634. constructor(scene: Scene);
  152635. /**
  152636. * Registers the component in a given scene
  152637. */
  152638. register(): void;
  152639. /**
  152640. * Serializes the component data to the specified json object
  152641. * @param serializationObject The object to serialize to
  152642. */
  152643. serialize(serializationObject: any): void;
  152644. /**
  152645. * Adds all the elements from the container to the scene
  152646. * @param container the container holding the elements
  152647. */
  152648. addFromContainer(container: AbstractScene): void;
  152649. /**
  152650. * Removes all the elements in the container from the scene
  152651. * @param container contains the elements to remove
  152652. * @param dispose if the removed element should be disposed (default: false)
  152653. */
  152654. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152655. /**
  152656. * Rebuilds the elements related to this component in case of
  152657. * context lost for instance.
  152658. */
  152659. rebuild(): void;
  152660. /**
  152661. * Disposes the component and the associated ressources
  152662. */
  152663. dispose(): void;
  152664. }
  152665. }
  152666. declare module BABYLON {
  152667. /** @hidden */
  152668. export var outlinePixelShader: {
  152669. name: string;
  152670. shader: string;
  152671. };
  152672. }
  152673. declare module BABYLON {
  152674. /** @hidden */
  152675. export var outlineVertexShader: {
  152676. name: string;
  152677. shader: string;
  152678. };
  152679. }
  152680. declare module BABYLON {
  152681. interface Scene {
  152682. /** @hidden */
  152683. _outlineRenderer: OutlineRenderer;
  152684. /**
  152685. * Gets the outline renderer associated with the scene
  152686. * @returns a OutlineRenderer
  152687. */
  152688. getOutlineRenderer(): OutlineRenderer;
  152689. }
  152690. interface AbstractMesh {
  152691. /** @hidden (Backing field) */
  152692. _renderOutline: boolean;
  152693. /**
  152694. * Gets or sets a boolean indicating if the outline must be rendered as well
  152695. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152696. */
  152697. renderOutline: boolean;
  152698. /** @hidden (Backing field) */
  152699. _renderOverlay: boolean;
  152700. /**
  152701. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152702. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152703. */
  152704. renderOverlay: boolean;
  152705. }
  152706. /**
  152707. * This class is responsible to draw bothe outline/overlay of meshes.
  152708. * It should not be used directly but through the available method on mesh.
  152709. */
  152710. export class OutlineRenderer implements ISceneComponent {
  152711. /**
  152712. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152713. */
  152714. private static _StencilReference;
  152715. /**
  152716. * The name of the component. Each component must have a unique name.
  152717. */
  152718. name: string;
  152719. /**
  152720. * The scene the component belongs to.
  152721. */
  152722. scene: Scene;
  152723. /**
  152724. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152725. */
  152726. zOffset: number;
  152727. private _engine;
  152728. private _effect;
  152729. private _cachedDefines;
  152730. private _savedDepthWrite;
  152731. /**
  152732. * Instantiates a new outline renderer. (There could be only one per scene).
  152733. * @param scene Defines the scene it belongs to
  152734. */
  152735. constructor(scene: Scene);
  152736. /**
  152737. * Register the component to one instance of a scene.
  152738. */
  152739. register(): void;
  152740. /**
  152741. * Rebuilds the elements related to this component in case of
  152742. * context lost for instance.
  152743. */
  152744. rebuild(): void;
  152745. /**
  152746. * Disposes the component and the associated ressources.
  152747. */
  152748. dispose(): void;
  152749. /**
  152750. * Renders the outline in the canvas.
  152751. * @param subMesh Defines the sumesh to render
  152752. * @param batch Defines the batch of meshes in case of instances
  152753. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152754. */
  152755. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152756. /**
  152757. * Returns whether or not the outline renderer is ready for a given submesh.
  152758. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152759. * @param subMesh Defines the submesh to check readyness for
  152760. * @param useInstances Defines wheter wee are trying to render instances or not
  152761. * @returns true if ready otherwise false
  152762. */
  152763. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152764. private _beforeRenderingMesh;
  152765. private _afterRenderingMesh;
  152766. }
  152767. }
  152768. declare module BABYLON {
  152769. /**
  152770. * Defines the basic options interface of a Sprite Frame Source Size.
  152771. */
  152772. export interface ISpriteJSONSpriteSourceSize {
  152773. /**
  152774. * number of the original width of the Frame
  152775. */
  152776. w: number;
  152777. /**
  152778. * number of the original height of the Frame
  152779. */
  152780. h: number;
  152781. }
  152782. /**
  152783. * Defines the basic options interface of a Sprite Frame Data.
  152784. */
  152785. export interface ISpriteJSONSpriteFrameData {
  152786. /**
  152787. * number of the x offset of the Frame
  152788. */
  152789. x: number;
  152790. /**
  152791. * number of the y offset of the Frame
  152792. */
  152793. y: number;
  152794. /**
  152795. * number of the width of the Frame
  152796. */
  152797. w: number;
  152798. /**
  152799. * number of the height of the Frame
  152800. */
  152801. h: number;
  152802. }
  152803. /**
  152804. * Defines the basic options interface of a JSON Sprite.
  152805. */
  152806. export interface ISpriteJSONSprite {
  152807. /**
  152808. * string name of the Frame
  152809. */
  152810. filename: string;
  152811. /**
  152812. * ISpriteJSONSpriteFrame basic object of the frame data
  152813. */
  152814. frame: ISpriteJSONSpriteFrameData;
  152815. /**
  152816. * boolean to flag is the frame was rotated.
  152817. */
  152818. rotated: boolean;
  152819. /**
  152820. * boolean to flag is the frame was trimmed.
  152821. */
  152822. trimmed: boolean;
  152823. /**
  152824. * ISpriteJSONSpriteFrame basic object of the source data
  152825. */
  152826. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152827. /**
  152828. * ISpriteJSONSpriteFrame basic object of the source data
  152829. */
  152830. sourceSize: ISpriteJSONSpriteSourceSize;
  152831. }
  152832. /**
  152833. * Defines the basic options interface of a JSON atlas.
  152834. */
  152835. export interface ISpriteJSONAtlas {
  152836. /**
  152837. * Array of objects that contain the frame data.
  152838. */
  152839. frames: Array<ISpriteJSONSprite>;
  152840. /**
  152841. * object basic object containing the sprite meta data.
  152842. */
  152843. meta?: object;
  152844. }
  152845. }
  152846. declare module BABYLON {
  152847. /** @hidden */
  152848. export var spriteMapPixelShader: {
  152849. name: string;
  152850. shader: string;
  152851. };
  152852. }
  152853. declare module BABYLON {
  152854. /** @hidden */
  152855. export var spriteMapVertexShader: {
  152856. name: string;
  152857. shader: string;
  152858. };
  152859. }
  152860. declare module BABYLON {
  152861. /**
  152862. * Defines the basic options interface of a SpriteMap
  152863. */
  152864. export interface ISpriteMapOptions {
  152865. /**
  152866. * Vector2 of the number of cells in the grid.
  152867. */
  152868. stageSize?: Vector2;
  152869. /**
  152870. * Vector2 of the size of the output plane in World Units.
  152871. */
  152872. outputSize?: Vector2;
  152873. /**
  152874. * Vector3 of the position of the output plane in World Units.
  152875. */
  152876. outputPosition?: Vector3;
  152877. /**
  152878. * Vector3 of the rotation of the output plane.
  152879. */
  152880. outputRotation?: Vector3;
  152881. /**
  152882. * number of layers that the system will reserve in resources.
  152883. */
  152884. layerCount?: number;
  152885. /**
  152886. * number of max animation frames a single cell will reserve in resources.
  152887. */
  152888. maxAnimationFrames?: number;
  152889. /**
  152890. * number cell index of the base tile when the system compiles.
  152891. */
  152892. baseTile?: number;
  152893. /**
  152894. * boolean flip the sprite after its been repositioned by the framing data.
  152895. */
  152896. flipU?: boolean;
  152897. /**
  152898. * Vector3 scalar of the global RGB values of the SpriteMap.
  152899. */
  152900. colorMultiply?: Vector3;
  152901. }
  152902. /**
  152903. * Defines the IDisposable interface in order to be cleanable from resources.
  152904. */
  152905. export interface ISpriteMap extends IDisposable {
  152906. /**
  152907. * String name of the SpriteMap.
  152908. */
  152909. name: string;
  152910. /**
  152911. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152912. */
  152913. atlasJSON: ISpriteJSONAtlas;
  152914. /**
  152915. * Texture of the SpriteMap.
  152916. */
  152917. spriteSheet: Texture;
  152918. /**
  152919. * The parameters to initialize the SpriteMap with.
  152920. */
  152921. options: ISpriteMapOptions;
  152922. }
  152923. /**
  152924. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152925. */
  152926. export class SpriteMap implements ISpriteMap {
  152927. /** The Name of the spriteMap */
  152928. name: string;
  152929. /** The JSON file with the frame and meta data */
  152930. atlasJSON: ISpriteJSONAtlas;
  152931. /** The systems Sprite Sheet Texture */
  152932. spriteSheet: Texture;
  152933. /** Arguments passed with the Constructor */
  152934. options: ISpriteMapOptions;
  152935. /** Public Sprite Storage array, parsed from atlasJSON */
  152936. sprites: Array<ISpriteJSONSprite>;
  152937. /** Returns the Number of Sprites in the System */
  152938. get spriteCount(): number;
  152939. /** Returns the Position of Output Plane*/
  152940. get position(): Vector3;
  152941. /** Returns the Position of Output Plane*/
  152942. set position(v: Vector3);
  152943. /** Returns the Rotation of Output Plane*/
  152944. get rotation(): Vector3;
  152945. /** Returns the Rotation of Output Plane*/
  152946. set rotation(v: Vector3);
  152947. /** Sets the AnimationMap*/
  152948. get animationMap(): RawTexture;
  152949. /** Sets the AnimationMap*/
  152950. set animationMap(v: RawTexture);
  152951. /** Scene that the SpriteMap was created in */
  152952. private _scene;
  152953. /** Texture Buffer of Float32 that holds tile frame data*/
  152954. private _frameMap;
  152955. /** Texture Buffers of Float32 that holds tileMap data*/
  152956. private _tileMaps;
  152957. /** Texture Buffer of Float32 that holds Animation Data*/
  152958. private _animationMap;
  152959. /** Custom ShaderMaterial Central to the System*/
  152960. private _material;
  152961. /** Custom ShaderMaterial Central to the System*/
  152962. private _output;
  152963. /** Systems Time Ticker*/
  152964. private _time;
  152965. /**
  152966. * Creates a new SpriteMap
  152967. * @param name defines the SpriteMaps Name
  152968. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152969. * @param spriteSheet is the Texture that the Sprites are on.
  152970. * @param options a basic deployment configuration
  152971. * @param scene The Scene that the map is deployed on
  152972. */
  152973. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152974. /**
  152975. * Returns tileID location
  152976. * @returns Vector2 the cell position ID
  152977. */
  152978. getTileID(): Vector2;
  152979. /**
  152980. * Gets the UV location of the mouse over the SpriteMap.
  152981. * @returns Vector2 the UV position of the mouse interaction
  152982. */
  152983. getMousePosition(): Vector2;
  152984. /**
  152985. * Creates the "frame" texture Buffer
  152986. * -------------------------------------
  152987. * Structure of frames
  152988. * "filename": "Falling-Water-2.png",
  152989. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152990. * "rotated": true,
  152991. * "trimmed": true,
  152992. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152993. * "sourceSize": {"w":32,"h":32}
  152994. * @returns RawTexture of the frameMap
  152995. */
  152996. private _createFrameBuffer;
  152997. /**
  152998. * Creates the tileMap texture Buffer
  152999. * @param buffer normally and array of numbers, or a false to generate from scratch
  153000. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153001. * @returns RawTexture of the tileMap
  153002. */
  153003. private _createTileBuffer;
  153004. /**
  153005. * Modifies the data of the tileMaps
  153006. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153007. * @param pos is the iVector2 Coordinates of the Tile
  153008. * @param tile The SpriteIndex of the new Tile
  153009. */
  153010. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153011. /**
  153012. * Creates the animationMap texture Buffer
  153013. * @param buffer normally and array of numbers, or a false to generate from scratch
  153014. * @returns RawTexture of the animationMap
  153015. */
  153016. private _createTileAnimationBuffer;
  153017. /**
  153018. * Modifies the data of the animationMap
  153019. * @param cellID is the Index of the Sprite
  153020. * @param _frame is the target Animation frame
  153021. * @param toCell is the Target Index of the next frame of the animation
  153022. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153023. * @param speed is a global scalar of the time variable on the map.
  153024. */
  153025. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153026. /**
  153027. * Exports the .tilemaps file
  153028. */
  153029. saveTileMaps(): void;
  153030. /**
  153031. * Imports the .tilemaps file
  153032. * @param url of the .tilemaps file
  153033. */
  153034. loadTileMaps(url: string): void;
  153035. /**
  153036. * Release associated resources
  153037. */
  153038. dispose(): void;
  153039. }
  153040. }
  153041. declare module BABYLON {
  153042. /**
  153043. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153044. * @see https://doc.babylonjs.com/babylon101/sprites
  153045. */
  153046. export class SpritePackedManager extends SpriteManager {
  153047. /** defines the packed manager's name */
  153048. name: string;
  153049. /**
  153050. * Creates a new sprite manager from a packed sprite sheet
  153051. * @param name defines the manager's name
  153052. * @param imgUrl defines the sprite sheet url
  153053. * @param capacity defines the maximum allowed number of sprites
  153054. * @param scene defines the hosting scene
  153055. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153056. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153057. * @param samplingMode defines the smapling mode to use with spritesheet
  153058. * @param fromPacked set to true; do not alter
  153059. */
  153060. constructor(
  153061. /** defines the packed manager's name */
  153062. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153063. }
  153064. }
  153065. declare module BABYLON {
  153066. /**
  153067. * Defines the list of states available for a task inside a AssetsManager
  153068. */
  153069. export enum AssetTaskState {
  153070. /**
  153071. * Initialization
  153072. */
  153073. INIT = 0,
  153074. /**
  153075. * Running
  153076. */
  153077. RUNNING = 1,
  153078. /**
  153079. * Done
  153080. */
  153081. DONE = 2,
  153082. /**
  153083. * Error
  153084. */
  153085. ERROR = 3
  153086. }
  153087. /**
  153088. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153089. */
  153090. export abstract class AbstractAssetTask {
  153091. /**
  153092. * Task name
  153093. */ name: string;
  153094. /**
  153095. * Callback called when the task is successful
  153096. */
  153097. onSuccess: (task: any) => void;
  153098. /**
  153099. * Callback called when the task is not successful
  153100. */
  153101. onError: (task: any, message?: string, exception?: any) => void;
  153102. /**
  153103. * Creates a new AssetsManager
  153104. * @param name defines the name of the task
  153105. */
  153106. constructor(
  153107. /**
  153108. * Task name
  153109. */ name: string);
  153110. private _isCompleted;
  153111. private _taskState;
  153112. private _errorObject;
  153113. /**
  153114. * Get if the task is completed
  153115. */
  153116. get isCompleted(): boolean;
  153117. /**
  153118. * Gets the current state of the task
  153119. */
  153120. get taskState(): AssetTaskState;
  153121. /**
  153122. * Gets the current error object (if task is in error)
  153123. */
  153124. get errorObject(): {
  153125. message?: string;
  153126. exception?: any;
  153127. };
  153128. /**
  153129. * Internal only
  153130. * @hidden
  153131. */
  153132. _setErrorObject(message?: string, exception?: any): void;
  153133. /**
  153134. * Execute the current task
  153135. * @param scene defines the scene where you want your assets to be loaded
  153136. * @param onSuccess is a callback called when the task is successfully executed
  153137. * @param onError is a callback called if an error occurs
  153138. */
  153139. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153140. /**
  153141. * Execute the current task
  153142. * @param scene defines the scene where you want your assets to be loaded
  153143. * @param onSuccess is a callback called when the task is successfully executed
  153144. * @param onError is a callback called if an error occurs
  153145. */
  153146. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153147. /**
  153148. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153149. * This can be used with failed tasks that have the reason for failure fixed.
  153150. */
  153151. reset(): void;
  153152. private onErrorCallback;
  153153. private onDoneCallback;
  153154. }
  153155. /**
  153156. * Define the interface used by progress events raised during assets loading
  153157. */
  153158. export interface IAssetsProgressEvent {
  153159. /**
  153160. * Defines the number of remaining tasks to process
  153161. */
  153162. remainingCount: number;
  153163. /**
  153164. * Defines the total number of tasks
  153165. */
  153166. totalCount: number;
  153167. /**
  153168. * Defines the task that was just processed
  153169. */
  153170. task: AbstractAssetTask;
  153171. }
  153172. /**
  153173. * Class used to share progress information about assets loading
  153174. */
  153175. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153176. /**
  153177. * Defines the number of remaining tasks to process
  153178. */
  153179. remainingCount: number;
  153180. /**
  153181. * Defines the total number of tasks
  153182. */
  153183. totalCount: number;
  153184. /**
  153185. * Defines the task that was just processed
  153186. */
  153187. task: AbstractAssetTask;
  153188. /**
  153189. * Creates a AssetsProgressEvent
  153190. * @param remainingCount defines the number of remaining tasks to process
  153191. * @param totalCount defines the total number of tasks
  153192. * @param task defines the task that was just processed
  153193. */
  153194. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153195. }
  153196. /**
  153197. * Define a task used by AssetsManager to load assets into a container
  153198. */
  153199. export class ContainerAssetTask extends AbstractAssetTask {
  153200. /**
  153201. * Defines the name of the task
  153202. */
  153203. name: string;
  153204. /**
  153205. * Defines the list of mesh's names you want to load
  153206. */
  153207. meshesNames: any;
  153208. /**
  153209. * Defines the root url to use as a base to load your meshes and associated resources
  153210. */
  153211. rootUrl: string;
  153212. /**
  153213. * Defines the filename or File of the scene to load from
  153214. */
  153215. sceneFilename: string | File;
  153216. /**
  153217. * Get the loaded asset container
  153218. */
  153219. loadedContainer: AssetContainer;
  153220. /**
  153221. * Gets the list of loaded meshes
  153222. */
  153223. loadedMeshes: Array<AbstractMesh>;
  153224. /**
  153225. * Gets the list of loaded particle systems
  153226. */
  153227. loadedParticleSystems: Array<IParticleSystem>;
  153228. /**
  153229. * Gets the list of loaded skeletons
  153230. */
  153231. loadedSkeletons: Array<Skeleton>;
  153232. /**
  153233. * Gets the list of loaded animation groups
  153234. */
  153235. loadedAnimationGroups: Array<AnimationGroup>;
  153236. /**
  153237. * Callback called when the task is successful
  153238. */
  153239. onSuccess: (task: ContainerAssetTask) => void;
  153240. /**
  153241. * Callback called when the task is successful
  153242. */
  153243. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153244. /**
  153245. * Creates a new ContainerAssetTask
  153246. * @param name defines the name of the task
  153247. * @param meshesNames defines the list of mesh's names you want to load
  153248. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153249. * @param sceneFilename defines the filename or File of the scene to load from
  153250. */
  153251. constructor(
  153252. /**
  153253. * Defines the name of the task
  153254. */
  153255. name: string,
  153256. /**
  153257. * Defines the list of mesh's names you want to load
  153258. */
  153259. meshesNames: any,
  153260. /**
  153261. * Defines the root url to use as a base to load your meshes and associated resources
  153262. */
  153263. rootUrl: string,
  153264. /**
  153265. * Defines the filename or File of the scene to load from
  153266. */
  153267. sceneFilename: string | File);
  153268. /**
  153269. * Execute the current task
  153270. * @param scene defines the scene where you want your assets to be loaded
  153271. * @param onSuccess is a callback called when the task is successfully executed
  153272. * @param onError is a callback called if an error occurs
  153273. */
  153274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153275. }
  153276. /**
  153277. * Define a task used by AssetsManager to load meshes
  153278. */
  153279. export class MeshAssetTask extends AbstractAssetTask {
  153280. /**
  153281. * Defines the name of the task
  153282. */
  153283. name: string;
  153284. /**
  153285. * Defines the list of mesh's names you want to load
  153286. */
  153287. meshesNames: any;
  153288. /**
  153289. * Defines the root url to use as a base to load your meshes and associated resources
  153290. */
  153291. rootUrl: string;
  153292. /**
  153293. * Defines the filename or File of the scene to load from
  153294. */
  153295. sceneFilename: string | File;
  153296. /**
  153297. * Gets the list of loaded meshes
  153298. */
  153299. loadedMeshes: Array<AbstractMesh>;
  153300. /**
  153301. * Gets the list of loaded particle systems
  153302. */
  153303. loadedParticleSystems: Array<IParticleSystem>;
  153304. /**
  153305. * Gets the list of loaded skeletons
  153306. */
  153307. loadedSkeletons: Array<Skeleton>;
  153308. /**
  153309. * Gets the list of loaded animation groups
  153310. */
  153311. loadedAnimationGroups: Array<AnimationGroup>;
  153312. /**
  153313. * Callback called when the task is successful
  153314. */
  153315. onSuccess: (task: MeshAssetTask) => void;
  153316. /**
  153317. * Callback called when the task is successful
  153318. */
  153319. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153320. /**
  153321. * Creates a new MeshAssetTask
  153322. * @param name defines the name of the task
  153323. * @param meshesNames defines the list of mesh's names you want to load
  153324. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153325. * @param sceneFilename defines the filename or File of the scene to load from
  153326. */
  153327. constructor(
  153328. /**
  153329. * Defines the name of the task
  153330. */
  153331. name: string,
  153332. /**
  153333. * Defines the list of mesh's names you want to load
  153334. */
  153335. meshesNames: any,
  153336. /**
  153337. * Defines the root url to use as a base to load your meshes and associated resources
  153338. */
  153339. rootUrl: string,
  153340. /**
  153341. * Defines the filename or File of the scene to load from
  153342. */
  153343. sceneFilename: string | File);
  153344. /**
  153345. * Execute the current task
  153346. * @param scene defines the scene where you want your assets to be loaded
  153347. * @param onSuccess is a callback called when the task is successfully executed
  153348. * @param onError is a callback called if an error occurs
  153349. */
  153350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153351. }
  153352. /**
  153353. * Define a task used by AssetsManager to load text content
  153354. */
  153355. export class TextFileAssetTask extends AbstractAssetTask {
  153356. /**
  153357. * Defines the name of the task
  153358. */
  153359. name: string;
  153360. /**
  153361. * Defines the location of the file to load
  153362. */
  153363. url: string;
  153364. /**
  153365. * Gets the loaded text string
  153366. */
  153367. text: string;
  153368. /**
  153369. * Callback called when the task is successful
  153370. */
  153371. onSuccess: (task: TextFileAssetTask) => void;
  153372. /**
  153373. * Callback called when the task is successful
  153374. */
  153375. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153376. /**
  153377. * Creates a new TextFileAssetTask object
  153378. * @param name defines the name of the task
  153379. * @param url defines the location of the file to load
  153380. */
  153381. constructor(
  153382. /**
  153383. * Defines the name of the task
  153384. */
  153385. name: string,
  153386. /**
  153387. * Defines the location of the file to load
  153388. */
  153389. url: string);
  153390. /**
  153391. * Execute the current task
  153392. * @param scene defines the scene where you want your assets to be loaded
  153393. * @param onSuccess is a callback called when the task is successfully executed
  153394. * @param onError is a callback called if an error occurs
  153395. */
  153396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153397. }
  153398. /**
  153399. * Define a task used by AssetsManager to load binary data
  153400. */
  153401. export class BinaryFileAssetTask extends AbstractAssetTask {
  153402. /**
  153403. * Defines the name of the task
  153404. */
  153405. name: string;
  153406. /**
  153407. * Defines the location of the file to load
  153408. */
  153409. url: string;
  153410. /**
  153411. * Gets the lodaded data (as an array buffer)
  153412. */
  153413. data: ArrayBuffer;
  153414. /**
  153415. * Callback called when the task is successful
  153416. */
  153417. onSuccess: (task: BinaryFileAssetTask) => void;
  153418. /**
  153419. * Callback called when the task is successful
  153420. */
  153421. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153422. /**
  153423. * Creates a new BinaryFileAssetTask object
  153424. * @param name defines the name of the new task
  153425. * @param url defines the location of the file to load
  153426. */
  153427. constructor(
  153428. /**
  153429. * Defines the name of the task
  153430. */
  153431. name: string,
  153432. /**
  153433. * Defines the location of the file to load
  153434. */
  153435. url: string);
  153436. /**
  153437. * Execute the current task
  153438. * @param scene defines the scene where you want your assets to be loaded
  153439. * @param onSuccess is a callback called when the task is successfully executed
  153440. * @param onError is a callback called if an error occurs
  153441. */
  153442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153443. }
  153444. /**
  153445. * Define a task used by AssetsManager to load images
  153446. */
  153447. export class ImageAssetTask extends AbstractAssetTask {
  153448. /**
  153449. * Defines the name of the task
  153450. */
  153451. name: string;
  153452. /**
  153453. * Defines the location of the image to load
  153454. */
  153455. url: string;
  153456. /**
  153457. * Gets the loaded images
  153458. */
  153459. image: HTMLImageElement;
  153460. /**
  153461. * Callback called when the task is successful
  153462. */
  153463. onSuccess: (task: ImageAssetTask) => void;
  153464. /**
  153465. * Callback called when the task is successful
  153466. */
  153467. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153468. /**
  153469. * Creates a new ImageAssetTask
  153470. * @param name defines the name of the task
  153471. * @param url defines the location of the image to load
  153472. */
  153473. constructor(
  153474. /**
  153475. * Defines the name of the task
  153476. */
  153477. name: string,
  153478. /**
  153479. * Defines the location of the image to load
  153480. */
  153481. url: string);
  153482. /**
  153483. * Execute the current task
  153484. * @param scene defines the scene where you want your assets to be loaded
  153485. * @param onSuccess is a callback called when the task is successfully executed
  153486. * @param onError is a callback called if an error occurs
  153487. */
  153488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153489. }
  153490. /**
  153491. * Defines the interface used by texture loading tasks
  153492. */
  153493. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153494. /**
  153495. * Gets the loaded texture
  153496. */
  153497. texture: TEX;
  153498. }
  153499. /**
  153500. * Define a task used by AssetsManager to load 2D textures
  153501. */
  153502. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153503. /**
  153504. * Defines the name of the task
  153505. */
  153506. name: string;
  153507. /**
  153508. * Defines the location of the file to load
  153509. */
  153510. url: string;
  153511. /**
  153512. * Defines if mipmap should not be generated (default is false)
  153513. */
  153514. noMipmap?: boolean | undefined;
  153515. /**
  153516. * Defines if texture must be inverted on Y axis (default is true)
  153517. */
  153518. invertY: boolean;
  153519. /**
  153520. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153521. */
  153522. samplingMode: number;
  153523. /**
  153524. * Gets the loaded texture
  153525. */
  153526. texture: Texture;
  153527. /**
  153528. * Callback called when the task is successful
  153529. */
  153530. onSuccess: (task: TextureAssetTask) => void;
  153531. /**
  153532. * Callback called when the task is successful
  153533. */
  153534. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153535. /**
  153536. * Creates a new TextureAssetTask object
  153537. * @param name defines the name of the task
  153538. * @param url defines the location of the file to load
  153539. * @param noMipmap defines if mipmap should not be generated (default is false)
  153540. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153541. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153542. */
  153543. constructor(
  153544. /**
  153545. * Defines the name of the task
  153546. */
  153547. name: string,
  153548. /**
  153549. * Defines the location of the file to load
  153550. */
  153551. url: string,
  153552. /**
  153553. * Defines if mipmap should not be generated (default is false)
  153554. */
  153555. noMipmap?: boolean | undefined,
  153556. /**
  153557. * Defines if texture must be inverted on Y axis (default is true)
  153558. */
  153559. invertY?: boolean,
  153560. /**
  153561. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153562. */
  153563. samplingMode?: number);
  153564. /**
  153565. * Execute the current task
  153566. * @param scene defines the scene where you want your assets to be loaded
  153567. * @param onSuccess is a callback called when the task is successfully executed
  153568. * @param onError is a callback called if an error occurs
  153569. */
  153570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153571. }
  153572. /**
  153573. * Define a task used by AssetsManager to load cube textures
  153574. */
  153575. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153576. /**
  153577. * Defines the name of the task
  153578. */
  153579. name: string;
  153580. /**
  153581. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153582. */
  153583. url: string;
  153584. /**
  153585. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153586. */
  153587. extensions?: string[] | undefined;
  153588. /**
  153589. * Defines if mipmaps should not be generated (default is false)
  153590. */
  153591. noMipmap?: boolean | undefined;
  153592. /**
  153593. * Defines the explicit list of files (undefined by default)
  153594. */
  153595. files?: string[] | undefined;
  153596. /**
  153597. * Gets the loaded texture
  153598. */
  153599. texture: CubeTexture;
  153600. /**
  153601. * Callback called when the task is successful
  153602. */
  153603. onSuccess: (task: CubeTextureAssetTask) => void;
  153604. /**
  153605. * Callback called when the task is successful
  153606. */
  153607. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153608. /**
  153609. * Creates a new CubeTextureAssetTask
  153610. * @param name defines the name of the task
  153611. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153612. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153613. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153614. * @param files defines the explicit list of files (undefined by default)
  153615. */
  153616. constructor(
  153617. /**
  153618. * Defines the name of the task
  153619. */
  153620. name: string,
  153621. /**
  153622. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153623. */
  153624. url: string,
  153625. /**
  153626. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153627. */
  153628. extensions?: string[] | undefined,
  153629. /**
  153630. * Defines if mipmaps should not be generated (default is false)
  153631. */
  153632. noMipmap?: boolean | undefined,
  153633. /**
  153634. * Defines the explicit list of files (undefined by default)
  153635. */
  153636. files?: string[] | undefined);
  153637. /**
  153638. * Execute the current task
  153639. * @param scene defines the scene where you want your assets to be loaded
  153640. * @param onSuccess is a callback called when the task is successfully executed
  153641. * @param onError is a callback called if an error occurs
  153642. */
  153643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153644. }
  153645. /**
  153646. * Define a task used by AssetsManager to load HDR cube textures
  153647. */
  153648. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153649. /**
  153650. * Defines the name of the task
  153651. */
  153652. name: string;
  153653. /**
  153654. * Defines the location of the file to load
  153655. */
  153656. url: string;
  153657. /**
  153658. * Defines the desired size (the more it increases the longer the generation will be)
  153659. */
  153660. size: number;
  153661. /**
  153662. * Defines if mipmaps should not be generated (default is false)
  153663. */
  153664. noMipmap: boolean;
  153665. /**
  153666. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153667. */
  153668. generateHarmonics: boolean;
  153669. /**
  153670. * 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)
  153671. */
  153672. gammaSpace: boolean;
  153673. /**
  153674. * Internal Use Only
  153675. */
  153676. reserved: boolean;
  153677. /**
  153678. * Gets the loaded texture
  153679. */
  153680. texture: HDRCubeTexture;
  153681. /**
  153682. * Callback called when the task is successful
  153683. */
  153684. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153685. /**
  153686. * Callback called when the task is successful
  153687. */
  153688. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153689. /**
  153690. * Creates a new HDRCubeTextureAssetTask object
  153691. * @param name defines the name of the task
  153692. * @param url defines the location of the file to load
  153693. * @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.
  153694. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153695. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153696. * @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)
  153697. * @param reserved Internal use only
  153698. */
  153699. constructor(
  153700. /**
  153701. * Defines the name of the task
  153702. */
  153703. name: string,
  153704. /**
  153705. * Defines the location of the file to load
  153706. */
  153707. url: string,
  153708. /**
  153709. * Defines the desired size (the more it increases the longer the generation will be)
  153710. */
  153711. size: number,
  153712. /**
  153713. * Defines if mipmaps should not be generated (default is false)
  153714. */
  153715. noMipmap?: boolean,
  153716. /**
  153717. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153718. */
  153719. generateHarmonics?: boolean,
  153720. /**
  153721. * 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)
  153722. */
  153723. gammaSpace?: boolean,
  153724. /**
  153725. * Internal Use Only
  153726. */
  153727. reserved?: boolean);
  153728. /**
  153729. * Execute the current task
  153730. * @param scene defines the scene where you want your assets to be loaded
  153731. * @param onSuccess is a callback called when the task is successfully executed
  153732. * @param onError is a callback called if an error occurs
  153733. */
  153734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153735. }
  153736. /**
  153737. * Define a task used by AssetsManager to load Equirectangular cube textures
  153738. */
  153739. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153740. /**
  153741. * Defines the name of the task
  153742. */
  153743. name: string;
  153744. /**
  153745. * Defines the location of the file to load
  153746. */
  153747. url: string;
  153748. /**
  153749. * Defines the desired size (the more it increases the longer the generation will be)
  153750. */
  153751. size: number;
  153752. /**
  153753. * Defines if mipmaps should not be generated (default is false)
  153754. */
  153755. noMipmap: boolean;
  153756. /**
  153757. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153758. * but the standard material would require them in Gamma space) (default is true)
  153759. */
  153760. gammaSpace: boolean;
  153761. /**
  153762. * Gets the loaded texture
  153763. */
  153764. texture: EquiRectangularCubeTexture;
  153765. /**
  153766. * Callback called when the task is successful
  153767. */
  153768. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153769. /**
  153770. * Callback called when the task is successful
  153771. */
  153772. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153773. /**
  153774. * Creates a new EquiRectangularCubeTextureAssetTask object
  153775. * @param name defines the name of the task
  153776. * @param url defines the location of the file to load
  153777. * @param size defines the desired size (the more it increases the longer the generation will be)
  153778. * If the size is omitted this implies you are using a preprocessed cubemap.
  153779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153780. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153781. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153782. * (default is true)
  153783. */
  153784. constructor(
  153785. /**
  153786. * Defines the name of the task
  153787. */
  153788. name: string,
  153789. /**
  153790. * Defines the location of the file to load
  153791. */
  153792. url: string,
  153793. /**
  153794. * Defines the desired size (the more it increases the longer the generation will be)
  153795. */
  153796. size: number,
  153797. /**
  153798. * Defines if mipmaps should not be generated (default is false)
  153799. */
  153800. noMipmap?: boolean,
  153801. /**
  153802. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153803. * but the standard material would require them in Gamma space) (default is true)
  153804. */
  153805. gammaSpace?: boolean);
  153806. /**
  153807. * Execute the current task
  153808. * @param scene defines the scene where you want your assets to be loaded
  153809. * @param onSuccess is a callback called when the task is successfully executed
  153810. * @param onError is a callback called if an error occurs
  153811. */
  153812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153813. }
  153814. /**
  153815. * This class can be used to easily import assets into a scene
  153816. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153817. */
  153818. export class AssetsManager {
  153819. private _scene;
  153820. private _isLoading;
  153821. protected _tasks: AbstractAssetTask[];
  153822. protected _waitingTasksCount: number;
  153823. protected _totalTasksCount: number;
  153824. /**
  153825. * Callback called when all tasks are processed
  153826. */
  153827. onFinish: (tasks: AbstractAssetTask[]) => void;
  153828. /**
  153829. * Callback called when a task is successful
  153830. */
  153831. onTaskSuccess: (task: AbstractAssetTask) => void;
  153832. /**
  153833. * Callback called when a task had an error
  153834. */
  153835. onTaskError: (task: AbstractAssetTask) => void;
  153836. /**
  153837. * Callback called when a task is done (whatever the result is)
  153838. */
  153839. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153840. /**
  153841. * Observable called when all tasks are processed
  153842. */
  153843. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153844. /**
  153845. * Observable called when a task had an error
  153846. */
  153847. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153848. /**
  153849. * Observable called when all tasks were executed
  153850. */
  153851. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153852. /**
  153853. * Observable called when a task is done (whatever the result is)
  153854. */
  153855. onProgressObservable: Observable<IAssetsProgressEvent>;
  153856. /**
  153857. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153858. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153859. */
  153860. useDefaultLoadingScreen: boolean;
  153861. /**
  153862. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153863. * when all assets have been downloaded.
  153864. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153865. */
  153866. autoHideLoadingUI: boolean;
  153867. /**
  153868. * Creates a new AssetsManager
  153869. * @param scene defines the scene to work on
  153870. */
  153871. constructor(scene: Scene);
  153872. /**
  153873. * Add a ContainerAssetTask to the list of active tasks
  153874. * @param taskName defines the name of the new task
  153875. * @param meshesNames defines the name of meshes to load
  153876. * @param rootUrl defines the root url to use to locate files
  153877. * @param sceneFilename defines the filename of the scene file
  153878. * @returns a new ContainerAssetTask object
  153879. */
  153880. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153881. /**
  153882. * Add a MeshAssetTask to the list of active tasks
  153883. * @param taskName defines the name of the new task
  153884. * @param meshesNames defines the name of meshes to load
  153885. * @param rootUrl defines the root url to use to locate files
  153886. * @param sceneFilename defines the filename of the scene file
  153887. * @returns a new MeshAssetTask object
  153888. */
  153889. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153890. /**
  153891. * Add a TextFileAssetTask to the list of active tasks
  153892. * @param taskName defines the name of the new task
  153893. * @param url defines the url of the file to load
  153894. * @returns a new TextFileAssetTask object
  153895. */
  153896. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153897. /**
  153898. * Add a BinaryFileAssetTask to the list of active tasks
  153899. * @param taskName defines the name of the new task
  153900. * @param url defines the url of the file to load
  153901. * @returns a new BinaryFileAssetTask object
  153902. */
  153903. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153904. /**
  153905. * Add a ImageAssetTask to the list of active tasks
  153906. * @param taskName defines the name of the new task
  153907. * @param url defines the url of the file to load
  153908. * @returns a new ImageAssetTask object
  153909. */
  153910. addImageTask(taskName: string, url: string): ImageAssetTask;
  153911. /**
  153912. * Add a TextureAssetTask to the list of active tasks
  153913. * @param taskName defines the name of the new task
  153914. * @param url defines the url of the file to load
  153915. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153916. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153917. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153918. * @returns a new TextureAssetTask object
  153919. */
  153920. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153921. /**
  153922. * Add a CubeTextureAssetTask to the list of active tasks
  153923. * @param taskName defines the name of the new task
  153924. * @param url defines the url of the file to load
  153925. * @param extensions defines the extension to use to load the cube map (can be null)
  153926. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153927. * @param files defines the list of files to load (can be null)
  153928. * @returns a new CubeTextureAssetTask object
  153929. */
  153930. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153931. /**
  153932. *
  153933. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153934. * @param taskName defines the name of the new task
  153935. * @param url defines the url of the file to load
  153936. * @param size defines the size you want for the cubemap (can be null)
  153937. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153938. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153939. * @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)
  153940. * @param reserved Internal use only
  153941. * @returns a new HDRCubeTextureAssetTask object
  153942. */
  153943. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153944. /**
  153945. *
  153946. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153947. * @param taskName defines the name of the new task
  153948. * @param url defines the url of the file to load
  153949. * @param size defines the size you want for the cubemap (can be null)
  153950. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153951. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153952. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153953. * @returns a new EquiRectangularCubeTextureAssetTask object
  153954. */
  153955. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153956. /**
  153957. * Remove a task from the assets manager.
  153958. * @param task the task to remove
  153959. */
  153960. removeTask(task: AbstractAssetTask): void;
  153961. private _decreaseWaitingTasksCount;
  153962. private _runTask;
  153963. /**
  153964. * Reset the AssetsManager and remove all tasks
  153965. * @return the current instance of the AssetsManager
  153966. */
  153967. reset(): AssetsManager;
  153968. /**
  153969. * Start the loading process
  153970. * @return the current instance of the AssetsManager
  153971. */
  153972. load(): AssetsManager;
  153973. /**
  153974. * Start the loading process as an async operation
  153975. * @return a promise returning the list of failed tasks
  153976. */
  153977. loadAsync(): Promise<void>;
  153978. }
  153979. }
  153980. declare module BABYLON {
  153981. /**
  153982. * Wrapper class for promise with external resolve and reject.
  153983. */
  153984. export class Deferred<T> {
  153985. /**
  153986. * The promise associated with this deferred object.
  153987. */
  153988. readonly promise: Promise<T>;
  153989. private _resolve;
  153990. private _reject;
  153991. /**
  153992. * The resolve method of the promise associated with this deferred object.
  153993. */
  153994. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153995. /**
  153996. * The reject method of the promise associated with this deferred object.
  153997. */
  153998. get reject(): (reason?: any) => void;
  153999. /**
  154000. * Constructor for this deferred object.
  154001. */
  154002. constructor();
  154003. }
  154004. }
  154005. declare module BABYLON {
  154006. /**
  154007. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154008. */
  154009. export class MeshExploder {
  154010. private _centerMesh;
  154011. private _meshes;
  154012. private _meshesOrigins;
  154013. private _toCenterVectors;
  154014. private _scaledDirection;
  154015. private _newPosition;
  154016. private _centerPosition;
  154017. /**
  154018. * Explodes meshes from a center mesh.
  154019. * @param meshes The meshes to explode.
  154020. * @param centerMesh The mesh to be center of explosion.
  154021. */
  154022. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154023. private _setCenterMesh;
  154024. /**
  154025. * Get class name
  154026. * @returns "MeshExploder"
  154027. */
  154028. getClassName(): string;
  154029. /**
  154030. * "Exploded meshes"
  154031. * @returns Array of meshes with the centerMesh at index 0.
  154032. */
  154033. getMeshes(): Array<Mesh>;
  154034. /**
  154035. * Explodes meshes giving a specific direction
  154036. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154037. */
  154038. explode(direction?: number): void;
  154039. }
  154040. }
  154041. declare module BABYLON {
  154042. /**
  154043. * Class used to help managing file picking and drag'n'drop
  154044. */
  154045. export class FilesInput {
  154046. /**
  154047. * List of files ready to be loaded
  154048. */
  154049. static get FilesToLoad(): {
  154050. [key: string]: File;
  154051. };
  154052. /**
  154053. * Callback called when a file is processed
  154054. */
  154055. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154056. private _engine;
  154057. private _currentScene;
  154058. private _sceneLoadedCallback;
  154059. private _progressCallback;
  154060. private _additionalRenderLoopLogicCallback;
  154061. private _textureLoadingCallback;
  154062. private _startingProcessingFilesCallback;
  154063. private _onReloadCallback;
  154064. private _errorCallback;
  154065. private _elementToMonitor;
  154066. private _sceneFileToLoad;
  154067. private _filesToLoad;
  154068. /**
  154069. * Creates a new FilesInput
  154070. * @param engine defines the rendering engine
  154071. * @param scene defines the hosting scene
  154072. * @param sceneLoadedCallback callback called when scene is loaded
  154073. * @param progressCallback callback called to track progress
  154074. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154075. * @param textureLoadingCallback callback called when a texture is loading
  154076. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154077. * @param onReloadCallback callback called when a reload is requested
  154078. * @param errorCallback callback call if an error occurs
  154079. */
  154080. 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>);
  154081. private _dragEnterHandler;
  154082. private _dragOverHandler;
  154083. private _dropHandler;
  154084. /**
  154085. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154086. * @param elementToMonitor defines the DOM element to track
  154087. */
  154088. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154089. /** Gets the current list of files to load */
  154090. get filesToLoad(): File[];
  154091. /**
  154092. * Release all associated resources
  154093. */
  154094. dispose(): void;
  154095. private renderFunction;
  154096. private drag;
  154097. private drop;
  154098. private _traverseFolder;
  154099. private _processFiles;
  154100. /**
  154101. * Load files from a drop event
  154102. * @param event defines the drop event to use as source
  154103. */
  154104. loadFiles(event: any): void;
  154105. private _processReload;
  154106. /**
  154107. * Reload the current scene from the loaded files
  154108. */
  154109. reload(): void;
  154110. }
  154111. }
  154112. declare module BABYLON {
  154113. /**
  154114. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154115. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154116. */
  154117. export class SceneOptimization {
  154118. /**
  154119. * Defines the priority of this optimization (0 by default which means first in the list)
  154120. */
  154121. priority: number;
  154122. /**
  154123. * Gets a string describing the action executed by the current optimization
  154124. * @returns description string
  154125. */
  154126. getDescription(): string;
  154127. /**
  154128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154129. * @param scene defines the current scene where to apply this optimization
  154130. * @param optimizer defines the current optimizer
  154131. * @returns true if everything that can be done was applied
  154132. */
  154133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154134. /**
  154135. * Creates the SceneOptimization object
  154136. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154137. * @param desc defines the description associated with the optimization
  154138. */
  154139. constructor(
  154140. /**
  154141. * Defines the priority of this optimization (0 by default which means first in the list)
  154142. */
  154143. priority?: number);
  154144. }
  154145. /**
  154146. * Defines an optimization used to reduce the size of render target textures
  154147. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154148. */
  154149. export class TextureOptimization extends SceneOptimization {
  154150. /**
  154151. * Defines the priority of this optimization (0 by default which means first in the list)
  154152. */
  154153. priority: number;
  154154. /**
  154155. * 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
  154156. */
  154157. maximumSize: number;
  154158. /**
  154159. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154160. */
  154161. step: number;
  154162. /**
  154163. * Gets a string describing the action executed by the current optimization
  154164. * @returns description string
  154165. */
  154166. getDescription(): string;
  154167. /**
  154168. * Creates the TextureOptimization object
  154169. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154170. * @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
  154171. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154172. */
  154173. constructor(
  154174. /**
  154175. * Defines the priority of this optimization (0 by default which means first in the list)
  154176. */
  154177. priority?: number,
  154178. /**
  154179. * 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
  154180. */
  154181. maximumSize?: number,
  154182. /**
  154183. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154184. */
  154185. step?: number);
  154186. /**
  154187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154188. * @param scene defines the current scene where to apply this optimization
  154189. * @param optimizer defines the current optimizer
  154190. * @returns true if everything that can be done was applied
  154191. */
  154192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154193. }
  154194. /**
  154195. * Defines an optimization used to increase or decrease the rendering resolution
  154196. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154197. */
  154198. export class HardwareScalingOptimization extends SceneOptimization {
  154199. /**
  154200. * Defines the priority of this optimization (0 by default which means first in the list)
  154201. */
  154202. priority: number;
  154203. /**
  154204. * Defines the maximum scale to use (2 by default)
  154205. */
  154206. maximumScale: number;
  154207. /**
  154208. * Defines the step to use between two passes (0.5 by default)
  154209. */
  154210. step: number;
  154211. private _currentScale;
  154212. private _directionOffset;
  154213. /**
  154214. * Gets a string describing the action executed by the current optimization
  154215. * @return description string
  154216. */
  154217. getDescription(): string;
  154218. /**
  154219. * Creates the HardwareScalingOptimization object
  154220. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154221. * @param maximumScale defines the maximum scale to use (2 by default)
  154222. * @param step defines the step to use between two passes (0.5 by default)
  154223. */
  154224. constructor(
  154225. /**
  154226. * Defines the priority of this optimization (0 by default which means first in the list)
  154227. */
  154228. priority?: number,
  154229. /**
  154230. * Defines the maximum scale to use (2 by default)
  154231. */
  154232. maximumScale?: number,
  154233. /**
  154234. * Defines the step to use between two passes (0.5 by default)
  154235. */
  154236. step?: number);
  154237. /**
  154238. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154239. * @param scene defines the current scene where to apply this optimization
  154240. * @param optimizer defines the current optimizer
  154241. * @returns true if everything that can be done was applied
  154242. */
  154243. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154244. }
  154245. /**
  154246. * Defines an optimization used to remove shadows
  154247. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154248. */
  154249. export class ShadowsOptimization extends SceneOptimization {
  154250. /**
  154251. * Gets a string describing the action executed by the current optimization
  154252. * @return description string
  154253. */
  154254. getDescription(): string;
  154255. /**
  154256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154257. * @param scene defines the current scene where to apply this optimization
  154258. * @param optimizer defines the current optimizer
  154259. * @returns true if everything that can be done was applied
  154260. */
  154261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154262. }
  154263. /**
  154264. * Defines an optimization used to turn post-processes off
  154265. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154266. */
  154267. export class PostProcessesOptimization extends SceneOptimization {
  154268. /**
  154269. * Gets a string describing the action executed by the current optimization
  154270. * @return description string
  154271. */
  154272. getDescription(): string;
  154273. /**
  154274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154275. * @param scene defines the current scene where to apply this optimization
  154276. * @param optimizer defines the current optimizer
  154277. * @returns true if everything that can be done was applied
  154278. */
  154279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154280. }
  154281. /**
  154282. * Defines an optimization used to turn lens flares off
  154283. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154284. */
  154285. export class LensFlaresOptimization extends SceneOptimization {
  154286. /**
  154287. * Gets a string describing the action executed by the current optimization
  154288. * @return description string
  154289. */
  154290. getDescription(): string;
  154291. /**
  154292. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154293. * @param scene defines the current scene where to apply this optimization
  154294. * @param optimizer defines the current optimizer
  154295. * @returns true if everything that can be done was applied
  154296. */
  154297. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154298. }
  154299. /**
  154300. * Defines an optimization based on user defined callback.
  154301. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154302. */
  154303. export class CustomOptimization extends SceneOptimization {
  154304. /**
  154305. * Callback called to apply the custom optimization.
  154306. */
  154307. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154308. /**
  154309. * Callback called to get custom description
  154310. */
  154311. onGetDescription: () => string;
  154312. /**
  154313. * Gets a string describing the action executed by the current optimization
  154314. * @returns description string
  154315. */
  154316. getDescription(): string;
  154317. /**
  154318. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154319. * @param scene defines the current scene where to apply this optimization
  154320. * @param optimizer defines the current optimizer
  154321. * @returns true if everything that can be done was applied
  154322. */
  154323. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154324. }
  154325. /**
  154326. * Defines an optimization used to turn particles off
  154327. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154328. */
  154329. export class ParticlesOptimization extends SceneOptimization {
  154330. /**
  154331. * Gets a string describing the action executed by the current optimization
  154332. * @return description string
  154333. */
  154334. getDescription(): string;
  154335. /**
  154336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154337. * @param scene defines the current scene where to apply this optimization
  154338. * @param optimizer defines the current optimizer
  154339. * @returns true if everything that can be done was applied
  154340. */
  154341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154342. }
  154343. /**
  154344. * Defines an optimization used to turn render targets off
  154345. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154346. */
  154347. export class RenderTargetsOptimization extends SceneOptimization {
  154348. /**
  154349. * Gets a string describing the action executed by the current optimization
  154350. * @return description string
  154351. */
  154352. getDescription(): string;
  154353. /**
  154354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154355. * @param scene defines the current scene where to apply this optimization
  154356. * @param optimizer defines the current optimizer
  154357. * @returns true if everything that can be done was applied
  154358. */
  154359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154360. }
  154361. /**
  154362. * Defines an optimization used to merge meshes with compatible materials
  154363. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154364. */
  154365. export class MergeMeshesOptimization extends SceneOptimization {
  154366. private static _UpdateSelectionTree;
  154367. /**
  154368. * Gets or sets a boolean which defines if optimization octree has to be updated
  154369. */
  154370. static get UpdateSelectionTree(): boolean;
  154371. /**
  154372. * Gets or sets a boolean which defines if optimization octree has to be updated
  154373. */
  154374. static set UpdateSelectionTree(value: boolean);
  154375. /**
  154376. * Gets a string describing the action executed by the current optimization
  154377. * @return description string
  154378. */
  154379. getDescription(): string;
  154380. private _canBeMerged;
  154381. /**
  154382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154383. * @param scene defines the current scene where to apply this optimization
  154384. * @param optimizer defines the current optimizer
  154385. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154386. * @returns true if everything that can be done was applied
  154387. */
  154388. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154389. }
  154390. /**
  154391. * Defines a list of options used by SceneOptimizer
  154392. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154393. */
  154394. export class SceneOptimizerOptions {
  154395. /**
  154396. * Defines the target frame rate to reach (60 by default)
  154397. */
  154398. targetFrameRate: number;
  154399. /**
  154400. * Defines the interval between two checkes (2000ms by default)
  154401. */
  154402. trackerDuration: number;
  154403. /**
  154404. * Gets the list of optimizations to apply
  154405. */
  154406. optimizations: SceneOptimization[];
  154407. /**
  154408. * Creates a new list of options used by SceneOptimizer
  154409. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154410. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154411. */
  154412. constructor(
  154413. /**
  154414. * Defines the target frame rate to reach (60 by default)
  154415. */
  154416. targetFrameRate?: number,
  154417. /**
  154418. * Defines the interval between two checkes (2000ms by default)
  154419. */
  154420. trackerDuration?: number);
  154421. /**
  154422. * Add a new optimization
  154423. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154424. * @returns the current SceneOptimizerOptions
  154425. */
  154426. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154427. /**
  154428. * Add a new custom optimization
  154429. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154430. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154431. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154432. * @returns the current SceneOptimizerOptions
  154433. */
  154434. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154435. /**
  154436. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154437. * @param targetFrameRate defines the target frame rate (60 by default)
  154438. * @returns a SceneOptimizerOptions object
  154439. */
  154440. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154441. /**
  154442. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154443. * @param targetFrameRate defines the target frame rate (60 by default)
  154444. * @returns a SceneOptimizerOptions object
  154445. */
  154446. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154447. /**
  154448. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154449. * @param targetFrameRate defines the target frame rate (60 by default)
  154450. * @returns a SceneOptimizerOptions object
  154451. */
  154452. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154453. }
  154454. /**
  154455. * Class used to run optimizations in order to reach a target frame rate
  154456. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154457. */
  154458. export class SceneOptimizer implements IDisposable {
  154459. private _isRunning;
  154460. private _options;
  154461. private _scene;
  154462. private _currentPriorityLevel;
  154463. private _targetFrameRate;
  154464. private _trackerDuration;
  154465. private _currentFrameRate;
  154466. private _sceneDisposeObserver;
  154467. private _improvementMode;
  154468. /**
  154469. * Defines an observable called when the optimizer reaches the target frame rate
  154470. */
  154471. onSuccessObservable: Observable<SceneOptimizer>;
  154472. /**
  154473. * Defines an observable called when the optimizer enables an optimization
  154474. */
  154475. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154476. /**
  154477. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154478. */
  154479. onFailureObservable: Observable<SceneOptimizer>;
  154480. /**
  154481. * Gets a boolean indicating if the optimizer is in improvement mode
  154482. */
  154483. get isInImprovementMode(): boolean;
  154484. /**
  154485. * Gets the current priority level (0 at start)
  154486. */
  154487. get currentPriorityLevel(): number;
  154488. /**
  154489. * Gets the current frame rate checked by the SceneOptimizer
  154490. */
  154491. get currentFrameRate(): number;
  154492. /**
  154493. * Gets or sets the current target frame rate (60 by default)
  154494. */
  154495. get targetFrameRate(): number;
  154496. /**
  154497. * Gets or sets the current target frame rate (60 by default)
  154498. */
  154499. set targetFrameRate(value: number);
  154500. /**
  154501. * Gets or sets the current interval between two checks (every 2000ms by default)
  154502. */
  154503. get trackerDuration(): number;
  154504. /**
  154505. * Gets or sets the current interval between two checks (every 2000ms by default)
  154506. */
  154507. set trackerDuration(value: number);
  154508. /**
  154509. * Gets the list of active optimizations
  154510. */
  154511. get optimizations(): SceneOptimization[];
  154512. /**
  154513. * Creates a new SceneOptimizer
  154514. * @param scene defines the scene to work on
  154515. * @param options defines the options to use with the SceneOptimizer
  154516. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154517. * @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)
  154518. */
  154519. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154520. /**
  154521. * Stops the current optimizer
  154522. */
  154523. stop(): void;
  154524. /**
  154525. * Reset the optimizer to initial step (current priority level = 0)
  154526. */
  154527. reset(): void;
  154528. /**
  154529. * Start the optimizer. By default it will try to reach a specific framerate
  154530. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154531. */
  154532. start(): void;
  154533. private _checkCurrentState;
  154534. /**
  154535. * Release all resources
  154536. */
  154537. dispose(): void;
  154538. /**
  154539. * Helper function to create a SceneOptimizer with one single line of code
  154540. * @param scene defines the scene to work on
  154541. * @param options defines the options to use with the SceneOptimizer
  154542. * @param onSuccess defines a callback to call on success
  154543. * @param onFailure defines a callback to call on failure
  154544. * @returns the new SceneOptimizer object
  154545. */
  154546. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154547. }
  154548. }
  154549. declare module BABYLON {
  154550. /**
  154551. * Class used to serialize a scene into a string
  154552. */
  154553. export class SceneSerializer {
  154554. /**
  154555. * Clear cache used by a previous serialization
  154556. */
  154557. static ClearCache(): void;
  154558. /**
  154559. * Serialize a scene into a JSON compatible object
  154560. * @param scene defines the scene to serialize
  154561. * @returns a JSON compatible object
  154562. */
  154563. static Serialize(scene: Scene): any;
  154564. /**
  154565. * Serialize a mesh into a JSON compatible object
  154566. * @param toSerialize defines the mesh to serialize
  154567. * @param withParents defines if parents must be serialized as well
  154568. * @param withChildren defines if children must be serialized as well
  154569. * @returns a JSON compatible object
  154570. */
  154571. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154572. }
  154573. }
  154574. declare module BABYLON {
  154575. /**
  154576. * Class used to host texture specific utilities
  154577. */
  154578. export class TextureTools {
  154579. /**
  154580. * Uses the GPU to create a copy texture rescaled at a given size
  154581. * @param texture Texture to copy from
  154582. * @param width defines the desired width
  154583. * @param height defines the desired height
  154584. * @param useBilinearMode defines if bilinear mode has to be used
  154585. * @return the generated texture
  154586. */
  154587. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154588. }
  154589. }
  154590. declare module BABYLON {
  154591. /**
  154592. * This represents the different options available for the video capture.
  154593. */
  154594. export interface VideoRecorderOptions {
  154595. /** Defines the mime type of the video. */
  154596. mimeType: string;
  154597. /** Defines the FPS the video should be recorded at. */
  154598. fps: number;
  154599. /** Defines the chunk size for the recording data. */
  154600. recordChunckSize: number;
  154601. /** The audio tracks to attach to the recording. */
  154602. audioTracks?: MediaStreamTrack[];
  154603. }
  154604. /**
  154605. * This can help with recording videos from BabylonJS.
  154606. * This is based on the available WebRTC functionalities of the browser.
  154607. *
  154608. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154609. */
  154610. export class VideoRecorder {
  154611. private static readonly _defaultOptions;
  154612. /**
  154613. * Returns whether or not the VideoRecorder is available in your browser.
  154614. * @param engine Defines the Babylon Engine.
  154615. * @returns true if supported otherwise false.
  154616. */
  154617. static IsSupported(engine: Engine): boolean;
  154618. private readonly _options;
  154619. private _canvas;
  154620. private _mediaRecorder;
  154621. private _recordedChunks;
  154622. private _fileName;
  154623. private _resolve;
  154624. private _reject;
  154625. /**
  154626. * True when a recording is already in progress.
  154627. */
  154628. get isRecording(): boolean;
  154629. /**
  154630. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154631. * @param engine Defines the BabylonJS Engine you wish to record.
  154632. * @param options Defines options that can be used to customize the capture.
  154633. */
  154634. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154635. /**
  154636. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154637. */
  154638. stopRecording(): void;
  154639. /**
  154640. * Starts recording the canvas for a max duration specified in parameters.
  154641. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154642. * If null no automatic download will start and you can rely on the promise to get the data back.
  154643. * @param maxDuration Defines the maximum recording time in seconds.
  154644. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154645. * @return A promise callback at the end of the recording with the video data in Blob.
  154646. */
  154647. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154648. /**
  154649. * Releases internal resources used during the recording.
  154650. */
  154651. dispose(): void;
  154652. private _handleDataAvailable;
  154653. private _handleError;
  154654. private _handleStop;
  154655. }
  154656. }
  154657. declare module BABYLON {
  154658. /**
  154659. * Class containing a set of static utilities functions for screenshots
  154660. */
  154661. export class ScreenshotTools {
  154662. /**
  154663. * Captures a screenshot of the current rendering
  154664. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154665. * @param engine defines the rendering engine
  154666. * @param camera defines the source camera
  154667. * @param size This parameter can be set to a single number or to an object with the
  154668. * following (optional) properties: precision, width, height. If a single number is passed,
  154669. * it will be used for both width and height. If an object is passed, the screenshot size
  154670. * will be derived from the parameters. The precision property is a multiplier allowing
  154671. * rendering at a higher or lower resolution
  154672. * @param successCallback defines the callback receives a single parameter which contains the
  154673. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154674. * src parameter of an <img> to display it
  154675. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154676. * Check your browser for supported MIME types
  154677. */
  154678. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154679. /**
  154680. * Captures a screenshot of the current rendering
  154681. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154682. * @param engine defines the rendering engine
  154683. * @param camera defines the source camera
  154684. * @param size This parameter can be set to a single number or to an object with the
  154685. * following (optional) properties: precision, width, height. If a single number is passed,
  154686. * it will be used for both width and height. If an object is passed, the screenshot size
  154687. * will be derived from the parameters. The precision property is a multiplier allowing
  154688. * rendering at a higher or lower resolution
  154689. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154690. * Check your browser for supported MIME types
  154691. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154692. * to the src parameter of an <img> to display it
  154693. */
  154694. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154695. /**
  154696. * Generates an image screenshot from the specified camera.
  154697. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154698. * @param engine The engine to use for rendering
  154699. * @param camera The camera to use for rendering
  154700. * @param size This parameter can be set to a single number or to an object with the
  154701. * following (optional) properties: precision, width, height. If a single number is passed,
  154702. * it will be used for both width and height. If an object is passed, the screenshot size
  154703. * will be derived from the parameters. The precision property is a multiplier allowing
  154704. * rendering at a higher or lower resolution
  154705. * @param successCallback The callback receives a single parameter which contains the
  154706. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154707. * src parameter of an <img> to display it
  154708. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154709. * Check your browser for supported MIME types
  154710. * @param samples Texture samples (default: 1)
  154711. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154712. * @param fileName A name for for the downloaded file.
  154713. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154714. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154715. */
  154716. 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;
  154717. /**
  154718. * Generates an image screenshot from the specified camera.
  154719. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154720. * @param engine The engine to use for rendering
  154721. * @param camera The camera to use for rendering
  154722. * @param size This parameter can be set to a single number or to an object with the
  154723. * following (optional) properties: precision, width, height. If a single number is passed,
  154724. * it will be used for both width and height. If an object is passed, the screenshot size
  154725. * will be derived from the parameters. The precision property is a multiplier allowing
  154726. * rendering at a higher or lower resolution
  154727. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154728. * Check your browser for supported MIME types
  154729. * @param samples Texture samples (default: 1)
  154730. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154731. * @param fileName A name for for the downloaded file.
  154732. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154733. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154734. * to the src parameter of an <img> to display it
  154735. */
  154736. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154737. /**
  154738. * Gets height and width for screenshot size
  154739. * @private
  154740. */
  154741. private static _getScreenshotSize;
  154742. }
  154743. }
  154744. declare module BABYLON {
  154745. /**
  154746. * Interface for a data buffer
  154747. */
  154748. export interface IDataBuffer {
  154749. /**
  154750. * Reads bytes from the data buffer.
  154751. * @param byteOffset The byte offset to read
  154752. * @param byteLength The byte length to read
  154753. * @returns A promise that resolves when the bytes are read
  154754. */
  154755. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154756. /**
  154757. * The byte length of the buffer.
  154758. */
  154759. readonly byteLength: number;
  154760. }
  154761. /**
  154762. * Utility class for reading from a data buffer
  154763. */
  154764. export class DataReader {
  154765. /**
  154766. * The data buffer associated with this data reader.
  154767. */
  154768. readonly buffer: IDataBuffer;
  154769. /**
  154770. * The current byte offset from the beginning of the data buffer.
  154771. */
  154772. byteOffset: number;
  154773. private _dataView;
  154774. private _dataByteOffset;
  154775. /**
  154776. * Constructor
  154777. * @param buffer The buffer to read
  154778. */
  154779. constructor(buffer: IDataBuffer);
  154780. /**
  154781. * Loads the given byte length.
  154782. * @param byteLength The byte length to load
  154783. * @returns A promise that resolves when the load is complete
  154784. */
  154785. loadAsync(byteLength: number): Promise<void>;
  154786. /**
  154787. * Read a unsigned 32-bit integer from the currently loaded data range.
  154788. * @returns The 32-bit integer read
  154789. */
  154790. readUint32(): number;
  154791. /**
  154792. * Read a byte array from the currently loaded data range.
  154793. * @param byteLength The byte length to read
  154794. * @returns The byte array read
  154795. */
  154796. readUint8Array(byteLength: number): Uint8Array;
  154797. /**
  154798. * Read a string from the currently loaded data range.
  154799. * @param byteLength The byte length to read
  154800. * @returns The string read
  154801. */
  154802. readString(byteLength: number): string;
  154803. /**
  154804. * Skips the given byte length the currently loaded data range.
  154805. * @param byteLength The byte length to skip
  154806. */
  154807. skipBytes(byteLength: number): void;
  154808. }
  154809. }
  154810. declare module BABYLON {
  154811. /**
  154812. * Class for storing data to local storage if available or in-memory storage otherwise
  154813. */
  154814. export class DataStorage {
  154815. private static _Storage;
  154816. private static _GetStorage;
  154817. /**
  154818. * Reads a string from the data storage
  154819. * @param key The key to read
  154820. * @param defaultValue The value if the key doesn't exist
  154821. * @returns The string value
  154822. */
  154823. static ReadString(key: string, defaultValue: string): string;
  154824. /**
  154825. * Writes a string to the data storage
  154826. * @param key The key to write
  154827. * @param value The value to write
  154828. */
  154829. static WriteString(key: string, value: string): void;
  154830. /**
  154831. * Reads a boolean from the data storage
  154832. * @param key The key to read
  154833. * @param defaultValue The value if the key doesn't exist
  154834. * @returns The boolean value
  154835. */
  154836. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154837. /**
  154838. * Writes a boolean to the data storage
  154839. * @param key The key to write
  154840. * @param value The value to write
  154841. */
  154842. static WriteBoolean(key: string, value: boolean): void;
  154843. /**
  154844. * Reads a number from the data storage
  154845. * @param key The key to read
  154846. * @param defaultValue The value if the key doesn't exist
  154847. * @returns The number value
  154848. */
  154849. static ReadNumber(key: string, defaultValue: number): number;
  154850. /**
  154851. * Writes a number to the data storage
  154852. * @param key The key to write
  154853. * @param value The value to write
  154854. */
  154855. static WriteNumber(key: string, value: number): void;
  154856. }
  154857. }
  154858. declare module BABYLON {
  154859. /**
  154860. * Class used to record delta files between 2 scene states
  154861. */
  154862. export class SceneRecorder {
  154863. private _trackedScene;
  154864. private _savedJSON;
  154865. /**
  154866. * Track a given scene. This means the current scene state will be considered the original state
  154867. * @param scene defines the scene to track
  154868. */
  154869. track(scene: Scene): void;
  154870. /**
  154871. * Get the delta between current state and original state
  154872. * @returns a string containing the delta
  154873. */
  154874. getDelta(): any;
  154875. private _compareArray;
  154876. private _compareObjects;
  154877. private _compareCollections;
  154878. private static GetShadowGeneratorById;
  154879. /**
  154880. * Apply a given delta to a given scene
  154881. * @param deltaJSON defines the JSON containing the delta
  154882. * @param scene defines the scene to apply the delta to
  154883. */
  154884. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154885. private static _ApplyPropertiesToEntity;
  154886. private static _ApplyDeltaForEntity;
  154887. }
  154888. }
  154889. declare module BABYLON {
  154890. /**
  154891. * A 3D trajectory consisting of an order list of vectors describing a
  154892. * path of motion through 3D space.
  154893. */
  154894. export class Trajectory {
  154895. private _points;
  154896. private readonly _segmentLength;
  154897. /**
  154898. * Serialize to JSON.
  154899. * @returns serialized JSON string
  154900. */
  154901. serialize(): string;
  154902. /**
  154903. * Deserialize from JSON.
  154904. * @param json serialized JSON string
  154905. * @returns deserialized Trajectory
  154906. */
  154907. static Deserialize(json: string): Trajectory;
  154908. /**
  154909. * Create a new empty Trajectory.
  154910. * @param segmentLength radius of discretization for Trajectory points
  154911. */
  154912. constructor(segmentLength?: number);
  154913. /**
  154914. * Get the length of the Trajectory.
  154915. * @returns length of the Trajectory
  154916. */
  154917. getLength(): number;
  154918. /**
  154919. * Append a new point to the Trajectory.
  154920. * NOTE: This implementation has many allocations.
  154921. * @param point point to append to the Trajectory
  154922. */
  154923. add(point: DeepImmutable<Vector3>): void;
  154924. /**
  154925. * Create a new Trajectory with a segment length chosen to make it
  154926. * probable that the new Trajectory will have a specified number of
  154927. * segments. This operation is imprecise.
  154928. * @param targetResolution number of segments desired
  154929. * @returns new Trajectory with approximately the requested number of segments
  154930. */
  154931. resampleAtTargetResolution(targetResolution: number): Trajectory;
  154932. /**
  154933. * Convert Trajectory segments into tokenized representation. This
  154934. * representation is an array of numbers where each nth number is the
  154935. * index of the token which is most similar to the nth segment of the
  154936. * Trajectory.
  154937. * @param tokens list of vectors which serve as discrete tokens
  154938. * @returns list of indices of most similar token per segment
  154939. */
  154940. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  154941. private static _forwardDir;
  154942. private static _inverseFromVec;
  154943. private static _upDir;
  154944. private static _fromToVec;
  154945. private static _lookMatrix;
  154946. /**
  154947. * Transform the rotation (i.e., direction) of a segment to isolate
  154948. * the relative transformation represented by the segment. This operation
  154949. * may or may not succeed due to singularities in the equations that define
  154950. * motion relativity in this context.
  154951. * @param priorVec the origin of the prior segment
  154952. * @param fromVec the origin of the current segment
  154953. * @param toVec the destination of the current segment
  154954. * @param result reference to output variable
  154955. * @returns whether or not transformation was successful
  154956. */
  154957. private static _transformSegmentDirToRef;
  154958. private static _bestMatch;
  154959. private static _score;
  154960. private static _bestScore;
  154961. /**
  154962. * Determine which token vector is most similar to the
  154963. * segment vector.
  154964. * @param segment segment vector
  154965. * @param tokens token vector list
  154966. * @returns index of the most similar token to the segment
  154967. */
  154968. private static _tokenizeSegment;
  154969. }
  154970. /**
  154971. * Class representing a set of known, named trajectories to which Trajectories can be
  154972. * added and using which Trajectories can be recognized.
  154973. */
  154974. export class TrajectoryClassifier {
  154975. private _maximumAllowableMatchCost;
  154976. private _vector3Alphabet;
  154977. private _levenshteinAlphabet;
  154978. private _nameToDescribedTrajectory;
  154979. /**
  154980. * Serialize to JSON.
  154981. * @returns JSON serialization
  154982. */
  154983. serialize(): string;
  154984. /**
  154985. * Deserialize from JSON.
  154986. * @param json JSON serialization
  154987. * @returns deserialized TrajectorySet
  154988. */
  154989. static Deserialize(json: string): TrajectoryClassifier;
  154990. /**
  154991. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  154992. * VERY naive, need to be generating these things from known
  154993. * sets. Better version later, probably eliminating this one.
  154994. * @returns auto-generated TrajectorySet
  154995. */
  154996. static Generate(): TrajectoryClassifier;
  154997. private constructor();
  154998. /**
  154999. * Add a new Trajectory to the set with a given name.
  155000. * @param trajectory new Trajectory to be added
  155001. * @param classification name to which to add the Trajectory
  155002. */
  155003. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155004. /**
  155005. * Remove a known named trajectory and all Trajectories associated with it.
  155006. * @param classification name to remove
  155007. * @returns whether anything was removed
  155008. */
  155009. deleteClassification(classification: string): boolean;
  155010. /**
  155011. * Attempt to recognize a Trajectory from among all the classifications
  155012. * already known to the classifier.
  155013. * @param trajectory Trajectory to be recognized
  155014. * @returns classification of Trajectory if recognized, null otherwise
  155015. */
  155016. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155017. }
  155018. }
  155019. declare module BABYLON {
  155020. /**
  155021. * An interface for all Hit test features
  155022. */
  155023. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155024. /**
  155025. * Triggered when new babylon (transformed) hit test results are available
  155026. */
  155027. onHitTestResultObservable: Observable<T[]>;
  155028. }
  155029. /**
  155030. * Options used for hit testing
  155031. */
  155032. export interface IWebXRLegacyHitTestOptions {
  155033. /**
  155034. * Only test when user interacted with the scene. Default - hit test every frame
  155035. */
  155036. testOnPointerDownOnly?: boolean;
  155037. /**
  155038. * The node to use to transform the local results to world coordinates
  155039. */
  155040. worldParentNode?: TransformNode;
  155041. }
  155042. /**
  155043. * Interface defining the babylon result of raycasting/hit-test
  155044. */
  155045. export interface IWebXRLegacyHitResult {
  155046. /**
  155047. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155048. */
  155049. transformationMatrix: Matrix;
  155050. /**
  155051. * The native hit test result
  155052. */
  155053. xrHitResult: XRHitResult | XRHitTestResult;
  155054. }
  155055. /**
  155056. * The currently-working hit-test module.
  155057. * Hit test (or Ray-casting) is used to interact with the real world.
  155058. * For further information read here - https://github.com/immersive-web/hit-test
  155059. */
  155060. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155061. /**
  155062. * options to use when constructing this feature
  155063. */
  155064. readonly options: IWebXRLegacyHitTestOptions;
  155065. private _direction;
  155066. private _mat;
  155067. private _onSelectEnabled;
  155068. private _origin;
  155069. /**
  155070. * The module's name
  155071. */
  155072. static readonly Name: string;
  155073. /**
  155074. * The (Babylon) version of this module.
  155075. * This is an integer representing the implementation version.
  155076. * This number does not correspond to the WebXR specs version
  155077. */
  155078. static readonly Version: number;
  155079. /**
  155080. * Populated with the last native XR Hit Results
  155081. */
  155082. lastNativeXRHitResults: XRHitResult[];
  155083. /**
  155084. * Triggered when new babylon (transformed) hit test results are available
  155085. */
  155086. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155087. /**
  155088. * Creates a new instance of the (legacy version) hit test feature
  155089. * @param _xrSessionManager an instance of WebXRSessionManager
  155090. * @param options options to use when constructing this feature
  155091. */
  155092. constructor(_xrSessionManager: WebXRSessionManager,
  155093. /**
  155094. * options to use when constructing this feature
  155095. */
  155096. options?: IWebXRLegacyHitTestOptions);
  155097. /**
  155098. * execute a hit test with an XR Ray
  155099. *
  155100. * @param xrSession a native xrSession that will execute this hit test
  155101. * @param xrRay the ray (position and direction) to use for ray-casting
  155102. * @param referenceSpace native XR reference space to use for the hit-test
  155103. * @param filter filter function that will filter the results
  155104. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155105. */
  155106. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155107. /**
  155108. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155109. * @param event the (select) event to use to select with
  155110. * @param referenceSpace the reference space to use for this hit test
  155111. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155112. */
  155113. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155114. /**
  155115. * attach this feature
  155116. * Will usually be called by the features manager
  155117. *
  155118. * @returns true if successful.
  155119. */
  155120. attach(): boolean;
  155121. /**
  155122. * detach this feature.
  155123. * Will usually be called by the features manager
  155124. *
  155125. * @returns true if successful.
  155126. */
  155127. detach(): boolean;
  155128. /**
  155129. * Dispose this feature and all of the resources attached
  155130. */
  155131. dispose(): void;
  155132. protected _onXRFrame(frame: XRFrame): void;
  155133. private _onHitTestResults;
  155134. private _onSelect;
  155135. }
  155136. }
  155137. declare module BABYLON {
  155138. /**
  155139. * Options used for hit testing (version 2)
  155140. */
  155141. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155142. /**
  155143. * Do not create a permanent hit test. Will usually be used when only
  155144. * transient inputs are needed.
  155145. */
  155146. disablePermanentHitTest?: boolean;
  155147. /**
  155148. * Enable transient (for example touch-based) hit test inspections
  155149. */
  155150. enableTransientHitTest?: boolean;
  155151. /**
  155152. * Offset ray for the permanent hit test
  155153. */
  155154. offsetRay?: Vector3;
  155155. /**
  155156. * Offset ray for the transient hit test
  155157. */
  155158. transientOffsetRay?: Vector3;
  155159. /**
  155160. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155161. */
  155162. useReferenceSpace?: boolean;
  155163. /**
  155164. * Override the default entity type(s) of the hit-test result
  155165. */
  155166. entityTypes?: XRHitTestTrackableType[];
  155167. }
  155168. /**
  155169. * Interface defining the babylon result of hit-test
  155170. */
  155171. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155172. /**
  155173. * The input source that generated this hit test (if transient)
  155174. */
  155175. inputSource?: XRInputSource;
  155176. /**
  155177. * Is this a transient hit test
  155178. */
  155179. isTransient?: boolean;
  155180. /**
  155181. * Position of the hit test result
  155182. */
  155183. position: Vector3;
  155184. /**
  155185. * Rotation of the hit test result
  155186. */
  155187. rotationQuaternion: Quaternion;
  155188. /**
  155189. * The native hit test result
  155190. */
  155191. xrHitResult: XRHitTestResult;
  155192. }
  155193. /**
  155194. * The currently-working hit-test module.
  155195. * Hit test (or Ray-casting) is used to interact with the real world.
  155196. * For further information read here - https://github.com/immersive-web/hit-test
  155197. *
  155198. * Tested on chrome (mobile) 80.
  155199. */
  155200. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155201. /**
  155202. * options to use when constructing this feature
  155203. */
  155204. readonly options: IWebXRHitTestOptions;
  155205. private _tmpMat;
  155206. private _tmpPos;
  155207. private _tmpQuat;
  155208. private _transientXrHitTestSource;
  155209. private _xrHitTestSource;
  155210. private initHitTestSource;
  155211. /**
  155212. * The module's name
  155213. */
  155214. static readonly Name: string;
  155215. /**
  155216. * The (Babylon) version of this module.
  155217. * This is an integer representing the implementation version.
  155218. * This number does not correspond to the WebXR specs version
  155219. */
  155220. static readonly Version: number;
  155221. /**
  155222. * When set to true, each hit test will have its own position/rotation objects
  155223. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155224. * the developers will clone them or copy them as they see fit.
  155225. */
  155226. autoCloneTransformation: boolean;
  155227. /**
  155228. * Triggered when new babylon (transformed) hit test results are available
  155229. * Note - this will be called when results come back from the device. It can be an empty array!!
  155230. */
  155231. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155232. /**
  155233. * Use this to temporarily pause hit test checks.
  155234. */
  155235. paused: boolean;
  155236. /**
  155237. * Creates a new instance of the hit test feature
  155238. * @param _xrSessionManager an instance of WebXRSessionManager
  155239. * @param options options to use when constructing this feature
  155240. */
  155241. constructor(_xrSessionManager: WebXRSessionManager,
  155242. /**
  155243. * options to use when constructing this feature
  155244. */
  155245. options?: IWebXRHitTestOptions);
  155246. /**
  155247. * attach this feature
  155248. * Will usually be called by the features manager
  155249. *
  155250. * @returns true if successful.
  155251. */
  155252. attach(): boolean;
  155253. /**
  155254. * detach this feature.
  155255. * Will usually be called by the features manager
  155256. *
  155257. * @returns true if successful.
  155258. */
  155259. detach(): boolean;
  155260. /**
  155261. * Dispose this feature and all of the resources attached
  155262. */
  155263. dispose(): void;
  155264. protected _onXRFrame(frame: XRFrame): void;
  155265. private _processWebXRHitTestResult;
  155266. }
  155267. }
  155268. declare module BABYLON {
  155269. /**
  155270. * Configuration options of the anchor system
  155271. */
  155272. export interface IWebXRAnchorSystemOptions {
  155273. /**
  155274. * a node that will be used to convert local to world coordinates
  155275. */
  155276. worldParentNode?: TransformNode;
  155277. /**
  155278. * If set to true a reference of the created anchors will be kept until the next session starts
  155279. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155280. */
  155281. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155282. }
  155283. /**
  155284. * A babylon container for an XR Anchor
  155285. */
  155286. export interface IWebXRAnchor {
  155287. /**
  155288. * A babylon-assigned ID for this anchor
  155289. */
  155290. id: number;
  155291. /**
  155292. * Transformation matrix to apply to an object attached to this anchor
  155293. */
  155294. transformationMatrix: Matrix;
  155295. /**
  155296. * The native anchor object
  155297. */
  155298. xrAnchor: XRAnchor;
  155299. /**
  155300. * if defined, this object will be constantly updated by the anchor's position and rotation
  155301. */
  155302. attachedNode?: TransformNode;
  155303. }
  155304. /**
  155305. * An implementation of the anchor system for WebXR.
  155306. * For further information see https://github.com/immersive-web/anchors/
  155307. */
  155308. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155309. private _options;
  155310. private _lastFrameDetected;
  155311. private _trackedAnchors;
  155312. private _referenceSpaceForFrameAnchors;
  155313. private _futureAnchors;
  155314. /**
  155315. * The module's name
  155316. */
  155317. static readonly Name: string;
  155318. /**
  155319. * The (Babylon) version of this module.
  155320. * This is an integer representing the implementation version.
  155321. * This number does not correspond to the WebXR specs version
  155322. */
  155323. static readonly Version: number;
  155324. /**
  155325. * Observers registered here will be executed when a new anchor was added to the session
  155326. */
  155327. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155328. /**
  155329. * Observers registered here will be executed when an anchor was removed from the session
  155330. */
  155331. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155332. /**
  155333. * Observers registered here will be executed when an existing anchor updates
  155334. * This can execute N times every frame
  155335. */
  155336. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155337. /**
  155338. * Set the reference space to use for anchor creation, when not using a hit test.
  155339. * Will default to the session's reference space if not defined
  155340. */
  155341. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155342. /**
  155343. * constructs a new anchor system
  155344. * @param _xrSessionManager an instance of WebXRSessionManager
  155345. * @param _options configuration object for this feature
  155346. */
  155347. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155348. private _tmpVector;
  155349. private _tmpQuaternion;
  155350. private _populateTmpTransformation;
  155351. /**
  155352. * Create a new anchor point using a hit test result at a specific point in the scene
  155353. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155354. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155355. *
  155356. * @param hitTestResult The hit test result to use for this anchor creation
  155357. * @param position an optional position offset for this anchor
  155358. * @param rotationQuaternion an optional rotation offset for this anchor
  155359. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155360. */
  155361. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155362. /**
  155363. * Add a new anchor at a specific position and rotation
  155364. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155365. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155366. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155367. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155368. *
  155369. * @param position the position in which to add an anchor
  155370. * @param rotationQuaternion an optional rotation for the anchor transformation
  155371. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155372. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155373. */
  155374. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155375. /**
  155376. * detach this feature.
  155377. * Will usually be called by the features manager
  155378. *
  155379. * @returns true if successful.
  155380. */
  155381. detach(): boolean;
  155382. /**
  155383. * Dispose this feature and all of the resources attached
  155384. */
  155385. dispose(): void;
  155386. protected _onXRFrame(frame: XRFrame): void;
  155387. /**
  155388. * avoiding using Array.find for global support.
  155389. * @param xrAnchor the plane to find in the array
  155390. */
  155391. private _findIndexInAnchorArray;
  155392. private _updateAnchorWithXRFrame;
  155393. private _createAnchorAtTransformation;
  155394. }
  155395. }
  155396. declare module BABYLON {
  155397. /**
  155398. * Options used in the plane detector module
  155399. */
  155400. export interface IWebXRPlaneDetectorOptions {
  155401. /**
  155402. * The node to use to transform the local results to world coordinates
  155403. */
  155404. worldParentNode?: TransformNode;
  155405. /**
  155406. * If set to true a reference of the created planes will be kept until the next session starts
  155407. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155408. */
  155409. doNotRemovePlanesOnSessionEnded?: boolean;
  155410. }
  155411. /**
  155412. * A babylon interface for a WebXR plane.
  155413. * A Plane is actually a polygon, built from N points in space
  155414. *
  155415. * Supported in chrome 79, not supported in canary 81 ATM
  155416. */
  155417. export interface IWebXRPlane {
  155418. /**
  155419. * a babylon-assigned ID for this polygon
  155420. */
  155421. id: number;
  155422. /**
  155423. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155424. */
  155425. polygonDefinition: Array<Vector3>;
  155426. /**
  155427. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155428. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155429. */
  155430. transformationMatrix: Matrix;
  155431. /**
  155432. * the native xr-plane object
  155433. */
  155434. xrPlane: XRPlane;
  155435. }
  155436. /**
  155437. * The plane detector is used to detect planes in the real world when in AR
  155438. * For more information see https://github.com/immersive-web/real-world-geometry/
  155439. */
  155440. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155441. private _options;
  155442. private _detectedPlanes;
  155443. private _enabled;
  155444. private _lastFrameDetected;
  155445. /**
  155446. * The module's name
  155447. */
  155448. static readonly Name: string;
  155449. /**
  155450. * The (Babylon) version of this module.
  155451. * This is an integer representing the implementation version.
  155452. * This number does not correspond to the WebXR specs version
  155453. */
  155454. static readonly Version: number;
  155455. /**
  155456. * Observers registered here will be executed when a new plane was added to the session
  155457. */
  155458. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155459. /**
  155460. * Observers registered here will be executed when a plane is no longer detected in the session
  155461. */
  155462. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155463. /**
  155464. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155465. * This can execute N times every frame
  155466. */
  155467. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155468. /**
  155469. * construct a new Plane Detector
  155470. * @param _xrSessionManager an instance of xr Session manager
  155471. * @param _options configuration to use when constructing this feature
  155472. */
  155473. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155474. /**
  155475. * detach this feature.
  155476. * Will usually be called by the features manager
  155477. *
  155478. * @returns true if successful.
  155479. */
  155480. detach(): boolean;
  155481. /**
  155482. * Dispose this feature and all of the resources attached
  155483. */
  155484. dispose(): void;
  155485. protected _onXRFrame(frame: XRFrame): void;
  155486. private _init;
  155487. private _updatePlaneWithXRPlane;
  155488. /**
  155489. * avoiding using Array.find for global support.
  155490. * @param xrPlane the plane to find in the array
  155491. */
  155492. private findIndexInPlaneArray;
  155493. }
  155494. }
  155495. declare module BABYLON {
  155496. /**
  155497. * Options interface for the background remover plugin
  155498. */
  155499. export interface IWebXRBackgroundRemoverOptions {
  155500. /**
  155501. * Further background meshes to disable when entering AR
  155502. */
  155503. backgroundMeshes?: AbstractMesh[];
  155504. /**
  155505. * flags to configure the removal of the environment helper.
  155506. * If not set, the entire background will be removed. If set, flags should be set as well.
  155507. */
  155508. environmentHelperRemovalFlags?: {
  155509. /**
  155510. * Should the skybox be removed (default false)
  155511. */
  155512. skyBox?: boolean;
  155513. /**
  155514. * Should the ground be removed (default false)
  155515. */
  155516. ground?: boolean;
  155517. };
  155518. /**
  155519. * don't disable the environment helper
  155520. */
  155521. ignoreEnvironmentHelper?: boolean;
  155522. }
  155523. /**
  155524. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155525. */
  155526. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155527. /**
  155528. * read-only options to be used in this module
  155529. */
  155530. readonly options: IWebXRBackgroundRemoverOptions;
  155531. /**
  155532. * The module's name
  155533. */
  155534. static readonly Name: string;
  155535. /**
  155536. * The (Babylon) version of this module.
  155537. * This is an integer representing the implementation version.
  155538. * This number does not correspond to the WebXR specs version
  155539. */
  155540. static readonly Version: number;
  155541. /**
  155542. * registered observers will be triggered when the background state changes
  155543. */
  155544. onBackgroundStateChangedObservable: Observable<boolean>;
  155545. /**
  155546. * constructs a new background remover module
  155547. * @param _xrSessionManager the session manager for this module
  155548. * @param options read-only options to be used in this module
  155549. */
  155550. constructor(_xrSessionManager: WebXRSessionManager,
  155551. /**
  155552. * read-only options to be used in this module
  155553. */
  155554. options?: IWebXRBackgroundRemoverOptions);
  155555. /**
  155556. * attach this feature
  155557. * Will usually be called by the features manager
  155558. *
  155559. * @returns true if successful.
  155560. */
  155561. attach(): boolean;
  155562. /**
  155563. * detach this feature.
  155564. * Will usually be called by the features manager
  155565. *
  155566. * @returns true if successful.
  155567. */
  155568. detach(): boolean;
  155569. /**
  155570. * Dispose this feature and all of the resources attached
  155571. */
  155572. dispose(): void;
  155573. protected _onXRFrame(_xrFrame: XRFrame): void;
  155574. private _setBackgroundState;
  155575. }
  155576. }
  155577. declare module BABYLON {
  155578. /**
  155579. * Options for the controller physics feature
  155580. */
  155581. export class IWebXRControllerPhysicsOptions {
  155582. /**
  155583. * Should the headset get its own impostor
  155584. */
  155585. enableHeadsetImpostor?: boolean;
  155586. /**
  155587. * Optional parameters for the headset impostor
  155588. */
  155589. headsetImpostorParams?: {
  155590. /**
  155591. * The type of impostor to create. Default is sphere
  155592. */
  155593. impostorType: number;
  155594. /**
  155595. * the size of the impostor. Defaults to 10cm
  155596. */
  155597. impostorSize?: number | {
  155598. width: number;
  155599. height: number;
  155600. depth: number;
  155601. };
  155602. /**
  155603. * Friction definitions
  155604. */
  155605. friction?: number;
  155606. /**
  155607. * Restitution
  155608. */
  155609. restitution?: number;
  155610. };
  155611. /**
  155612. * The physics properties of the future impostors
  155613. */
  155614. physicsProperties?: {
  155615. /**
  155616. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155617. * Note that this requires a physics engine that supports mesh impostors!
  155618. */
  155619. useControllerMesh?: boolean;
  155620. /**
  155621. * The type of impostor to create. Default is sphere
  155622. */
  155623. impostorType?: number;
  155624. /**
  155625. * the size of the impostor. Defaults to 10cm
  155626. */
  155627. impostorSize?: number | {
  155628. width: number;
  155629. height: number;
  155630. depth: number;
  155631. };
  155632. /**
  155633. * Friction definitions
  155634. */
  155635. friction?: number;
  155636. /**
  155637. * Restitution
  155638. */
  155639. restitution?: number;
  155640. };
  155641. /**
  155642. * the xr input to use with this pointer selection
  155643. */
  155644. xrInput: WebXRInput;
  155645. }
  155646. /**
  155647. * Add physics impostor to your webxr controllers,
  155648. * including naive calculation of their linear and angular velocity
  155649. */
  155650. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  155651. private readonly _options;
  155652. private _attachController;
  155653. private _controllers;
  155654. private _debugMode;
  155655. private _delta;
  155656. private _headsetImpostor?;
  155657. private _headsetMesh?;
  155658. private _lastTimestamp;
  155659. private _tmpQuaternion;
  155660. private _tmpVector;
  155661. /**
  155662. * The module's name
  155663. */
  155664. static readonly Name: string;
  155665. /**
  155666. * The (Babylon) version of this module.
  155667. * This is an integer representing the implementation version.
  155668. * This number does not correspond to the webxr specs version
  155669. */
  155670. static readonly Version: number;
  155671. /**
  155672. * Construct a new Controller Physics Feature
  155673. * @param _xrSessionManager the corresponding xr session manager
  155674. * @param _options options to create this feature with
  155675. */
  155676. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  155677. /**
  155678. * @hidden
  155679. * enable debugging - will show console outputs and the impostor mesh
  155680. */
  155681. _enablePhysicsDebug(): void;
  155682. /**
  155683. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  155684. * @param xrController the controller to add
  155685. */
  155686. addController(xrController: WebXRInputSource): void;
  155687. /**
  155688. * attach this feature
  155689. * Will usually be called by the features manager
  155690. *
  155691. * @returns true if successful.
  155692. */
  155693. attach(): boolean;
  155694. /**
  155695. * detach this feature.
  155696. * Will usually be called by the features manager
  155697. *
  155698. * @returns true if successful.
  155699. */
  155700. detach(): boolean;
  155701. /**
  155702. * Get the headset impostor, if enabled
  155703. * @returns the impostor
  155704. */
  155705. getHeadsetImpostor(): PhysicsImpostor | undefined;
  155706. /**
  155707. * Get the physics impostor of a specific controller.
  155708. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  155709. * @param controller the controller or the controller id of which to get the impostor
  155710. * @returns the impostor or null
  155711. */
  155712. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  155713. /**
  155714. * Update the physics properties provided in the constructor
  155715. * @param newProperties the new properties object
  155716. */
  155717. setPhysicsProperties(newProperties: {
  155718. impostorType?: number;
  155719. impostorSize?: number | {
  155720. width: number;
  155721. height: number;
  155722. depth: number;
  155723. };
  155724. friction?: number;
  155725. restitution?: number;
  155726. }): void;
  155727. protected _onXRFrame(_xrFrame: any): void;
  155728. private _detachController;
  155729. }
  155730. }
  155731. declare module BABYLON {
  155732. /**
  155733. * A babylon interface for a "WebXR" feature point.
  155734. * Represents the position and confidence value of a given feature point.
  155735. */
  155736. export interface IWebXRFeaturePoint {
  155737. /**
  155738. * Represents the position of the feature point in world space.
  155739. */
  155740. position: Vector3;
  155741. /**
  155742. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  155743. */
  155744. confidenceValue: number;
  155745. }
  155746. /**
  155747. * The feature point system is used to detect feature points from real world geometry.
  155748. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  155749. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  155750. */
  155751. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  155752. private _enabled;
  155753. private _featurePointCloud;
  155754. /**
  155755. * The module's name
  155756. */
  155757. static readonly Name: string;
  155758. /**
  155759. * The (Babylon) version of this module.
  155760. * This is an integer representing the implementation version.
  155761. * This number does not correspond to the WebXR specs version
  155762. */
  155763. static readonly Version: number;
  155764. /**
  155765. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155766. * Will notify the observers about which feature points have been added.
  155767. */
  155768. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155769. /**
  155770. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155771. * Will notify the observers about which feature points have been updated.
  155772. */
  155773. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155774. /**
  155775. * The current feature point cloud maintained across frames.
  155776. */
  155777. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155778. /**
  155779. * construct the feature point system
  155780. * @param _xrSessionManager an instance of xr Session manager
  155781. */
  155782. constructor(_xrSessionManager: WebXRSessionManager);
  155783. /**
  155784. * Detach this feature.
  155785. * Will usually be called by the features manager
  155786. *
  155787. * @returns true if successful.
  155788. */
  155789. detach(): boolean;
  155790. /**
  155791. * Dispose this feature and all of the resources attached
  155792. */
  155793. dispose(): void;
  155794. /**
  155795. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155796. */
  155797. protected _onXRFrame(frame: XRFrame): void;
  155798. /**
  155799. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155800. */
  155801. private _init;
  155802. }
  155803. }
  155804. declare module BABYLON {
  155805. /**
  155806. * Configuration interface for the hand tracking feature
  155807. */
  155808. export interface IWebXRHandTrackingOptions {
  155809. /**
  155810. * The xrInput that will be used as source for new hands
  155811. */
  155812. xrInput: WebXRInput;
  155813. /**
  155814. * Configuration object for the joint meshes
  155815. */
  155816. jointMeshes?: {
  155817. /**
  155818. * Should the meshes created be invisible (defaults to false)
  155819. */
  155820. invisible?: boolean;
  155821. /**
  155822. * A source mesh to be used to create instances. Defaults to a sphere.
  155823. * This mesh will be the source for all other (25) meshes.
  155824. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155825. */
  155826. sourceMesh?: Mesh;
  155827. /**
  155828. * Should the source mesh stay visible. Defaults to false
  155829. */
  155830. keepOriginalVisible?: boolean;
  155831. /**
  155832. * Scale factor for all instances (defaults to 2)
  155833. */
  155834. scaleFactor?: number;
  155835. /**
  155836. * Should each instance have its own physics impostor
  155837. */
  155838. enablePhysics?: boolean;
  155839. /**
  155840. * If enabled, override default physics properties
  155841. */
  155842. physicsProps?: {
  155843. friction?: number;
  155844. restitution?: number;
  155845. impostorType?: number;
  155846. };
  155847. /**
  155848. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155849. */
  155850. handMesh?: AbstractMesh;
  155851. };
  155852. }
  155853. /**
  155854. * Parts of the hands divided to writs and finger names
  155855. */
  155856. export const enum HandPart {
  155857. /**
  155858. * HandPart - Wrist
  155859. */
  155860. WRIST = "wrist",
  155861. /**
  155862. * HandPart - The THumb
  155863. */
  155864. THUMB = "thumb",
  155865. /**
  155866. * HandPart - Index finger
  155867. */
  155868. INDEX = "index",
  155869. /**
  155870. * HandPart - Middle finger
  155871. */
  155872. MIDDLE = "middle",
  155873. /**
  155874. * HandPart - Ring finger
  155875. */
  155876. RING = "ring",
  155877. /**
  155878. * HandPart - Little finger
  155879. */
  155880. LITTLE = "little"
  155881. }
  155882. /**
  155883. * Representing a single hand (with its corresponding native XRHand object)
  155884. */
  155885. export class WebXRHand implements IDisposable {
  155886. /** the controller to which the hand correlates */
  155887. readonly xrController: WebXRInputSource;
  155888. /** the meshes to be used to track the hand joints */
  155889. readonly trackedMeshes: AbstractMesh[];
  155890. /**
  155891. * Hand-parts definition (key is HandPart)
  155892. */
  155893. handPartsDefinition: {
  155894. [key: string]: number[];
  155895. };
  155896. /**
  155897. * Populate the HandPartsDefinition object.
  155898. * This is called as a side effect since certain browsers don't have XRHand defined.
  155899. */
  155900. private generateHandPartsDefinition;
  155901. /**
  155902. * Construct a new hand object
  155903. * @param xrController the controller to which the hand correlates
  155904. * @param trackedMeshes the meshes to be used to track the hand joints
  155905. */
  155906. constructor(
  155907. /** the controller to which the hand correlates */
  155908. xrController: WebXRInputSource,
  155909. /** the meshes to be used to track the hand joints */
  155910. trackedMeshes: AbstractMesh[]);
  155911. /**
  155912. * Update this hand from the latest xr frame
  155913. * @param xrFrame xrFrame to update from
  155914. * @param referenceSpace The current viewer reference space
  155915. * @param scaleFactor optional scale factor for the meshes
  155916. */
  155917. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155918. /**
  155919. * Get meshes of part of the hand
  155920. * @param part the part of hand to get
  155921. * @returns An array of meshes that correlate to the hand part requested
  155922. */
  155923. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155924. /**
  155925. * Dispose this Hand object
  155926. */
  155927. dispose(): void;
  155928. }
  155929. /**
  155930. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155931. */
  155932. export class WebXRHandTracking extends WebXRAbstractFeature {
  155933. /**
  155934. * options to use when constructing this feature
  155935. */
  155936. readonly options: IWebXRHandTrackingOptions;
  155937. private static _idCounter;
  155938. /**
  155939. * The module's name
  155940. */
  155941. static readonly Name: string;
  155942. /**
  155943. * The (Babylon) version of this module.
  155944. * This is an integer representing the implementation version.
  155945. * This number does not correspond to the WebXR specs version
  155946. */
  155947. static readonly Version: number;
  155948. /**
  155949. * This observable will notify registered observers when a new hand object was added and initialized
  155950. */
  155951. onHandAddedObservable: Observable<WebXRHand>;
  155952. /**
  155953. * This observable will notify its observers right before the hand object is disposed
  155954. */
  155955. onHandRemovedObservable: Observable<WebXRHand>;
  155956. private _hands;
  155957. /**
  155958. * Creates a new instance of the hit test feature
  155959. * @param _xrSessionManager an instance of WebXRSessionManager
  155960. * @param options options to use when constructing this feature
  155961. */
  155962. constructor(_xrSessionManager: WebXRSessionManager,
  155963. /**
  155964. * options to use when constructing this feature
  155965. */
  155966. options: IWebXRHandTrackingOptions);
  155967. /**
  155968. * Check if the needed objects are defined.
  155969. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155970. */
  155971. isCompatible(): boolean;
  155972. /**
  155973. * attach this feature
  155974. * Will usually be called by the features manager
  155975. *
  155976. * @returns true if successful.
  155977. */
  155978. attach(): boolean;
  155979. /**
  155980. * detach this feature.
  155981. * Will usually be called by the features manager
  155982. *
  155983. * @returns true if successful.
  155984. */
  155985. detach(): boolean;
  155986. /**
  155987. * Dispose this feature and all of the resources attached
  155988. */
  155989. dispose(): void;
  155990. /**
  155991. * Get the hand object according to the controller id
  155992. * @param controllerId the controller id to which we want to get the hand
  155993. * @returns null if not found or the WebXRHand object if found
  155994. */
  155995. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155996. /**
  155997. * Get a hand object according to the requested handedness
  155998. * @param handedness the handedness to request
  155999. * @returns null if not found or the WebXRHand object if found
  156000. */
  156001. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156002. protected _onXRFrame(_xrFrame: XRFrame): void;
  156003. private _attachHand;
  156004. private _detachHand;
  156005. }
  156006. }
  156007. declare module BABYLON {
  156008. /**
  156009. * The motion controller class for all microsoft mixed reality controllers
  156010. */
  156011. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156012. protected readonly _mapping: {
  156013. defaultButton: {
  156014. valueNodeName: string;
  156015. unpressedNodeName: string;
  156016. pressedNodeName: string;
  156017. };
  156018. defaultAxis: {
  156019. valueNodeName: string;
  156020. minNodeName: string;
  156021. maxNodeName: string;
  156022. };
  156023. buttons: {
  156024. "xr-standard-trigger": {
  156025. rootNodeName: string;
  156026. componentProperty: string;
  156027. states: string[];
  156028. };
  156029. "xr-standard-squeeze": {
  156030. rootNodeName: string;
  156031. componentProperty: string;
  156032. states: string[];
  156033. };
  156034. "xr-standard-touchpad": {
  156035. rootNodeName: string;
  156036. labelAnchorNodeName: string;
  156037. touchPointNodeName: string;
  156038. };
  156039. "xr-standard-thumbstick": {
  156040. rootNodeName: string;
  156041. componentProperty: string;
  156042. states: string[];
  156043. };
  156044. };
  156045. axes: {
  156046. "xr-standard-touchpad": {
  156047. "x-axis": {
  156048. rootNodeName: string;
  156049. };
  156050. "y-axis": {
  156051. rootNodeName: string;
  156052. };
  156053. };
  156054. "xr-standard-thumbstick": {
  156055. "x-axis": {
  156056. rootNodeName: string;
  156057. };
  156058. "y-axis": {
  156059. rootNodeName: string;
  156060. };
  156061. };
  156062. };
  156063. };
  156064. /**
  156065. * The base url used to load the left and right controller models
  156066. */
  156067. static MODEL_BASE_URL: string;
  156068. /**
  156069. * The name of the left controller model file
  156070. */
  156071. static MODEL_LEFT_FILENAME: string;
  156072. /**
  156073. * The name of the right controller model file
  156074. */
  156075. static MODEL_RIGHT_FILENAME: string;
  156076. profileId: string;
  156077. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156078. protected _getFilenameAndPath(): {
  156079. filename: string;
  156080. path: string;
  156081. };
  156082. protected _getModelLoadingConstraints(): boolean;
  156083. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156084. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156085. protected _updateModel(): void;
  156086. }
  156087. }
  156088. declare module BABYLON {
  156089. /**
  156090. * The motion controller class for oculus touch (quest, rift).
  156091. * This class supports legacy mapping as well the standard xr mapping
  156092. */
  156093. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156094. private _forceLegacyControllers;
  156095. private _modelRootNode;
  156096. /**
  156097. * The base url used to load the left and right controller models
  156098. */
  156099. static MODEL_BASE_URL: string;
  156100. /**
  156101. * The name of the left controller model file
  156102. */
  156103. static MODEL_LEFT_FILENAME: string;
  156104. /**
  156105. * The name of the right controller model file
  156106. */
  156107. static MODEL_RIGHT_FILENAME: string;
  156108. /**
  156109. * Base Url for the Quest controller model.
  156110. */
  156111. static QUEST_MODEL_BASE_URL: string;
  156112. profileId: string;
  156113. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156114. protected _getFilenameAndPath(): {
  156115. filename: string;
  156116. path: string;
  156117. };
  156118. protected _getModelLoadingConstraints(): boolean;
  156119. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156120. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156121. protected _updateModel(): void;
  156122. /**
  156123. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156124. * between the touch and touch 2.
  156125. */
  156126. private _isQuest;
  156127. }
  156128. }
  156129. declare module BABYLON {
  156130. /**
  156131. * The motion controller class for the standard HTC-Vive controllers
  156132. */
  156133. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156134. private _modelRootNode;
  156135. /**
  156136. * The base url used to load the left and right controller models
  156137. */
  156138. static MODEL_BASE_URL: string;
  156139. /**
  156140. * File name for the controller model.
  156141. */
  156142. static MODEL_FILENAME: string;
  156143. profileId: string;
  156144. /**
  156145. * Create a new Vive motion controller object
  156146. * @param scene the scene to use to create this controller
  156147. * @param gamepadObject the corresponding gamepad object
  156148. * @param handedness the handedness of the controller
  156149. */
  156150. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156151. protected _getFilenameAndPath(): {
  156152. filename: string;
  156153. path: string;
  156154. };
  156155. protected _getModelLoadingConstraints(): boolean;
  156156. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156157. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156158. protected _updateModel(): void;
  156159. }
  156160. }
  156161. declare module BABYLON {
  156162. /**
  156163. * A cursor which tracks a point on a path
  156164. */
  156165. export class PathCursor {
  156166. private path;
  156167. /**
  156168. * Stores path cursor callbacks for when an onchange event is triggered
  156169. */
  156170. private _onchange;
  156171. /**
  156172. * The value of the path cursor
  156173. */
  156174. value: number;
  156175. /**
  156176. * The animation array of the path cursor
  156177. */
  156178. animations: Animation[];
  156179. /**
  156180. * Initializes the path cursor
  156181. * @param path The path to track
  156182. */
  156183. constructor(path: Path2);
  156184. /**
  156185. * Gets the cursor point on the path
  156186. * @returns A point on the path cursor at the cursor location
  156187. */
  156188. getPoint(): Vector3;
  156189. /**
  156190. * Moves the cursor ahead by the step amount
  156191. * @param step The amount to move the cursor forward
  156192. * @returns This path cursor
  156193. */
  156194. moveAhead(step?: number): PathCursor;
  156195. /**
  156196. * Moves the cursor behind by the step amount
  156197. * @param step The amount to move the cursor back
  156198. * @returns This path cursor
  156199. */
  156200. moveBack(step?: number): PathCursor;
  156201. /**
  156202. * Moves the cursor by the step amount
  156203. * If the step amount is greater than one, an exception is thrown
  156204. * @param step The amount to move the cursor
  156205. * @returns This path cursor
  156206. */
  156207. move(step: number): PathCursor;
  156208. /**
  156209. * Ensures that the value is limited between zero and one
  156210. * @returns This path cursor
  156211. */
  156212. private ensureLimits;
  156213. /**
  156214. * Runs onchange callbacks on change (used by the animation engine)
  156215. * @returns This path cursor
  156216. */
  156217. private raiseOnChange;
  156218. /**
  156219. * Executes a function on change
  156220. * @param f A path cursor onchange callback
  156221. * @returns This path cursor
  156222. */
  156223. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156224. }
  156225. }
  156226. declare module BABYLON {
  156227. /** @hidden */
  156228. export var blurPixelShader: {
  156229. name: string;
  156230. shader: string;
  156231. };
  156232. }
  156233. declare module BABYLON {
  156234. /** @hidden */
  156235. export var pointCloudVertexDeclaration: {
  156236. name: string;
  156237. shader: string;
  156238. };
  156239. }
  156240. // Mixins
  156241. interface Window {
  156242. mozIndexedDB: IDBFactory;
  156243. webkitIndexedDB: IDBFactory;
  156244. msIndexedDB: IDBFactory;
  156245. webkitURL: typeof URL;
  156246. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156247. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156248. WebGLRenderingContext: WebGLRenderingContext;
  156249. MSGesture: MSGesture;
  156250. CANNON: any;
  156251. AudioContext: AudioContext;
  156252. webkitAudioContext: AudioContext;
  156253. PointerEvent: any;
  156254. Math: Math;
  156255. Uint8Array: Uint8ArrayConstructor;
  156256. Float32Array: Float32ArrayConstructor;
  156257. mozURL: typeof URL;
  156258. msURL: typeof URL;
  156259. VRFrameData: any; // WebVR, from specs 1.1
  156260. DracoDecoderModule: any;
  156261. setImmediate(handler: (...args: any[]) => void): number;
  156262. }
  156263. interface HTMLCanvasElement {
  156264. requestPointerLock(): void;
  156265. msRequestPointerLock?(): void;
  156266. mozRequestPointerLock?(): void;
  156267. webkitRequestPointerLock?(): void;
  156268. /** Track wether a record is in progress */
  156269. isRecording: boolean;
  156270. /** Capture Stream method defined by some browsers */
  156271. captureStream(fps?: number): MediaStream;
  156272. }
  156273. interface CanvasRenderingContext2D {
  156274. msImageSmoothingEnabled: boolean;
  156275. }
  156276. interface MouseEvent {
  156277. mozMovementX: number;
  156278. mozMovementY: number;
  156279. webkitMovementX: number;
  156280. webkitMovementY: number;
  156281. msMovementX: number;
  156282. msMovementY: number;
  156283. }
  156284. interface Navigator {
  156285. mozGetVRDevices: (any: any) => any;
  156286. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156287. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156288. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156289. webkitGetGamepads(): Gamepad[];
  156290. msGetGamepads(): Gamepad[];
  156291. webkitGamepads(): Gamepad[];
  156292. }
  156293. interface HTMLVideoElement {
  156294. mozSrcObject: any;
  156295. }
  156296. interface Math {
  156297. fround(x: number): number;
  156298. imul(a: number, b: number): number;
  156299. }
  156300. interface WebGLRenderingContext {
  156301. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156302. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156303. vertexAttribDivisor(index: number, divisor: number): void;
  156304. createVertexArray(): any;
  156305. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156306. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156307. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156308. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156309. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156310. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156311. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156312. // Queries
  156313. createQuery(): WebGLQuery;
  156314. deleteQuery(query: WebGLQuery): void;
  156315. beginQuery(target: number, query: WebGLQuery): void;
  156316. endQuery(target: number): void;
  156317. getQueryParameter(query: WebGLQuery, pname: number): any;
  156318. getQuery(target: number, pname: number): any;
  156319. MAX_SAMPLES: number;
  156320. RGBA8: number;
  156321. READ_FRAMEBUFFER: number;
  156322. DRAW_FRAMEBUFFER: number;
  156323. UNIFORM_BUFFER: number;
  156324. HALF_FLOAT_OES: number;
  156325. RGBA16F: number;
  156326. RGBA32F: number;
  156327. R32F: number;
  156328. RG32F: number;
  156329. RGB32F: number;
  156330. R16F: number;
  156331. RG16F: number;
  156332. RGB16F: number;
  156333. RED: number;
  156334. RG: number;
  156335. R8: number;
  156336. RG8: number;
  156337. UNSIGNED_INT_24_8: number;
  156338. DEPTH24_STENCIL8: number;
  156339. MIN: number;
  156340. MAX: number;
  156341. /* Multiple Render Targets */
  156342. drawBuffers(buffers: number[]): void;
  156343. readBuffer(src: number): void;
  156344. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156345. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156346. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156347. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156348. // Occlusion Query
  156349. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156350. ANY_SAMPLES_PASSED: number;
  156351. QUERY_RESULT_AVAILABLE: number;
  156352. QUERY_RESULT: number;
  156353. }
  156354. interface WebGLProgram {
  156355. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156356. }
  156357. interface EXT_disjoint_timer_query {
  156358. QUERY_COUNTER_BITS_EXT: number;
  156359. TIME_ELAPSED_EXT: number;
  156360. TIMESTAMP_EXT: number;
  156361. GPU_DISJOINT_EXT: number;
  156362. QUERY_RESULT_EXT: number;
  156363. QUERY_RESULT_AVAILABLE_EXT: number;
  156364. queryCounterEXT(query: WebGLQuery, target: number): void;
  156365. createQueryEXT(): WebGLQuery;
  156366. beginQueryEXT(target: number, query: WebGLQuery): void;
  156367. endQueryEXT(target: number): void;
  156368. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156369. deleteQueryEXT(query: WebGLQuery): void;
  156370. }
  156371. interface WebGLUniformLocation {
  156372. _currentState: any;
  156373. }
  156374. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156375. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156376. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156377. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156378. interface WebGLRenderingContext {
  156379. readonly RASTERIZER_DISCARD: number;
  156380. readonly DEPTH_COMPONENT24: number;
  156381. readonly TEXTURE_3D: number;
  156382. readonly TEXTURE_2D_ARRAY: number;
  156383. readonly TEXTURE_COMPARE_FUNC: number;
  156384. readonly TEXTURE_COMPARE_MODE: number;
  156385. readonly COMPARE_REF_TO_TEXTURE: number;
  156386. readonly TEXTURE_WRAP_R: number;
  156387. readonly HALF_FLOAT: number;
  156388. readonly RGB8: number;
  156389. readonly RED_INTEGER: number;
  156390. readonly RG_INTEGER: number;
  156391. readonly RGB_INTEGER: number;
  156392. readonly RGBA_INTEGER: number;
  156393. readonly R8_SNORM: number;
  156394. readonly RG8_SNORM: number;
  156395. readonly RGB8_SNORM: number;
  156396. readonly RGBA8_SNORM: number;
  156397. readonly R8I: number;
  156398. readonly RG8I: number;
  156399. readonly RGB8I: number;
  156400. readonly RGBA8I: number;
  156401. readonly R8UI: number;
  156402. readonly RG8UI: number;
  156403. readonly RGB8UI: number;
  156404. readonly RGBA8UI: number;
  156405. readonly R16I: number;
  156406. readonly RG16I: number;
  156407. readonly RGB16I: number;
  156408. readonly RGBA16I: number;
  156409. readonly R16UI: number;
  156410. readonly RG16UI: number;
  156411. readonly RGB16UI: number;
  156412. readonly RGBA16UI: number;
  156413. readonly R32I: number;
  156414. readonly RG32I: number;
  156415. readonly RGB32I: number;
  156416. readonly RGBA32I: number;
  156417. readonly R32UI: number;
  156418. readonly RG32UI: number;
  156419. readonly RGB32UI: number;
  156420. readonly RGBA32UI: number;
  156421. readonly RGB10_A2UI: number;
  156422. readonly R11F_G11F_B10F: number;
  156423. readonly RGB9_E5: number;
  156424. readonly RGB10_A2: number;
  156425. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156426. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156427. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156428. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156429. readonly DEPTH_COMPONENT32F: number;
  156430. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156431. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156432. 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;
  156433. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156434. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156435. readonly TRANSFORM_FEEDBACK: number;
  156436. readonly INTERLEAVED_ATTRIBS: number;
  156437. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156438. createTransformFeedback(): WebGLTransformFeedback;
  156439. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156440. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156441. beginTransformFeedback(primitiveMode: number): void;
  156442. endTransformFeedback(): void;
  156443. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156444. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156445. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156446. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156447. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156448. }
  156449. interface ImageBitmap {
  156450. readonly width: number;
  156451. readonly height: number;
  156452. close(): void;
  156453. }
  156454. interface WebGLQuery extends WebGLObject {
  156455. }
  156456. declare var WebGLQuery: {
  156457. prototype: WebGLQuery;
  156458. new(): WebGLQuery;
  156459. };
  156460. interface WebGLSampler extends WebGLObject {
  156461. }
  156462. declare var WebGLSampler: {
  156463. prototype: WebGLSampler;
  156464. new(): WebGLSampler;
  156465. };
  156466. interface WebGLSync extends WebGLObject {
  156467. }
  156468. declare var WebGLSync: {
  156469. prototype: WebGLSync;
  156470. new(): WebGLSync;
  156471. };
  156472. interface WebGLTransformFeedback extends WebGLObject {
  156473. }
  156474. declare var WebGLTransformFeedback: {
  156475. prototype: WebGLTransformFeedback;
  156476. new(): WebGLTransformFeedback;
  156477. };
  156478. interface WebGLVertexArrayObject extends WebGLObject {
  156479. }
  156480. declare var WebGLVertexArrayObject: {
  156481. prototype: WebGLVertexArrayObject;
  156482. new(): WebGLVertexArrayObject;
  156483. };
  156484. // Type definitions for WebVR API
  156485. // Project: https://w3c.github.io/webvr/
  156486. // Definitions by: six a <https://github.com/lostfictions>
  156487. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156488. interface VRDisplay extends EventTarget {
  156489. /**
  156490. * Dictionary of capabilities describing the VRDisplay.
  156491. */
  156492. readonly capabilities: VRDisplayCapabilities;
  156493. /**
  156494. * z-depth defining the far plane of the eye view frustum
  156495. * enables mapping of values in the render target depth
  156496. * attachment to scene coordinates. Initially set to 10000.0.
  156497. */
  156498. depthFar: number;
  156499. /**
  156500. * z-depth defining the near plane of the eye view frustum
  156501. * enables mapping of values in the render target depth
  156502. * attachment to scene coordinates. Initially set to 0.01.
  156503. */
  156504. depthNear: number;
  156505. /**
  156506. * An identifier for this distinct VRDisplay. Used as an
  156507. * association point in the Gamepad API.
  156508. */
  156509. readonly displayId: number;
  156510. /**
  156511. * A display name, a user-readable name identifying it.
  156512. */
  156513. readonly displayName: string;
  156514. readonly isConnected: boolean;
  156515. readonly isPresenting: boolean;
  156516. /**
  156517. * If this VRDisplay supports room-scale experiences, the optional
  156518. * stage attribute contains details on the room-scale parameters.
  156519. */
  156520. readonly stageParameters: VRStageParameters | null;
  156521. /**
  156522. * Passing the value returned by `requestAnimationFrame` to
  156523. * `cancelAnimationFrame` will unregister the callback.
  156524. * @param handle Define the hanle of the request to cancel
  156525. */
  156526. cancelAnimationFrame(handle: number): void;
  156527. /**
  156528. * Stops presenting to the VRDisplay.
  156529. * @returns a promise to know when it stopped
  156530. */
  156531. exitPresent(): Promise<void>;
  156532. /**
  156533. * Return the current VREyeParameters for the given eye.
  156534. * @param whichEye Define the eye we want the parameter for
  156535. * @returns the eye parameters
  156536. */
  156537. getEyeParameters(whichEye: string): VREyeParameters;
  156538. /**
  156539. * Populates the passed VRFrameData with the information required to render
  156540. * the current frame.
  156541. * @param frameData Define the data structure to populate
  156542. * @returns true if ok otherwise false
  156543. */
  156544. getFrameData(frameData: VRFrameData): boolean;
  156545. /**
  156546. * Get the layers currently being presented.
  156547. * @returns the list of VR layers
  156548. */
  156549. getLayers(): VRLayer[];
  156550. /**
  156551. * Return a VRPose containing the future predicted pose of the VRDisplay
  156552. * when the current frame will be presented. The value returned will not
  156553. * change until JavaScript has returned control to the browser.
  156554. *
  156555. * The VRPose will contain the position, orientation, velocity,
  156556. * and acceleration of each of these properties.
  156557. * @returns the pose object
  156558. */
  156559. getPose(): VRPose;
  156560. /**
  156561. * Return the current instantaneous pose of the VRDisplay, with no
  156562. * prediction applied.
  156563. * @returns the current instantaneous pose
  156564. */
  156565. getImmediatePose(): VRPose;
  156566. /**
  156567. * The callback passed to `requestAnimationFrame` will be called
  156568. * any time a new frame should be rendered. When the VRDisplay is
  156569. * presenting the callback will be called at the native refresh
  156570. * rate of the HMD. When not presenting this function acts
  156571. * identically to how window.requestAnimationFrame acts. Content should
  156572. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156573. * asynchronously from other displays and at differing refresh rates.
  156574. * @param callback Define the eaction to run next frame
  156575. * @returns the request handle it
  156576. */
  156577. requestAnimationFrame(callback: FrameRequestCallback): number;
  156578. /**
  156579. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156580. * Repeat calls while already presenting will update the VRLayers being displayed.
  156581. * @param layers Define the list of layer to present
  156582. * @returns a promise to know when the request has been fulfilled
  156583. */
  156584. requestPresent(layers: VRLayer[]): Promise<void>;
  156585. /**
  156586. * Reset the pose for this display, treating its current position and
  156587. * orientation as the "origin/zero" values. VRPose.position,
  156588. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156589. * updated when calling resetPose(). This should be called in only
  156590. * sitting-space experiences.
  156591. */
  156592. resetPose(): void;
  156593. /**
  156594. * The VRLayer provided to the VRDisplay will be captured and presented
  156595. * in the HMD. Calling this function has the same effect on the source
  156596. * canvas as any other operation that uses its source image, and canvases
  156597. * created without preserveDrawingBuffer set to true will be cleared.
  156598. * @param pose Define the pose to submit
  156599. */
  156600. submitFrame(pose?: VRPose): void;
  156601. }
  156602. declare var VRDisplay: {
  156603. prototype: VRDisplay;
  156604. new(): VRDisplay;
  156605. };
  156606. interface VRLayer {
  156607. leftBounds?: number[] | Float32Array | null;
  156608. rightBounds?: number[] | Float32Array | null;
  156609. source?: HTMLCanvasElement | null;
  156610. }
  156611. interface VRDisplayCapabilities {
  156612. readonly canPresent: boolean;
  156613. readonly hasExternalDisplay: boolean;
  156614. readonly hasOrientation: boolean;
  156615. readonly hasPosition: boolean;
  156616. readonly maxLayers: number;
  156617. }
  156618. interface VREyeParameters {
  156619. /** @deprecated */
  156620. readonly fieldOfView: VRFieldOfView;
  156621. readonly offset: Float32Array;
  156622. readonly renderHeight: number;
  156623. readonly renderWidth: number;
  156624. }
  156625. interface VRFieldOfView {
  156626. readonly downDegrees: number;
  156627. readonly leftDegrees: number;
  156628. readonly rightDegrees: number;
  156629. readonly upDegrees: number;
  156630. }
  156631. interface VRFrameData {
  156632. readonly leftProjectionMatrix: Float32Array;
  156633. readonly leftViewMatrix: Float32Array;
  156634. readonly pose: VRPose;
  156635. readonly rightProjectionMatrix: Float32Array;
  156636. readonly rightViewMatrix: Float32Array;
  156637. readonly timestamp: number;
  156638. }
  156639. interface VRPose {
  156640. readonly angularAcceleration: Float32Array | null;
  156641. readonly angularVelocity: Float32Array | null;
  156642. readonly linearAcceleration: Float32Array | null;
  156643. readonly linearVelocity: Float32Array | null;
  156644. readonly orientation: Float32Array | null;
  156645. readonly position: Float32Array | null;
  156646. readonly timestamp: number;
  156647. }
  156648. interface VRStageParameters {
  156649. sittingToStandingTransform?: Float32Array;
  156650. sizeX?: number;
  156651. sizeY?: number;
  156652. }
  156653. interface Navigator {
  156654. getVRDisplays(): Promise<VRDisplay[]>;
  156655. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  156656. }
  156657. interface Window {
  156658. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  156659. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  156660. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  156661. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156662. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156663. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  156664. }
  156665. interface Gamepad {
  156666. readonly displayId: number;
  156667. }
  156668. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  156669. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  156670. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  156671. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  156672. type XRHandedness = "none" | "left" | "right";
  156673. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  156674. type XREye = "none" | "left" | "right";
  156675. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  156676. interface XRSpace extends EventTarget {}
  156677. interface XRRenderState {
  156678. depthNear?: number;
  156679. depthFar?: number;
  156680. inlineVerticalFieldOfView?: number;
  156681. baseLayer?: XRWebGLLayer;
  156682. }
  156683. interface XRInputSource {
  156684. handedness: XRHandedness;
  156685. targetRayMode: XRTargetRayMode;
  156686. targetRaySpace: XRSpace;
  156687. gripSpace: XRSpace | undefined;
  156688. gamepad: Gamepad | undefined;
  156689. profiles: Array<string>;
  156690. hand: XRHand | undefined;
  156691. }
  156692. interface XRSessionInit {
  156693. optionalFeatures?: string[];
  156694. requiredFeatures?: string[];
  156695. }
  156696. interface XRSession {
  156697. addEventListener: Function;
  156698. removeEventListener: Function;
  156699. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  156700. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  156701. requestAnimationFrame: Function;
  156702. end(): Promise<void>;
  156703. renderState: XRRenderState;
  156704. inputSources: Array<XRInputSource>;
  156705. // hit test
  156706. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  156707. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  156708. // legacy AR hit test
  156709. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156710. // legacy plane detection
  156711. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  156712. }
  156713. interface XRReferenceSpace extends XRSpace {
  156714. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  156715. onreset: any;
  156716. }
  156717. type XRPlaneSet = Set<XRPlane>;
  156718. type XRAnchorSet = Set<XRAnchor>;
  156719. interface XRFrame {
  156720. session: XRSession;
  156721. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  156722. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  156723. // AR
  156724. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  156725. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  156726. // Anchors
  156727. trackedAnchors?: XRAnchorSet;
  156728. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  156729. // Planes
  156730. worldInformation: {
  156731. detectedPlanes?: XRPlaneSet;
  156732. };
  156733. // Hand tracking
  156734. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  156735. }
  156736. interface XRViewerPose extends XRPose {
  156737. views: Array<XRView>;
  156738. }
  156739. interface XRPose {
  156740. transform: XRRigidTransform;
  156741. emulatedPosition: boolean;
  156742. }
  156743. interface XRWebGLLayerOptions {
  156744. antialias?: boolean;
  156745. depth?: boolean;
  156746. stencil?: boolean;
  156747. alpha?: boolean;
  156748. multiview?: boolean;
  156749. framebufferScaleFactor?: number;
  156750. }
  156751. declare var XRWebGLLayer: {
  156752. prototype: XRWebGLLayer;
  156753. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  156754. };
  156755. interface XRWebGLLayer {
  156756. framebuffer: WebGLFramebuffer;
  156757. framebufferWidth: number;
  156758. framebufferHeight: number;
  156759. getViewport: Function;
  156760. }
  156761. declare class XRRigidTransform {
  156762. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156763. position: DOMPointReadOnly;
  156764. orientation: DOMPointReadOnly;
  156765. matrix: Float32Array;
  156766. inverse: XRRigidTransform;
  156767. }
  156768. interface XRView {
  156769. eye: XREye;
  156770. projectionMatrix: Float32Array;
  156771. transform: XRRigidTransform;
  156772. }
  156773. interface XRInputSourceChangeEvent {
  156774. session: XRSession;
  156775. removed: Array<XRInputSource>;
  156776. added: Array<XRInputSource>;
  156777. }
  156778. interface XRInputSourceEvent extends Event {
  156779. readonly frame: XRFrame;
  156780. readonly inputSource: XRInputSource;
  156781. }
  156782. // Experimental(er) features
  156783. declare class XRRay {
  156784. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156785. origin: DOMPointReadOnly;
  156786. direction: DOMPointReadOnly;
  156787. matrix: Float32Array;
  156788. }
  156789. declare enum XRHitTestTrackableType {
  156790. "point",
  156791. "plane",
  156792. "mesh",
  156793. }
  156794. interface XRHitResult {
  156795. hitMatrix: Float32Array;
  156796. }
  156797. interface XRTransientInputHitTestResult {
  156798. readonly inputSource: XRInputSource;
  156799. readonly results: Array<XRHitTestResult>;
  156800. }
  156801. interface XRHitTestResult {
  156802. getPose(baseSpace: XRSpace): XRPose | undefined;
  156803. // When anchor system is enabled
  156804. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156805. }
  156806. interface XRHitTestSource {
  156807. cancel(): void;
  156808. }
  156809. interface XRTransientInputHitTestSource {
  156810. cancel(): void;
  156811. }
  156812. interface XRHitTestOptionsInit {
  156813. space: XRSpace;
  156814. entityTypes?: Array<XRHitTestTrackableType>;
  156815. offsetRay?: XRRay;
  156816. }
  156817. interface XRTransientInputHitTestOptionsInit {
  156818. profile: string;
  156819. entityTypes?: Array<XRHitTestTrackableType>;
  156820. offsetRay?: XRRay;
  156821. }
  156822. interface XRAnchor {
  156823. anchorSpace: XRSpace;
  156824. delete(): void;
  156825. }
  156826. interface XRPlane {
  156827. orientation: "Horizontal" | "Vertical";
  156828. planeSpace: XRSpace;
  156829. polygon: Array<DOMPointReadOnly>;
  156830. lastChangedTime: number;
  156831. }
  156832. interface XRJointSpace extends XRSpace {}
  156833. interface XRJointPose extends XRPose {
  156834. radius: number | undefined;
  156835. }
  156836. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156837. readonly length: number;
  156838. [index: number]: XRJointSpace;
  156839. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156840. readonly WRIST: number;
  156841. readonly THUMB_METACARPAL: number;
  156842. readonly THUMB_PHALANX_PROXIMAL: number;
  156843. readonly THUMB_PHALANX_DISTAL: number;
  156844. readonly THUMB_PHALANX_TIP: number;
  156845. readonly INDEX_METACARPAL: number;
  156846. readonly INDEX_PHALANX_PROXIMAL: number;
  156847. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156848. readonly INDEX_PHALANX_DISTAL: number;
  156849. readonly INDEX_PHALANX_TIP: number;
  156850. readonly MIDDLE_METACARPAL: number;
  156851. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156852. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156853. readonly MIDDLE_PHALANX_DISTAL: number;
  156854. readonly MIDDLE_PHALANX_TIP: number;
  156855. readonly RING_METACARPAL: number;
  156856. readonly RING_PHALANX_PROXIMAL: number;
  156857. readonly RING_PHALANX_INTERMEDIATE: number;
  156858. readonly RING_PHALANX_DISTAL: number;
  156859. readonly RING_PHALANX_TIP: number;
  156860. readonly LITTLE_METACARPAL: number;
  156861. readonly LITTLE_PHALANX_PROXIMAL: number;
  156862. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156863. readonly LITTLE_PHALANX_DISTAL: number;
  156864. readonly LITTLE_PHALANX_TIP: number;
  156865. }
  156866. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156867. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156868. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156869. interface XRSession {
  156870. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156871. }
  156872. interface XRFrame {
  156873. featurePointCloud? : Array<number>;
  156874. }